2 if (!defined('MOODLE_INTERNAL')) {
3 die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
6 require_once($CFG->libdir
.'/formslib.php');
7 require_once($CFG->libdir
.'/csvlib.class.php');
9 class mod_data_import_form
extends moodleform
{
11 function definition() {
12 $mform =& $this->_form
;
14 $dataid = $this->_customdata
['dataid'];
15 $backtourl = $this->_customdata
['backtourl'];
17 $mform->addElement('filepicker', 'recordsfile', get_string('csvfile', 'data'),
18 null, ['accepted_types' => ['application/zip', 'text/csv']]);
20 $delimiters = csv_import_reader
::get_delimiter_list();
21 $mform->addElement('select', 'fielddelimiter', get_string('fielddelimiter', 'data'), $delimiters);
22 $mform->setDefault('fielddelimiter', 'comma');
24 $mform->addElement('text', 'fieldenclosure', get_string('fieldenclosure', 'data'));
25 $mform->setType('fieldenclosure', PARAM_CLEANHTML
);
27 $choices = core_text
::get_encodings();
28 $mform->addElement('select', 'encoding', get_string('fileencoding', 'mod_data'), $choices);
29 $mform->setDefault('encoding', 'UTF-8');
31 // Database activity ID.
32 $mform->addElement('hidden', 'd');
33 $mform->setType('d', PARAM_INT
);
34 $mform->setDefault('d', $dataid);
37 $mform->addElement('hidden', 'backto');
38 $mform->setType('backto', PARAM_LOCALURL
);
39 $mform->setDefault('backto', $backtourl);
41 $this->add_action_buttons(true, get_string('submit'));