Displays all assigned submissions to be reviewed and saves the calculated grade
[moodle.git] / mod / workshop / mod_form.php
CommitLineData
4eab2e7f 1<?php
53fad4b9
DM
2
3// This file is part of Moodle - http://moodle.org/
4//
4eab2e7f
DM
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.
53fad4b9 14//
4eab2e7f
DM
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/>.
53fad4b9 17
4eab2e7f
DM
18/**
19 * The main workshop configuration form
20 *
21 * The UI mockup has been proposed in MDL-18688
53fad4b9 22 * It uses the standard core Moodle formslib. For more info about them, please
4eab2e7f
DM
23 * visit: http://docs.moodle.org/en/Development:lib/formslib.php
24 *
25 * @package mod-workshop
26 * @copyright 2009 David Mudrak <david.mudrak@gmail.com>
27 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
28 */
29
6867e05d
DM
30defined('MOODLE_INTERNAL') || die();
31
4eab2e7f
DM
32require_once($CFG->dirroot.'/course/moodleform_mod.php');
33
34class mod_workshop_mod_form extends moodleform_mod {
35
36 function definition() {
37
38 global $CFG, $COURSE;
39 $workshopconfig = get_config('workshop');
74e28b26 40 $mform = $this->_form;
4eab2e7f
DM
41
42/// General --------------------------------------------------------------------
43 $mform->addElement('header', 'general', get_string('general', 'form'));
44
45 /// Workshop name
46 $label = get_string('workshopname', 'workshop');
47 $mform->addElement('text', 'name', $label, array('size'=>'64'));
48 if (!empty($CFG->formatstringstriptags)) {
49 $mform->setType('name', PARAM_TEXT);
50 } else {
51 $mform->setType('name', PARAM_CLEAN);
52 }
53 $mform->addRule('name', null, 'required', null, 'client');
54 $mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');
55 $mform->setHelpButton('name', array('workshopname', $label, 'workshop'));
56
57 /// Introduction
58 $this->add_intro_editor(false, get_string('introduction', 'workshop'));
59
60/// Workshop features ----------------------------------------------------------
61 $mform->addElement('header', 'workshopfeatures', get_string('workshopfeatures', 'workshop'));
62
63 $label = get_string('useexamples', 'workshop');
64 $text = get_string('useexamplesdesc', 'workshop');
65 $mform->addElement('advcheckbox', 'useexamples', $label, $text);
66 $mform->setHelpButton('useexamples', array('useexamples', $label, 'workshop'));
67
68 $label = get_string('usepeerassessment', 'workshop');
69 $text = get_string('usepeerassessmentdesc', 'workshop');
70 $mform->addElement('advcheckbox', 'usepeerassessment', $label, $text);
71 $mform->setHelpButton('usepeerassessment', array('usepeerassessment', $label, 'workshop'));
72
73 $label = get_string('useselfassessment', 'workshop');
74 $text = get_string('useselfassessmentdesc', 'workshop');
75 $mform->addElement('advcheckbox', 'useselfassessment', $label, $text);
76 $mform->setHelpButton('useselfassessment', array('useselfassessment', $label, 'workshop'));
77
78/// Grading settings -----------------------------------------------------------
79 $mform->addElement('header', 'gradingsettings', get_string('gradingsettings', 'workshop'));
80
81 $grades = workshop_get_maxgrades();
82
83 $label = get_string('gradeforsubmission', 'workshop');
84 $mform->addElement('select', 'grade', $label, $grades);
85 $mform->setDefault('grade', $workshopconfig->grade);
86 $mform->setHelpButton('grade', array('grade', $label, 'workshop'));
87
88 $label = get_string('gradeforassessment', 'workshop');
89 $mform->addElement('select', 'gradinggrade', $label , $grades);
90 $mform->setDefault('gradinggrade', $workshopconfig->gradinggrade);
91 $mform->setHelpButton('gradinggrade', array('gradinggrade', $label, 'workshop'));
92
93 $label = get_string('strategy', 'workshop');
94 $mform->addElement('select', 'strategy', $label, workshop_get_strategies());
95 $mform->setDefault('strategy', $workshopconfig->strategy);
96 $mform->setHelpButton('strategy', array('strategy', $label, 'workshop'));
97
98/// Submission settings --------------------------------------------------------
99 $mform->addElement('header', 'submissionsettings', get_string('submissionsettings', 'workshop'));
100
4eab2e7f
DM
101 $options = array();
102 for ($i=7; $i>=0; $i--) {
103 $options[$i] = $i;
104 }
105 $label = get_string('nattachments', 'workshop');
106 $mform->addElement('select', 'nattachments', $label, $options);
107 $mform->setDefault('nattachments', 1);
108 $mform->setHelpButton('nattachments', array('nattachments', $label, 'workshop'));
6405b254
DM
109
110 $label = get_string('latesubmissions', 'workshop');
111 $text = get_string('latesubmissionsdesc', 'workshop');
112 $mform->addElement('advcheckbox', 'latesubmissions', $label, $text);
113 $mform->setHelpButton('latesubmissions', array('latesubmissions', $label, 'workshop'));
4eab2e7f 114
53fad4b9 115 $options = get_max_upload_sizes($CFG->maxbytes, $COURSE->maxbytes);
4eab2e7f
DM
116 $options[0] = get_string('courseuploadlimit') . ' ('.display_size($COURSE->maxbytes).')';
117 $mform->addElement('select', 'maxbytes', get_string('maximumsize', 'assignment'), $options);
118 $mform->setDefault('maxbytes', $workshopconfig->maxbytes);
119 $mform->setHelpButton('maxbytes', array('maxbytes', $label, 'workshop'));
4eab2e7f
DM
120
121/// Assessment settings
122 $mform->addElement('header', 'assessmentsettings', get_string('assessmentsettings', 'workshop'));
123
4eab2e7f
DM
124 $label = get_string('nexassessments', 'workshop');
125 $options = workshop_get_numbers_of_assessments();
126 $options[0] = get_string('assessallexamples', 'workshop');
127 $mform->addElement('select', 'nexassessments', $label, $options);
128 $mform->setDefault('nexassessments', $workshopconfig->nexassessments);
129 $mform->setHelpButton('nexassessments', array('nexassessments', $label, 'workshop'));
130 $mform->disabledIf('nexassessments', 'useexamples');
131
4eab2e7f
DM
132 $label = get_string('examplesmode', 'workshop');
133 $options = workshop_get_example_modes();
134 $mform->addElement('select', 'examplesmode', $label, $options);
135 $mform->setDefault('examplesmode', $workshopconfig->examplesmode);
136 $mform->setHelpButton('examplesmode', array('examplesmode', $label, 'workshop'));
6405b254 137 $mform->disabledIf('nexassessments', 'useexamples');
4eab2e7f
DM
138 $mform->setAdvanced('examplesmode');
139
140 $label = get_string('teacherweight', 'workshop');
141 $options = workshop_get_teacher_weights();
142 $mform->addElement('select', 'teacherweight', $label, $options);
143 $mform->setDefault('teacherweight', 1);
144 $mform->setHelpButton('teacherweight', array('teacherweight', $label, 'workshop'));
4eab2e7f
DM
145
146 $label = get_string('agreeassessments', 'workshop');
147 $text = get_string('agreeassessmentsdesc', 'workshop');
148 $mform->addElement('advcheckbox', 'agreeassessments', $label, $text);
149 $mform->setHelpButton('agreeassessments', array('agreeassessments', $label, 'workshop'));
150 $mform->setAdvanced('agreeassessments');
151
4eab2e7f
DM
152 $label = get_string('assessmentcomps', 'workshop');
153 $levels = array();
154 foreach (workshop_get_comparison_levels() as $code => $level) {
155 $levels[$code] = $level->name;
156 }
157 $mform->addElement('select', 'assessmentcomps', $label, $levels);
158 $mform->setDefault('assessmentcomps', $workshopconfig->assessmentcomps);
159 $mform->setHelpButton('assessmentcomps', array('assessmentcomps', $label, 'workshop'));
4eab2e7f
DM
160
161/// Access control
162 $mform->addElement('header', 'accesscontrol', get_string('accesscontrol', 'workshop'));
163
164 $label = get_string('submissionstart', 'workshop');
165 $mform->addElement('date_selector', 'submissionstart', $label, array('optional' => true));
166 $mform->setHelpButton('submissionstart', array('submissionstart', $label, 'workshop'));
167 $mform->setAdvanced('submissionstart');
168
169 $label = get_string('submissionend', 'workshop');
170 $mform->addElement('date_selector', 'submissionend', $label, array('optional' => true));
171 $mform->setHelpButton('submissionend', array('submissionend', $label, 'workshop'));
172 $mform->setAdvanced('submissionend');
173
174 $label = get_string('assessmentstart', 'workshop');
175 $mform->addElement('date_selector', 'assessmentstart', $label, array('optional' => true));
176 $mform->setHelpButton('assessmentstart', array('assessmentstart', $label, 'workshop'));
177 $mform->setAdvanced('assessmentstart');
178
179 $label = get_string('assessmentend', 'workshop');
180 $mform->addElement('date_selector', 'assessmentend', $label, array('optional' => true));
181 $mform->setHelpButton('assessmentend', array('assessmentend', $label, 'workshop'));
182 $mform->setAdvanced('assessmentend');
183
184 $label = get_string('releasegrades', 'workshop');
185 $mform->addElement('date_selector', 'releasegrades', $label, array('optional' => true));
186 $mform->setHelpButton('releasegrades', array('releasegrades', $label, 'workshop'));
187 $mform->setAdvanced('releasegrades');
188
4eab2e7f 189/// Common module settinga, Restrict availability, Activity completion etc. ----
53fad4b9
DM
190 $features = array('groups'=>true, 'groupings'=>true, 'groupmembersonly'=>true,
191 'outcomes'=>true, 'gradecat'=>false, 'idnumber'=>false);
192
4eab2e7f
DM
193 $this->standard_coursemodule_elements();
194
195/// Save and close, Save, Cancel -----------------------------------------------
196 // add standard buttons, common to all modules
197 $this->add_action_buttons();
198
199 }
200}