Proyectos de Subversion Moodle

Rev

Rev 1 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1 Rev 1441
Línea 35... Línea 35...
35
    protected $userview;
35
    protected $userview;
Línea 36... Línea 36...
36
 
36
 
37
    /** @var int|null $currentgroupid The user report view mode. */
37
    /** @var int|null $currentgroupid The user report view mode. */
Línea -... Línea 38...
-
 
38
    protected $currentgroupid;
-
 
39
 
-
 
40
    /** @var string $usersearch String to search matching users. */
38
    protected $currentgroupid;
41
    protected $usersearch;
39
 
42
 
40
    /**
43
    /**
41
     * The class constructor.
44
     * The class constructor.
42
     *
45
     *
43
     * @param \context $context The context object.
46
     * @param \context $context The context object.
44
     * @param int $userview The user report view mode.
47
     * @param int $userview The user report view mode.
-
 
48
     * @param int|null $userid The user ID or 0 if displaying all users.
45
     * @param int|null $userid The user ID or 0 if displaying all users.
49
     * @param int|null $currentgroupid The ID of the current group.
-
 
50
     * @param string $usersearch String to search matching user.
-
 
51
     */
-
 
52
    public function __construct(
-
 
53
        \context $context,
46
     * @param int|null $currentgroupid The ID of the current group.
54
        int $userview,
-
 
55
        ?int $userid = null,
-
 
56
        ?int $currentgroupid = null,
47
     */
57
        string $usersearch = ''
48
    public function __construct(\context $context, int $userview, ?int $userid = null, ?int $currentgroupid = null) {
58
    ) {
49
        parent::__construct($context);
59
        parent::__construct($context);
50
        $this->userview = $userview;
60
        $this->userview = $userview;
-
 
61
        $this->userid = $userid;
51
        $this->userid = $userid;
62
        $this->currentgroupid = $currentgroupid;
Línea 52... Línea 63...
52
        $this->currentgroupid = $currentgroupid;
63
        $this->usersearch = $usersearch;
53
    }
64
    }
54
 
65
 
Línea 78... Línea 89...
78
        $data = $generalnavselector->export_for_template($output);
89
        $data = $generalnavselector->export_for_template($output);
Línea 79... Línea 90...
79
 
90
 
80
        // If the user has the capability to view all grades, display the group selector (if applicable), the user selector
91
        // If the user has the capability to view all grades, display the group selector (if applicable), the user selector
81
        // and the view mode selector (if applicable).
92
        // and the view mode selector (if applicable).
82
        if (has_capability('moodle/grade:viewall', $this->context)) {
93
        if (has_capability('moodle/grade:viewall', $this->context)) {
-
 
94
            $course = get_course($courseid);
83
            $userreportrenderer = $PAGE->get_renderer('gradereport_user');
95
            if ($course->groupmode) {
-
 
96
                $groupselector = new \core_course\output\actionbar\group_selector($this->context);
-
 
97
                $data['groupselector'] = $groupselector->export_for_template($output);
-
 
98
            }
-
 
99
 
-
 
100
            $resetlink = new moodle_url('/grade/report/user/index.php', ['id' => $courseid, 'group' => 0]);
-
 
101
            $baseurl = new moodle_url('/grade/report/user/index.php', ['id' => $courseid]);
-
 
102
            $PAGE->requires->js_call_amd('gradereport_user/user', 'init', [$baseurl->out(false)]);
-
 
103
 
-
 
104
            $userselector = new \core_course\output\actionbar\user_selector(
-
 
105
                course: $course,
-
 
106
                resetlink: $resetlink,
-
 
107
                userid: $this->userid,
-
 
108
                groupid: $this->currentgroupid,
-
 
109
                usersearch: $this->usersearch
84
            $data['groupselector'] = $PAGE->get_renderer('core_grades')->group_selector(get_course($courseid));
110
            );
85
            $data['userselector'] = [
111
            $data['userselector'] = [
86
                'courseid' => $courseid,
112
                'courseid' => $courseid,
87
                'content' => $userreportrenderer->users_selector(get_course($courseid), $this->userid, $this->currentgroupid)
113
                'content' => $userselector->export_for_template($output),
Línea 88... Línea 114...
88
            ];
114
            ];
89
 
115
 
-
 
116
            // Do not output the 'view mode' selector when in zero state or when the current user is viewing its own report.
-
 
117
            if (!is_null($this->userid) && $USER->id != $this->userid) {
-
 
118
                $viewasotheruser = new moodle_url('/grade/report/user/index.php',
-
 
119
                    ['id' => $courseid, 'userid' => $this->userid, 'userview' => GRADE_REPORT_USER_VIEW_USER]);
-
 
120
                $viewasmyself = new moodle_url('/grade/report/user/index.php',
-
 
121
                    ['id' => $courseid, 'userid' => $this->userid, 'userview' => GRADE_REPORT_USER_VIEW_SELF]);
-
 
122
 
-
 
123
                $selectoroptions = [
-
 
124
                    $viewasotheruser->out(false) => get_string('otheruser', 'core_grades'),
-
 
125
                    $viewasmyself->out(false) => get_string('myself', 'core_grades')
-
 
126
                ];
-
 
127
 
-
 
128
                $selectoractiveurl = $this->userview === GRADE_REPORT_USER_VIEW_USER ? $viewasotheruser : $viewasmyself;
-
 
129
 
-
 
130
                $viewasselect = new \core\output\select_menu('viewas', $selectoroptions, $selectoractiveurl->out(false));
90
            // Do not output the 'view mode' selector when in zero state or when the current user is viewing its own report.
131
                $viewasselect->set_label(get_string('viewas', 'core_grades'));
91
            if (!is_null($this->userid) && $USER->id != $this->userid) {
132
 
92
                $data['viewasselector'] = $userreportrenderer->view_mode_selector($this->userid, $this->userview, $courseid);
133
                $data['viewasselector'] = $viewasselect->export_for_template($output);
Línea 93... Línea 134...
93
            }
134
            }
94
        }
135
        }