MDL-18910 moving modedit features to modname_supports()
[moodle.git] / mod / data / mod_form.php
CommitLineData
6403e679 1<?php
23a7718b 2require_once ($CFG->dirroot.'/course/moodleform_mod.php');
e24b7f85 3
f07b9627 4class mod_data_mod_form extends moodleform_mod {
6403e679 5
aab98aaf 6 function definition() {
c18269c7 7 global $CFG, $DB;
6403e679 8
13534ef7 9 $mform =& $this->_form;
6403e679 10
11//-------------------------------------------------------------------------------
12 $mform->addElement('header', 'general', get_string('general', 'form'));
13
26de8d35 14 $mform->addElement('text', 'name', get_string('name'), array('size'=>'64'));
8eb1d25f 15 if (!empty($CFG->formatstringstriptags)) {
16 $mform->setType('name', PARAM_TEXT);
17 } else {
18 $mform->setType('name', PARAM_CLEAN);
19 }
aab98aaf 20 $mform->addRule('name', null, 'required', null, 'client');
6403e679 21
aab98aaf 22 $mform->addElement('htmleditor', 'intro', get_string('intro', 'data'));
23 $mform->setType('intro', PARAM_RAW);
24 $mform->addRule('intro', null, 'required', null, 'client');
16851b22 25 $mform->setHelpButton('intro', array('writing', 'questions', 'richtext2'), false, 'editorhelpbutton');
6403e679 26
46e648b6 27 $mform->addElement('date_selector', 'timeavailablefrom', get_string('availablefromdate', 'data'), array('optional'=>true));
46e648b6 28
29 $mform->addElement('date_selector', 'timeavailableto', get_string('availabletodate', 'data'), array('optional'=>true));
46e648b6 30
31 $mform->addElement('date_selector', 'timeviewfrom', get_string('viewfromdate', 'data'), array('optional'=>true));
46e648b6 32
33 $mform->addElement('date_selector', 'timeviewto', get_string('viewtodate', 'data'), array('optional'=>true));
6403e679 34
35
13534ef7 36 $countoptions = array(0=>get_string('none'))+
6403e679 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);
aab98aaf 40 $mform->setHelpButton('requiredentries', array('requiredentries', get_string('requiredentries', 'data'), 'data'));
6403e679 41
42 $mform->addElement('select', 'requiredentriestoview', get_string('requiredentriestoview', 'data'), $countoptions);
aab98aaf 43 $mform->setHelpButton('requiredentriestoview', array('requiredentriestoview', get_string('requiredentriestoview', 'data'), 'data'));
6403e679 44
45 $mform->addElement('select', 'maxentries', get_string('maxentries', 'data'), $countoptions);
aab98aaf 46 $mform->setHelpButton('maxentries', array('maxentries', get_string('maxentries', 'data'), 'data'));
6403e679 47
13534ef7 48 $ynoptions = array(0 => get_string('no'), 1 => get_string('yes'));
6403e679 49 $mform->addElement('select', 'comments', get_string('comments', 'data'), $ynoptions);
aab98aaf 50 $mform->setHelpButton('comments', array('comments', get_string('allowcomments', 'data'), 'data'));
6403e679 51
52 $mform->addElement('select', 'approval', get_string('requireapproval', 'data'), $ynoptions);
aab98aaf 53 $mform->setHelpButton('approval', array('requireapproval', get_string('requireapproval', 'data'), 'data'));
6403e679 54
4282d047 55 if($CFG->enablerssfeeds && $CFG->data_enablerssfeeds){
56 $mform->addElement('select', 'rssarticles', get_string('numberrssarticles', 'data') , $countoptions);
57 }
6403e679 58
13534ef7 59 $mform->addElement('checkbox', 'assessed', get_string('allowratings', 'data') , get_string('ratingsuse', 'data'));
6403e679 60
a02c77dc 61 $mform->addElement('modgrade', 'scale', get_string('grade'), false);
abf11956 62 $mform->disabledIf('scale', 'assessed');
6403e679 63
64
42f103be 65 $this->standard_coursemodule_elements();
6403e679 66
a23f0aaf 67//-------------------------------------------------------------------------------
68 // buttons
69 $this->add_action_buttons();
aab98aaf 70 }
6403e679 71
c3cec421 72 function data_preprocessing(&$default_values){
73 if (empty($default_values['scale'])){
74 $default_values['assessed'] = 0;
75 }
76 }
6403e679 77
6403e679 78}
4282d047 79?>