Differences Between: [Versions 310 and 400] [Versions 310 and 401] [Versions 310 and 402] [Versions 310 and 403]
1 <?php 2 // This file is part of Moodle - http://moodle.org/ 3 // 4 // Moodle is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // Moodle is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 16 17 /** 18 * Display example submission followed by its reference assessment and the user's assessment to compare them 19 * 20 * @package mod_workshop 21 * @copyright 2009 David Mudrak <david.mudrak@gmail.com> 22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 */ 24 25 require(__DIR__.'/../../config.php'); 26 require_once (__DIR__.'/locallib.php'); 27 28 $cmid = required_param('cmid', PARAM_INT); // course module id 29 $sid = required_param('sid', PARAM_INT); // example submission id 30 $aid = required_param('aid', PARAM_INT); // the user's assessment id 31 32 $cm = get_coursemodule_from_id('workshop', $cmid, 0, false, MUST_EXIST); 33 $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); 34 35 require_login($course, false, $cm); 36 if (isguestuser()) { 37 print_error('guestsarenotallowed'); 38 } 39 40 $workshop = $DB->get_record('workshop', array('id' => $cm->instance), '*', MUST_EXIST); 41 $workshop = new workshop($workshop, $cm, $course); 42 $strategy = $workshop->grading_strategy_instance(); 43 44 $PAGE->set_url($workshop->excompare_url($sid, $aid)); 45 46 $example = $workshop->get_example_by_id($sid); 47 $assessment = $workshop->get_assessment_by_id($aid); 48 if ($assessment->submissionid != $example->id) { 49 print_error('invalidarguments'); 50 } 51 $mformassessment = $strategy->get_assessment_form($PAGE->url, 'assessment', $assessment, false); 52 if ($refasid = $DB->get_field('workshop_assessments', 'id', array('submissionid' => $example->id, 'weight' => 1))) { 53 $reference = $workshop->get_assessment_by_id($refasid); 54 $mformreference = $strategy->get_assessment_form($PAGE->url, 'assessment', $reference, false); 55 } 56 57 $canmanage = has_capability('mod/workshop:manageexamples', $workshop->context); 58 $isreviewer = ($USER->id == $assessment->reviewerid); 59 60 if ($canmanage) { 61 // ok you can go 62 } elseif ($isreviewer and $workshop->assessing_examples_allowed()) { 63 // ok you can go 64 } else { 65 print_error('nopermissions', 'error', $workshop->view_url(), 'compare example assessment'); 66 } 67 68 $PAGE->set_title($workshop->name); 69 $PAGE->set_heading($course->fullname); 70 $PAGE->navbar->add(get_string('examplecomparing', 'workshop')); 71 72 // Output starts here 73 $output = $PAGE->get_renderer('mod_workshop'); 74 echo $output->header(); 75 echo $output->heading(format_string($workshop->name)); 76 echo $output->heading(get_string('assessedexample', 'workshop'), 3); 77 78 echo $output->render($workshop->prepare_example_submission($example)); 79 80 // if the reference assessment is available, display it 81 if (!empty($mformreference)) { 82 $options = array( 83 'showreviewer' => false, 84 'showauthor' => false, 85 'showform' => true, 86 ); 87 $reference = $workshop->prepare_example_reference_assessment($reference, $mformreference, $options); 88 $reference->title = get_string('assessmentreference', 'workshop'); 89 if ($canmanage) { 90 $reference->url = $workshop->exassess_url($reference->id); 91 } 92 echo $output->render($reference); 93 } 94 95 if ($isreviewer) { 96 $options = array( 97 'showreviewer' => true, 98 'showauthor' => false, 99 'showform' => true, 100 ); 101 $assessment = $workshop->prepare_example_assessment($assessment, $mformassessment, $options); 102 $assessment->title = get_string('assessmentbyyourself', 'workshop'); 103 if ($workshop->assessing_examples_allowed()) { 104 $assessment->add_action( 105 new moodle_url($workshop->exsubmission_url($example->id), array('assess' => 'on', 'sesskey' => sesskey())), 106 get_string('reassess', 'workshop') 107 ); 108 } 109 echo $output->render($assessment); 110 111 } elseif ($canmanage) { 112 $options = array( 113 'showreviewer' => true, 114 'showauthor' => false, 115 'showform' => true, 116 ); 117 $assessment = $workshop->prepare_example_assessment($assessment, $mformassessment, $options); 118 echo $output->render($assessment); 119 } 120 121 echo $output->footer();
title
Description
Body
title
Description
Body
title
Description
Body
title
Body