See Release Notes
Long Term Support Release
Differences Between: [Versions 310 and 401] [Versions 311 and 401] [Versions 39 and 401] [Versions 400 and 401]
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 * Assess an example submission 20 * 21 * @package mod_workshop 22 * @copyright 2009 David Mudrak <david.mudrak@gmail.com> 23 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 24 */ 25 26 require(__DIR__.'/../../config.php'); 27 require_once (__DIR__.'/locallib.php'); 28 29 $asid = required_param('asid', PARAM_INT); // assessment id 30 $assessment = $DB->get_record('workshop_assessments', array('id' => $asid), '*', MUST_EXIST); 31 $example = $DB->get_record('workshop_submissions', array('id' => $assessment->submissionid, 'example' => 1), '*', MUST_EXIST); 32 $workshop = $DB->get_record('workshop', array('id' => $example->workshopid), '*', MUST_EXIST); 33 $course = $DB->get_record('course', array('id' => $workshop->course), '*', MUST_EXIST); 34 $cm = get_coursemodule_from_instance('workshop', $workshop->id, $course->id, false, MUST_EXIST); 35 36 require_login($course, false, $cm); 37 if (isguestuser()) { 38 throw new \moodle_exception('guestsarenotallowed'); 39 } 40 $workshop = new workshop($workshop, $cm, $course); 41 42 $PAGE->set_url($workshop->exassess_url($assessment->id)); 43 $PAGE->set_title($workshop->name); 44 $PAGE->set_heading($course->fullname); 45 $PAGE->navbar->add(get_string('assessingexample', 'workshop')); 46 $PAGE->set_secondary_active_tab('modulepage'); 47 $currenttab = 'assessment'; 48 49 $canmanage = has_capability('mod/workshop:manageexamples', $workshop->context); 50 $isreviewer = ($USER->id == $assessment->reviewerid); 51 52 if ($isreviewer or $canmanage) { 53 // such a user can continue 54 } else { 55 throw new \moodle_exception('nopermissions', 'error', $workshop->view_url(), 'assess example submission'); 56 } 57 58 // only the reviewer is allowed to modify the assessment 59 if (($canmanage and $assessment->weight == 1) or ($isreviewer and $workshop->assessing_examples_allowed())) { 60 $assessmenteditable = true; 61 } else { 62 $assessmenteditable = false; 63 } 64 65 // load the grading strategy logic 66 $strategy = $workshop->grading_strategy_instance(); 67 68 // load the assessment form and process the submitted data eventually 69 $mform = $strategy->get_assessment_form($PAGE->url, 'assessment', $assessment, $assessmenteditable); 70 71 // Set data managed by the workshop core, subplugins set their own data themselves. 72 $currentdata = (object)array( 73 'feedbackauthor' => $assessment->feedbackauthor, 74 'feedbackauthorformat' => $assessment->feedbackauthorformat, 75 ); 76 if ($assessmenteditable and $workshop->overallfeedbackmode) { 77 $currentdata = file_prepare_standard_editor($currentdata, 'feedbackauthor', $workshop->overall_feedback_content_options(), 78 $workshop->context, 'mod_workshop', 'overallfeedback_content', $assessment->id); 79 if ($workshop->overallfeedbackfiles) { 80 $currentdata = file_prepare_standard_filemanager($currentdata, 'feedbackauthorattachment', 81 $workshop->overall_feedback_attachment_options(), $workshop->context, 'mod_workshop', 'overallfeedback_attachment', 82 $assessment->id); 83 } 84 } 85 $mform->set_data($currentdata); 86 87 if ($mform->is_cancelled()) { 88 redirect($workshop->view_url()); 89 } elseif ($assessmenteditable and ($data = $mform->get_data())) { 90 91 // Let the grading strategy subplugin save its data. 92 $rawgrade = $strategy->save_assessment($assessment, $data); 93 94 // Store the data managed by the workshop core. 95 $coredata = (object)array('id' => $assessment->id); 96 if (isset($data->feedbackauthor_editor)) { 97 $coredata->feedbackauthor_editor = $data->feedbackauthor_editor; 98 $coredata = file_postupdate_standard_editor($coredata, 'feedbackauthor', $workshop->overall_feedback_content_options(), 99 $workshop->context, 'mod_workshop', 'overallfeedback_content', $assessment->id); 100 unset($coredata->feedbackauthor_editor); 101 } 102 if (isset($data->feedbackauthorattachment_filemanager)) { 103 $coredata->feedbackauthorattachment_filemanager = $data->feedbackauthorattachment_filemanager; 104 $coredata = file_postupdate_standard_filemanager($coredata, 'feedbackauthorattachment', 105 $workshop->overall_feedback_attachment_options(), $workshop->context, 'mod_workshop', 'overallfeedback_attachment', 106 $assessment->id); 107 unset($coredata->feedbackauthorattachment_filemanager); 108 if (empty($coredata->feedbackauthorattachment)) { 109 $coredata->feedbackauthorattachment = 0; 110 } 111 } 112 if ($canmanage) { 113 // Remember the last one who edited the reference assessment. 114 $coredata->reviewerid = $USER->id; 115 } 116 // Update the assessment data if there is something other than just the 'id'. 117 if (count((array)$coredata) > 1 ) { 118 $DB->update_record('workshop_assessments', $coredata); 119 } 120 121 if (!is_null($rawgrade) and isset($data->saveandclose)) { 122 if ($canmanage) { 123 redirect($workshop->view_url()); 124 } else { 125 redirect($workshop->excompare_url($example->id, $assessment->id)); 126 } 127 } else { 128 // either it is not possible to calculate the $rawgrade 129 // or the reviewer has chosen "Save and continue" 130 redirect($PAGE->url); 131 } 132 } 133 134 // output starts here 135 $output = $PAGE->get_renderer('mod_workshop'); // workshop renderer 136 echo $output->header(); 137 if (!$PAGE->has_secondary_navigation()) { 138 echo $output->heading(format_string($workshop->name)); 139 } 140 echo $output->heading(get_string('assessedexample', 'workshop'), 3); 141 142 $example = $workshop->get_example_by_id($example->id); // reload so can be passed to the renderer 143 echo $output->render($workshop->prepare_example_submission(($example))); 144 145 // show instructions for assessing as thay may contain important information 146 // for evaluating the assessment 147 if (trim($workshop->instructreviewers)) { 148 $instructions = file_rewrite_pluginfile_urls($workshop->instructreviewers, 'pluginfile.php', $PAGE->context->id, 149 'mod_workshop', 'instructreviewers', null, workshop::instruction_editors_options($PAGE->context)); 150 print_collapsible_region_start('', 'workshop-viewlet-instructreviewers', get_string('instructreviewers', 'workshop'), 151 'workshop-viewlet-instructreviewers-collapsed'); 152 echo $output->box(format_text($instructions, $workshop->instructreviewersformat, array('overflowdiv'=>true)), array('generalbox', 'instructions')); 153 print_collapsible_region_end(); 154 } 155 156 // extend the current assessment record with user details 157 $assessment = $workshop->get_assessment_by_id($assessment->id); 158 159 if ($canmanage and $assessment->weight == 1) { 160 $options = array( 161 'showreviewer' => false, 162 'showauthor' => false, 163 'showform' => true, 164 ); 165 $assessment = $workshop->prepare_example_reference_assessment($assessment, $mform, $options); 166 $assessment->title = get_string('assessmentreference', 'workshop'); 167 echo $output->render($assessment); 168 169 } else if ($isreviewer) { 170 $options = array( 171 'showreviewer' => true, 172 'showauthor' => false, 173 'showform' => true, 174 ); 175 $assessment = $workshop->prepare_example_assessment($assessment, $mform, $options); 176 $assessment->title = get_string('assessmentbyyourself', 'workshop'); 177 echo $output->render($assessment); 178 179 } else if ($canmanage) { 180 $options = array( 181 'showreviewer' => true, 182 'showauthor' => false, 183 'showform' => true, 184 'showweight' => false, 185 ); 186 $assessment = $workshop->prepare_example_assessment($assessment, $mform, $options); 187 echo $output->render($assessment); 188 } 189 190 echo $output->footer();
title
Description
Body
title
Description
Body
title
Description
Body
title
Body