Merge commit 'catalyst/MOODLE_19_STABLE' into mdl19-linuxchix
[moodle-linuxchix.git] / mod / data / mod_form.php
blobce1c94a4914b3472466c8c3c81e55153bebcfa42
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 if (!empty($CFG->formatstringstriptags)) {
16 $mform->setType('name', PARAM_TEXT);
17 } else {
18 $mform->setType('name', PARAM_CLEAN);
20 $mform->addRule('name', null, 'required', null, 'client');
22 $mform->addElement('htmleditor', 'intro', get_string('intro', 'data'));
23 $mform->setType('intro', PARAM_RAW);
24 $mform->addRule('intro', null, 'required', null, 'client');
25 $mform->setHelpButton('intro', array('writing', 'questions', 'richtext'), false, 'editorhelpbutton');
27 $mform->addElement('date_selector', 'timeavailablefrom', get_string('availablefromdate', 'data'), array('optional'=>true));
29 $mform->addElement('date_selector', 'timeavailableto', get_string('availabletodate', 'data'), array('optional'=>true));
31 $mform->addElement('date_selector', 'timeviewfrom', get_string('viewfromdate', 'data'), array('optional'=>true));
33 $mform->addElement('date_selector', 'timeviewto', get_string('viewtodate', 'data'), array('optional'=>true));
36 $countoptions = array(0=>get_string('none'))+
37 (array_combine(range(1, DATA_MAX_ENTRIES),//keys
38 range(1, DATA_MAX_ENTRIES)));//values
39 $mform->addElement('select', 'requiredentries', get_string('requiredentries', 'data'), $countoptions);
40 $mform->setHelpButton('requiredentries', array('requiredentries', get_string('requiredentries', 'data'), 'data'));
42 $mform->addElement('select', 'requiredentriestoview', get_string('requiredentriestoview', 'data'), $countoptions);
43 $mform->setHelpButton('requiredentriestoview', array('requiredentriestoview', get_string('requiredentriestoview', 'data'), 'data'));
45 $mform->addElement('select', 'maxentries', get_string('maxentries', 'data'), $countoptions);
46 $mform->setHelpButton('maxentries', array('maxentries', get_string('maxentries', 'data'), 'data'));
48 $ynoptions = array(0 => get_string('no'), 1 => get_string('yes'));
49 $mform->addElement('select', 'comments', get_string('comments', 'data'), $ynoptions);
50 $mform->setHelpButton('comments', array('comments', get_string('allowcomments', 'data'), 'data'));
52 $mform->addElement('select', 'approval', get_string('requireapproval', 'data'), $ynoptions);
53 $mform->setHelpButton('approval', array('requireapproval', get_string('requireapproval', 'data'), 'data'));
55 if($CFG->enablerssfeeds && $CFG->data_enablerssfeeds){
56 $mform->addElement('select', 'rssarticles', get_string('numberrssarticles', 'data') , $countoptions);
59 $mform->addElement('checkbox', 'assessed', get_string('allowratings', 'data') , get_string('ratingsuse', 'data'));
61 $mform->addElement('modgrade', 'scale', get_string('grade'), false);
62 $mform->disabledIf('scale', 'assessed');
65 $this->standard_coursemodule_elements(array('groups'=>true, 'groupings'=>true, 'groupmembersonly'=>true));
67 //-------------------------------------------------------------------------------
68 // buttons
69 $this->add_action_buttons();
72 function data_preprocessing(&$default_values){
73 if (empty($default_values['scale'])){
74 $default_values['assessed'] = 0;