3 // This file is part of Moodle - http://moodle.org/
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.
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/>.
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');
46 $mform->addElement('editor', 'content_editor', get_string('submissioncontent', 'workshop'), null, $contentopts);
47 $mform->setType('content', PARAM_RAW
);
49 if ($workshop->nattachments
> 0) {
50 $mform->addElement('static', 'filemanagerinfo', get_string('nattachments', 'workshop'), $workshop->nattachments
);
51 $mform->addElement('filemanager', 'attachment_filemanager', get_string('submissionattachment', 'workshop'),
52 null, $attachmentopts);
55 $mform->addElement('hidden', 'id', $current->id
);
56 $mform->setType('id', PARAM_INT
);
58 $mform->addElement('hidden', 'cmid', $workshop->cm
->id
);
59 $mform->setType('cmid', PARAM_INT
);
61 $mform->addElement('hidden', 'edit', 1);
62 $mform->setType('edit', PARAM_INT
);
64 $mform->addElement('hidden', 'example', 0);
65 $mform->setType('example', PARAM_INT
);
67 $this->add_action_buttons();
69 $this->set_data($current);
72 function validation($data, $files) {
73 global $CFG, $USER, $DB;
75 $errors = parent
::validation($data, $files);
77 $errors +
= $this->_customdata
['workshop']->validate_submission_data($data);