2 require_once ($CFG->dirroot
.'/course/moodleform_mod.php');
4 class mod_resource_mod_form
extends moodleform_mod
{
7 function definition() {
9 $mform =& $this->_form
;
11 // this hack is needed for different settings of each subtype
12 if (!empty($this->_instance
)) {
13 if($res = get_record('resource', 'id', (int)$this->_instance
)) {
16 error('incorrect assignment');
19 $type = required_param('type', PARAM_ALPHA
);
21 $mform->addElement('hidden', 'type', $type);
22 $mform->setDefault('type', $type);
24 require($CFG->dirroot
.'/mod/resource/type/'.$type.'/resource.class.php');
25 $resclass = 'resource_'.$type;
26 $this->_resinstance
= new $resclass();
28 //-------------------------------------------------------------------------------
29 $mform->addElement('header', 'general', get_string('general', 'form'));
31 // $mform->addElement('static', 'statictype', get_string('assignmenttype', 'assignment'), get_string('type'.$type,'assignment'));
33 $mform->addElement('text', 'name', get_string('name'), array('size'=>'48'));
34 if (!empty($CFG->formatstringstriptags
)) {
35 $mform->setType('name', PARAM_TEXT
);
37 $mform->setType('name', PARAM_CLEAN
);
39 $mform->addRule('name', null, 'required', null, 'client');
41 $mform->addElement('htmleditor', 'summary', get_string('summary'));
42 $mform->setType('summary', PARAM_RAW
);
43 $mform->setHelpButton('summary', array('summary', get_string('summary'), 'resource'));
44 // summary should be optional again MDL-9485
45 //$mform->addRule('summary', get_string('required'), 'required', null, 'client');
47 $mform->addElement('header', 'typedesc', get_string('resourcetype'.$type,'resource'));
48 $this->_resinstance
->setup_elements($mform);
50 $this->standard_coursemodule_elements(array('groups'=>false, 'groupmembersonly'=>true, 'gradecat'=>false));
52 $this->add_action_buttons();
55 function data_preprocessing(&$default_values){
56 $this->_resinstance
->setup_preprocessing($default_values);