Proyectos de Subversion Moodle

Rev

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

Rev 1 Rev 1441
Línea 85... Línea 85...
85
     *
85
     *
86
     * @param report_log_renderable $reportlog log report.
86
     * @param report_log_renderable $reportlog log report.
87
     */
87
     */
88
    public function report_selector_form(report_log_renderable $reportlog) {
88
    public function report_selector_form(report_log_renderable $reportlog) {
89
        echo html_writer::start_tag('form', array('class' => 'logselecform', 'action' => $reportlog->url, 'method' => 'get'));
89
        echo html_writer::start_tag('form', array('class' => 'logselecform', 'action' => $reportlog->url, 'method' => 'get'));
90
        echo html_writer::start_div();
90
        echo html_writer::start_div('d-flex flex-wrap align-items-center gap-2');
91
        echo html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'chooselog', 'value' => '1'));
91
        echo html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'chooselog', 'value' => '1'));
92
        echo html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'showusers', 'value' => $reportlog->showusers));
92
        echo html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'showusers', 'value' => $reportlog->showusers));
93
        echo html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'showcourses',
93
        echo html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'showcourses',
94
            'value' => $reportlog->showcourses));
94
            'value' => $reportlog->showcourses));
Línea -... Línea 95...
-
 
95
 
95
 
96
        $selectedcourseid = empty($reportlog->sitecoursefilter)
-
 
97
            ? (empty($reportlog->course) ? 0 : $reportlog->course->id)
Línea 96... Línea -...
96
        $selectedcourseid = empty($reportlog->course) ? 0 : $reportlog->course->id;
-
 
97
 
-
 
98
        // Add course selector.
-
 
99
        $sitecontext = context_system::instance();
98
            : $reportlog->sitecoursefilter;
100
        $courses = $reportlog->get_course_list();
-
 
101
        if (!empty($courses) && $reportlog->showcourses) {
-
 
102
            echo html_writer::label(get_string('selectacourse'), 'menuid', false, array('class' => 'accesshide'));
-
 
103
            echo html_writer::select($courses, "id", $selectedcourseid, null, ['class' => 'mr-2 mb-2']);
-
 
104
        } else {
-
 
105
            $courses = array();
-
 
106
            $courses[$selectedcourseid] = get_course_display_name_for_list($reportlog->course) . (($selectedcourseid == SITEID) ?
-
 
107
                ' (' . get_string('site') . ') ' : '');
-
 
108
            echo html_writer::label(get_string('selectacourse'), 'menuid', false, array('class' => 'accesshide'));
-
 
109
            echo html_writer::select($courses, "id", $selectedcourseid, false, ['class' => 'mr-2 mb-2']);
-
 
110
            // Check if user is admin and this came because of limitation on number of courses to show in dropdown.
-
 
111
            if (has_capability('report/log:view', $sitecontext)) {
-
 
112
                $a = new stdClass();
-
 
113
                $a->url = new moodle_url('/report/log/index.php', array('chooselog' => 0,
-
 
114
                    'group' => $reportlog->get_selected_group(), 'user' => $reportlog->userid,
-
 
115
                    'id' => $selectedcourseid, 'date' => $reportlog->date, 'modid' => $reportlog->modid,
-
 
116
                    'showcourses' => 1, 'showusers' => $reportlog->showusers));
-
 
117
                $a->url = $a->url->out(false);
-
 
118
                print_string('logtoomanycourses', 'moodle', $a);
-
 
Línea 119... Línea 99...
119
            }
99
 
120
        }
100
        echo $this->get_course_selector_field($reportlog, $selectedcourseid);
121
 
101
 
122
        // Add group selector.
102
        // Add group selector.
123
        $groups = $reportlog->get_group_list();
103
        $groups = $reportlog->get_group_list();
