forked from patrickpollet/moodle_local_mass_enroll
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmass_enroll_form.php
72 lines (54 loc) · 2.65 KB
/
mass_enroll_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
// $Id: inscriptions_massives_form.php 352 2010-02-27 12:16:55Z ppollet $
require_once ($CFG->libdir . '/formslib.php');
class mass_enroll_form extends moodleform {
function definition() {
global $CFG,$DB;
$mform = & $this->_form;
$course = $this->_customdata['course'];
$context = $this->_customdata['context'];
$mform->addElement('header', 'general', ''); //fill in the data depending on page params
//later using set_data
$mform->addElement('filepicker', 'attachment', get_string('location', 'enrol_flatfile'));
$mform->addRule('attachment', null, 'required');
$choices = csv_import_reader::get_delimiter_list();
$mform->addElement('select', 'delimiter_name', get_string('csvdelimiter', 'tool_uploaduser'), $choices);
if (array_key_exists('cfg', $choices)) {
$mform->setDefault('delimiter_name', 'cfg');
} else if (get_string('listsep', 'langconfig') == ';') {
$mform->setDefault('delimiter_name', 'semicolon');
} else {
$mform->setDefault('delimiter_name', 'comma');
}
$choices = textlib::get_encodings();
$mform->addElement('select', 'encoding', get_string('encoding', 'tool_uploaduser'), $choices);
$mform->setDefault('encoding', 'UTF-8');
$roles = get_assignable_roles($context);
$mform->addElement('select', 'roleassign', get_string('roleassign', 'local_mass_enroll'), $roles);
$studentRole= $DB->get_record('role', array('archetype'=>'student'));
$mform->setDefault('roleassign', $studentRole->id);
$ids = array (
'idnumber' => get_string('idnumber', 'local_mass_enroll'),
'username' => get_string('username', 'local_mass_enroll'),
'email' => get_string('email')
);
$mform->addElement('select', 'firstcolumn', get_string('firstcolumn', 'local_mass_enroll'), $ids);
$mform->setDefault('firstcolumn', 'idnumber');
$mform->addElement('selectyesno', 'creategroups', get_string('creategroups', 'local_mass_enroll'));
$mform->setDefault('creategroups', 1);
$mform->addElement('selectyesno', 'creategroupings', get_string('creategroupings', 'local_mass_enroll'));
$mform->setDefault('creategroupings', 1);
$mform->addElement('selectyesno', 'mailreport', get_string('mailreport', 'local_mass_enroll'));
$mform->setDefault('mailreport', 1);
//-------------------------------------------------------------------------------
// buttons
$this->add_action_buttons(true, get_string('enroll', 'local_mass_enroll'));
$mform->addElement('hidden', 'id', $course->id);
$mform->setType('id', PARAM_INT);
}
function validation($data, $files) {
$errors = parent :: validation($data, $files);
return $errors;
}
}
?>