MDL-11517 reserved word MOD used in table alias in questions backup code
[moodle-pu.git] / grade / export / grade_export_form.php
blobc1b994b68059c0d7004b5318bd16ecaef0c0eed7
1 <?php // $Id$
2 require_once $CFG->libdir.'/formslib.php';
4 class grade_export_form extends moodleform {
5 function definition() {
6 global $CFG, $COURSE, $USER;
8 $mform =& $this->_form;
9 if (isset($this->_customdata)) { // hardcoding plugin names here is hacky
10 $features = $this->_customdata;
11 } else {
12 $features = array();
15 $mform->addElement('header', 'options', get_string('options', 'grades'));
17 $mform->addElement('advcheckbox', 'export_letters', get_string('exportletters', 'grades'));
18 $mform->setDefault('export_letters', 0);
19 $mform->setHelpButton('export_letters', array(false, get_string('exportletters', 'grades'),
20 false, true, false, get_string("exportlettershelp", 'grades')));
22 $mform->addElement('advcheckbox', 'export_feedback', get_string('exportfeedback', 'grades'));
23 $mform->setDefault('export_feedback', 0);
25 $options = array('10'=>10, '20'=>20, '100'=>100, '1000'=>1000, '100000'=>100000);
26 $mform->addElement('select', 'previewrows', get_string('previewrows', 'grades'), $options);
28 if (!empty($features['includeseparator'])) {
29 $radio = array();
30 $radio[] = &MoodleQuickForm::createElement('radio', 'separator', null, get_string('septab', 'grades'), 'tab');
31 $radio[] = &MoodleQuickForm::createElement('radio', 'separator', null, get_string('sepcomma', 'grades'), 'comma');
32 $mform->addGroup($radio, 'separator', get_string('separator', 'grades'), ' ', false);
33 $mform->setDefault('separator', 'comma');
36 if (!empty($CFG->gradepublishing) and !empty($features['publishing'])) {
37 $mform->addElement('header', 'publishing', get_string('publishing', 'grades'));
38 $options = array(get_string('nopublish', 'grades'), get_string('createnewkey', 'userkey'));
39 if ($keys = get_records_select('user_private_key', "script='grade/export' AND instance={$COURSE->id} AND userid={$USER->id}")) {
40 foreach ($keys as $key) {
41 $options[$key->value] = $key->value; // TODO: add more details - ip restriction, valid until ??
44 $mform->addElement('select', 'key', get_string('userkey', 'userkey'), $options);
45 $mform->setHelpButton('key', array(false, get_string('userkey', 'userkey'),
46 false, true, false, get_string("userkeyhelp", 'grades')));
47 $mform->addElement('static', 'keymanagerlink', get_string('keymanager', 'userkey'),
48 '<a href="'.$CFG->wwwroot.'/grade/export/keymanager.php?id='.$COURSE->id.'">'.get_string('keymanager', 'userkey').'</a>');
50 $mform->addElement('text', 'iprestriction', get_string('keyiprestriction', 'userkey'), array('size'=>80));
51 $mform->setHelpButton('iprestriction', array(false, get_string('keyiprestriction', 'userkey'),
52 false, true, false, get_string("keyiprestrictionhelp", 'userkey')));
53 $mform->setDefault('iprestriction', getremoteaddr()); // own IP - just in case somebody does not know what user key is
55 $mform->addElement('date_time_selector', 'validuntil', get_string('keyvaliduntil', 'userkey'), array('optional'=>true));
56 $mform->setHelpButton('validuntil', array(false, get_string('keyvaliduntil', 'userkey'),
57 false, true, false, get_string("keyvaliduntilhelp", 'userkey')));
58 $mform->setDefault('validuntil', time()+3600*24*7); // only 1 week default duration - just in case somebody does not know what user key is
60 $mform->disabledIf('iprestriction', 'key', 'noteq', 1);
61 $mform->disabledIf('validuntil', 'key', 'noteq', 1);
64 $mform->addElement('header', 'gradeitems', get_string('gradeitemsinc', 'grades'));
66 if ($grade_items = grade_item::fetch_all(array('courseid'=>$COURSE->id))) {
67 foreach ($grade_items as $grade_item) {
68 if (!empty($features['idnumberrequired']) and empty($grade_item->idnumber)) {
69 $mform->addElement('advcheckbox', 'itemids['.$grade_item->id.']', $grade_item->get_name(), get_string('noidnumber', 'grades'));
70 $mform->hardFreeze('itemids['.$grade_item->id.']');
72 } else {
73 $mform->addElement('advcheckbox', 'itemids['.$grade_item->id.']', $grade_item->get_name());
74 $mform->setDefault('itemids['.$grade_item->id.']', 1);
79 $mform->addElement('hidden', 'id', $COURSE->id);
81 $this->add_action_buttons(false, get_string('submit'));