-
Notifications
You must be signed in to change notification settings - Fork 0
/
sort_edit_studentwork_form.php
53 lines (41 loc) · 1.99 KB
/
sort_edit_studentwork_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
<?php
require_once($CFG->libdir . "/formslib.php");
class sort_new_studentwork_form extends moodleform {
function definition() {
global $CFG;
$mform =& $this->_form; // Don't forget the underscore!
$studentworks = $this->_customdata['studentworks'];
$this_studentwork = $this->_customdata['this_studentwork'];
$sort = $this->_customdata['sort'];
$problem = $this->_customdata['problem'];
if ($sort->custom_labels) {
$mform->addElement('text', 'studentworkname', 'Name');
} else {
$letters = range('A','Z');
$options = array_combine($letters,$letters);
foreach ($studentworks as $studentwork) {
if (isset($options[$studentwork->name]) && (isset($this_studentwork) && $this_studentwork->name != $studentwork->name) || !isset($this_studentwork)) {
unset($options[$studentwork->name]);
}
}
$mform->addElement('select', 'studentworkname', 'Name', $options);
}
$mform->addRule('studentworkname', 'This field is required', 'required');
$mform->addElement('filemanager', 'attachments', 'sample image', null,
array('subdirs' => 0, 'maxbytes' => 33554432, 'maxfiles' => 1,
));
$mform->addRule('attachments', 'This field is required', 'required');
//$DB = new moodle_database();
global $DB;
$categories = $DB->get_records('sort_category', array('sid' => $sort->id));
$options = array(
'0' => '- None -',
);
foreach ($categories as $id => $category) {
$options[$id] = $category->category;
}
if ($sort->has_correct) $mform->addElement('select','correct_answer','Correct Answer', $options);
else $mform->addElement('hidden','correct_answer','0');
$this->add_action_buttons(false);
}
}