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