2 require_once ($CFG->dirroot
.'/course/moodleform_mod.php');
4 class mod_assignment_mod_form
extends moodleform_mod
{
6 function definition() {
8 $mform =& $this->_form
;
10 // this hack is needed for different settings of each subtype
11 if (!empty($this->_instance
)) {
12 if($ass = get_record('assignment', 'id', (int)$this->_instance
)) {
13 $type = $ass->assignmenttype
;
15 error('incorrect assignment');
18 $type = required_param('type', PARAM_ALPHA
);
20 $mform->addElement('hidden', 'assignmenttype', $type);
21 $mform->setDefault('assignmenttype', $type);
22 $mform->addElement('hidden', 'type', $type);
23 $mform->setDefault('type', $type);
25 require($CFG->dirroot
.'/mod/assignment/type/'.$type.'/assignment.class.php');
26 $assignmentclass = 'assignment_'.$type;
27 $assignmentinstance = new $assignmentclass();
29 //-------------------------------------------------------------------------------
30 $mform->addElement('header', 'general', get_string('general', 'form'));
32 // $mform->addElement('static', 'statictype', get_string('assignmenttype', 'assignment'), get_string('type'.$type,'assignment'));
34 $mform->addElement('text', 'name', get_string('assignmentname', 'assignment'), array('size'=>'64'));
35 $mform->setType('name', PARAM_TEXT
);
36 $mform->addRule('name', null, 'required', null, 'client');
38 $mform->addElement('htmleditor', 'description', get_string('description', 'assignment'));
39 $mform->setType('description', PARAM_RAW
);
40 $mform->setHelpButton('description', array('writing', 'questions', 'richtext'), false, 'editorhelpbutton');
41 $mform->addRule('description', get_string('required'), 'required', null, 'client');
43 $mform->addElement('modgrade', 'grade', get_string('grade'));
44 $mform->setDefault('grade', 100);
46 $mform->addElement('date_time_selector', 'timeavailable', get_string('availabledate', 'assignment'), array('optional'=>true));
47 $mform->setDefault('timeavailable', time());
48 $mform->addElement('date_time_selector', 'timedue', get_string('duedate', 'assignment'), array('optional'=>true));
49 $mform->setDefault('timedue', time()+
7*24*3600);
51 $ynoptions = array( 0 => get_string('no'), 1 => get_string('yes'));
53 $mform->addElement('select', 'preventlate', get_string('preventlate', 'assignment'), $ynoptions);
54 $mform->setDefault('preventlate', 0);
56 $mform->addElement('header', 'typedesc', get_string('type'.$type,'assignment'));
57 $assignmentinstance->setup_elements($mform);
59 $features = new stdClass
;
60 $features->groups
= true;
61 $features->groupings
= true;
62 $features->groupmembersonly
= true;
63 $this->standard_coursemodule_elements($features);
65 $this->add_action_buttons();