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); | |
4eab2e7f DM |
37 | |
38 | if ($id) { | |
66c9894d DM |
39 | $cm = get_coursemodule_from_id('workshop', $id, 0, false, MUST_EXIST); |
40 | $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); | |
41 | $workshop = $DB->get_record('workshop', array('id' => $cm->instance), '*', MUST_EXIST); | |
4eab2e7f | 42 | } else { |
66c9894d DM |
43 | $workshop = $DB->get_record('workshop', array('id' => $w), '*', MUST_EXIST); |
44 | $course = $DB->get_record('course', array('id' => $workshop->course), '*', MUST_EXIST); | |
45 | $cm = get_coursemodule_from_instance('workshop', $workshop->id, $course->id, false, MUST_EXIST); | |
4eab2e7f DM |
46 | } |
47 | ||
48 | require_login($course, true, $cm); | |
b761e6d9 | 49 | require_capability('mod/workshop:view', $PAGE->context); |
6e309973 | 50 | |
b761e6d9 | 51 | $workshop = new workshop($workshop, $cm, $course); |
e7ff48d2 | 52 | $workshop->log('view'); |
4eab2e7f | 53 | |
f82567af DM |
54 | if (!is_null($editmode) && $PAGE->user_allowed_editing()) { |
55 | $USER->editing = $editmode; | |
a39d7d87 DM |
56 | } |
57 | ||
b8ead2e6 | 58 | $PAGE->set_url($workshop->view_url()); |
ffac17df | 59 | $PAGE->set_title($workshop->name); |
6e309973 | 60 | $PAGE->set_heading($course->fullname); |
b761e6d9 | 61 | |
55fc1e59 | 62 | $output = $PAGE->get_renderer('mod_workshop'); |
cff28ef0 | 63 | $userplan = new workshop_user_plan($workshop, $USER->id); |
b761e6d9 | 64 | |
b8ead2e6 | 65 | /// Output starts here |
66c9894d | 66 | |
55fc1e59 DM |
67 | echo $output->header(); |
68 | echo $output->heading_with_help(format_string($workshop->name), 'userplan', 'workshop'); | |
cff28ef0 | 69 | echo $output->render($userplan); |
b761e6d9 | 70 | |
b761e6d9 DM |
71 | switch ($workshop->phase) { |
72 | case workshop::PHASE_SETUP: | |
bfbca63d | 73 | if (trim($workshop->intro)) { |
ef96efe0 | 74 | print_collapsible_region_start('', 'workshop-viewlet-intro', get_string('introduction', 'workshop')); |
55fc1e59 | 75 | echo $output->box(format_module_intro('workshop', $workshop, $workshop->cm->id), 'generalbox'); |
ef96efe0 | 76 | print_collapsible_region_end(); |
b761e6d9 | 77 | } |
81eccf0a | 78 | if ($workshop->useexamples and has_capability('mod/workshop:manageexamples', $PAGE->context)) { |
ef96efe0 | 79 | print_collapsible_region_start('', 'workshop-viewlet-allexamples', get_string('examplesubmissions', 'workshop')); |
55fc1e59 | 80 | echo $output->box_start('generalbox examples'); |
cbf87967 DM |
81 | if ($workshop->grading_strategy_instance()->form_ready()) { |
82 | if (! $examples = $workshop->get_examples_for_manager()) { | |
55fc1e59 | 83 | echo $output->container(get_string('noexamples', 'workshop'), 'noexamples'); |
cbf87967 DM |
84 | } |
85 | foreach ($examples as $example) { | |
86 | $summary = $workshop->prepare_example_summary($example); | |
81b22887 DM |
87 | $summary->editable = true; |
88 | echo $output->render($summary); | |
cbf87967 | 89 | } |
3ba60ee1 | 90 | $aurl = new moodle_url($workshop->exsubmission_url(0), array('edit' => 'on')); |
55fc1e59 | 91 | echo $output->single_button($aurl, get_string('exampleadd', 'workshop'), 'get'); |
cbf87967 | 92 | } else { |
55fc1e59 | 93 | echo $output->container(get_string('noexamplesformready', 'workshop')); |
81eccf0a | 94 | } |
55fc1e59 | 95 | echo $output->box_end(); |
4437929e | 96 | print_collapsible_region_end(); |
81eccf0a | 97 | } |
b761e6d9 DM |
98 | break; |
99 | case workshop::PHASE_SUBMISSION: | |
bfbca63d | 100 | if (trim($workshop->instructauthors)) { |
6516b9e9 | 101 | $instructions = file_rewrite_pluginfile_urls($workshop->instructauthors, 'pluginfile.php', $PAGE->context->id, |
64f93798 | 102 | 'mod_workshop', 'instructauthors', 0, workshop::instruction_editors_options($PAGE->context)); |
ef96efe0 | 103 | print_collapsible_region_start('', 'workshop-viewlet-instructauthors', get_string('instructauthors', 'workshop')); |
367a75fa | 104 | echo $output->box(format_text($instructions, $workshop->instructauthorsformat, array('overflowdiv'=>true)), array('generalbox', 'instructions')); |
ef96efe0 DM |
105 | print_collapsible_region_end(); |
106 | } | |
ef96efe0 | 107 | |
2f289d36 DM |
108 | // does the user have to assess examples before submitting their own work? |
109 | $examplesmust = ($workshop->useexamples and $workshop->examplesmode == workshop::EXAMPLES_BEFORE_SUBMISSION); | |
110 | ||
111 | // is the assessment of example submissions considered finished? | |
112 | $examplesdone = has_capability('mod/workshop:manageexamples', $workshop->context); | |
cbf87967 DM |
113 | if ($workshop->assessing_examples_allowed() |
114 | and has_capability('mod/workshop:submit', $workshop->context) | |
115 | and ! has_capability('mod/workshop:manageexamples', $workshop->context)) { | |
cff28ef0 | 116 | $examples = $userplan->get_examples(); |
cbf87967 | 117 | $total = count($examples); |
514d8c22 | 118 | $left = 0; |
cbf87967 DM |
119 | // make sure the current user has all examples allocated |
120 | foreach ($examples as $exampleid => $example) { | |
121 | if (is_null($example->assessmentid)) { | |
67ae13d9 | 122 | $examples[$exampleid]->assessmentid = $workshop->add_allocation($example, $USER->id, 0); |
cbf87967 DM |
123 | } |
124 | if (is_null($example->grade)) { | |
514d8c22 | 125 | $left++; |
ef96efe0 DM |
126 | } |
127 | } | |
514d8c22 | 128 | if ($left > 0 and $workshop->examplesmode != workshop::EXAMPLES_VOLUNTARY) { |
cbf87967 | 129 | $examplesdone = false; |
514d8c22 DM |
130 | } else { |
131 | $examplesdone = true; | |
ef96efe0 | 132 | } |
cff28ef0 | 133 | print_collapsible_region_start('', 'workshop-viewlet-examples', get_string('exampleassessments', 'workshop'), false, $examplesdone); |
55fc1e59 | 134 | echo $output->box_start('generalbox exampleassessments'); |
cbf87967 | 135 | if ($total == 0) { |
55fc1e59 | 136 | echo $output->heading(get_string('noexamples', 'workshop'), 3); |
cbf87967 DM |
137 | } else { |
138 | foreach ($examples as $example) { | |
139 | $summary = $workshop->prepare_example_summary($example); | |
81b22887 | 140 | echo $output->render($summary); |
cbf87967 | 141 | } |
ef96efe0 | 142 | } |
55fc1e59 | 143 | echo $output->box_end(); |
cbf87967 | 144 | print_collapsible_region_end(); |
6516b9e9 | 145 | } |
cbf87967 | 146 | |
2f289d36 | 147 | if (has_capability('mod/workshop:submit', $PAGE->context) and (!$examplesmust or $examplesdone)) { |
ef96efe0 | 148 | print_collapsible_region_start('', 'workshop-viewlet-ownsubmission', get_string('yoursubmission', 'workshop')); |
55fc1e59 | 149 | echo $output->box_start('generalbox ownsubmission'); |
e9b0f0ab | 150 | if ($submission = $workshop->get_submission_by_author($USER->id)) { |
81b22887 | 151 | echo $output->render($workshop->prepare_submission_summary($submission, true)); |
2f289d36 DM |
152 | if ($workshop->modifying_submission_allowed()) { |
153 | $btnurl = new moodle_url($workshop->submission_url(), array('edit' => 'on')); | |
154 | $btntxt = get_string('editsubmission', 'workshop'); | |
155 | } | |
81eccf0a | 156 | } else { |
55fc1e59 | 157 | echo $output->container(get_string('noyoursubmission', 'workshop')); |
2f289d36 DM |
158 | if ($workshop->creating_submission_allowed()) { |
159 | $btnurl = new moodle_url($workshop->submission_url(), array('edit' => 'on')); | |
160 | $btntxt = get_string('createsubmission', 'workshop'); | |
161 | } | |
81eccf0a | 162 | } |
2f289d36 DM |
163 | if (!empty($btnurl)) { |
164 | echo $output->single_button($btnurl, $btntxt, 'get'); | |
e9b0f0ab | 165 | } |
55fc1e59 | 166 | echo $output->box_end(); |
ef96efe0 | 167 | print_collapsible_region_end(); |
e9b0f0ab | 168 | } |
cbf87967 | 169 | |
e9b0f0ab DM |
170 | if (has_capability('mod/workshop:viewallsubmissions', $PAGE->context)) { |
171 | $shownames = has_capability('mod/workshop:viewauthornames', $PAGE->context); | |
ef96efe0 | 172 | print_collapsible_region_start('', 'workshop-viewlet-allsubmissions', get_string('allsubmissions', 'workshop')); |
55fc1e59 | 173 | echo $output->box_start('generalbox allsubmissions'); |
29dc43e7 | 174 | if (! $submissions = $workshop->get_submissions('all')) { |
55fc1e59 | 175 | echo $output->container(get_string('nosubmissions', 'workshop'), 'nosubmissions'); |
ddb59c77 | 176 | } |
3dc78e5b | 177 | foreach ($submissions as $submission) { |
81b22887 | 178 | echo $output->render($workshop->prepare_submission_summary($submission, $shownames)); |
e9b0f0ab | 179 | } |
55fc1e59 | 180 | echo $output->box_end(); |
ef96efe0 | 181 | print_collapsible_region_end(); |
e9b0f0ab | 182 | } |
cbf87967 | 183 | |
e9b0f0ab | 184 | break; |
cbf87967 | 185 | |
b761e6d9 | 186 | case workshop::PHASE_ASSESSMENT: |
2f289d36 DM |
187 | |
188 | $ownsubmissionexists = null; | |
189 | if (has_capability('mod/workshop:submit', $PAGE->context)) { | |
190 | if ($ownsubmission = $workshop->get_submission_by_author($USER->id)) { | |
191 | print_collapsible_region_start('', 'workshop-viewlet-ownsubmission', get_string('yoursubmission', 'workshop'), false, true); | |
192 | echo $output->box_start('generalbox ownsubmission'); | |
81b22887 | 193 | echo $output->render($workshop->prepare_submission_summary($ownsubmission, true)); |
2f289d36 DM |
194 | $ownsubmissionexists = true; |
195 | } else { | |
196 | print_collapsible_region_start('', 'workshop-viewlet-ownsubmission', get_string('yoursubmission', 'workshop')); | |
197 | echo $output->box_start('generalbox ownsubmission'); | |
198 | echo $output->container(get_string('noyoursubmission', 'workshop')); | |
199 | $ownsubmissionexists = false; | |
200 | if ($workshop->creating_submission_allowed()) { | |
201 | $btnurl = new moodle_url($workshop->submission_url(), array('edit' => 'on')); | |
202 | $btntxt = get_string('createsubmission', 'workshop'); | |
203 | } | |
204 | } | |
205 | if (!empty($btnurl)) { | |
206 | echo $output->single_button($btnurl, $btntxt, 'get'); | |
207 | } | |
208 | echo $output->box_end(); | |
209 | print_collapsible_region_end(); | |
210 | } | |
211 | ||
d183140d DM |
212 | if (has_capability('mod/workshop:viewallassessments', $PAGE->context)) { |
213 | $page = optional_param('page', 0, PARAM_INT); | |
214 | $sortby = optional_param('sortby', 'lastname', PARAM_ALPHA); | |
215 | $sorthow = optional_param('sorthow', 'ASC', PARAM_ALPHA); | |
216 | $perpage = 10; // todo let the user modify this | |
217 | $groups = ''; // todo let the user choose the group | |
a6855934 | 218 | $PAGE->set_url($PAGE->url, compact('sortby', 'sorthow', 'page')); // TODO: this is suspicious |
c2a35266 | 219 | $data = $workshop->prepare_grading_report_data($USER->id, $groups, $page, $perpage, $sortby, $sorthow); |
d183140d DM |
220 | if ($data) { |
221 | $showauthornames = has_capability('mod/workshop:viewauthornames', $workshop->context); | |
222 | $showreviewernames = has_capability('mod/workshop:viewreviewernames', $workshop->context); | |
223 | ||
224 | // prepare paging bar | |
929d7a83 | 225 | $pagingbar = new paging_bar($data->totalcount, $page, $perpage, $PAGE->url, 'page'); |
d183140d DM |
226 | |
227 | // grading report display options | |
7a789aa8 | 228 | $reportopts = new stdclass(); |
d183140d DM |
229 | $reportopts->showauthornames = $showauthornames; |
230 | $reportopts->showreviewernames = $showreviewernames; | |
231 | $reportopts->sortby = $sortby; | |
232 | $reportopts->sorthow = $sorthow; | |
233 | $reportopts->showsubmissiongrade = false; | |
234 | $reportopts->showgradinggrade = false; | |
d183140d | 235 | |
55fc1e59 | 236 | echo $output->render($pagingbar); |
c2a35266 | 237 | echo $output->render(new workshop_grading_report($data, $reportopts)); |
55fc1e59 | 238 | echo $output->render($pagingbar); |
d183140d DM |
239 | } |
240 | } | |
bfbca63d | 241 | if (trim($workshop->instructreviewers)) { |
15d12b54 | 242 | $instructions = file_rewrite_pluginfile_urls($workshop->instructreviewers, 'pluginfile.php', $PAGE->context->id, |
64f93798 | 243 | 'mod_workshop', 'instructreviewers', 0, workshop::instruction_editors_options($PAGE->context)); |
ef96efe0 | 244 | print_collapsible_region_start('', 'workshop-viewlet-instructreviewers', get_string('instructreviewers', 'workshop')); |
367a75fa | 245 | echo $output->box(format_text($instructions, $workshop->instructreviewersformat, array('overflowdiv'=>true)), array('generalbox', 'instructions')); |
ef96efe0 | 246 | print_collapsible_region_end(); |
15d12b54 | 247 | } |
2f289d36 DM |
248 | |
249 | // does the user have to assess examples before assessing other's work? | |
250 | $examplesmust = ($workshop->useexamples and $workshop->examplesmode == workshop::EXAMPLES_BEFORE_ASSESSMENT); | |
251 | ||
252 | // is the assessment of example submissions considered finished? | |
253 | $examplesdone = has_capability('mod/workshop:manageexamples', $workshop->context); | |
254 | ||
255 | // can the examples be assessed? | |
256 | $examplesavailable = true; | |
257 | ||
258 | if (!$examplesdone and $examplesmust and ($ownsubmissionexists === false)) { | |
259 | print_collapsible_region_start('', 'workshop-viewlet-examplesfail', get_string('exampleassessments', 'workshop')); | |
260 | echo $output->box(get_string('exampleneedsubmission', 'workshop')); | |
261 | print_collapsible_region_end(); | |
262 | $examplesavailable = false; | |
263 | } | |
264 | ||
cff28ef0 DM |
265 | if ($workshop->assessing_examples_allowed() |
266 | and has_capability('mod/workshop:submit', $workshop->context) | |
2f289d36 DM |
267 | and ! has_capability('mod/workshop:manageexamples', $workshop->context) |
268 | and $examplesavailable) { | |
cff28ef0 DM |
269 | $examples = $userplan->get_examples(); |
270 | $total = count($examples); | |
271 | $left = 0; | |
272 | // make sure the current user has all examples allocated | |
273 | foreach ($examples as $exampleid => $example) { | |
274 | if (is_null($example->assessmentid)) { | |
275 | $examples[$exampleid]->assessmentid = $workshop->add_allocation($example, $USER->id, 0); | |
ddb59c77 | 276 | } |
cff28ef0 DM |
277 | if (is_null($example->grade)) { |
278 | $left++; | |
279 | } | |
280 | } | |
281 | if ($left > 0 and $workshop->examplesmode != workshop::EXAMPLES_VOLUNTARY) { | |
282 | $examplesdone = false; | |
283 | } else { | |
284 | $examplesdone = true; | |
285 | } | |
286 | print_collapsible_region_start('', 'workshop-viewlet-examples', get_string('exampleassessments', 'workshop'), false, $examplesdone); | |
287 | echo $output->box_start('generalbox exampleassessments'); | |
288 | if ($total == 0) { | |
289 | echo $output->heading(get_string('noexamples', 'workshop'), 3); | |
290 | } else { | |
291 | foreach ($examples as $example) { | |
292 | $summary = $workshop->prepare_example_summary($example); | |
81b22887 | 293 | echo $output->render($summary); |
cff28ef0 DM |
294 | } |
295 | } | |
296 | echo $output->box_end(); | |
297 | print_collapsible_region_end(); | |
298 | } | |
2f289d36 | 299 | if (!$examplesmust or $examplesdone) { |
cff28ef0 DM |
300 | print_collapsible_region_start('', 'workshop-viewlet-assignedassessments', get_string('assignedassessments', 'workshop')); |
301 | if (! $assessments = $workshop->get_assessments_by_reviewer($USER->id)) { | |
302 | echo $output->box_start('generalbox assessment-none'); | |
303 | echo $output->heading(get_string('assignedassessmentsnone', 'workshop'), 3); | |
55fc1e59 | 304 | echo $output->box_end(); |
cff28ef0 DM |
305 | } else { |
306 | $shownames = has_capability('mod/workshop:viewauthornames', $PAGE->context); | |
307 | foreach ($assessments as $assessment) { | |
81b22887 | 308 | $submission = new stdClass(); |
cff28ef0 DM |
309 | $submission->id = $assessment->submissionid; |
310 | $submission->title = $assessment->submissiontitle; | |
311 | $submission->timecreated = $assessment->submissioncreated; | |
312 | $submission->timemodified = $assessment->submissionmodified; | |
313 | $submission->authorid = $assessment->authorid; | |
314 | $submission->authorfirstname = $assessment->authorfirstname; | |
315 | $submission->authorlastname = $assessment->authorlastname; | |
316 | $submission->authorpicture = $assessment->authorpicture; | |
317 | $submission->authorimagealt = $assessment->authorimagealt; | |
3a11c09f | 318 | $submission->authoremail = $assessment->authoremail; |
81b22887 DM |
319 | |
320 | // transform the submission object into renderable component | |
321 | $submission = $workshop->prepare_submission_summary($submission, $shownames); | |
322 | ||
cff28ef0 | 323 | if (is_null($assessment->grade)) { |
4d63c194 | 324 | $submission->status = 'notgraded'; |
81b22887 | 325 | $class = ' notgraded'; |
cff28ef0 DM |
326 | $buttontext = get_string('assess', 'workshop'); |
327 | } else { | |
4d63c194 | 328 | $submission->status = 'graded'; |
81b22887 | 329 | $class = ' graded'; |
cff28ef0 DM |
330 | $buttontext = get_string('reassess', 'workshop'); |
331 | } | |
4d63c194 | 332 | |
cff28ef0 | 333 | echo $output->box_start('generalbox assessment-summary' . $class); |
81b22887 | 334 | echo $output->render($submission); |
cff28ef0 DM |
335 | $aurl = $workshop->assess_url($assessment->id); |
336 | echo $output->single_button($aurl, $buttontext, 'get'); | |
337 | echo $output->box_end(); | |
338 | } | |
ddb59c77 | 339 | } |
cff28ef0 | 340 | print_collapsible_region_end(); |
ddb59c77 | 341 | } |
00aca3c1 | 342 | break; |
b761e6d9 | 343 | case workshop::PHASE_EVALUATION: |
d183140d | 344 | if (has_capability('mod/workshop:viewallassessments', $PAGE->context)) { |
1fed6ce3 DM |
345 | $page = optional_param('page', 0, PARAM_INT); |
346 | $sortby = optional_param('sortby', 'lastname', PARAM_ALPHA); | |
347 | $sorthow = optional_param('sorthow', 'ASC', PARAM_ALPHA); | |
348 | $perpage = 10; // todo let the user modify this | |
349 | $groups = ''; // todo let the user choose the group | |
a6855934 | 350 | $PAGE->set_url($PAGE->url, compact('sortby', 'sorthow', 'page')); // TODO: this is suspicious |
c2a35266 | 351 | $data = $workshop->prepare_grading_report_data($USER->id, $groups, $page, $perpage, $sortby, $sorthow); |
1fed6ce3 | 352 | if ($data) { |
f55650e6 DM |
353 | $showauthornames = has_capability('mod/workshop:viewauthornames', $workshop->context); |
354 | $showreviewernames = has_capability('mod/workshop:viewreviewernames', $workshop->context); | |
355 | ||
d183140d DM |
356 | if (has_capability('mod/workshop:overridegrades', $PAGE->context)) { |
357 | // load the grading evaluator | |
358 | $evaluator = $workshop->grading_evaluation_instance(); | |
359 | $form = $evaluator->get_settings_form(new moodle_url($workshop->aggregate_url(), | |
360 | compact('sortby', 'sorthow', 'page'))); | |
361 | $form->display(); | |
362 | } | |
1fed6ce3 DM |
363 | |
364 | // prepare paging bar | |
929d7a83 | 365 | $pagingbar = new paging_bar($data->totalcount, $page, $perpage, $PAGE->url, 'page'); |
1fed6ce3 | 366 | |
d183140d | 367 | // grading report display options |
7a789aa8 | 368 | $reportopts = new stdclass(); |
d183140d DM |
369 | $reportopts->showauthornames = $showauthornames; |
370 | $reportopts->showreviewernames = $showreviewernames; | |
371 | $reportopts->sortby = $sortby; | |
372 | $reportopts->sorthow = $sorthow; | |
373 | $reportopts->showsubmissiongrade = true; | |
374 | $reportopts->showgradinggrade = true; | |
d183140d | 375 | |
55fc1e59 | 376 | echo $output->render($pagingbar); |
c2a35266 | 377 | echo $output->render(new workshop_grading_report($data, $reportopts)); |
55fc1e59 | 378 | echo $output->render($pagingbar); |
e807e9a3 | 379 | } |
1fed6ce3 | 380 | } |
32c78bc3 | 381 | if (has_capability('mod/workshop:overridegrades', $workshop->context)) { |
e706b9c3 | 382 | print_collapsible_region_start('', 'workshop-viewlet-cleargrades', get_string('toolbox', 'workshop'), false, true); |
32c78bc3 | 383 | echo $output->box_start('generalbox toolbox'); |
e706b9c3 | 384 | |
32c78bc3 | 385 | // Clear aggregated grades |
e706b9c3 | 386 | $url = new moodle_url($workshop->toolbox_url('clearaggregatedgrades')); |
32c78bc3 DM |
387 | $btn = new single_button($url, get_string('clearaggregatedgrades', 'workshop'), 'post'); |
388 | $btn->add_confirm_action(get_string('clearaggregatedgradesconfirm', 'workshop')); | |
e706b9c3 | 389 | echo $output->container_start('toolboxaction'); |
32c78bc3 DM |
390 | echo $output->render($btn); |
391 | echo $output->help_icon('clearaggregatedgrades', 'workshop'); | |
e706b9c3 DM |
392 | echo $output->container_end(); |
393 | // Clear assessments | |
394 | $url = new moodle_url($workshop->toolbox_url('clearassessments')); | |
395 | $btn = new single_button($url, get_string('clearassessments', 'workshop'), 'post'); | |
396 | $btn->add_confirm_action(get_string('clearassessmentsconfirm', 'workshop')); | |
397 | echo $output->container_start('toolboxaction'); | |
398 | echo $output->render($btn); | |
399 | echo $output->help_icon('clearassessments', 'workshop'); | |
400 | echo html_writer::empty_tag('img', array('src' => $output->pix_url('i/risk_dataloss'), | |
401 | 'title' => get_string('riskdatalossshort', 'admin'), | |
402 | 'alt' => get_string('riskdatalossshort', 'admin'))); | |
403 | echo $output->container_end(); | |
32c78bc3 DM |
404 | |
405 | echo $output->box_end(); | |
406 | print_collapsible_region_end(); | |
407 | } | |
4d63c194 DM |
408 | if (has_capability('mod/workshop:submit', $PAGE->context)) { |
409 | print_collapsible_region_start('', 'workshop-viewlet-ownsubmission', get_string('yoursubmission', 'workshop')); | |
410 | echo $output->box_start('generalbox ownsubmission'); | |
411 | if ($submission = $workshop->get_submission_by_author($USER->id)) { | |
757bade1 | 412 | echo $output->render($workshop->prepare_submission_summary($submission, true)); |
4d63c194 DM |
413 | } else { |
414 | echo $output->container(get_string('noyoursubmission', 'workshop')); | |
415 | } | |
416 | echo $output->box_end(); | |
417 | print_collapsible_region_end(); | |
418 | } | |
419 | if ($assessments = $workshop->get_assessments_by_reviewer($USER->id)) { | |
420 | print_collapsible_region_start('', 'workshop-viewlet-assignedassessments', get_string('assignedassessments', 'workshop')); | |
421 | $shownames = has_capability('mod/workshop:viewauthornames', $PAGE->context); | |
422 | foreach ($assessments as $assessment) { | |
423 | $submission = new stdclass(); | |
424 | $submission->id = $assessment->submissionid; | |
425 | $submission->title = $assessment->submissiontitle; | |
426 | $submission->timecreated = $assessment->submissioncreated; | |
427 | $submission->timemodified = $assessment->submissionmodified; | |
428 | $submission->authorid = $assessment->authorid; | |
429 | $submission->authorfirstname = $assessment->authorfirstname; | |
430 | $submission->authorlastname = $assessment->authorlastname; | |
431 | $submission->authorpicture = $assessment->authorpicture; | |
432 | $submission->authorimagealt = $assessment->authorimagealt; | |
3a11c09f | 433 | $submission->authoremail = $assessment->authoremail; |
4d63c194 DM |
434 | |
435 | if (is_null($assessment->grade)) { | |
436 | $class = ' notgraded'; | |
437 | $submission->status = 'notgraded'; | |
438 | $buttontext = get_string('assess', 'workshop'); | |
439 | } else { | |
440 | $class = ' graded'; | |
441 | $submission->status = 'graded'; | |
442 | $buttontext = get_string('reassess', 'workshop'); | |
443 | } | |
444 | echo $output->box_start('generalbox assessment-summary' . $class); | |
81b22887 | 445 | echo $output->render($workshop->prepare_submission_summary($submission, $shownames)); |
4d63c194 DM |
446 | echo $output->box_end(); |
447 | } | |
448 | print_collapsible_region_end(); | |
449 | } | |
1fed6ce3 DM |
450 | break; |
451 | case workshop::PHASE_CLOSED: | |
5a372494 DM |
452 | if (has_capability('mod/workshop:viewallassessments', $PAGE->context)) { |
453 | $page = optional_param('page', 0, PARAM_INT); | |
454 | $sortby = optional_param('sortby', 'lastname', PARAM_ALPHA); | |
455 | $sorthow = optional_param('sorthow', 'ASC', PARAM_ALPHA); | |
456 | $perpage = 10; // todo let the user modify this | |
457 | $groups = ''; // todo let the user choose the group | |
458 | $PAGE->set_url($PAGE->url, compact('sortby', 'sorthow', 'page')); // TODO: this is suspicious | |
c2a35266 | 459 | $data = $workshop->prepare_grading_report_data($USER->id, $groups, $page, $perpage, $sortby, $sorthow); |
5a372494 DM |
460 | if ($data) { |
461 | $showauthornames = has_capability('mod/workshop:viewauthornames', $workshop->context); | |
462 | $showreviewernames = has_capability('mod/workshop:viewreviewernames', $workshop->context); | |
463 | ||
464 | // prepare paging bar | |
465 | $pagingbar = new paging_bar($data->totalcount, $page, $perpage, $PAGE->url, 'page'); | |
466 | ||
467 | // grading report display options | |
468 | $reportopts = new stdclass(); | |
469 | $reportopts->showauthornames = $showauthornames; | |
470 | $reportopts->showreviewernames = $showreviewernames; | |
471 | $reportopts->sortby = $sortby; | |
472 | $reportopts->sorthow = $sorthow; | |
473 | $reportopts->showsubmissiongrade = true; | |
474 | $reportopts->showgradinggrade = true; | |
475 | ||
476 | print_collapsible_region_start('', 'workshop-viewlet-gradereport', get_string('gradesreport', 'workshop')); | |
477 | echo $output->render($pagingbar); | |
c2a35266 | 478 | echo $output->render(new workshop_grading_report($data, $reportopts)); |
5a372494 DM |
479 | echo $output->render($pagingbar); |
480 | print_collapsible_region_end(); | |
481 | } | |
482 | } | |
0aed4a55 DM |
483 | if (has_capability('mod/workshop:submit', $PAGE->context)) { |
484 | print_collapsible_region_start('', 'workshop-viewlet-ownsubmission', get_string('yoursubmission', 'workshop')); | |
485 | echo $output->box_start('generalbox ownsubmission'); | |
486 | if ($submission = $workshop->get_submission_by_author($USER->id)) { | |
81b22887 | 487 | echo $output->render($workshop->prepare_submission_summary($submission, true)); |
0aed4a55 DM |
488 | } else { |
489 | echo $output->container(get_string('noyoursubmission', 'workshop')); | |
490 | } | |
491 | echo $output->box_end(); | |
492 | print_collapsible_region_end(); | |
493 | } | |
00bc77ee | 494 | if (has_capability('mod/workshop:viewpublishedsubmissions', $workshop->context)) { |
e13d02f5 | 495 | $shownames = has_capability('mod/workshop:viewauthorpublished', $workshop->context); |
00bc77ee DM |
496 | if ($submissions = $workshop->get_published_submissions()) { |
497 | print_collapsible_region_start('', 'workshop-viewlet-publicsubmissions', get_string('publishedsubmissions', 'workshop')); | |
498 | foreach ($submissions as $submission) { | |
499 | echo $output->box_start('generalbox submission-summary'); | |
e13d02f5 | 500 | echo $output->render($workshop->prepare_submission_summary($submission, $shownames)); |
00bc77ee DM |
501 | echo $output->box_end(); |
502 | } | |
503 | print_collapsible_region_end(); | |
504 | } | |
505 | } | |
29dc43e7 | 506 | break; |
b761e6d9 DM |
507 | default: |
508 | } | |
509 | ||
3a7507d0 SM |
510 | $completion = new completion_info($course); |
511 | $completion->set_module_viewed($cm); | |
512 | ||
55fc1e59 | 513 | echo $output->footer(); |