2 // This file is part of Moodle - http://moodle.org/
4 // Moodle is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
9 // Moodle is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
18 * File containing the step 1 of the upload form.
20 * @package tool_uploadcourse
21 * @copyright 2013 Frédéric Massart
22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
25 defined('MOODLE_INTERNAL') || die();
27 require_once($CFG->libdir.'/formslib.php');
30 * Upload a file CVS file with course information.
32 * @package tool_uploadcourse
33 * @copyright 2011 Piers Harding
34 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
36 class tool_uploadcourse_step1_form extends tool_uploadcourse_base_form {
39 * The standard form definiton.
42 public function definition () {
43 $mform = $this->_form;
45 $mform->addElement('header', 'generalhdr', get_string('general'));
47 $mform->addElement('filepicker', 'coursefile', get_string('file'));
48 $mform->addRule('coursefile', null, 'required');
50 $choices = csv_import_reader::get_delimiter_list();
51 $mform->addElement('select', 'delimiter_name', get_string('csvdelimiter', 'tool_uploadcourse'), $choices);
52 if (array_key_exists('cfg', $choices)) {
53 $mform->setDefault('delimiter_name', 'cfg');
54 } else if (get_string('listsep', 'langconfig') == ';') {
55 $mform->setDefault('delimiter_name', 'semicolon');
57 $mform->setDefault('delimiter_name', 'comma');
60 $choices = textlib::get_encodings();
61 $mform->addElement('select', 'encoding', get_string('encoding', 'tool_uploadcourse'), $choices);
62 $mform->setDefault('encoding', 'UTF-8');
64 $choices = array('10' => 10, '20' => 20, '100' => 100, '1000' => 1000, '100000' => 100000);
65 $mform->addElement('select', 'previewrows', get_string('rowpreviewnum', 'tool_uploadcourse'), $choices);
66 $mform->setType('previewrows', PARAM_INT);
68 $this->add_import_options();
70 $mform->addElement('hidden', 'showpreview', 1);
71 $mform->setType('showpreview', PARAM_INT);
73 $this->add_action_buttons(false, get_string('preview', 'tool_uploadcourse'));