124
        if (!empty($groups)) {
-
 
125
            echo html_writer::label(get_string('selectagroup'), 'menugroup', false, array('class' => 'accesshide'));
104
        if (!empty($groups)) {
Línea 126... Línea 105...
126
            echo html_writer::select($groups, "group", $reportlog->groupid, get_string("allgroups"),
105
            echo html_writer::label(get_string('selectagroup'), 'menugroup', false, array('class' => 'accesshide'));
127
                ['class' => 'mr-2 mb-2']);
106
            echo html_writer::select($groups, "group", $reportlog->groupid, get_string("allgroups"));
Línea 128... Línea 107...
128
        }
107
        }
129
 
108
 
130
        // Add user selector.
109
        // Add user selector.
131
        $users = $reportlog->get_user_list();
-
 
132
 
110
        $users = $reportlog->get_user_list();
133
        if ($reportlog->showusers) {
111
 
134
            echo html_writer::label(get_string('selctauser'), 'menuuser', false, array('class' => 'accesshide'));
112
        if ($reportlog->showusers) {
135
            echo html_writer::select($users, "user", $reportlog->userid, get_string("allparticipants"),
113
            echo html_writer::label(get_string('selctauser'), 'menuuser', false, array('class' => 'accesshide'));
136
                ['class' => 'mr-2 mb-2']);
114
            echo html_writer::select($users, "user", $reportlog->userid, get_string("allparticipants"));
137
        } else {
115
        } else {
138
            $users = array();
116
            $users = array();
139
            if (!empty($reportlog->userid)) {
117
            if (!empty($reportlog->userid)) {
140
                $users[$reportlog->userid] = $reportlog->get_selected_user_fullname();
118
                $users[$reportlog->userid] = $reportlog->get_selected_user_fullname();
141
            } else {
119
            } else {
142
                $users[0] = get_string('allparticipants');
120
                $users[0] = get_string('allparticipants');
143
            }
121
            }
144
            echo html_writer::label(get_string('selctauser'), 'menuuser', false, array('class' => 'accesshide'));
122
            echo html_writer::label(get_string('selctauser'), 'menuuser', false, array('class' => 'accesshide'));
145
            echo html_writer::select($users, "user", $reportlog->userid, false, ['class' => 'mr-2 mb-2']);
123
            echo html_writer::select($users, "user", $reportlog->userid, false);
Línea 155... Línea 133...
155
        }
133
        }
Línea 156... Línea 134...
156
 
134
 
157
        // Add date selector.
135
        // Add date selector.
158
        $dates = $reportlog->get_date_options();
136
        $dates = $reportlog->get_date_options();
159
        echo html_writer::label(get_string('date'), 'menudate', false, array('class' => 'accesshide'));
137
        echo html_writer::label(get_string('date'), 'menudate', false, array('class' => 'accesshide'));
160
        echo html_writer::select($dates, "date", $reportlog->date, get_string("alldays"),
-
 
Línea 161... Línea 138...
161
            ['class' => 'mr-2 mb-2']);
138
        echo html_writer::select($dates, "date", $reportlog->date, get_string("alldays"));
162
 
139
 
163
        // Add activity selector.
-
 
164
        $activities = $reportlog->get_activities_list();
-
 
165
        echo html_writer::label(get_string('activities'), 'menumodid', false, array('class' => 'accesshide'));
-
 
Línea 166... Línea 140...
166
        echo html_writer::select($activities, "modid", $reportlog->modid, get_string("allactivities"),
140
        // Add activity selector.
167
            ['class' => 'mr-2 mb-2']);
141
        echo $this->get_activity_selector_field($reportlog);
168
 
142
 
169
        // Add actions selector.
143
        // Add actions selector.
Línea 170... Línea 144...
170
        echo html_writer::label(get_string('actions'), 'menumodaction', false, array('class' => 'accesshide'));
144
        echo html_writer::label(get_string('actions'), 'menumodaction', false, array('class' => 'accesshide'));
