Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1441 ariadna 1
<?php
2
// This file is part of Moodle - http://moodle.org/
3
//
4
// Moodle is free software: you can redistribute it and/or modify
5
// it under the terms of the GNU General Public License as published by
6
// the Free Software Foundation, either version 3 of the License, or
7
// (at your option) any later version.
8
//
9
// Moodle is distributed in the hope that it will be useful,
10
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
// GNU General Public License for more details.
13
//
14
// You should have received a copy of the GNU General Public License
15
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
16
 
17
namespace mod_feedback;
18
 
19
use cm_info;
20
use stdClass;
21
 
22
/**
23
 * Class manager for feedback
24
 *
25
 * @package    mod_feedback
26
 * @copyright  2024 Mikel Martín <mikel@moodle.com>
27
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
28
 */
29
class manager {
30
 
31
    /**
32
     * Get the template record from the template id
33
     *
34
     * @param int $templateid
35
     * @return stdClass
36
     */
37
    public static function get_template_record(int $templateid): stdClass {
38
        global $DB;
39
 
40
        return $DB->get_record('feedback_template', ['id' => $templateid], '*', MUST_EXIST);
41
    }
42
 
43
    /**
44
     * Check if the current user can see other users if in groups
45
     *
46
     * @param cm_info $cm
47
     * @return bool
48
     */
49
    public static function can_see_others_in_groups(cm_info $cm): bool {
50
        $canaccessallgroups = has_capability('moodle/site:accessallgroups', $cm->context);
51
        if ($canaccessallgroups) {
52
            return true;
53
        }
54
        $course = $cm->get_course();
55
        $groupmode = groups_get_activity_groupmode($cm, $course);
56
        $usergroups = groups_get_user_groups($course->id);
57
        return ($groupmode != SEPARATEGROUPS || !empty($usergroups['0']));
58
    }
59
}