Differences Between: [Versions 310 and 400] [Versions 311 and 400] [Versions 39 and 400]
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 * Edit grading form in for a particular instance of workshop 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 $cmid = required_param('cmid', PARAM_INT); 30 31 $cm = get_coursemodule_from_id('workshop', $cmid, 0, false, MUST_EXIST); 32 $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); 33 34 require_login($course, false, $cm); 35 require_capability('mod/workshop:editdimensions', $PAGE->context); 36 37 $workshop = $DB->get_record('workshop', array('id' => $cm->instance), '*', MUST_EXIST); 38 $workshop = new workshop($workshop, $cm, $course); 39 40 // todo: check if there already is some assessment done and do not allowed the change of the form 41 // once somebody already used it to assess 42 43 $PAGE->set_url($workshop->editform_url()); 44 $PAGE->set_title($workshop->name); 45 $PAGE->set_heading($course->fullname); 46 $PAGE->activityheader->set_attrs([ 47 'hidecompletion' => true, 48 'description' => '' 49 ]); 50 $PAGE->navbar->add(get_string('editingassessmentform', 'workshop')); 51 52 // load the grading strategy logic 53 $strategy = $workshop->grading_strategy_instance(); 54 55 // load the form to edit the grading strategy dimensions 56 $mform = $strategy->get_edit_strategy_form($PAGE->url); 57 58 if ($mform->is_cancelled()) { 59 redirect($workshop->view_url()); 60 } elseif ($data = $mform->get_data()) { 61 if (($data->workshopid != $workshop->id) or ($data->strategy != $workshop->strategy)) { 62 // this may happen if someone changes the workshop setting while the user had the 63 // editing form opened 64 throw new invalid_parameter_exception('Invalid workshop ID or the grading strategy has changed.'); 65 } 66 $strategy->save_edit_strategy_form($data); 67 if (isset($data->saveandclose)) { 68 redirect($workshop->view_url()); 69 } elseif (isset($data->saveandpreview)) { 70 redirect($workshop->previewform_url()); 71 } else { 72 // save and continue - redirect to self to prevent data being re-posted by pressing "Reload" 73 redirect($PAGE->url); 74 } 75 } 76 77 // Output starts here 78 79 echo $OUTPUT->header(); 80 echo $OUTPUT->heading(get_string('pluginname', 'workshopform_' . $workshop->strategy), 3); 81 82 $mform->display(); 83 84 echo $OUTPUT->footer();
title
Description
Body
title
Description
Body
title
Description
Body
title
Body