2 if (!defined('MOODLE_INTERNAL')) {
3 die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
6 require_once ($CFG->dirroot
.'/course/moodleform_mod.php');
8 class mod_data_mod_form
extends moodleform_mod
{
10 function definition() {
13 $mform =& $this->_form
;
15 //-------------------------------------------------------------------------------
16 $mform->addElement('header', 'general', get_string('general', 'form'));
18 $mform->addElement('text', 'name', get_string('name'), array('size'=>'64'));
19 if (!empty($CFG->formatstringstriptags
)) {
20 $mform->setType('name', PARAM_TEXT
);
22 $mform->setType('name', PARAM_CLEANHTML
);
24 $mform->addRule('name', null, 'required', null, 'client');
26 $this->add_intro_editor(true, get_string('intro', 'data'));
28 $mform->addElement('date_selector', 'timeavailablefrom', get_string('availablefromdate', 'data'), array('optional'=>true));
30 $mform->addElement('date_selector', 'timeavailableto', get_string('availabletodate', 'data'), array('optional'=>true));
32 $mform->addElement('date_selector', 'timeviewfrom', get_string('viewfromdate', 'data'), array('optional'=>true));
34 $mform->addElement('date_selector', 'timeviewto', get_string('viewtodate', 'data'), array('optional'=>true));
37 $countoptions = array(0=>get_string('none'))+
38 (array_combine(range(1, DATA_MAX_ENTRIES
),//keys
39 range(1, DATA_MAX_ENTRIES
)));//values
40 $mform->addElement('select', 'requiredentries', get_string('requiredentries', 'data'), $countoptions);
41 $mform->addHelpButton('requiredentries', 'requiredentries', 'data');
43 $mform->addElement('select', 'requiredentriestoview', get_string('requiredentriestoview', 'data'), $countoptions);
44 $mform->addHelpButton('requiredentriestoview', 'requiredentriestoview', 'data');
46 $mform->addElement('select', 'maxentries', get_string('maxentries', 'data'), $countoptions);
47 $mform->addHelpButton('maxentries', 'maxentries', 'data');
49 $ynoptions = array(0 => get_string('no'), 1 => get_string('yes'));
50 $mform->addElement('select', 'comments', get_string('comments', 'data'), $ynoptions);
52 $mform->addElement('select', 'approval', get_string('requireapproval', 'data'), $ynoptions);
53 $mform->addHelpButton('approval', 'requireapproval', 'data');
55 if($CFG->enablerssfeeds
&& $CFG->data_enablerssfeeds
){
56 $mform->addElement('select', 'rssarticles', get_string('numberrssarticles', 'data') , $countoptions);
59 $this->standard_grading_coursemodule_elements();
61 $this->standard_coursemodule_elements();
63 //-------------------------------------------------------------------------------
65 $this->add_action_buttons();
68 function data_preprocessing(&$default_values){
69 parent
::data_preprocessing($default_values);