moodle/mod/data/mod_form.php

76 lines
3.6 KiB
PHP
Raw Normal View History

<?php
require_once ($CFG->dirroot.'/course/moodleform_mod.php');
class mod_data_mod_form extends moodleform_mod {
function definition() {
global $CFG;
2007-08-20 10:52:59 +00:00
$mform =& $this->_form;
//-------------------------------------------------------------------------------
$mform->addElement('header', 'general', get_string('general', 'form'));
2007-01-11 19:47:08 +00:00
$mform->addElement('text', 'name', get_string('name'), array('size'=>'64'));
$mform->setType('name', PARAM_TEXT);
$mform->addRule('name', null, 'required', null, 'client');
$mform->addElement('htmleditor', 'intro', get_string('intro', 'data'));
$mform->setType('intro', PARAM_RAW);
$mform->addRule('intro', null, 'required', null, 'client');
$mform->setHelpButton('intro', array('writing', 'questions', 'richtext'), false, 'editorhelpbutton');
$mform->addElement('date_selector', 'timeavailablefrom', get_string('availablefromdate', 'data'), array('optional'=>true));
$mform->addElement('date_selector', 'timeavailableto', get_string('availabletodate', 'data'), array('optional'=>true));
$mform->addElement('date_selector', 'timeviewfrom', get_string('viewfromdate', 'data'), array('optional'=>true));
$mform->addElement('date_selector', 'timeviewto', get_string('viewtodate', 'data'), array('optional'=>true));
2007-08-20 10:52:59 +00:00
$countoptions = array(0=>get_string('none'))+
(array_combine(range(1, DATA_MAX_ENTRIES),//keys
range(1, DATA_MAX_ENTRIES)));//values
$mform->addElement('select', 'requiredentries', get_string('requiredentries', 'data'), $countoptions);
$mform->setHelpButton('requiredentries', array('requiredentries', get_string('requiredentries', 'data'), 'data'));
$mform->addElement('select', 'requiredentriestoview', get_string('requiredentriestoview', 'data'), $countoptions);
$mform->setHelpButton('requiredentriestoview', array('requiredentriestoview', get_string('requiredentriestoview', 'data'), 'data'));
$mform->addElement('select', 'maxentries', get_string('maxentries', 'data'), $countoptions);
$mform->setHelpButton('maxentries', array('maxentries', get_string('maxentries', 'data'), 'data'));
2007-08-20 10:52:59 +00:00
$ynoptions = array(0 => get_string('no'), 1 => get_string('yes'));
$mform->addElement('select', 'comments', get_string('comments', 'data'), $ynoptions);
$mform->setHelpButton('comments', array('comments', get_string('allowcomments', 'data'), 'data'));
$mform->addElement('select', 'approval', get_string('requireapproval', 'data'), $ynoptions);
$mform->setHelpButton('approval', array('requireapproval', get_string('requireapproval', 'data'), 'data'));
if($CFG->enablerssfeeds && $CFG->data_enablerssfeeds){
$mform->addElement('select', 'rssarticles', get_string('numberrssarticles', 'data') , $countoptions);
}
2007-08-20 10:52:59 +00:00
$mform->addElement('checkbox', 'assessed', get_string('allowratings', 'data') , get_string('ratingsuse', 'data'));
$mform->addElement('modgrade', 'scale', get_string('grade'), false);
$mform->disabledIf('scale', 'assessed');
2007-08-20 10:52:59 +00:00
$this->standard_coursemodule_elements(array('groups'=>true, 'groupings'=>true, 'groupmembersonly'=>true));
* Added setAdvanced functionality see http://docs.moodle.org/en/Development:lib/formslib.php_setAdvanced * 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
2006-12-19 07:03:08 +00:00
//-------------------------------------------------------------------------------
// buttons
$this->add_action_buttons();
}
2007-06-03 19:08:14 +00:00
function data_preprocessing(&$default_values){
if (empty($default_values['scale'])){
$default_values['assessed'] = 0;
}
}
}
?>