MDL-9629 Beginning the edit category page. Also added dmllib::sql_max($field) and...
[moodle.git] / grade / import / grade_import_form.php
CommitLineData
7f999ccb 1<?php // $Id$
2require_once $CFG->libdir.'/formslib.php';
3
4class grade_import_form extends moodleform {
5 function definition (){
6 $mform =& $this->_form;
7
8 // course id needs to be passed for auth purposes
9 $mform->addElement('hidden', 'id', optional_param('id'));
10
11 // file upload
12 $mform->addElement('file', 'userfile', get_string('file'));
13 $mform->addRule('userfile', null, 'required');
14
15 $this->add_action_buttons(false, get_string('uploadgrades'));
16 }
17
18 function get_userfile_name(){
19 if ($this->is_submitted() and $this->is_validated()) {
20 // return the temporary filename to process
21 return $this->_upload_manager->files['userfile']['tmp_name'];
22 }else{
23 return NULL;
24 }
25 }
26}
85e287de 27
28
29class grade_import_mapping_form extends moodleform {
30 function definition () {
31 $mform =& $this->_form;
32
33 // course id needs to be passed for auth purposes
34 $mform->addElement('hidden', 'id', optional_param('id'));
35
36 $this->add_action_buttons(false, get_string('uploadgrades'));
37 }
38
39 function setup ($headers = '', $filename = '') {
40 $mform =& $this->_form;
41 if (is_array($headers)) {
42 foreach ($headers as $header) {
43 $mform->addElement('hidden', $header, $header);
44 $mform->addRule($header, null, 'required');
45 }
46 }
47 if ($filename) {
48 $mform->addElement('hidden', 'filename', $filename);
49 $mform->addRule('filename', null, 'required');
50 }
51
52 print_object($mform);
53
54 }
55}
7f999ccb 56?>