Merge branch 'MDL-50430' of https://github.com/danielneis/moodle
[moodle.git] / mod / workshop / editformpreview.php
blob5594d3ab5219d79c9cab8b6d3fbfb10b51d103f8
1 <?php
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.
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/>.
18 /**
19 * Preview the assessment form.
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
26 require_once(dirname(dirname(dirname(__FILE__))).'/config.php');
27 require_once(dirname(__FILE__).'/locallib.php');
29 $cmid = required_param('cmid', PARAM_INT);
30 $cm = get_coursemodule_from_id('workshop', $cmid, 0, false, MUST_EXIST);
31 $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
32 $workshop = $DB->get_record('workshop', array('id' => $cm->instance), '*', MUST_EXIST);
34 require_login($course, false, $cm);
35 if (isguestuser()) {
36 print_error('guestsarenotallowed');
38 $workshop = new workshop($workshop, $cm, $course);
40 require_capability('mod/workshop:editdimensions', $workshop->context);
41 $PAGE->set_url($workshop->previewform_url());
42 $PAGE->set_title($workshop->name);
43 $PAGE->set_heading($course->fullname);
44 $PAGE->navbar->add(get_string('editingassessmentform', 'workshop'), $workshop->editform_url(), navigation_node::TYPE_CUSTOM);
45 $PAGE->navbar->add(get_string('previewassessmentform', 'workshop'));
46 $currenttab = 'editform';
48 // load the grading strategy logic
49 $strategy = $workshop->grading_strategy_instance();
51 // load the assessment form
52 $mform = $strategy->get_assessment_form($workshop->editform_url(), 'preview');
54 // output starts here
55 echo $OUTPUT->header();
56 echo $OUTPUT->heading(format_string($workshop->name));
57 echo $OUTPUT->heading(get_string('assessmentform', 'workshop'), 3);
58 $mform->display();
59 echo $OUTPUT->footer();