. /** * File containing the step 1 of the upload form. * * @package tool_uploadcourse * @copyright 2013 Frédéric Massart * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ defined('MOODLE_INTERNAL') || die(); require_once($CFG->libdir.'/formslib.php'); /** * Upload a file CVS file with course information. * * @package tool_uploadcourse * @copyright 2011 Piers Harding * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class tool_uploadcourse_step1_form extends moodleform { /** * The standard form definiton. * @return void */ public function definition () { $mform = $this->_form; $mform->addElement('header', 'settingsheader', get_string('upload')); $mform->addElement('filepicker', 'coursefile', get_string('file')); $mform->addRule('coursefile', null, 'required'); $choices = csv_import_reader::get_delimiter_list(); $mform->addElement('select', 'delimiter_name', get_string('csvdelimiter', 'tool_uploadcourse'), $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_uploadcourse'), $choices); $mform->setDefault('encoding', 'UTF-8'); $choices = array('10' => 10, '20' => 20, '100' => 100, '1000' => 1000, '100000' => 100000); $mform->addElement('select', 'previewrows', get_string('rowpreviewnum', 'tool_uploadcourse'), $choices); $mform->setType('previewrows', PARAM_INT); $this->add_action_buttons(false, get_string('uploadcourses', 'tool_uploadcourse')); } }