forked from moodle/moodle
-
Notifications
You must be signed in to change notification settings - Fork 1
/
mod_form.php
56 lines (43 loc) · 2.15 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
<?php
require_once ($CFG->dirroot.'/course/moodleform_mod.php');
class mod_resource_mod_form extends moodleform_mod {
var $_resinstance;
function definition() {
global $CFG, $DB;
$mform =& $this->_form;
// this hack is needed for different settings of each subtype
if (!empty($this->_instance)) {
if($res = $DB->get_record('resource', array('id'=>$this->_instance))) {
$type = $res->type;
} else {
print_error('incorrect assignment');
}
} else {
$type = required_param('type', PARAM_ALPHA);
}
$mform->addElement('hidden', 'type', $type);
$mform->setDefault('type', $type);
require($CFG->dirroot.'/mod/resource/type/'.$type.'/resource.class.php');
$resclass = 'resource_'.$type;
$this->_resinstance = new $resclass();
//-------------------------------------------------------------------------------
$mform->addElement('header', 'general', get_string('general', 'form'));
// $mform->addElement('static', 'statictype', get_string('assignmenttype', 'assignment'), get_string('type'.$type,'assignment'));
$mform->addElement('text', 'name', get_string('name'), array('size'=>'48'));
$mform->setType('name', PARAM_TEXT);
$mform->addRule('name', null, 'required', null, 'client');
$mform->addElement('htmleditor', 'summary', get_string('summary'));
$mform->setType('summary', PARAM_RAW);
$mform->setHelpButton('summary', array('summary', get_string('summary'), 'resource'));
// summary should be optional again MDL-9485
//$mform->addRule('summary', get_string('required'), 'required', null, 'client');
$mform->addElement('header', 'typedesc', get_string('resourcetype'.$type,'resource'));
$this->_resinstance->setup_elements($mform);
$this->standard_coursemodule_elements(array('groups'=>false, 'groupmembersonly'=>true, 'gradecat'=>false));
$this->add_action_buttons();
}
function data_preprocessing(&$default_values){
$this->_resinstance->setup_preprocessing($default_values);
}
}
?>