Merge branch 'MDL-62782-master' of git://github.com/damyon/moodle
[moodle.git] / mod / workshop / submission_form.php
blobf8088a6a2dc6c88de8d606c87fa615654c6c67b9
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 * Submit an assignment or edit the already submitted work
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 defined('MOODLE_INTERNAL') || die();
28 require_once($CFG->dirroot . '/lib/formslib.php');
30 class workshop_submission_form extends moodleform {
32 function definition() {
33 $mform = $this->_form;
35 $current = $this->_customdata['current'];
36 $workshop = $this->_customdata['workshop'];
37 $contentopts = $this->_customdata['contentopts'];
38 $attachmentopts = $this->_customdata['attachmentopts'];
40 $mform->addElement('header', 'general', get_string('submission', 'workshop'));
42 $mform->addElement('text', 'title', get_string('submissiontitle', 'workshop'));
43 $mform->setType('title', PARAM_TEXT);
44 $mform->addRule('title', null, 'required', null, 'client');
45 $mform->addRule('title', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');
47 $mform->addElement('editor', 'content_editor', get_string('submissioncontent', 'workshop'), null, $contentopts);
48 $mform->setType('content', PARAM_RAW);
50 if ($workshop->nattachments > 0) {
51 $mform->addElement('static', 'filemanagerinfo', get_string('nattachments', 'workshop'), $workshop->nattachments);
52 $mform->addElement('filemanager', 'attachment_filemanager', get_string('submissionattachment', 'workshop'),
53 null, $attachmentopts);
56 $mform->addElement('hidden', 'id', $current->id);
57 $mform->setType('id', PARAM_INT);
59 $mform->addElement('hidden', 'cmid', $workshop->cm->id);
60 $mform->setType('cmid', PARAM_INT);
62 $mform->addElement('hidden', 'edit', 1);
63 $mform->setType('edit', PARAM_INT);
65 $mform->addElement('hidden', 'example', 0);
66 $mform->setType('example', PARAM_INT);
68 $this->add_action_buttons();
70 $this->set_data($current);
73 function validation($data, $files) {
74 global $CFG, $USER, $DB;
76 $errors = parent::validation($data, $files);
78 $errors += $this->_customdata['workshop']->validate_submission_data($data);
80 return $errors;