MDL-11082 Improved groups upgrade performance 1.8x -> 1.9; thanks Eloy for telling...
[moodle-pu.git] / mod / data / mod_form.php
blobb65fc9b165ff6588d84bc64765620b77f1ebb46e
1 <?php
2 require_once ($CFG->dirroot.'/course/moodleform_mod.php');
4 class mod_data_mod_form extends moodleform_mod {
6 function definition() {
8 global $CFG;
9 $mform =& $this->_form;
11 //-------------------------------------------------------------------------------
12 $mform->addElement('header', 'general', get_string('general', 'form'));
14 $mform->addElement('text', 'name', get_string('name'), array('size'=>'64'));
15 $mform->setType('name', PARAM_TEXT);
16 $mform->addRule('name', null, 'required', null, 'client');
18 $mform->addElement('htmleditor', 'intro', get_string('intro', 'data'));
19 $mform->setType('intro', PARAM_RAW);
20 $mform->addRule('intro', null, 'required', null, 'client');
21 $mform->setHelpButton('intro', array('writing', 'questions', 'richtext'), false, 'editorhelpbutton');
23 $mform->addElement('date_selector', 'timeavailablefrom', get_string('availablefromdate', 'data'), array('optional'=>true));
25 $mform->addElement('date_selector', 'timeavailableto', get_string('availabletodate', 'data'), array('optional'=>true));
27 $mform->addElement('date_selector', 'timeviewfrom', get_string('viewfromdate', 'data'), array('optional'=>true));
29 $mform->addElement('date_selector', 'timeviewto', get_string('viewtodate', 'data'), array('optional'=>true));
32 $countoptions = array(0=>get_string('none'))+
33 (array_combine(range(1, DATA_MAX_ENTRIES),//keys
34 range(1, DATA_MAX_ENTRIES)));//values
35 $mform->addElement('select', 'requiredentries', get_string('requiredentries', 'data'), $countoptions);
36 $mform->setHelpButton('requiredentries', array('requiredentries', get_string('requiredentries', 'data'), 'data'));
38 $mform->addElement('select', 'requiredentriestoview', get_string('requiredentriestoview', 'data'), $countoptions);
39 $mform->setHelpButton('requiredentriestoview', array('requiredentriestoview', get_string('requiredentriestoview', 'data'), 'data'));
41 $mform->addElement('select', 'maxentries', get_string('maxentries', 'data'), $countoptions);
42 $mform->setHelpButton('maxentries', array('maxentries', get_string('maxentries', 'data'), 'data'));
44 $ynoptions = array(0 => get_string('no'), 1 => get_string('yes'));
45 $mform->addElement('select', 'comments', get_string('comments', 'data'), $ynoptions);
46 $mform->setHelpButton('comments', array('comments', get_string('allowcomments', 'data'), 'data'));
48 $mform->addElement('select', 'approval', get_string('requireapproval', 'data'), $ynoptions);
49 $mform->setHelpButton('approval', array('requireapproval', get_string('requireapproval', 'data'), 'data'));
51 $mform->addElement('select', 'rssarticles', get_string('numberrssarticles', 'data') , $countoptions);
53 $mform->addElement('checkbox', 'assessed', get_string('allowratings', 'data') , get_string('ratingsuse', 'data'));
55 $mform->addElement('modgrade', 'scale', get_string('grade'), false);
56 $mform->disabledIf('scale', 'assessed');
59 $this->standard_coursemodule_elements(array('groups'=>true, 'groupings'=>true, 'groupmembersonly'=>true));
61 //-------------------------------------------------------------------------------
62 // buttons
63 $this->add_action_buttons();
66 function data_preprocessing(&$default_values){
67 if (empty($default_values['scale'])){
68 $default_values['assessed'] = 0;