|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00002 00003 // This file is part of Moodle - http://moodle.org/ 00004 // 00005 // Moodle is free software: you can redistribute it and/or modify 00006 // it under the terms of the GNU General Public License as published by 00007 // the Free Software Foundation, either version 3 of the License, or 00008 // (at your option) any later version. 00009 // 00010 // Moodle is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 // GNU General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU General Public License 00016 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 00017 00027 require_once(dirname(dirname(dirname(__FILE__))).'/config.php'); 00028 require_once(dirname(__FILE__).'/locallib.php'); 00029 00030 $cmid = required_param('cmid', PARAM_INT); 00031 00032 $cm = get_coursemodule_from_id('workshop', $cmid, 0, false, MUST_EXIST); 00033 $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); 00034 00035 require_login($course, false, $cm); 00036 require_capability('mod/workshop:editdimensions', $PAGE->context); 00037 00038 $workshop = $DB->get_record('workshop', array('id' => $cm->instance), '*', MUST_EXIST); 00039 $workshop = new workshop($workshop, $cm, $course); 00040 00041 // todo: check if there already is some assessment done and do not allowed the change of the form 00042 // once somebody already used it to assess 00043 00044 $PAGE->set_url($workshop->editform_url()); 00045 $PAGE->set_title($workshop->name); 00046 $PAGE->set_heading($course->fullname); 00047 $PAGE->navbar->add(get_string('editingassessmentform', 'workshop')); 00048 00049 // load the grading strategy logic 00050 $strategy = $workshop->grading_strategy_instance(); 00051 00052 // load the form to edit the grading strategy dimensions 00053 $mform = $strategy->get_edit_strategy_form($PAGE->url); 00054 00055 if ($mform->is_cancelled()) { 00056 redirect($workshop->view_url()); 00057 } elseif ($data = $mform->get_data()) { 00058 if (($data->workshopid != $workshop->id) or ($data->strategy != $workshop->strategy)) { 00059 // this may happen if someone changes the workshop setting while the user had the 00060 // editing form opened 00061 throw new invalid_parameter_exception('Invalid workshop ID or the grading strategy has changed.'); 00062 } 00063 $strategy->save_edit_strategy_form($data); 00064 if (isset($data->saveandclose)) { 00065 redirect($workshop->view_url()); 00066 } elseif (isset($data->saveandpreview)) { 00067 redirect($workshop->previewform_url()); 00068 } else { 00069 // save and continue - redirect to self to prevent data being re-posted by pressing "Reload" 00070 redirect($PAGE->url); 00071 } 00072 } 00073 00074 // Output starts here 00075 00076 echo $OUTPUT->header(); 00077 echo $OUTPUT->heading(get_string('pluginname', 'workshopform_' . $workshop->strategy)); 00078 00079 $mform->display(); 00080 00081 echo $OUTPUT->footer();