Commit | Line | Data |
---|---|---|
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 |
30 | defined('MOODLE_INTERNAL') || die(); |
31 | ||
4eab2e7f DM |
32 | require_once($CFG->dirroot.'/course/moodleform_mod.php'); |
33 | ||
34 | class mod_workshop_mod_form extends moodleform_mod { | |
35 | ||
36 | function definition() { | |
37 | ||
38 | global $CFG, $COURSE; | |
39 | $workshopconfig = get_config('workshop'); | |
40 | $mform =& $this->_form; | |
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 | ||
101 | $label = get_string('latesubmissions', 'workshop'); | |
102 | $text = get_string('latesubmissionsdesc', 'workshop'); | |
103 | $mform->addElement('advcheckbox', 'latesubmissions', $label, $text); | |
104 | $mform->setHelpButton('latesubmissions', array('latesubmissions', $label, 'workshop')); | |
105 | $mform->setAdvanced('latesubmissions'); | |
106 | ||
107 | $options = array(); | |
108 | for ($i=7; $i>=0; $i--) { | |
109 | $options[$i] = $i; | |
110 | } | |
111 | $label = get_string('nattachments', 'workshop'); | |
112 | $mform->addElement('select', 'nattachments', $label, $options); | |
113 | $mform->setDefault('nattachments', 1); | |
114 | $mform->setHelpButton('nattachments', array('nattachments', $label, 'workshop')); | |
115 | $mform->setAdvanced('nattachments'); | |
116 | ||
53fad4b9 | 117 | $options = get_max_upload_sizes($CFG->maxbytes, $COURSE->maxbytes); |
4eab2e7f DM |
118 | $options[0] = get_string('courseuploadlimit') . ' ('.display_size($COURSE->maxbytes).')'; |
119 | $mform->addElement('select', 'maxbytes', get_string('maximumsize', 'assignment'), $options); | |
120 | $mform->setDefault('maxbytes', $workshopconfig->maxbytes); | |
121 | $mform->setHelpButton('maxbytes', array('maxbytes', $label, 'workshop')); | |
122 | $mform->setAdvanced('maxbytes'); | |
123 | ||
124 | /// Assessment settings | |
125 | $mform->addElement('header', 'assessmentsettings', get_string('assessmentsettings', 'workshop')); | |
126 | ||
4eab2e7f DM |
127 | $label = get_string('nsassessments', 'workshop'); |
128 | $options = workshop_get_numbers_of_assessments(); | |
129 | $mform->addElement('select', 'nsassessments', $label, $options); | |
130 | $mform->setDefault('nsassessments', $workshopconfig->nsassessments); | |
131 | $mform->setHelpButton('nsassessments', array('nsassessments', $label, 'workshop')); | |
132 | ||
133 | $label = get_string('nexassessments', 'workshop'); | |
134 | $options = workshop_get_numbers_of_assessments(); | |
135 | $options[0] = get_string('assessallexamples', 'workshop'); | |
136 | $mform->addElement('select', 'nexassessments', $label, $options); | |
137 | $mform->setDefault('nexassessments', $workshopconfig->nexassessments); | |
138 | $mform->setHelpButton('nexassessments', array('nexassessments', $label, 'workshop')); | |
139 | $mform->disabledIf('nexassessments', 'useexamples'); | |
140 | ||
141 | $label = get_string('assesswosubmission', 'workshop'); | |
142 | $text = get_string('assesswosubmissiondesc', 'workshop'); | |
143 | $mform->addElement('advcheckbox', 'assesswosubmission', $label, $text); | |
144 | $mform->setHelpButton('assesswosubmission', array('assesswosubmission', $label, 'workshop')); | |
145 | $mform->setAdvanced('assesswosubmission'); | |
146 | ||
147 | $label = get_string('examplesmode', 'workshop'); | |
148 | $options = workshop_get_example_modes(); | |
149 | $mform->addElement('select', 'examplesmode', $label, $options); | |
150 | $mform->setDefault('examplesmode', $workshopconfig->examplesmode); | |
151 | $mform->setHelpButton('examplesmode', array('examplesmode', $label, 'workshop')); | |
152 | $mform->setAdvanced('examplesmode'); | |
153 | ||
154 | $label = get_string('teacherweight', 'workshop'); | |
155 | $options = workshop_get_teacher_weights(); | |
156 | $mform->addElement('select', 'teacherweight', $label, $options); | |
157 | $mform->setDefault('teacherweight', 1); | |
158 | $mform->setHelpButton('teacherweight', array('teacherweight', $label, 'workshop')); | |
159 | $mform->setAdvanced('teacherweight'); | |
160 | ||
161 | $label = get_string('agreeassessments', 'workshop'); | |
162 | $text = get_string('agreeassessmentsdesc', 'workshop'); | |
163 | $mform->addElement('advcheckbox', 'agreeassessments', $label, $text); | |
164 | $mform->setHelpButton('agreeassessments', array('agreeassessments', $label, 'workshop')); | |
165 | $mform->setAdvanced('agreeassessments'); | |
166 | ||
4eab2e7f DM |
167 | $label = get_string('assessmentcomps', 'workshop'); |
168 | $levels = array(); | |
169 | foreach (workshop_get_comparison_levels() as $code => $level) { | |
170 | $levels[$code] = $level->name; | |
171 | } | |
172 | $mform->addElement('select', 'assessmentcomps', $label, $levels); | |
173 | $mform->setDefault('assessmentcomps', $workshopconfig->assessmentcomps); | |
174 | $mform->setHelpButton('assessmentcomps', array('assessmentcomps', $label, 'workshop')); | |
175 | $mform->setAdvanced('assessmentcomps'); | |
176 | ||
177 | /// Access control | |
178 | $mform->addElement('header', 'accesscontrol', get_string('accesscontrol', 'workshop')); | |
179 | ||
180 | $label = get_string('submissionstart', 'workshop'); | |
181 | $mform->addElement('date_selector', 'submissionstart', $label, array('optional' => true)); | |
182 | $mform->setHelpButton('submissionstart', array('submissionstart', $label, 'workshop')); | |
183 | $mform->setAdvanced('submissionstart'); | |
184 | ||
185 | $label = get_string('submissionend', 'workshop'); | |
186 | $mform->addElement('date_selector', 'submissionend', $label, array('optional' => true)); | |
187 | $mform->setHelpButton('submissionend', array('submissionend', $label, 'workshop')); | |
188 | $mform->setAdvanced('submissionend'); | |
189 | ||
190 | $label = get_string('assessmentstart', 'workshop'); | |
191 | $mform->addElement('date_selector', 'assessmentstart', $label, array('optional' => true)); | |
192 | $mform->setHelpButton('assessmentstart', array('assessmentstart', $label, 'workshop')); | |
193 | $mform->setAdvanced('assessmentstart'); | |
194 | ||
195 | $label = get_string('assessmentend', 'workshop'); | |
196 | $mform->addElement('date_selector', 'assessmentend', $label, array('optional' => true)); | |
197 | $mform->setHelpButton('assessmentend', array('assessmentend', $label, 'workshop')); | |
198 | $mform->setAdvanced('assessmentend'); | |
199 | ||
200 | $label = get_string('releasegrades', 'workshop'); | |
201 | $mform->addElement('date_selector', 'releasegrades', $label, array('optional' => true)); | |
202 | $mform->setHelpButton('releasegrades', array('releasegrades', $label, 'workshop')); | |
203 | $mform->setAdvanced('releasegrades'); | |
204 | ||
205 | $label = get_string('requirepassword', 'workshop'); | |
206 | $mform->addElement('passwordunmask', 'password', $label); | |
207 | $mform->setType('quizpassword', PARAM_TEXT); | |
208 | $mform->setHelpButton('password', array('requirepassword', $label, 'workshop')); | |
209 | $mform->setAdvanced('password'); | |
210 | ||
4eab2e7f | 211 | /// Common module settinga, Restrict availability, Activity completion etc. ---- |
53fad4b9 DM |
212 | $features = array('groups'=>true, 'groupings'=>true, 'groupmembersonly'=>true, |
213 | 'outcomes'=>true, 'gradecat'=>false, 'idnumber'=>false); | |
214 | ||
4eab2e7f DM |
215 | $this->standard_coursemodule_elements(); |
216 | ||
217 | /// Save and close, Save, Cancel ----------------------------------------------- | |
218 | // add standard buttons, common to all modules | |
219 | $this->add_action_buttons(); | |
220 | ||
221 | } | |
222 | } |