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