a23f0aaf95
* Added MoodleQuickForm method closeHeaderBefore($elementName); http://docs.moodle.org/en/Development:lib/formslib.php_Form_Definition#Use_Fieldsets_to_group_Form_Elements * Added moodleform method add_action_buttons(); see http://docs.moodle.org/en/Development:lib/formslib.php_Form_Definition#add_action_buttons.28.24cancel_.3D_true.2C_.24revert_.3D_true.2C_.24submitlabel.3Dnull.29.3B * is_cancelled method added to moodleform http://docs.moodle.org/en/Development:lib/formslib.php_Usage#Basic_Usage_in_A_Normal_Page * added hidden labels to elements within groups such as the date_selector select boxes and other elements in 'groups' * quiz/mod.html migrated to formslib * glossary/edit.html migrated to formslib * extended registerNoSubmitButton() functionality to automatically add js to onclick to bypass client side js input validation. * added no_submit_button_pressed() function that can be used in a similar way to is_cancelled() as a test in the main script to see if some button in the page has been pressed that is a submit button that is used for some dynamic functionality within the form and not to submit the data for the whole form. * added new condition for disabledIf which allows to disable another form element if no options are selected from within a select element. * added default 'action' for moodleform - strip_querystring(qualified_me()) http://docs.moodle.org/en/Development:lib/formslib.php_Usage#Basic_Usage_in_A_Normal_Page
110 lines
5.7 KiB
PHP
110 lines
5.7 KiB
PHP
<?php
|
|
require_once ('moodleform_mod.php');
|
|
|
|
class exercise_mod_form extends moodleform_mod {
|
|
|
|
function definition() {
|
|
|
|
global $CFG, $COURSE, $EXERCISE_TYPE, $EXERCISE_ASSESSMENT_COMPS;
|
|
$mform =& $this->_form;
|
|
|
|
//-------------------------------------------------------------------------------
|
|
$mform->addElement('header', 'general', get_string('general', 'form'));
|
|
|
|
$mform->addElement('text', 'name', get_string('title', 'exercise'));
|
|
$mform->setType('name', PARAM_TEXT);
|
|
$mform->addRule('name', null, 'required', null, 'client');
|
|
|
|
$mform->addElement('static', 'description', get_string('description', 'exercise'), get_string('descriptionofexercise', 'exercise', $COURSE->students));
|
|
|
|
$filesize = array();
|
|
$sizelist = array('10Kb', '50Kb', '100Kb', '500Kb', '1Mb', '2Mb', '5Mb', '10Mb', '20Mb', '50Mb');
|
|
$maxsize = get_max_upload_file_size();
|
|
foreach ($sizelist as $size) {
|
|
$sizebytes = get_real_size($size);
|
|
if ($sizebytes < $maxsize) {
|
|
$filesize[$sizebytes] = $size;
|
|
}
|
|
}
|
|
$filesize[$maxsize] = display_size($maxsize);
|
|
ksort($filesize, SORT_NUMERIC);
|
|
$mform->addElement('select', 'maxbytes', get_string('maximumsize', 'exercise'), $filesize);
|
|
$mform->setHelpButton('maxbytes', array('comparisonofassessments', get_string('comparisonofassessments', 'exercise'), 'exercise'));
|
|
$mform->setDefault('maxbytes', get_real_size('500K'));
|
|
|
|
$mform->addElement('date_time_selector', 'deadline', get_string('deadline', 'exercise'));
|
|
|
|
$numbers = array();
|
|
$numbers[22] = 'All';
|
|
$numbers[21] = 50;
|
|
for ($i=20; $i>=0; $i--) {
|
|
$numbers[$i] = $i;
|
|
}
|
|
//-------------------------------------------------------------------------------
|
|
$mform->addElement('header', 'leaguetablehdr', get_string('leaguetable', 'exercise'));
|
|
$mform->addElement('select', 'showleaguetable', get_string('numberofentriesinleaguetable', 'exercise'), $numbers);
|
|
$mform->setHelpButton('showleaguetable', array('leaguetable', get_string('numberofentriesinleaguetable', 'exercise'), 'exercise'));
|
|
|
|
$mform->addElement('selectyesno', 'anonymous', get_string('hidenamesfromstudents', 'exercise', $COURSE->students), $numbers);
|
|
$mform->setHelpButton('anonymous', array('leaguetablenames', get_string('hidenamesfromstudents', 'exercise', $COURSE->students), 'exercise'));
|
|
|
|
//-------------------------------------------------------------------------------
|
|
$mform->addElement('header', 'gradeshdr', get_string('grades'));
|
|
$grades = array();
|
|
for ($i=100; $i>=0; $i--) {
|
|
$grades[$i] = $i;
|
|
}
|
|
$mform->addElement('select', 'gradinggrade', get_string('gradeforstudentsassessment', 'exercise', $COURSE->student), $grades);
|
|
$mform->setHelpButton('gradinggrade', array('gradinggrade', get_string('gradinggrade', 'exercise'), 'exercise'));
|
|
$mform->setDefault('gradinggrade', 100);
|
|
|
|
$mform->addElement('select', 'grade', get_string('gradeforsubmission', 'exercise'), $grades);
|
|
$mform->setHelpButton('grade', array('grade', get_string('gradeforsubmission', 'exercise'), 'exercise'));
|
|
$mform->setDefault('grade', 100);
|
|
|
|
$mform->addElement('select', 'gradingstrategy', get_string('gradingstrategy', 'exercise'), $EXERCISE_TYPE);
|
|
$mform->setHelpButton('gradingstrategy', array('gradingstrategy', get_string('gradingstrategy', 'exercise'), 'exercise'));
|
|
$mform->setDefault('gradingstrategy', 1);
|
|
|
|
$options= array(get_string('usemean', 'exercise'), get_string('usemaximum', 'exercise'));
|
|
$mform->addElement('select', 'usemaximum', get_string('handlingofmultiplesubmissions', 'exercise'), $options);
|
|
$mform->setHelpButton('usemaximum', array('usemax', get_string('handlingofmultiplesubmissions', 'exercise'), 'exercise'));
|
|
$mform->setDefault('usemaximum', 0);
|
|
|
|
$options= array();
|
|
for ($i=20; $i>=0; $i--) {
|
|
$options[$i] = $i;
|
|
}
|
|
$mform->addElement('select', 'nelements', get_string('numberofassessmentelements', 'exercise'), $options);
|
|
$mform->setHelpButton('nelements', array('nelements', get_string('numberofassessmentelements', 'exercise'), 'exercise'));
|
|
$mform->setDefault('nelements', 1);
|
|
|
|
$COMPARISONS=array();
|
|
foreach ($EXERCISE_ASSESSMENT_COMPS as $KEY => $COMPARISON) {
|
|
$COMPARISONS[] = $COMPARISON['name'];
|
|
}
|
|
$mform->addElement('select', 'assessmentcomps', get_string('comparisonofassessments', 'exercise'), $options);
|
|
$mform->setHelpButton('assessmentcomps', array('comparisonofassessments', get_string('comparisonofassessments', 'exercise'), 'exercise'));
|
|
$mform->setDefault('assessmentcomps', 2);
|
|
|
|
//-------------------------------------------------------------------------------
|
|
$mform->addElement('header', 'passwordhdr', get_string('password'));
|
|
$mform->addElement('selectyesno', 'usepassword', get_string('usepassword', 'exercise'));
|
|
$mform->setHelpButton('usepassword', array('usepassword', get_string('usepassword', 'exercise'), 'exercise'));
|
|
$mform->setDefault('usepassword', 0);
|
|
|
|
$mform->addElement('text', 'password', get_string('password'));
|
|
$mform->setHelpButton('password', array('usepassword', get_string('usepassword', 'exercise'), 'exercise'));
|
|
$mform->setType('password', PARAM_RAW);
|
|
|
|
//-------------------------------------------------------------------------------
|
|
$this->standard_coursemodule_elements();
|
|
//-------------------------------------------------------------------------------
|
|
// buttons
|
|
$this->add_action_buttons();
|
|
}
|
|
|
|
|
|
|
|
}
|
|
?>
|