forked from moodle/moodle
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmod_form.php
73 lines (49 loc) · 3.02 KB
/
mod_form.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<?php
if (!defined('MOODLE_INTERNAL')) {
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
}
require_once ($CFG->dirroot.'/course/moodleform_mod.php');
class mod_data_mod_form extends moodleform_mod {
function definition() {
global $CFG, $DB;
$mform =& $this->_form;
//-------------------------------------------------------------------------------
$mform->addElement('header', 'general', get_string('general', 'form'));
$mform->addElement('text', 'name', get_string('name'), array('size'=>'64'));
if (!empty($CFG->formatstringstriptags)) {
$mform->setType('name', PARAM_TEXT);
} else {
$mform->setType('name', PARAM_CLEANHTML);
}
$mform->addRule('name', null, 'required', null, 'client');
$this->add_intro_editor(true, get_string('intro', 'data'));
$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));
$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->addHelpButton('requiredentries', 'requiredentries', 'data');
$mform->addElement('select', 'requiredentriestoview', get_string('requiredentriestoview', 'data'), $countoptions);
$mform->addHelpButton('requiredentriestoview', 'requiredentriestoview', 'data');
$mform->addElement('select', 'maxentries', get_string('maxentries', 'data'), $countoptions);
$mform->addHelpButton('maxentries', 'maxentries', 'data');
$ynoptions = array(0 => get_string('no'), 1 => get_string('yes'));
$mform->addElement('select', 'comments', get_string('comments', 'data'), $ynoptions);
$mform->addElement('select', 'approval', get_string('requireapproval', 'data'), $ynoptions);
$mform->addHelpButton('approval', 'requireapproval', 'data');
if($CFG->enablerssfeeds && $CFG->data_enablerssfeeds){
$mform->addElement('select', 'rssarticles', get_string('numberrssarticles', 'data') , $countoptions);
}
$this->standard_grading_coursemodule_elements();
$this->standard_coursemodule_elements();
//-------------------------------------------------------------------------------
// buttons
$this->add_action_buttons();
}
function data_preprocessing(&$default_values){
parent::data_preprocessing($default_values);
}
}