171
        echo html_writer::select($reportlog->get_actions(), 'modaction', $reportlog->action,
145
        echo html_writer::select($reportlog->get_actions(), 'modaction', $reportlog->action,
172
            get_string("allactions"), ['class' => 'mr-2 mb-2']);
146
            get_string("allactions"));
173
 
147
 
Línea 174... Línea 148...
174
        // Add origin.
148
        // Add origin.
175
        $origin = $reportlog->get_origin_options();
149
        $origin = $reportlog->get_origin_options();
176
        echo html_writer::label(get_string('origin', 'report_log'), 'menuorigin', false, array('class' => 'accesshide'));
150
        echo html_writer::label(get_string('origin', 'report_log'), 'menuorigin', false, array('class' => 'accesshide'));
177
        echo html_writer::select($origin, 'origin', $reportlog->origin, false, ['class' => 'mr-2 mb-2']);
151
        echo html_writer::select($origin, 'origin', $reportlog->origin, false);
178
 
-
 
Línea 179... Línea 152...
179
        // Add edulevel.
152
 
180
        $edulevel = $reportlog->get_edulevel_options();
153
        // Add edulevel.
181
        echo html_writer::label(get_string('edulevel'), 'menuedulevel', false, array('class' => 'accesshide'));
154
        $edulevel = $reportlog->get_edulevel_options();
182
        echo html_writer::select($edulevel, 'edulevel', $reportlog->edulevel, false,
155
        echo html_writer::label(get_string('edulevel'), 'menuedulevel', false, array('class' => 'accesshide'));
Línea 190... Línea 163...
190
                $attributes = array('type' => 'hidden', 'name' => 'logreader', 'value' => key($readers));
163
                $attributes = array('type' => 'hidden', 'name' => 'logreader', 'value' => key($readers));
191
                echo html_writer::empty_tag('input', $attributes);
164
                echo html_writer::empty_tag('input', $attributes);
192
            } else {
165
            } else {
193
                echo html_writer::label(get_string('selectlogreader', 'report_log'), 'menureader', false,
166
                echo html_writer::label(get_string('selectlogreader', 'report_log'), 'menureader', false,
194
                        array('class' => 'accesshide'));
167
                        array('class' => 'accesshide'));
195
                echo html_writer::select($readers, 'logreader', $reportlog->selectedlogreader, false,
168
                echo html_writer::select($readers, 'logreader', $reportlog->selectedlogreader, false);
196
                    ['class' => 'mr-2 mb-2']);
-
 
197
            }
169
            }
-
 
170
            echo html_writer::end_div();
198
            echo html_writer::start_div('mt-1');
171
            echo html_writer::start_div('mt-2');
199
            echo html_writer::empty_tag('input', array('type' => 'submit',
172
            echo html_writer::empty_tag('input', array('type' => 'submit',
200
                'value' => get_string('gettheselogs'), 'class' => 'btn btn-primary'));
173
                'value' => get_string('gettheselogs'), 'class' => 'btn btn-primary'));
201
            echo html_writer::end_div();
174
            echo html_writer::end_div();
202
        }
175
        }
203
        echo html_writer::end_div();
-
 
204
        echo html_writer::end_tag('form');
176
        echo html_writer::end_tag('form');
205
    }
177
    }
206
}
-
 
Línea -... Línea 178...
-
 
178
 
-
 
179
    /**
-
 
180
     * Generates the course selector field for the log report.
-
 
181
     *
-
 
182
     * @param report_log_renderable $reportlog The output instance.
-
 
183
     * @param int $selectedcourseid
-
 
184
     * @return string
-
 
185
     */
-
 
