MDL-9716
[moodle-linuxchix.git] / mod / exercise / mod_form.php
blob6bd33ed108a64ee403f1ea2e7d75bb43b1b67d2e
1 <?php
2 require_once ('moodleform_mod.php');
4 class mod_exercise_mod_form extends moodleform_mod {
6 function definition() {
8 global $CFG, $COURSE, $EXERCISE_TYPE, $EXERCISE_ASSESSMENT_COMPS;
9 $mform =& $this->_form;
11 //-------------------------------------------------------------------------------
12 $mform->addElement('header', 'general', get_string('general', 'form'));
14 $mform->addElement('text', 'name', get_string('title', 'exercise'), array('size'=>'64'));
15 $mform->setType('name', PARAM_TEXT);
16 $mform->addRule('name', null, 'required', null, 'client');
18 $mform->addElement('static', 'description', get_string('description', 'exercise'), get_string('descriptionofexercise', 'exercise', $COURSE->students));
20 $filesize = array();
21 $sizelist = array('10Kb', '50Kb', '100Kb', '500Kb', '1Mb', '2Mb', '5Mb', '10Mb', '20Mb', '50Mb');
22 $maxsize = get_max_upload_file_size();
23 foreach ($sizelist as $size) {
24 $sizebytes = get_real_size($size);
25 if ($sizebytes < $maxsize) {
26 $filesize[$sizebytes] = $size;
29 $filesize[$maxsize] = display_size($maxsize);
30 ksort($filesize, SORT_NUMERIC);
31 $mform->addElement('select', 'maxbytes', get_string('maximumsize', 'exercise'), $filesize);
32 $mform->setHelpButton('maxbytes', array('comparisonofassessments', get_string('comparisonofassessments', 'exercise'), 'exercise'));
33 $mform->setDefault('maxbytes', get_real_size('500K'));
35 $mform->addElement('date_time_selector', 'deadline', get_string('deadline', 'exercise'));
37 $numbers = array();
38 $numbers[22] = 'All';
39 $numbers[21] = 50;
40 for ($i=20; $i>=0; $i--) {
41 $numbers[$i] = $i;
43 //-------------------------------------------------------------------------------
44 $mform->addElement('header', 'leaguetablehdr', get_string('leaguetable', 'exercise'));
45 $mform->addElement('select', 'showleaguetable', get_string('numberofentriesinleaguetable', 'exercise'), $numbers);
46 $mform->setHelpButton('showleaguetable', array('leaguetable', get_string('numberofentriesinleaguetable', 'exercise'), 'exercise'));
48 $mform->addElement('selectyesno', 'anonymous', get_string('hidenamesfromstudents', 'exercise', $COURSE->students), $numbers);
49 $mform->setHelpButton('anonymous', array('leaguetablenames', get_string('hidenamesfromstudents', 'exercise', $COURSE->students), 'exercise'));
51 //-------------------------------------------------------------------------------
52 $mform->addElement('header', 'gradeshdr', get_string('grades'));
53 $grades = array();
54 for ($i=100; $i>=0; $i--) {
55 $grades[$i] = $i;
57 $mform->addElement('select', 'gradinggrade', get_string('gradeforstudentsassessment', 'exercise', $COURSE->student), $grades);
58 $mform->setHelpButton('gradinggrade', array('gradinggrade', get_string('gradinggrade', 'exercise'), 'exercise'));
59 $mform->setDefault('gradinggrade', 100);
61 $mform->addElement('select', 'grade', get_string('gradeforsubmission', 'exercise'), $grades);
62 $mform->setHelpButton('grade', array('grade', get_string('gradeforsubmission', 'exercise'), 'exercise'));
63 $mform->setDefault('grade', 100);
65 $mform->addElement('select', 'gradingstrategy', get_string('gradingstrategy', 'exercise'), $EXERCISE_TYPE);
66 $mform->setHelpButton('gradingstrategy', array('gradingstrategy', get_string('gradingstrategy', 'exercise'), 'exercise'));
67 $mform->setDefault('gradingstrategy', 1);
69 $options= array(get_string('usemean', 'exercise'), get_string('usemaximum', 'exercise'));
70 $mform->addElement('select', 'usemaximum', get_string('handlingofmultiplesubmissions', 'exercise'), $options);
71 $mform->setHelpButton('usemaximum', array('usemax', get_string('handlingofmultiplesubmissions', 'exercise'), 'exercise'));
72 $mform->setDefault('usemaximum', 0);
74 $options= array();
75 for ($i=20; $i>=0; $i--) {
76 $options[$i] = $i;
78 $mform->addElement('select', 'nelements', get_string('numberofassessmentelements', 'exercise'), $options);
79 $mform->setHelpButton('nelements', array('nelements', get_string('numberofassessmentelements', 'exercise'), 'exercise'));
80 $mform->setDefault('nelements', 1);
82 $COMPARISONS=array();
83 foreach ($EXERCISE_ASSESSMENT_COMPS as $KEY => $COMPARISON) {
84 $COMPARISONS[] = $COMPARISON['name'];
86 $mform->addElement('select', 'assessmentcomps', get_string('comparisonofassessments', 'exercise'), $options);
87 $mform->setHelpButton('assessmentcomps', array('comparisonofassessments', get_string('comparisonofassessments', 'exercise'), 'exercise'));
88 $mform->setDefault('assessmentcomps', 2);
90 //-------------------------------------------------------------------------------
91 $mform->addElement('header', 'passwordhdr', get_string('password'));
92 $mform->addElement('selectyesno', 'usepassword', get_string('usepassword', 'exercise'));
93 $mform->setHelpButton('usepassword', array('usepassword', get_string('usepassword', 'exercise'), 'exercise'));
94 $mform->setDefault('usepassword', 0);
96 $mform->addElement('text', 'password', get_string('password'));
97 $mform->setHelpButton('password', array('usepassword', get_string('usepassword', 'exercise'), 'exercise'));
98 $mform->setType('password', PARAM_RAW);
100 //-------------------------------------------------------------------------------
101 $this->standard_coursemodule_elements();
102 //-------------------------------------------------------------------------------
103 // buttons
104 $this->add_action_buttons();