Differences Between: [Versions 310 and 400] [Versions 311 and 400] [Versions 39 and 400] [Versions 400 and 401] [Versions 400 and 402] [Versions 400 and 403]
1 <?php 2 3 // This file is part of Moodle - http://moodle.org/ 4 // 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. 14 // 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/>. 17 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 * 24 * @package mod_workshop 25 * @copyright 2009 David Mudrak <david.mudrak@gmail.com> 26 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 27 */ 28 29 require(__DIR__.'/../../config.php'); 30 require_once (__DIR__.'/locallib.php'); 31 32 $id = optional_param('id', 0, PARAM_INT); // course_module ID, or 33 $w = optional_param('w', 0, PARAM_INT); // workshop instance ID 34 $editmode = optional_param('editmode', null, PARAM_BOOL); 35 $page = optional_param('page', 0, PARAM_INT); 36 $perpage = optional_param('perpage', null, PARAM_INT); 37 $sortby = optional_param('sortby', 'lastname', PARAM_ALPHA); 38 $sorthow = optional_param('sorthow', 'ASC', PARAM_ALPHA); 39 $eval = optional_param('eval', null, PARAM_PLUGIN); 40 41 if ($id) { 42 $cm = get_coursemodule_from_id('workshop', $id, 0, false, MUST_EXIST); 43 $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); 44 $workshoprecord = $DB->get_record('workshop', array('id' => $cm->instance), '*', MUST_EXIST); 45 } else { 46 $workshoprecord = $DB->get_record('workshop', array('id' => $w), '*', MUST_EXIST); 47 $course = $DB->get_record('course', array('id' => $workshoprecord->course), '*', MUST_EXIST); 48 $cm = get_coursemodule_from_instance('workshop', $workshoprecord->id, $course->id, false, MUST_EXIST); 49 } 50 51 require_login($course, true, $cm); 52 require_capability('mod/workshop:view', $PAGE->context); 53 54 $workshop = new workshop($workshoprecord, $cm, $course); 55 56 $PAGE->set_url($workshop->view_url()); 57 58 // Mark viewed. 59 $workshop->set_module_viewed(); 60 61 // If the phase is to be switched, do it asap. This just has to happen after triggering 62 // the event so that the scheduled allocator had a chance to allocate submissions. 63 if ($workshop->phase == workshop::PHASE_SUBMISSION and $workshop->phaseswitchassessment 64 and $workshop->submissionend > 0 and $workshop->submissionend < time()) { 65 $workshop->switch_phase(workshop::PHASE_ASSESSMENT); 66 // Disable the automatic switching now so that it is not executed again by accident 67 // if the teacher changes the phase back to the submission one. 68 $DB->set_field('workshop', 'phaseswitchassessment', 0, array('id' => $workshop->id)); 69 $workshop->phaseswitchassessment = 0; 70 } 71 72 if (!is_null($editmode) && $PAGE->user_allowed_editing()) { 73 $USER->editing = $editmode; 74 } 75 76 $userplan = new workshop_user_plan($workshop, $USER->id); 77 78 foreach ($userplan->phases as $phase) { 79 if ($phase->active) { 80 $currentphasetitle = $phase->title; 81 } 82 } 83 84 $PAGE->set_title($workshop->name . " (" . $currentphasetitle . ")"); 85 $PAGE->set_heading($course->fullname); 86 87 if ($perpage and $perpage > 0 and $perpage <= 1000) { 88 require_sesskey(); 89 set_user_preference('workshop_perpage', $perpage); 90 redirect($PAGE->url); 91 } 92 93 if ($eval) { 94 require_sesskey(); 95 require_capability('mod/workshop:overridegrades', $workshop->context); 96 $workshop->set_grading_evaluation_method($eval); 97 redirect($PAGE->url); 98 } 99 100 $heading = $OUTPUT->heading_with_help(format_string($workshop->name), 'userplan', 'workshop'); 101 $heading = preg_replace('/<h2[^>]*>([.\s\S]*)<\/h2>/', '$1', $heading); 102 $PAGE->activityheader->set_attrs([ 103 'title' => $PAGE->activityheader->is_title_allowed() ? $heading : "", 104 'description' => '' 105 ]); 106 107 $output = $PAGE->get_renderer('mod_workshop'); 108 109 /// Output starts here 110 111 echo $output->header(); 112 113 // Output action buttons here. 114 switch ($workshop->phase) { 115 case workshop::PHASE_SUBMISSION: 116 // Does the user have to assess examples before submitting their own work? 117 $examplesmust = ($workshop->useexamples and $workshop->examplesmode == workshop::EXAMPLES_BEFORE_SUBMISSION); 118 119 // Is the assessment of example submissions considered finished? 120 $examplesdone = has_capability('mod/workshop:manageexamples', $workshop->context); 121 122 if ($workshop->assessing_examples_allowed() && has_capability('mod/workshop:submit', $workshop->context) && 123 !has_capability('mod/workshop:manageexamples', $workshop->context)) { 124 $examples = $userplan->get_examples(); 125 $left = 0; 126 // Make sure the current user has all examples allocated. 127 foreach ($examples as $exampleid => $example) { 128 if (is_null($example->grade)) { 129 $left++; 130 break; 131 } 132 } 133 if ($left > 0 and $workshop->examplesmode != workshop::EXAMPLES_VOLUNTARY) { 134 $examplesdone = false; 135 } else { 136 $examplesdone = true; 137 } 138 } 139 140 if (has_capability('mod/workshop:submit', $PAGE->context) and (!$examplesmust or $examplesdone)) { 141 if (!$workshop->get_submission_by_author($USER->id)) { 142 $btnurl = new moodle_url($workshop->submission_url(), ['edit' => 'on']); 143 $btntxt = get_string('createsubmission', 'workshop'); 144 echo $output->single_button($btnurl, $btntxt, 'get', ['primary' => true]); 145 } 146 } 147 break; 148 149 case workshop::PHASE_ASSESSMENT: 150 if (has_capability('mod/workshop:submit', $PAGE->context)) { 151 if (!$workshop->get_submission_by_author($USER->id)) { 152 if ($workshop->creating_submission_allowed($USER->id)) { 153 $btnurl = new moodle_url($workshop->submission_url(), array('edit' => 'on')); 154 $btntxt = get_string('createsubmission', 'workshop'); 155 echo $output->single_button($btnurl, $btntxt, 'get', ['primary' => true]); 156 } 157 } 158 } 159 } 160 161 echo $output->heading(format_string($currentphasetitle), 3, null, 'mod_workshop-userplanheading'); 162 echo $output->render($userplan); 163 164 switch ($workshop->phase) { 165 case workshop::PHASE_SETUP: 166 if (trim($workshop->intro)) { 167 print_collapsible_region_start('', 'workshop-viewlet-intro', get_string('introduction', 'workshop'), 168 'workshop-viewlet-intro-collapsed'); 169 echo $output->box(format_module_intro('workshop', $workshop, $workshop->cm->id), 'generalbox'); 170 print_collapsible_region_end(); 171 } 172 if ($workshop->useexamples and has_capability('mod/workshop:manageexamples', $PAGE->context)) { 173 print_collapsible_region_start('', 'workshop-viewlet-allexamples', get_string('examplesubmissions', 'workshop'), 174 'workshop-viewlet-allexamples-collapsed'); 175 echo $output->box_start('generalbox examples'); 176 if ($workshop->grading_strategy_instance()->form_ready()) { 177 if (! $examples = $workshop->get_examples_for_manager()) { 178 echo $output->container(get_string('noexamples', 'workshop'), 'noexamples'); 179 } 180 foreach ($examples as $example) { 181 $summary = $workshop->prepare_example_summary($example); 182 $summary->editable = true; 183 echo $output->render($summary); 184 } 185 $aurl = new moodle_url($workshop->exsubmission_url(0), array('edit' => 'on')); 186 echo $output->single_button($aurl, get_string('exampleadd', 'workshop'), 'get'); 187 } else { 188 echo $output->container(get_string('noexamplesformready', 'workshop')); 189 } 190 echo $output->box_end(); 191 print_collapsible_region_end(); 192 } 193 break; 194 case workshop::PHASE_SUBMISSION: 195 if (trim($workshop->instructauthors)) { 196 $instructions = file_rewrite_pluginfile_urls($workshop->instructauthors, 'pluginfile.php', $PAGE->context->id, 197 'mod_workshop', 'instructauthors', null, workshop::instruction_editors_options($PAGE->context)); 198 print_collapsible_region_start('', 'workshop-viewlet-instructauthors', get_string('instructauthors', 'workshop'), 199 'workshop-viewlet-instructauthors-collapsed'); 200 echo $output->box(format_text($instructions, $workshop->instructauthorsformat, array('overflowdiv'=>true)), array('generalbox', 'instructions')); 201 print_collapsible_region_end(); 202 } 203 204 if ($workshop->assessing_examples_allowed() 205 and has_capability('mod/workshop:submit', $workshop->context) 206 and ! has_capability('mod/workshop:manageexamples', $workshop->context)) { 207 $examples = $userplan->get_examples(); 208 $total = count($examples); 209 print_collapsible_region_start('', 'workshop-viewlet-examples', get_string('exampleassessments', 'workshop'), 210 'workshop-viewlet-examples-collapsed', $examplesdone); 211 echo $output->box_start('generalbox exampleassessments'); 212 if ($total == 0) { 213 echo $output->heading(get_string('noexamples', 'workshop'), 3); 214 } else { 215 foreach ($examples as $example) { 216 $summary = $workshop->prepare_example_summary($example); 217 echo $output->render($summary); 218 } 219 } 220 echo $output->box_end(); 221 print_collapsible_region_end(); 222 } 223 224 if (has_capability('mod/workshop:submit', $PAGE->context) and (!$examplesmust or $examplesdone)) { 225 print_collapsible_region_start('', 'workshop-viewlet-ownsubmission', get_string('yoursubmission', 'workshop'), 226 'workshop-viewlet-ownsubmission-collapsed'); 227 echo $output->box_start('generalbox ownsubmission'); 228 if ($submission = $workshop->get_submission_by_author($USER->id)) { 229 echo $output->render($workshop->prepare_submission_summary($submission, true)); 230 } else { 231 echo $output->container(get_string('noyoursubmission', 'workshop')); 232 } 233 234 echo $output->box_end(); 235 print_collapsible_region_end(); 236 } 237 238 if (has_capability('mod/workshop:viewallsubmissions', $PAGE->context)) { 239 $groupmode = groups_get_activity_groupmode($workshop->cm); 240 $groupid = groups_get_activity_group($workshop->cm, true); 241 242 if ($groupmode == SEPARATEGROUPS and !has_capability('moodle/site:accessallgroups', $workshop->context)) { 243 $allowedgroups = groups_get_activity_allowed_groups($workshop->cm); 244 if (empty($allowedgroups)) { 245 echo $output->container(get_string('groupnoallowed', 'mod_workshop'), 'groupwidget error'); 246 break; 247 } 248 if (! in_array($groupid, array_keys($allowedgroups))) { 249 echo $output->container(get_string('groupnotamember', 'core_group'), 'groupwidget error'); 250 break; 251 } 252 } 253 254 print_collapsible_region_start('', 'workshop-viewlet-allsubmissions', get_string('submissionsreport', 'workshop'), 255 'workshop-viewlet-allsubmissions-collapsed'); 256 257 $perpage = get_user_preferences('workshop_perpage', 10); 258 $data = $workshop->prepare_grading_report_data($USER->id, $groupid, $page, $perpage, $sortby, $sorthow); 259 if ($data) { 260 $countparticipants = $workshop->count_participants(); 261 $countsubmissions = $workshop->count_submissions(array_keys($data->grades), $groupid); 262 $a = new stdClass(); 263 $a->submitted = $countsubmissions; 264 $a->notsubmitted = $data->totalcount - $countsubmissions; 265 266 echo html_writer::tag('div', get_string('submittednotsubmitted', 'workshop', $a)); 267 268 echo $output->container(groups_print_activity_menu($workshop->cm, $PAGE->url, true), 'groupwidget'); 269 270 // Prepare the paging bar. 271 $baseurl = new moodle_url($PAGE->url, array('sortby' => $sortby, 'sorthow' => $sorthow)); 272 $pagingbar = new paging_bar($data->totalcount, $page, $perpage, $baseurl, 'page'); 273 274 // Populate the display options for the submissions report. 275 $reportopts = new stdclass(); 276 $reportopts->showauthornames = has_capability('mod/workshop:viewauthornames', $workshop->context); 277 $reportopts->showreviewernames = has_capability('mod/workshop:viewreviewernames', $workshop->context); 278 $reportopts->sortby = $sortby; 279 $reportopts->sorthow = $sorthow; 280 $reportopts->showsubmissiongrade = false; 281 $reportopts->showgradinggrade = false; 282 $reportopts->workshopphase = $workshop->phase; 283 284 echo $output->render($pagingbar); 285 echo $output->render(new workshop_grading_report($data, $reportopts)); 286 echo $output->render($pagingbar); 287 echo $output->perpage_selector($perpage); 288 } else { 289 echo html_writer::tag('div', get_string('nothingfound', 'workshop'), array('class' => 'nothingfound')); 290 } 291 print_collapsible_region_end(); 292 } 293 break; 294 295 case workshop::PHASE_ASSESSMENT: 296 297 $ownsubmissionexists = null; 298 if (has_capability('mod/workshop:submit', $PAGE->context)) { 299 if ($ownsubmission = $workshop->get_submission_by_author($USER->id)) { 300 print_collapsible_region_start('', 'workshop-viewlet-ownsubmission', get_string('yoursubmission', 'workshop'), 301 'workshop-viewlet-ownsubmission-collapsed', true); 302 echo $output->box_start('generalbox ownsubmission'); 303 echo $output->render($workshop->prepare_submission_summary($ownsubmission, true)); 304 $ownsubmissionexists = true; 305 } else { 306 print_collapsible_region_start('', 'workshop-viewlet-ownsubmission', get_string('yoursubmission', 'workshop'), 307 'workshop-viewlet-ownsubmission-collapsed'); 308 echo $output->box_start('generalbox ownsubmission'); 309 echo $output->container(get_string('noyoursubmission', 'workshop')); 310 $ownsubmissionexists = false; 311 } 312 313 echo $output->box_end(); 314 print_collapsible_region_end(); 315 } 316 317 if (has_capability('mod/workshop:viewallassessments', $PAGE->context)) { 318 $perpage = get_user_preferences('workshop_perpage', 10); 319 $groupid = groups_get_activity_group($workshop->cm, true); 320 $data = $workshop->prepare_grading_report_data($USER->id, $groupid, $page, $perpage, $sortby, $sorthow); 321 if ($data) { 322 $showauthornames = has_capability('mod/workshop:viewauthornames', $workshop->context); 323 $showreviewernames = has_capability('mod/workshop:viewreviewernames', $workshop->context); 324 325 // prepare paging bar 326 $baseurl = new moodle_url($PAGE->url, array('sortby' => $sortby, 'sorthow' => $sorthow)); 327 $pagingbar = new paging_bar($data->totalcount, $page, $perpage, $baseurl, 'page'); 328 329 // grading report display options 330 $reportopts = new stdclass(); 331 $reportopts->showauthornames = $showauthornames; 332 $reportopts->showreviewernames = $showreviewernames; 333 $reportopts->sortby = $sortby; 334 $reportopts->sorthow = $sorthow; 335 $reportopts->showsubmissiongrade = false; 336 $reportopts->showgradinggrade = false; 337 $reportopts->workshopphase = $workshop->phase; 338 339 print_collapsible_region_start('', 'workshop-viewlet-gradereport', get_string('gradesreport', 'workshop'), 340 'workshop-viewlet-gradereport-collapsed'); 341 echo $output->box_start('generalbox gradesreport'); 342 echo $output->container(groups_print_activity_menu($workshop->cm, $PAGE->url, true), 'groupwidget'); 343 echo $output->render($pagingbar); 344 echo $output->render(new workshop_grading_report($data, $reportopts)); 345 echo $output->render($pagingbar); 346 echo $output->perpage_selector($perpage); 347 echo $output->box_end(); 348 print_collapsible_region_end(); 349 } 350 } 351 if (trim($workshop->instructreviewers)) { 352 $instructions = file_rewrite_pluginfile_urls($workshop->instructreviewers, 'pluginfile.php', $PAGE->context->id, 353 'mod_workshop', 'instructreviewers', null, workshop::instruction_editors_options($PAGE->context)); 354 print_collapsible_region_start('', 'workshop-viewlet-instructreviewers', get_string('instructreviewers', 'workshop'), 355 'workshop-viewlet-instructreviewers-collapsed'); 356 echo $output->box(format_text($instructions, $workshop->instructreviewersformat, array('overflowdiv'=>true)), array('generalbox', 'instructions')); 357 print_collapsible_region_end(); 358 } 359 360 // does the user have to assess examples before assessing other's work? 361 $examplesmust = ($workshop->useexamples and $workshop->examplesmode == workshop::EXAMPLES_BEFORE_ASSESSMENT); 362 363 // is the assessment of example submissions considered finished? 364 $examplesdone = has_capability('mod/workshop:manageexamples', $workshop->context); 365 366 // can the examples be assessed? 367 $examplesavailable = true; 368 369 if (!$examplesdone and $examplesmust and ($ownsubmissionexists === false)) { 370 print_collapsible_region_start('', 'workshop-viewlet-examplesfail', get_string('exampleassessments', 'workshop'), 371 'workshop-viewlet-examplesfail-collapsed'); 372 echo $output->box(get_string('exampleneedsubmission', 'workshop')); 373 print_collapsible_region_end(); 374 $examplesavailable = false; 375 } 376 377 if ($workshop->assessing_examples_allowed() 378 and has_capability('mod/workshop:submit', $workshop->context) 379 and ! has_capability('mod/workshop:manageexamples', $workshop->context) 380 and $examplesavailable) { 381 $examples = $userplan->get_examples(); 382 $total = count($examples); 383 $left = 0; 384 // make sure the current user has all examples allocated 385 foreach ($examples as $exampleid => $example) { 386 if (is_null($example->assessmentid)) { 387 $examples[$exampleid]->assessmentid = $workshop->add_allocation($example, $USER->id, 0); 388 } 389 if (is_null($example->grade)) { 390 $left++; 391 } 392 } 393 if ($left > 0 and $workshop->examplesmode != workshop::EXAMPLES_VOLUNTARY) { 394 $examplesdone = false; 395 } else { 396 $examplesdone = true; 397 } 398 print_collapsible_region_start('', 'workshop-viewlet-examples', get_string('exampleassessments', 'workshop'), 399 'workshop-viewlet-examples-collapsed', $examplesdone); 400 echo $output->box_start('generalbox exampleassessments'); 401 if ($total == 0) { 402 echo $output->heading(get_string('noexamples', 'workshop'), 3); 403 } else { 404 foreach ($examples as $example) { 405 $summary = $workshop->prepare_example_summary($example); 406 echo $output->render($summary); 407 } 408 } 409 echo $output->box_end(); 410 print_collapsible_region_end(); 411 } 412 if (!$examplesmust or $examplesdone) { 413 print_collapsible_region_start('', 'workshop-viewlet-assignedassessments', get_string('assignedassessments', 'workshop'), 414 'workshop-viewlet-assignedassessments-collapsed'); 415 if (! $assessments = $workshop->get_assessments_by_reviewer($USER->id)) { 416 echo $output->box_start('generalbox assessment-none'); 417 echo $output->notification(get_string('assignedassessmentsnone', 'workshop')); 418 echo $output->box_end(); 419 } else { 420 $shownames = has_capability('mod/workshop:viewauthornames', $PAGE->context); 421 foreach ($assessments as $assessment) { 422 $submission = new stdClass(); 423 $submission->id = $assessment->submissionid; 424 $submission->title = $assessment->submissiontitle; 425 $submission->timecreated = $assessment->submissioncreated; 426 $submission->timemodified = $assessment->submissionmodified; 427 $userpicturefields = explode(',', implode(',', \core_user\fields::get_picture_fields())); 428 foreach ($userpicturefields as $userpicturefield) { 429 $prefixedusernamefield = 'author' . $userpicturefield; 430 $submission->$prefixedusernamefield = $assessment->$prefixedusernamefield; 431 } 432 433 // transform the submission object into renderable component 434 $submission = $workshop->prepare_submission_summary($submission, $shownames); 435 436 if (is_null($assessment->grade)) { 437 $submission->status = 'notgraded'; 438 $class = ' notgraded'; 439 $buttontext = get_string('assess', 'workshop'); 440 } else { 441 $submission->status = 'graded'; 442 $class = ' graded'; 443 $buttontext = get_string('reassess', 'workshop'); 444 } 445 446 echo $output->box_start('generalbox assessment-summary' . $class); 447 echo $output->render($submission); 448 $aurl = $workshop->assess_url($assessment->id); 449 echo $output->single_button($aurl, $buttontext, 'get'); 450 echo $output->box_end(); 451 } 452 } 453 print_collapsible_region_end(); 454 } 455 break; 456 case workshop::PHASE_EVALUATION: 457 if (has_capability('mod/workshop:viewallassessments', $PAGE->context)) { 458 $perpage = get_user_preferences('workshop_perpage', 10); 459 $groupid = groups_get_activity_group($workshop->cm, true); 460 $data = $workshop->prepare_grading_report_data($USER->id, $groupid, $page, $perpage, $sortby, $sorthow); 461 if ($data) { 462 $showauthornames = has_capability('mod/workshop:viewauthornames', $workshop->context); 463 $showreviewernames = has_capability('mod/workshop:viewreviewernames', $workshop->context); 464 465 if (has_capability('mod/workshop:overridegrades', $PAGE->context)) { 466 // Print a drop-down selector to change the current evaluation method. 467 $selector = new single_select($PAGE->url, 'eval', workshop::available_evaluators_list(), 468 $workshop->evaluation, false, 'evaluationmethodchooser'); 469 $selector->set_label(get_string('evaluationmethod', 'mod_workshop')); 470 $selector->set_help_icon('evaluationmethod', 'mod_workshop'); 471 $selector->method = 'post'; 472 echo $output->render($selector); 473 // load the grading evaluator 474 $evaluator = $workshop->grading_evaluation_instance(); 475 $form = $evaluator->get_settings_form(new moodle_url($workshop->aggregate_url(), 476 compact('sortby', 'sorthow', 'page'))); 477 $form->display(); 478 } 479 480 // prepare paging bar 481 $baseurl = new moodle_url($PAGE->url, array('sortby' => $sortby, 'sorthow' => $sorthow)); 482 $pagingbar = new paging_bar($data->totalcount, $page, $perpage, $baseurl, 'page'); 483 484 // grading report display options 485 $reportopts = new stdclass(); 486 $reportopts->showauthornames = $showauthornames; 487 $reportopts->showreviewernames = $showreviewernames; 488 $reportopts->sortby = $sortby; 489 $reportopts->sorthow = $sorthow; 490 $reportopts->showsubmissiongrade = true; 491 $reportopts->showgradinggrade = true; 492 $reportopts->workshopphase = $workshop->phase; 493 494 print_collapsible_region_start('', 'workshop-viewlet-gradereport', get_string('gradesreport', 'workshop'), 495 'workshop-viewlet-gradereport-collapsed'); 496 echo $output->box_start('generalbox gradesreport'); 497 echo $output->container(groups_print_activity_menu($workshop->cm, $PAGE->url, true), 'groupwidget'); 498 echo $output->render($pagingbar); 499 echo $output->render(new workshop_grading_report($data, $reportopts)); 500 echo $output->render($pagingbar); 501 echo $output->perpage_selector($perpage); 502 echo $output->box_end(); 503 print_collapsible_region_end(); 504 } 505 } 506 if (has_capability('mod/workshop:overridegrades', $workshop->context)) { 507 print_collapsible_region_start('', 'workshop-viewlet-cleargrades', get_string('toolbox', 'workshop'), 508 'workshop-viewlet-cleargrades-collapsed', true); 509 echo $output->box_start('generalbox toolbox'); 510 511 // Clear aggregated grades 512 $url = new moodle_url($workshop->toolbox_url('clearaggregatedgrades')); 513 $btn = new single_button($url, get_string('clearaggregatedgrades', 'workshop'), 'post'); 514 $btn->add_confirm_action(get_string('clearaggregatedgradesconfirm', 'workshop')); 515 echo $output->container_start('toolboxaction'); 516 echo $output->render($btn); 517 echo $output->help_icon('clearaggregatedgrades', 'workshop'); 518 echo $output->container_end(); 519 // Clear assessments 520 $url = new moodle_url($workshop->toolbox_url('clearassessments')); 521 $btn = new single_button($url, get_string('clearassessments', 'workshop'), 'post'); 522 $btn->add_confirm_action(get_string('clearassessmentsconfirm', 'workshop')); 523 echo $output->container_start('toolboxaction'); 524 echo $output->render($btn); 525 echo $output->help_icon('clearassessments', 'workshop'); 526 527 echo $OUTPUT->pix_icon('i/risk_dataloss', get_string('riskdatalossshort', 'admin')); 528 echo $output->container_end(); 529 530 echo $output->box_end(); 531 print_collapsible_region_end(); 532 } 533 if (has_capability('mod/workshop:submit', $PAGE->context)) { 534 print_collapsible_region_start('', 'workshop-viewlet-ownsubmission', get_string('yoursubmission', 'workshop'), 535 'workshop-viewlet-ownsubmission-collapsed'); 536 echo $output->box_start('generalbox ownsubmission'); 537 if ($submission = $workshop->get_submission_by_author($USER->id)) { 538 echo $output->render($workshop->prepare_submission_summary($submission, true)); 539 } else { 540 echo $output->container(get_string('noyoursubmission', 'workshop')); 541 } 542 echo $output->box_end(); 543 print_collapsible_region_end(); 544 } 545 if ($assessments = $workshop->get_assessments_by_reviewer($USER->id)) { 546 print_collapsible_region_start('', 'workshop-viewlet-assignedassessments', get_string('assignedassessments', 'workshop'), 547 'workshop-viewlet-assignedassessments-collapsed'); 548 $shownames = has_capability('mod/workshop:viewauthornames', $PAGE->context); 549 foreach ($assessments as $assessment) { 550 $submission = new stdclass(); 551 $submission->id = $assessment->submissionid; 552 $submission->title = $assessment->submissiontitle; 553 $submission->timecreated = $assessment->submissioncreated; 554 $submission->timemodified = $assessment->submissionmodified; 555 $userpicturefields = explode(',', implode(',', \core_user\fields::get_picture_fields())); 556 foreach ($userpicturefields as $userpicturefield) { 557 $prefixedusernamefield = 'author' . $userpicturefield; 558 $submission->$prefixedusernamefield = $assessment->$prefixedusernamefield; 559 } 560 561 if (is_null($assessment->grade)) { 562 $class = ' notgraded'; 563 $submission->status = 'notgraded'; 564 $buttontext = get_string('assess', 'workshop'); 565 } else { 566 $class = ' graded'; 567 $submission->status = 'graded'; 568 $buttontext = get_string('reassess', 'workshop'); 569 } 570 echo $output->box_start('generalbox assessment-summary' . $class); 571 echo $output->render($workshop->prepare_submission_summary($submission, $shownames)); 572 echo $output->box_end(); 573 } 574 print_collapsible_region_end(); 575 } 576 break; 577 case workshop::PHASE_CLOSED: 578 if (trim($workshop->conclusion)) { 579 $conclusion = file_rewrite_pluginfile_urls($workshop->conclusion, 'pluginfile.php', $workshop->context->id, 580 'mod_workshop', 'conclusion', null, workshop::instruction_editors_options($workshop->context)); 581 print_collapsible_region_start('', 'workshop-viewlet-conclusion', get_string('conclusion', 'workshop'), 582 'workshop-viewlet-conclusion-collapsed'); 583 echo $output->box(format_text($conclusion, $workshop->conclusionformat, array('overflowdiv'=>true)), array('generalbox', 'conclusion')); 584 print_collapsible_region_end(); 585 } 586 $finalgrades = $workshop->get_gradebook_grades($USER->id); 587 if (!empty($finalgrades)) { 588 print_collapsible_region_start('', 'workshop-viewlet-yourgrades', get_string('yourgrades', 'workshop'), 589 'workshop-viewlet-yourgrades-collapsed'); 590 echo $output->box_start('generalbox grades-yourgrades'); 591 echo $output->render($finalgrades); 592 echo $output->box_end(); 593 print_collapsible_region_end(); 594 } 595 if (has_capability('mod/workshop:viewallassessments', $PAGE->context)) { 596 $perpage = get_user_preferences('workshop_perpage', 10); 597 $groupid = groups_get_activity_group($workshop->cm, true); 598 $data = $workshop->prepare_grading_report_data($USER->id, $groupid, $page, $perpage, $sortby, $sorthow); 599 if ($data) { 600 $showauthornames = has_capability('mod/workshop:viewauthornames', $workshop->context); 601 $showreviewernames = has_capability('mod/workshop:viewreviewernames', $workshop->context); 602 603 // prepare paging bar 604 $baseurl = new moodle_url($PAGE->url, array('sortby' => $sortby, 'sorthow' => $sorthow)); 605 $pagingbar = new paging_bar($data->totalcount, $page, $perpage, $baseurl, 'page'); 606 607 // grading report display options 608 $reportopts = new stdclass(); 609 $reportopts->showauthornames = $showauthornames; 610 $reportopts->showreviewernames = $showreviewernames; 611 $reportopts->sortby = $sortby; 612 $reportopts->sorthow = $sorthow; 613 $reportopts->showsubmissiongrade = true; 614 $reportopts->showgradinggrade = true; 615 $reportopts->workshopphase = $workshop->phase; 616 617 print_collapsible_region_start('', 'workshop-viewlet-gradereport', get_string('gradesreport', 'workshop'), 618 'workshop-viewlet-gradereport-collapsed'); 619 echo $output->box_start('generalbox gradesreport'); 620 echo $output->container(groups_print_activity_menu($workshop->cm, $PAGE->url, true), 'groupwidget'); 621 echo $output->render($pagingbar); 622 echo $output->render(new workshop_grading_report($data, $reportopts)); 623 echo $output->render($pagingbar); 624 echo $output->perpage_selector($perpage); 625 echo $output->box_end(); 626 print_collapsible_region_end(); 627 } 628 } 629 if (has_capability('mod/workshop:submit', $PAGE->context)) { 630 print_collapsible_region_start('', 'workshop-viewlet-ownsubmission', 631 get_string('yoursubmissionwithassessments', 'workshop'), 'workshop-viewlet-ownsubmission-collapsed'); 632 echo $output->box_start('generalbox ownsubmission'); 633 if ($submission = $workshop->get_submission_by_author($USER->id)) { 634 echo $output->render($workshop->prepare_submission_summary($submission, true)); 635 } else { 636 echo $output->container(get_string('noyoursubmission', 'workshop')); 637 } 638 echo $output->box_end(); 639 640 if (!empty($submission->gradeoverby) and strlen(trim($submission->feedbackauthor)) > 0) { 641 echo $output->render(new workshop_feedback_author($submission)); 642 } 643 644 print_collapsible_region_end(); 645 } 646 if (has_capability('mod/workshop:viewpublishedsubmissions', $workshop->context)) { 647 $shownames = has_capability('mod/workshop:viewauthorpublished', $workshop->context); 648 if ($submissions = $workshop->get_published_submissions()) { 649 print_collapsible_region_start('', 'workshop-viewlet-publicsubmissions', get_string('publishedsubmissions', 'workshop'), 650 'workshop-viewlet-publicsubmissions-collapsed'); 651 foreach ($submissions as $submission) { 652 echo $output->box_start('generalbox submission-summary'); 653 echo $output->render($workshop->prepare_submission_summary($submission, $shownames)); 654 echo $output->box_end(); 655 } 656 print_collapsible_region_end(); 657 } 658 } 659 if ($assessments = $workshop->get_assessments_by_reviewer($USER->id)) { 660 print_collapsible_region_start('', 'workshop-viewlet-assignedassessments', get_string('assignedassessments', 'workshop'), 661 'workshop-viewlet-assignedassessments-collapsed'); 662 $shownames = has_capability('mod/workshop:viewauthornames', $PAGE->context); 663 foreach ($assessments as $assessment) { 664 $submission = new stdclass(); 665 $submission->id = $assessment->submissionid; 666 $submission->title = $assessment->submissiontitle; 667 $submission->timecreated = $assessment->submissioncreated; 668 $submission->timemodified = $assessment->submissionmodified; 669 $userpicturefields = explode(',', implode(',', \core_user\fields::get_picture_fields())); 670 foreach ($userpicturefields as $userpicturefield) { 671 $prefixedusernamefield = 'author' . $userpicturefield; 672 $submission->$prefixedusernamefield = $assessment->$prefixedusernamefield; 673 } 674 675 if (is_null($assessment->grade)) { 676 $class = ' notgraded'; 677 $submission->status = 'notgraded'; 678 $buttontext = get_string('assess', 'workshop'); 679 } else { 680 $class = ' graded'; 681 $submission->status = 'graded'; 682 $buttontext = get_string('reassess', 'workshop'); 683 } 684 echo $output->box_start('generalbox assessment-summary' . $class); 685 echo $output->render($workshop->prepare_submission_summary($submission, $shownames)); 686 echo $output->box_end(); 687 688 if (strlen(trim($assessment->feedbackreviewer)) > 0) { 689 echo $output->render(new workshop_feedback_reviewer($assessment)); 690 } 691 } 692 print_collapsible_region_end(); 693 } 694 break; 695 default: 696 } 697 $PAGE->requires->js_call_amd('mod_workshop/workshopview', 'init'); 698 echo $output->footer();
title
Description
Body
title
Description
Body
title
Description
Body
title
Body