186
    private function get_course_selector_field(report_log_renderable $reportlog, int $selectedcourseid): string {
-
 
187
        // When the log report is accessed vie an activity, we do not need a course selector.
-
 
188
        if ($reportlog->isactivitypage) {
-
 
189
            return html_writer::empty_tag(
-
 
190
                'input',
-
 
191
                ['type' => 'hidden', 'name' => 'id', 'value' => $selectedcourseid]
-
 
192
            );
-
 
193
        }
-
 
194
 
-
 
195
        $result = '';
-
 
196
        $sitecontext = context_system::instance();
-
 
197
        $courses = $reportlog->get_course_list();
-
 
198
 
-
 
199
        if (!empty($courses) && $reportlog->showcourses) {
-
 
200
            $result .= html_writer::label(get_string('selectacourse'), 'menuid', false, ['class' => 'accesshide']);
-
 
201
            $result .= html_writer::select($courses, "id", $selectedcourseid, null);
-
 
202
            return $result;
-
 
203
        }
-
 
204
 
-
 
205
        $courses = [];
-
 
206
        $courseinfo = ($selectedcourseid == SITEID) ? ' (' . get_string('site') . ') ' : '';
-
 
207
        $courses[$selectedcourseid] = get_course_display_name_for_list($reportlog->course) . $courseinfo;
-
 
208
 
-
 
209
        $result .= html_writer::label(get_string('selectacourse'), 'menuid', false, ['class' => 'accesshide']);
-
 
210
        $result .= html_writer::select($courses, "id", $selectedcourseid, false);
-
 
211
 
-
 
212
        // Check if user is admin and this came because of limitation on number of courses to show in dropdown.
-
 
213
        if (has_capability('report/log:view', $sitecontext)) {
-
 
214
            $a = new stdClass();
-
 
215
            $a->url = new moodle_url(
-
 
216
                '/report/log/index.php',
-
 
217
                [
-
 
218
                    'chooselog' => 0,
-
 
219
                    'group' => $reportlog->get_selected_group(),
-
 
220
                    'user' => $reportlog->userid,
-
 
221
                    'id' => $selectedcourseid,
-
 
222
                    'date' => $reportlog->date,
-
 
223
                    'modid' => $reportlog->modid,
-
 
224
                    'showcourses' => 1, 'showusers' => $reportlog->showusers,
-
 
225
                ]
-
 
226
            );
-
 
227
            $a->url = $a->url->out(false);
-
 
228
            $result .= get_string('logtoomanycourses', 'moodle', $a);
-
 
229
        }
-
 
230
 
-
 
231
        return $result;
-
 
232
    }
-
 
233
 
-
 
234
    /**
-
 
235
     * Generates the activity selector field for the log report.
-
 
236
     *
-
 
237
     * @param report_log_renderable $reportlog The output instance.
-
 
238
     * @return string
-
 
239
     */
-
 
240
    private function get_activity_selector_field(report_log_renderable $reportlog): string {
-
 
241
        $result = '';
-
 
242
        // When the log report is accessed vie an activity, we do not need an activity selector.
-
 
243
        if ($reportlog->isactivitypage) {
-
 
244
            $result .= html_writer::empty_tag(
-
 
245
                'input',
-
 
246
                ['type' => 'hidden', 'name' => 'isactivitypage', 'value' => $reportlog->isactivitypage]
-
 
247
            );
-
 
248
            $result .= html_writer::empty_tag(
-
 
249
                'input',
-
 
250
                ['type' => 'hidden', 'name' => 'modid', 'value' => $reportlog->modid]
-
 
251
            );
-
 
252
            return $result;
-
 
253
        }
-
 
254
 
-
 
255
        [$activities, $disabled] = $reportlog->get_activities_list();
-
 
256
 
-
 
257
        $result .= html_writer::label(
-
 
258
            text: get_string('activities'),
-
 
259
            for: 'menumodid',
-
 
260
            colonize: false,
-
 
261
            attributes: ['class' => 'accesshide'],
-
 
262
        );
-
 
263
        $result .= html_writer::select(
-
 
264
            options: $activities,
-
 
265
            name: "modid",
-
 
266
            selected: $reportlog->modid,
-
 
267
            nothing: get_string("allactivities"),
-
 
268
            attributes: [],
-
 
269
            disabled: $disabled,
-
 
270
        );
-
 
271
        return $result;
-
 
272
    }