Commit | Line | Data |
---|---|---|
4eab2e7f | 1 | <?php |
53fad4b9 DM |
2 | |
3 | // This file is part of Moodle - http://moodle.org/ | |
4 | // | |
4eab2e7f DM |
5 | // Moodle is free software: you can redistribute it and/or modify |
6 | // it under the terms of the GNU General Public License as published by | |
7 | // the Free Software Foundation, either version 3 of the License, or | |
8 | // (at your option) any later version. | |
9 | // | |
10 | // Moodle is distributed in the hope that it will be useful, | |
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | // GNU General Public License for more details. | |
53fad4b9 | 14 | // |
4eab2e7f DM |
15 | // You should have received a copy of the GNU General Public License |
16 | // along with Moodle. If not, see <http://www.gnu.org/licenses/>. | |
53fad4b9 | 17 | |
4eab2e7f DM |
18 | /** |
19 | * Prints a particular instance of workshop | |
20 | * | |
21 | * You can have a rather longer description of the file as well, | |
22 | * if you like, and it can span multiple lines. | |
23 | * | |
65601f04 DM |
24 | * @package mod |
25 | * @subpackage workshop | |
26 | * @copyright 2009 David Mudrak <david.mudrak@gmail.com> | |
27 | * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | |
4eab2e7f DM |
28 | */ |
29 | ||
4eab2e7f | 30 | require_once(dirname(dirname(dirname(__FILE__))).'/config.php'); |
ffac17df | 31 | require_once(dirname(__FILE__).'/locallib.php'); |
516c5eca | 32 | require_once($CFG->libdir.'/completionlib.php'); |
4eab2e7f | 33 | |
f82567af DM |
34 | $id = optional_param('id', 0, PARAM_INT); // course_module ID, or |
35 | $w = optional_param('w', 0, PARAM_INT); // workshop instance ID | |
36 | $editmode = optional_param('editmode', null, PARAM_BOOL); | |
8a237337 | 37 | $page = optional_param('page', 0, PARAM_INT); |
11a97e66 | 38 | $perpage = optional_param('perpage', null, PARAM_INT); |
8a237337 DM |
39 | $sortby = optional_param('sortby', 'lastname', PARAM_ALPHA); |
40 | $sorthow = optional_param('sorthow', 'ASC', PARAM_ALPHA); | |
4eab2e7f DM |
41 | |
42 | if ($id) { | |
66c9894d DM |
43 | $cm = get_coursemodule_from_id('workshop', $id, 0, false, MUST_EXIST); |
44 | $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); | |
45 | $workshop = $DB->get_record('workshop', array('id' => $cm->instance), '*', MUST_EXIST); | |
4eab2e7f | 46 | } else { |
66c9894d DM |
47 | $workshop = $DB->get_record('workshop', array('id' => $w), '*', MUST_EXIST); |
48 | $course = $DB->get_record('course', array('id' => $workshop->course), '*', MUST_EXIST); | |
49 | $cm = get_coursemodule_from_instance('workshop', $workshop->id, $course->id, false, MUST_EXIST); | |
4eab2e7f DM |
50 | } |
51 | ||
52 | require_login($course, true, $cm); | |
b761e6d9 | 53 | require_capability('mod/workshop:view', $PAGE->context); |
6e309973 | 54 | |
b761e6d9 | 55 | $workshop = new workshop($workshop, $cm, $course); |
e7ff48d2 | 56 | $workshop->log('view'); |
4eab2e7f | 57 | |
6553cda7 | 58 | // Mark viewed |
59 | $completion = new completion_info($course); | |
60 | $completion->set_module_viewed($cm); | |
61 | ||
f82567af DM |
62 | if (!is_null($editmode) && $PAGE->user_allowed_editing()) { |
63 | $USER->editing = $editmode; | |
a39d7d87 DM |
64 | } |
65 | ||
b8ead2e6 | 66 | $PAGE->set_url($workshop->view_url()); |
ffac17df | 67 | $PAGE->set_title($workshop->name); |
6e309973 | 68 | $PAGE->set_heading($course->fullname); |
b761e6d9 | 69 | |
11a97e66 DM |
70 | if ($perpage and $perpage > 0 and $perpage <= 1000) { |
71 | require_sesskey(); | |
72 | set_user_preference('workshop_perpage', $perpage); | |
73 | redirect($PAGE->url); | |
74 | } | |
75 | ||
55fc1e59 | 76 | $output = $PAGE->get_renderer('mod_workshop'); |
cff28ef0 | 77 | $userplan = new workshop_user_plan($workshop, $USER->id); |
b761e6d9 | 78 | |
b8ead2e6 | 79 | /// Output starts here |
66c9894d | 80 | |
55fc1e59 DM |
81 | echo $output->header(); |
82 | echo $output->heading_with_help(format_string($workshop->name), 'userplan', 'workshop'); | |
cff28ef0 | 83 | echo $output->render($userplan); |
b761e6d9 | 84 | |
b761e6d9 DM |
85 | switch ($workshop->phase) { |
86 | case workshop::PHASE_SETUP: | |
bfbca63d | 87 | if (trim($workshop->intro)) { |
ef96efe0 | 88 | print_collapsible_region_start('', 'workshop-viewlet-intro', get_string('introduction', 'workshop')); |
55fc1e59 | 89 | echo $output->box(format_module_intro('workshop', $workshop, $workshop->cm->id), 'generalbox'); |
ef96efe0 | 90 | print_collapsible_region_end(); |
b761e6d9 | 91 | } |
81eccf0a | 92 | if ($workshop->useexamples and has_capability('mod/workshop:manageexamples', $PAGE->context)) { |
ef96efe0 | 93 | print_collapsible_region_start('', 'workshop-viewlet-allexamples', get_string('examplesubmissions', 'workshop')); |
55fc1e59 | 94 | echo $output->box_start('generalbox examples'); |
cbf87967 DM |
95 | if ($workshop->grading_strategy_instance()->form_ready()) { |
96 | if (! $examples = $workshop->get_examples_for_manager()) { | |
55fc1e59 | 97 | echo $output->container(get_string('noexamples', 'workshop'), 'noexamples'); |
cbf87967 DM |
98 | } |
99 | foreach ($examples as $example) { | |
100 | $summary = $workshop->prepare_example_summary($example); | |
81b22887 DM |
101 | $summary->editable = true; |
102 | echo $output->render($summary); | |
cbf87967 | 103 | } |
3ba60ee1 | 104 | $aurl = new moodle_url($workshop->exsubmission_url(0), array('edit' => 'on')); |
55fc1e59 | 105 | echo $output->single_button($aurl, get_string('exampleadd', 'workshop'), 'get'); |
cbf87967 | 106 | } else { |
55fc1e59 | 107 | echo $output->container(get_string('noexamplesformready', 'workshop')); |
81eccf0a | 108 | } |
55fc1e59 | 109 | echo $output->box_end(); |
4437929e | 110 | print_collapsible_region_end(); |
81eccf0a | 111 | } |
b761e6d9 DM |
112 | break; |
113 | case workshop::PHASE_SUBMISSION: | |
bfbca63d | 114 | if (trim($workshop->instructauthors)) { |
6516b9e9 | 115 | $instructions = file_rewrite_pluginfile_urls($workshop->instructauthors, 'pluginfile.php', $PAGE->context->id, |
64f93798 | 116 | 'mod_workshop', 'instructauthors', 0, workshop::instruction_editors_options($PAGE->context)); |
ef96efe0 | 117 | print_collapsible_region_start('', 'workshop-viewlet-instructauthors', get_string('instructauthors', 'workshop')); |
367a75fa | 118 | echo $output->box(format_text($instructions, $workshop->instructauthorsformat, array('overflowdiv'=>true)), array('generalbox', 'instructions')); |
ef96efe0 DM |
119 | print_collapsible_region_end(); |
120 | } | |
ef96efe0 | 121 | |
2f289d36 DM |
122 | // does the user have to assess examples before submitting their own work? |
123 | $examplesmust = ($workshop->useexamples and $workshop->examplesmode == workshop::EXAMPLES_BEFORE_SUBMISSION); | |
124 | ||
125 | // is the assessment of example submissions considered finished? | |
126 | $examplesdone = has_capability('mod/workshop:manageexamples', $workshop->context); | |
cbf87967 DM |
127 | if ($workshop->assessing_examples_allowed() |
128 | and has_capability('mod/workshop:submit', $workshop->context) | |
129 | and ! has_capability('mod/workshop:manageexamples', $workshop->context)) { | |
cff28ef0 | 130 | $examples = $userplan->get_examples(); |
cbf87967 | 131 | $total = count($examples); |
514d8c22 | 132 | $left = 0; |
cbf87967 DM |
133 | // make sure the current user has all examples allocated |
134 | foreach ($examples as $exampleid => $example) { | |
135 | if (is_null($example->assessmentid)) { | |
67ae13d9 | 136 | $examples[$exampleid]->assessmentid = $workshop->add_allocation($example, $USER->id, 0); |
cbf87967 DM |
137 | } |
138 | if (is_null($example->grade)) { | |
514d8c22 | 139 | $left++; |
ef96efe0 DM |
140 | } |
141 | } | |
514d8c22 | 142 | if ($left > 0 and $workshop->examplesmode != workshop::EXAMPLES_VOLUNTARY) { |
cbf87967 | 143 | $examplesdone = false; |
514d8c22 DM |
144 | } else { |
145 | $examplesdone = true; | |
ef96efe0 | 146 | } |
cff28ef0 | 147 | print_collapsible_region_start('', 'workshop-viewlet-examples', get_string('exampleassessments', 'workshop'), false, $examplesdone); |
55fc1e59 | 148 | echo $output->box_start('generalbox exampleassessments'); |
cbf87967 | 149 | if ($total == 0) { |
55fc1e59 | 150 | echo $output->heading(get_string('noexamples', 'workshop'), 3); |
cbf87967 DM |
151 | } else { |
152 | foreach ($examples as $example) { | |
153 | $summary = $workshop->prepare_example_summary($example); | |
81b22887 | 154 | echo $output->render($summary); |
cbf87967 | 155 | } |
ef96efe0 | 156 | } |
55fc1e59 | 157 | echo $output->box_end(); |
cbf87967 | 158 | print_collapsible_region_end(); |
6516b9e9 | 159 | } |
cbf87967 | 160 | |
2f289d36 | 161 | if (has_capability('mod/workshop:submit', $PAGE->context) and (!$examplesmust or $examplesdone)) { |
ef96efe0 | 162 | print_collapsible_region_start('', 'workshop-viewlet-ownsubmission', get_string('yoursubmission', 'workshop')); |
55fc1e59 | 163 | echo $output->box_start('generalbox ownsubmission'); |
e9b0f0ab | 164 | if ($submission = $workshop->get_submission_by_author($USER->id)) { |
81b22887 | 165 | echo $output->render($workshop->prepare_submission_summary($submission, true)); |
9ddff589 | 166 | if ($workshop->modifying_submission_allowed($USER->id)) { |
2f289d36 DM |
167 | $btnurl = new moodle_url($workshop->submission_url(), array('edit' => 'on')); |
168 | $btntxt = get_string('editsubmission', 'workshop'); | |
169 | } | |
81eccf0a | 170 | } else { |
55fc1e59 | 171 | echo $output->container(get_string('noyoursubmission', 'workshop')); |
9ddff589 | 172 | if ($workshop->creating_submission_allowed($USER->id)) { |
2f289d36 DM |
173 | $btnurl = new moodle_url($workshop->submission_url(), array('edit' => 'on')); |
174 | $btntxt = get_string('createsubmission', 'workshop'); | |
175 | } | |
81eccf0a | 176 | } |
2f289d36 DM |
177 | if (!empty($btnurl)) { |
178 | echo $output->single_button($btnurl, $btntxt, 'get'); | |
e9b0f0ab | 179 | } |
55fc1e59 | 180 | echo $output->box_end(); |
ef96efe0 | 181 | print_collapsible_region_end(); |
e9b0f0ab | 182 | } |
cbf87967 | 183 | |
e9b0f0ab | 184 | if (has_capability('mod/workshop:viewallsubmissions', $PAGE->context)) { |
1c0c3ef5 DM |
185 | $groupmode = groups_get_activity_groupmode($workshop->cm); |
186 | $groupid = groups_get_activity_group($workshop->cm, true); | |
187 | ||
188 | if ($groupmode == SEPARATEGROUPS and !has_capability('moodle/site:accessallgroups', $workshop->context)) { | |
189 | $allowedgroups = groups_get_activity_allowed_groups($workshop->cm); | |
190 | if (empty($allowedgroups)) { | |
191 | echo $output->container(get_string('groupnoallowed', 'mod_workshop'), 'groupwidget error'); | |
192 | break; | |
193 | } | |
194 | if (! in_array($groupid, array_keys($allowedgroups))) { | |
195 | echo $output->container(get_string('groupnotamember', 'core_group'), 'groupwidget error'); | |
196 | break; | |
197 | } | |
198 | } | |
199 | ||
0d2331cc | 200 | $countsubmissions = $workshop->count_submissions('all', $groupid); |
11a97e66 | 201 | $perpage = get_user_preferences('workshop_perpage', 10); |
0d2331cc | 202 | $pagingbar = new paging_bar($countsubmissions, $page, $perpage, $PAGE->url, 'page'); |
1c0c3ef5 | 203 | |
0d2331cc | 204 | print_collapsible_region_start('', 'workshop-viewlet-allsubmissions', get_string('allsubmissions', 'workshop', $countsubmissions)); |
55fc1e59 | 205 | echo $output->box_start('generalbox allsubmissions'); |
0d2331cc | 206 | echo $output->container(groups_print_activity_menu($workshop->cm, $PAGE->url, true), 'groupwidget'); |
0d2331cc DM |
207 | |
208 | if ($countsubmissions == 0) { | |
55fc1e59 | 209 | echo $output->container(get_string('nosubmissions', 'workshop'), 'nosubmissions'); |
0d2331cc DM |
210 | |
211 | } else { | |
212 | $submissions = $workshop->get_submissions('all', $groupid, $page * $perpage, $perpage); | |
213 | $shownames = has_capability('mod/workshop:viewauthornames', $workshop->context); | |
11a97e66 | 214 | echo $output->render($pagingbar); |
0d2331cc DM |
215 | foreach ($submissions as $submission) { |
216 | echo $output->render($workshop->prepare_submission_summary($submission, $shownames)); | |
217 | } | |
11a97e66 DM |
218 | echo $output->render($pagingbar); |
219 | echo $output->perpage_selector($perpage); | |
ddb59c77 | 220 | } |
0d2331cc | 221 | |
55fc1e59 | 222 | echo $output->box_end(); |
ef96efe0 | 223 | print_collapsible_region_end(); |
e9b0f0ab | 224 | } |
cbf87967 | 225 | |
e9b0f0ab | 226 | break; |
cbf87967 | 227 | |
b761e6d9 | 228 | case workshop::PHASE_ASSESSMENT: |
2f289d36 DM |
229 | |
230 | $ownsubmissionexists = null; | |
231 | if (has_capability('mod/workshop:submit', $PAGE->context)) { | |
232 | if ($ownsubmission = $workshop->get_submission_by_author($USER->id)) { | |
233 | print_collapsible_region_start('', 'workshop-viewlet-ownsubmission', get_string('yoursubmission', 'workshop'), false, true); | |
234 | echo $output->box_start('generalbox ownsubmission'); | |
81b22887 | 235 | echo $output->render($workshop->prepare_submission_summary($ownsubmission, true)); |
2f289d36 DM |
236 | $ownsubmissionexists = true; |
237 | } else { | |
238 | print_collapsible_region_start('', 'workshop-viewlet-ownsubmission', get_string('yoursubmission', 'workshop')); | |
239 | echo $output->box_start('generalbox ownsubmission'); | |
240 | echo $output->container(get_string('noyoursubmission', 'workshop')); | |
241 | $ownsubmissionexists = false; | |
9ddff589 | 242 | if ($workshop->creating_submission_allowed($USER->id)) { |
2f289d36 DM |
243 | $btnurl = new moodle_url($workshop->submission_url(), array('edit' => 'on')); |
244 | $btntxt = get_string('createsubmission', 'workshop'); | |
245 | } | |
246 | } | |
247 | if (!empty($btnurl)) { | |
248 | echo $output->single_button($btnurl, $btntxt, 'get'); | |
249 | } | |
250 | echo $output->box_end(); | |
251 | print_collapsible_region_end(); | |
252 | } | |
253 | ||
d183140d | 254 | if (has_capability('mod/workshop:viewallassessments', $PAGE->context)) { |
11a97e66 | 255 | $perpage = get_user_preferences('workshop_perpage', 10); |
d183140d | 256 | $groups = ''; // todo let the user choose the group |
a6855934 | 257 | $PAGE->set_url($PAGE->url, compact('sortby', 'sorthow', 'page')); // TODO: this is suspicious |
c2a35266 | 258 | $data = $workshop->prepare_grading_report_data($USER->id, $groups, $page, $perpage, $sortby, $sorthow); |
d183140d DM |
259 | if ($data) { |
260 | $showauthornames = has_capability('mod/workshop:viewauthornames', $workshop->context); | |
261 | $showreviewernames = has_capability('mod/workshop:viewreviewernames', $workshop->context); | |
262 | ||
263 | // prepare paging bar | |
929d7a83 | 264 | $pagingbar = new paging_bar($data->totalcount, $page, $perpage, $PAGE->url, 'page'); |
d183140d DM |
265 | |
266 | // grading report display options | |
7a789aa8 | 267 | $reportopts = new stdclass(); |
d183140d DM |
268 | $reportopts->showauthornames = $showauthornames; |
269 | $reportopts->showreviewernames = $showreviewernames; | |
270 | $reportopts->sortby = $sortby; | |
271 | $reportopts->sorthow = $sorthow; | |
272 | $reportopts->showsubmissiongrade = false; | |
273 | $reportopts->showgradinggrade = false; | |
d183140d | 274 | |
55fc1e59 | 275 | echo $output->render($pagingbar); |
c2a35266 | 276 | echo $output->render(new workshop_grading_report($data, $reportopts)); |
55fc1e59 | 277 | echo $output->render($pagingbar); |
11a97e66 | 278 | echo $output->perpage_selector($perpage); |
d183140d DM |
279 | } |
280 | } | |
bfbca63d | 281 | if (trim($workshop->instructreviewers)) { |
15d12b54 | 282 | $instructions = file_rewrite_pluginfile_urls($workshop->instructreviewers, 'pluginfile.php', $PAGE->context->id, |
64f93798 | 283 | 'mod_workshop', 'instructreviewers', 0, workshop::instruction_editors_options($PAGE->context)); |
ef96efe0 | 284 | print_collapsible_region_start('', 'workshop-viewlet-instructreviewers', get_string('instructreviewers', 'workshop')); |
367a75fa | 285 | echo $output->box(format_text($instructions, $workshop->instructreviewersformat, array('overflowdiv'=>true)), array('generalbox', 'instructions')); |
ef96efe0 | 286 | print_collapsible_region_end(); |
15d12b54 | 287 | } |
2f289d36 DM |
288 | |
289 | // does the user have to assess examples before assessing other's work? | |
290 | $examplesmust = ($workshop->useexamples and $workshop->examplesmode == workshop::EXAMPLES_BEFORE_ASSESSMENT); | |
291 | ||
292 | // is the assessment of example submissions considered finished? | |
293 | $examplesdone = has_capability('mod/workshop:manageexamples', $workshop->context); | |
294 | ||
295 | // can the examples be assessed? | |
296 | $examplesavailable = true; | |
297 | ||
298 | if (!$examplesdone and $examplesmust and ($ownsubmissionexists === false)) { | |
299 | print_collapsible_region_start('', 'workshop-viewlet-examplesfail', get_string('exampleassessments', 'workshop')); | |
300 | echo $output->box(get_string('exampleneedsubmission', 'workshop')); | |
301 | print_collapsible_region_end(); | |
302 | $examplesavailable = false; | |
303 | } | |
304 | ||
cff28ef0 DM |
305 | if ($workshop->assessing_examples_allowed() |
306 | and has_capability('mod/workshop:submit', $workshop->context) | |
2f289d36 DM |
307 | and ! has_capability('mod/workshop:manageexamples', $workshop->context) |
308 | and $examplesavailable) { | |
cff28ef0 DM |
309 | $examples = $userplan->get_examples(); |
310 | $total = count($examples); | |
311 | $left = 0; | |
312 | // make sure the current user has all examples allocated | |
313 | foreach ($examples as $exampleid => $example) { | |
314 | if (is_null($example->assessmentid)) { | |
315 | $examples[$exampleid]->assessmentid = $workshop->add_allocation($example, $USER->id, 0); | |
ddb59c77 | 316 | } |
cff28ef0 DM |
317 | if (is_null($example->grade)) { |
318 | $left++; | |
319 | } | |
320 | } | |
321 | if ($left > 0 and $workshop->examplesmode != workshop::EXAMPLES_VOLUNTARY) { | |
322 | $examplesdone = false; | |
323 | } else { | |
324 | $examplesdone = true; | |
325 | } | |
326 | print_collapsible_region_start('', 'workshop-viewlet-examples', get_string('exampleassessments', 'workshop'), false, $examplesdone); | |
327 | echo $output->box_start('generalbox exampleassessments'); | |
328 | if ($total == 0) { | |
329 | echo $output->heading(get_string('noexamples', 'workshop'), 3); | |
330 | } else { | |
331 | foreach ($examples as $example) { | |
332 | $summary = $workshop->prepare_example_summary($example); | |
81b22887 | 333 | echo $output->render($summary); |
cff28ef0 DM |
334 | } |
335 | } | |
336 | echo $output->box_end(); | |
337 | print_collapsible_region_end(); | |
338 | } | |
2f289d36 | 339 | if (!$examplesmust or $examplesdone) { |
cff28ef0 DM |
340 | print_collapsible_region_start('', 'workshop-viewlet-assignedassessments', get_string('assignedassessments', 'workshop')); |
341 | if (! $assessments = $workshop->get_assessments_by_reviewer($USER->id)) { | |
342 | echo $output->box_start('generalbox assessment-none'); | |
343 | echo $output->heading(get_string('assignedassessmentsnone', 'workshop'), 3); | |
55fc1e59 | 344 | echo $output->box_end(); |
cff28ef0 DM |
345 | } else { |
346 | $shownames = has_capability('mod/workshop:viewauthornames', $PAGE->context); | |
347 | foreach ($assessments as $assessment) { | |
81b22887 | 348 | $submission = new stdClass(); |
cff28ef0 DM |
349 | $submission->id = $assessment->submissionid; |
350 | $submission->title = $assessment->submissiontitle; | |
351 | $submission->timecreated = $assessment->submissioncreated; | |
352 | $submission->timemodified = $assessment->submissionmodified; | |
353 | $submission->authorid = $assessment->authorid; | |
354 | $submission->authorfirstname = $assessment->authorfirstname; | |
355 | $submission->authorlastname = $assessment->authorlastname; | |
356 | $submission->authorpicture = $assessment->authorpicture; | |
357 | $submission->authorimagealt = $assessment->authorimagealt; | |
3a11c09f | 358 | $submission->authoremail = $assessment->authoremail; |
81b22887 DM |
359 | |
360 | // transform the submission object into renderable component | |
361 | $submission = $workshop->prepare_submission_summary($submission, $shownames); | |
362 | ||
cff28ef0 | 363 | if (is_null($assessment->grade)) { |
4d63c194 | 364 | $submission->status = 'notgraded'; |
81b22887 | 365 | $class = ' notgraded'; |
cff28ef0 DM |
366 | $buttontext = get_string('assess', 'workshop'); |
367 | } else { | |
4d63c194 | 368 | $submission->status = 'graded'; |
81b22887 | 369 | $class = ' graded'; |
cff28ef0 DM |
370 | $buttontext = get_string('reassess', 'workshop'); |
371 | } | |
4d63c194 | 372 | |
cff28ef0 | 373 | echo $output->box_start('generalbox assessment-summary' . $class); |
81b22887 | 374 | echo $output->render($submission); |
cff28ef0 DM |
375 | $aurl = $workshop->assess_url($assessment->id); |
376 | echo $output->single_button($aurl, $buttontext, 'get'); | |
377 | echo $output->box_end(); | |
378 | } | |
ddb59c77 | 379 | } |
cff28ef0 | 380 | print_collapsible_region_end(); |
ddb59c77 | 381 | } |
00aca3c1 | 382 | break; |
b761e6d9 | 383 | case workshop::PHASE_EVALUATION: |
d183140d | 384 | if (has_capability('mod/workshop:viewallassessments', $PAGE->context)) { |
11a97e66 | 385 | $perpage = get_user_preferences('workshop_perpage', 10); |
1fed6ce3 | 386 | $groups = ''; // todo let the user choose the group |
a6855934 | 387 | $PAGE->set_url($PAGE->url, compact('sortby', 'sorthow', 'page')); // TODO: this is suspicious |
c2a35266 | 388 | $data = $workshop->prepare_grading_report_data($USER->id, $groups, $page, $perpage, $sortby, $sorthow); |
1fed6ce3 | 389 | if ($data) { |
f55650e6 DM |
390 | $showauthornames = has_capability('mod/workshop:viewauthornames', $workshop->context); |
391 | $showreviewernames = has_capability('mod/workshop:viewreviewernames', $workshop->context); | |
392 | ||
d183140d DM |
393 | if (has_capability('mod/workshop:overridegrades', $PAGE->context)) { |
394 | // load the grading evaluator | |
395 | $evaluator = $workshop->grading_evaluation_instance(); | |
396 | $form = $evaluator->get_settings_form(new moodle_url($workshop->aggregate_url(), | |
397 | compact('sortby', 'sorthow', 'page'))); | |
398 | $form->display(); | |
399 | } | |
1fed6ce3 DM |
400 | |
401 | // prepare paging bar | |
929d7a83 | 402 | $pagingbar = new paging_bar($data->totalcount, $page, $perpage, $PAGE->url, 'page'); |
1fed6ce3 | 403 | |
d183140d | 404 | // grading report display options |
7a789aa8 | 405 | $reportopts = new stdclass(); |
d183140d DM |
406 | $reportopts->showauthornames = $showauthornames; |
407 | $reportopts->showreviewernames = $showreviewernames; | |
408 | $reportopts->sortby = $sortby; | |
409 | $reportopts->sorthow = $sorthow; | |
410 | $reportopts->showsubmissiongrade = true; | |
411 | $reportopts->showgradinggrade = true; | |
d183140d | 412 | |
55fc1e59 | 413 | echo $output->render($pagingbar); |
c2a35266 | 414 | echo $output->render(new workshop_grading_report($data, $reportopts)); |
55fc1e59 | 415 | echo $output->render($pagingbar); |
11a97e66 | 416 | echo $output->perpage_selector($perpage); |
e807e9a3 | 417 | } |
1fed6ce3 | 418 | } |
32c78bc3 | 419 | if (has_capability('mod/workshop:overridegrades', $workshop->context)) { |
e706b9c3 | 420 | print_collapsible_region_start('', 'workshop-viewlet-cleargrades', get_string('toolbox', 'workshop'), false, true); |
32c78bc3 | 421 | echo $output->box_start('generalbox toolbox'); |
e706b9c3 | 422 | |
32c78bc3 | 423 | // Clear aggregated grades |
e706b9c3 | 424 | $url = new moodle_url($workshop->toolbox_url('clearaggregatedgrades')); |
32c78bc3 DM |
425 | $btn = new single_button($url, get_string('clearaggregatedgrades', 'workshop'), 'post'); |
426 | $btn->add_confirm_action(get_string('clearaggregatedgradesconfirm', 'workshop')); | |
e706b9c3 | 427 | echo $output->container_start('toolboxaction'); |
32c78bc3 DM |
428 | echo $output->render($btn); |
429 | echo $output->help_icon('clearaggregatedgrades', 'workshop'); | |
e706b9c3 DM |
430 | echo $output->container_end(); |
431 | // Clear assessments | |
432 | $url = new moodle_url($workshop->toolbox_url('clearassessments')); | |
433 | $btn = new single_button($url, get_string('clearassessments', 'workshop'), 'post'); | |
434 | $btn->add_confirm_action(get_string('clearassessmentsconfirm', 'workshop')); | |
435 | echo $output->container_start('toolboxaction'); | |
436 | echo $output->render($btn); | |
437 | echo $output->help_icon('clearassessments', 'workshop'); | |
438 | echo html_writer::empty_tag('img', array('src' => $output->pix_url('i/risk_dataloss'), | |
439 | 'title' => get_string('riskdatalossshort', 'admin'), | |
440 | 'alt' => get_string('riskdatalossshort', 'admin'))); | |
441 | echo $output->container_end(); | |
32c78bc3 DM |
442 | |
443 | echo $output->box_end(); | |
444 | print_collapsible_region_end(); | |
445 | } | |
4d63c194 DM |
446 | if (has_capability('mod/workshop:submit', $PAGE->context)) { |
447 | print_collapsible_region_start('', 'workshop-viewlet-ownsubmission', get_string('yoursubmission', 'workshop')); | |
448 | echo $output->box_start('generalbox ownsubmission'); | |
449 | if ($submission = $workshop->get_submission_by_author($USER->id)) { | |
757bade1 | 450 | echo $output->render($workshop->prepare_submission_summary($submission, true)); |
4d63c194 DM |
451 | } else { |
452 | echo $output->container(get_string('noyoursubmission', 'workshop')); | |
453 | } | |
454 | echo $output->box_end(); | |
455 | print_collapsible_region_end(); | |
456 | } | |
457 | if ($assessments = $workshop->get_assessments_by_reviewer($USER->id)) { | |
458 | print_collapsible_region_start('', 'workshop-viewlet-assignedassessments', get_string('assignedassessments', 'workshop')); | |
459 | $shownames = has_capability('mod/workshop:viewauthornames', $PAGE->context); | |
460 | foreach ($assessments as $assessment) { | |
461 | $submission = new stdclass(); | |
462 | $submission->id = $assessment->submissionid; | |
463 | $submission->title = $assessment->submissiontitle; | |
464 | $submission->timecreated = $assessment->submissioncreated; | |
465 | $submission->timemodified = $assessment->submissionmodified; | |
466 | $submission->authorid = $assessment->authorid; | |
467 | $submission->authorfirstname = $assessment->authorfirstname; | |
468 | $submission->authorlastname = $assessment->authorlastname; | |
469 | $submission->authorpicture = $assessment->authorpicture; | |
470 | $submission->authorimagealt = $assessment->authorimagealt; | |
3a11c09f | 471 | $submission->authoremail = $assessment->authoremail; |
4d63c194 DM |
472 | |
473 | if (is_null($assessment->grade)) { | |
474 | $class = ' notgraded'; | |
475 | $submission->status = 'notgraded'; | |
476 | $buttontext = get_string('assess', 'workshop'); | |
477 | } else { | |
478 | $class = ' graded'; | |
479 | $submission->status = 'graded'; | |
480 | $buttontext = get_string('reassess', 'workshop'); | |
481 | } | |
482 | echo $output->box_start('generalbox assessment-summary' . $class); | |
81b22887 | 483 | echo $output->render($workshop->prepare_submission_summary($submission, $shownames)); |
4d63c194 DM |
484 | echo $output->box_end(); |
485 | } | |
486 | print_collapsible_region_end(); | |
487 | } | |
1fed6ce3 DM |
488 | break; |
489 | case workshop::PHASE_CLOSED: | |
5a372494 | 490 | if (has_capability('mod/workshop:viewallassessments', $PAGE->context)) { |
11a97e66 | 491 | $perpage = get_user_preferences('workshop_perpage', 10); |
5a372494 DM |
492 | $groups = ''; // todo let the user choose the group |
493 | $PAGE->set_url($PAGE->url, compact('sortby', 'sorthow', 'page')); // TODO: this is suspicious | |
c2a35266 | 494 | $data = $workshop->prepare_grading_report_data($USER->id, $groups, $page, $perpage, $sortby, $sorthow); |
5a372494 DM |
495 | if ($data) { |
496 | $showauthornames = has_capability('mod/workshop:viewauthornames', $workshop->context); | |
497 | $showreviewernames = has_capability('mod/workshop:viewreviewernames', $workshop->context); | |
498 | ||
499 | // prepare paging bar | |
500 | $pagingbar = new paging_bar($data->totalcount, $page, $perpage, $PAGE->url, 'page'); | |
501 | ||
502 | // grading report display options | |
503 | $reportopts = new stdclass(); | |
504 | $reportopts->showauthornames = $showauthornames; | |
505 | $reportopts->showreviewernames = $showreviewernames; | |
506 | $reportopts->sortby = $sortby; | |
507 | $reportopts->sorthow = $sorthow; | |
508 | $reportopts->showsubmissiongrade = true; | |
509 | $reportopts->showgradinggrade = true; | |
510 | ||
511 | print_collapsible_region_start('', 'workshop-viewlet-gradereport', get_string('gradesreport', 'workshop')); | |
512 | echo $output->render($pagingbar); | |
c2a35266 | 513 | echo $output->render(new workshop_grading_report($data, $reportopts)); |
5a372494 | 514 | echo $output->render($pagingbar); |
11a97e66 | 515 | echo $output->perpage_selector($perpage); |
5a372494 DM |
516 | print_collapsible_region_end(); |
517 | } | |
518 | } | |
0aed4a55 DM |
519 | if (has_capability('mod/workshop:submit', $PAGE->context)) { |
520 | print_collapsible_region_start('', 'workshop-viewlet-ownsubmission', get_string('yoursubmission', 'workshop')); | |
521 | echo $output->box_start('generalbox ownsubmission'); | |
522 | if ($submission = $workshop->get_submission_by_author($USER->id)) { | |
81b22887 | 523 | echo $output->render($workshop->prepare_submission_summary($submission, true)); |
0aed4a55 DM |
524 | } else { |
525 | echo $output->container(get_string('noyoursubmission', 'workshop')); | |
526 | } | |
527 | echo $output->box_end(); | |
0dfb4bad DM |
528 | |
529 | if (!empty($submission->gradeoverby) and strlen(trim($submission->feedbackauthor)) > 0) { | |
530 | echo $output->render(new workshop_feedback_author($submission)); | |
531 | } | |
532 | ||
0aed4a55 DM |
533 | print_collapsible_region_end(); |
534 | } | |
00bc77ee | 535 | if (has_capability('mod/workshop:viewpublishedsubmissions', $workshop->context)) { |
e13d02f5 | 536 | $shownames = has_capability('mod/workshop:viewauthorpublished', $workshop->context); |
00bc77ee DM |
537 | if ($submissions = $workshop->get_published_submissions()) { |
538 | print_collapsible_region_start('', 'workshop-viewlet-publicsubmissions', get_string('publishedsubmissions', 'workshop')); | |
539 | foreach ($submissions as $submission) { | |
540 | echo $output->box_start('generalbox submission-summary'); | |
e13d02f5 | 541 | echo $output->render($workshop->prepare_submission_summary($submission, $shownames)); |
00bc77ee DM |
542 | echo $output->box_end(); |
543 | } | |
544 | print_collapsible_region_end(); | |
545 | } | |
546 | } | |
d67c20b8 DM |
547 | if ($assessments = $workshop->get_assessments_by_reviewer($USER->id)) { |
548 | print_collapsible_region_start('', 'workshop-viewlet-assignedassessments', get_string('assignedassessments', 'workshop')); | |
549 | $shownames = has_capability('mod/workshop:viewauthornames', $PAGE->context); | |
550 | foreach ($assessments as $assessment) { | |
551 | $submission = new stdclass(); | |
552 | $submission->id = $assessment->submissionid; | |
553 | $submission->title = $assessment->submissiontitle; | |
554 | $submission->timecreated = $assessment->submissioncreated; | |
555 | $submission->timemodified = $assessment->submissionmodified; | |
556 | $submission->authorid = $assessment->authorid; | |
557 | $submission->authorfirstname = $assessment->authorfirstname; | |
558 | $submission->authorlastname = $assessment->authorlastname; | |
559 | $submission->authorpicture = $assessment->authorpicture; | |
560 | $submission->authorimagealt = $assessment->authorimagealt; | |
561 | $submission->authoremail = $assessment->authoremail; | |
562 | ||
563 | if (is_null($assessment->grade)) { | |
564 | $class = ' notgraded'; | |
565 | $submission->status = 'notgraded'; | |
566 | $buttontext = get_string('assess', 'workshop'); | |
567 | } else { | |
568 | $class = ' graded'; | |
569 | $submission->status = 'graded'; | |
570 | $buttontext = get_string('reassess', 'workshop'); | |
571 | } | |
572 | echo $output->box_start('generalbox assessment-summary' . $class); | |
573 | echo $output->render($workshop->prepare_submission_summary($submission, $shownames)); | |
574 | echo $output->box_end(); | |
f68648e9 DM |
575 | |
576 | if (strlen(trim($assessment->feedbackreviewer)) > 0) { | |
577 | echo $output->render(new workshop_feedback_reviewer($assessment)); | |
578 | } | |
d67c20b8 DM |
579 | } |
580 | print_collapsible_region_end(); | |
581 | } | |
29dc43e7 | 582 | break; |
b761e6d9 DM |
583 | default: |
584 | } | |
585 | ||
55fc1e59 | 586 | echo $output->footer(); |