2010-01-04 17:34:08 +00:00
|
|
|
<?php
|
2010-01-04 17:47:09 +00:00
|
|
|
|
|
|
|
// This file is part of Moodle - http://moodle.org/
|
|
|
|
//
|
2010-01-04 17:34:08 +00:00
|
|
|
// Moodle is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// Moodle is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
2010-01-04 17:47:09 +00:00
|
|
|
//
|
2010-01-04 17:34:08 +00:00
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
2010-01-04 17:47:09 +00:00
|
|
|
|
2010-01-04 17:34:08 +00:00
|
|
|
/**
|
|
|
|
* Edit grading form in for a particular instance of workshop
|
|
|
|
*
|
2014-02-16 12:01:40 +13:00
|
|
|
* @package mod_workshop
|
2010-09-30 14:44:33 +00:00
|
|
|
* @copyright 2009 David Mudrak <david.mudrak@gmail.com>
|
|
|
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
2010-01-04 17:34:08 +00:00
|
|
|
*/
|
|
|
|
|
2016-02-26 17:47:58 +11:00
|
|
|
require(__DIR__.'/../../config.php');
|
|
|
|
require_once(__DIR__.'/locallib.php');
|
2010-01-04 17:34:08 +00:00
|
|
|
|
2010-01-04 17:48:33 +00:00
|
|
|
$cmid = required_param('cmid', PARAM_INT);
|
2010-01-04 17:47:09 +00:00
|
|
|
|
2010-01-04 17:48:20 +00:00
|
|
|
$cm = get_coursemodule_from_id('workshop', $cmid, 0, false, MUST_EXIST);
|
2013-08-21 13:42:30 +08:00
|
|
|
$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
|
2010-01-04 17:34:08 +00:00
|
|
|
|
2010-01-04 17:38:29 +00:00
|
|
|
require_login($course, false, $cm);
|
2010-01-04 17:48:20 +00:00
|
|
|
require_capability('mod/workshop:editdimensions', $PAGE->context);
|
2010-01-04 17:34:08 +00:00
|
|
|
|
2010-01-04 17:48:20 +00:00
|
|
|
$workshop = $DB->get_record('workshop', array('id' => $cm->instance), '*', MUST_EXIST);
|
2010-01-04 17:49:01 +00:00
|
|
|
$workshop = new workshop($workshop, $cm, $course);
|
2010-01-04 17:46:05 +00:00
|
|
|
|
2010-01-04 17:51:10 +00:00
|
|
|
// todo: check if there already is some assessment done and do not allowed the change of the form
|
|
|
|
// once somebody already used it to assess
|
|
|
|
|
2010-01-04 17:48:33 +00:00
|
|
|
$PAGE->set_url($workshop->editform_url());
|
|
|
|
$PAGE->set_title($workshop->name);
|
|
|
|
$PAGE->set_heading($course->fullname);
|
2010-01-04 18:00:12 +00:00
|
|
|
$PAGE->navbar->add(get_string('editingassessmentform', 'workshop'));
|
2010-01-04 17:34:08 +00:00
|
|
|
|
2010-01-04 17:35:56 +00:00
|
|
|
// load the grading strategy logic
|
2010-01-04 17:46:05 +00:00
|
|
|
$strategy = $workshop->grading_strategy_instance();
|
2010-01-04 17:35:56 +00:00
|
|
|
|
|
|
|
// load the form to edit the grading strategy dimensions
|
2010-01-04 17:48:33 +00:00
|
|
|
$mform = $strategy->get_edit_strategy_form($PAGE->url);
|
2010-01-04 17:34:08 +00:00
|
|
|
|
|
|
|
if ($mform->is_cancelled()) {
|
2010-01-04 17:48:33 +00:00
|
|
|
redirect($workshop->view_url());
|
2010-01-04 17:34:08 +00:00
|
|
|
} elseif ($data = $mform->get_data()) {
|
2010-01-04 18:15:24 +00:00
|
|
|
if (($data->workshopid != $workshop->id) or ($data->strategy != $workshop->strategy)) {
|
|
|
|
// this may happen if someone changes the workshop setting while the user had the
|
|
|
|
// editing form opened
|
|
|
|
throw new invalid_parameter_exception('Invalid workshop ID or the grading strategy has changed.');
|
|
|
|
}
|
2010-01-04 17:49:01 +00:00
|
|
|
$strategy->save_edit_strategy_form($data);
|
2010-01-04 17:37:31 +00:00
|
|
|
if (isset($data->saveandclose)) {
|
2010-01-04 17:48:33 +00:00
|
|
|
redirect($workshop->view_url());
|
2010-01-04 17:44:52 +00:00
|
|
|
} elseif (isset($data->saveandpreview)) {
|
2010-01-04 17:48:33 +00:00
|
|
|
redirect($workshop->previewform_url());
|
2010-01-04 17:37:31 +00:00
|
|
|
} else {
|
2010-01-04 17:44:52 +00:00
|
|
|
// save and continue - redirect to self to prevent data being re-posted by pressing "Reload"
|
2010-01-04 17:48:33 +00:00
|
|
|
redirect($PAGE->url);
|
2010-01-04 17:37:31 +00:00
|
|
|
}
|
2010-01-04 17:34:08 +00:00
|
|
|
}
|
|
|
|
|
2010-01-04 17:56:44 +00:00
|
|
|
// Output starts here
|
|
|
|
|
|
|
|
echo $OUTPUT->header();
|
2013-09-17 12:44:25 +08:00
|
|
|
echo $OUTPUT->heading(format_string($workshop->name));
|
|
|
|
echo $OUTPUT->heading(get_string('pluginname', 'workshopform_' . $workshop->strategy), 3);
|
2010-01-04 17:34:08 +00:00
|
|
|
|
|
|
|
$mform->display();
|
|
|
|
|
2010-01-04 17:56:44 +00:00
|
|
|
echo $OUTPUT->footer();
|