on-demand release 3.7dev+
[moodle.git] / mod / workshop / submission_form.php
bloba2cbb845422d1cc9fa57ab537caca654ff3a284c
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 if ($workshop->submissiontypetext != WORKSHOP_SUBMISSION_TYPE_DISABLED) {
48 $mform->addElement('editor', 'content_editor', get_string('submissioncontent', 'workshop'), null, $contentopts);
49 $mform->setType('content_editor', PARAM_RAW);
50 if ($workshop->submissiontypetext == WORKSHOP_SUBMISSION_TYPE_REQUIRED) {
51 $mform->addRule('content_editor', null, 'required', null, 'client');
55 if ($workshop->submissiontypefile != WORKSHOP_SUBMISSION_TYPE_DISABLED) {
56 $mform->addElement('static', 'filemanagerinfo', get_string('nattachments', 'workshop'), $workshop->nattachments);
57 $mform->addElement('filemanager', 'attachment_filemanager', get_string('submissionattachment', 'workshop'),
58 null, $attachmentopts);
59 if ($workshop->submissiontypefile == WORKSHOP_SUBMISSION_TYPE_REQUIRED) {
60 $mform->addRule('attachment_filemanager', null, 'required', null, 'client');
64 $mform->addElement('hidden', 'id', $current->id);
65 $mform->setType('id', PARAM_INT);
67 $mform->addElement('hidden', 'cmid', $workshop->cm->id);
68 $mform->setType('cmid', PARAM_INT);
70 $mform->addElement('hidden', 'edit', 1);
71 $mform->setType('edit', PARAM_INT);
73 $mform->addElement('hidden', 'example', 0);
74 $mform->setType('example', PARAM_INT);
76 $this->add_action_buttons();
78 $this->set_data($current);
81 function validation($data, $files) {
82 global $CFG, $USER, $DB;
84 $errors = parent::validation($data, $files);
86 $errors += $this->_customdata['workshop']->validate_submission_data($data);
88 return $errors;