Skip to content

Commit

Permalink
MDL-26401 group: add delimiter and encoding fields to import
Browse files Browse the repository at this point in the history
  • Loading branch information
lameze committed Aug 12, 2020
1 parent 24c6876 commit 4cdcf3a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
14 changes: 14 additions & 0 deletions group/import_form.php
Expand Up @@ -27,6 +27,7 @@
}

require_once($CFG->libdir.'/formslib.php');
require_once($CFG->libdir . '/csvlib.class.php');

/**
* Groups import form class
Expand Down Expand Up @@ -56,6 +57,19 @@ function definition() {
$mform->addElement('hidden', 'id');
$mform->setType('id', PARAM_INT);

$choices = csv_import_reader::get_delimiter_list();
$mform->addElement('select', 'delimiter_name', get_string('csvdelimiter', 'group'), $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 = core_text::get_encodings();
$mform->addElement('select', 'encoding', get_string('encoding', 'group'), $choices);
$mform->setDefault('encoding', 'UTF-8');
$this->add_action_buttons(true, get_string('importgroups', 'core_group'));

$this->set_data($data);
Expand Down
2 changes: 2 additions & 0 deletions lang/en/group.php
Expand Up @@ -43,6 +43,7 @@
$string['creategroupinselectedgrouping'] = 'Create group in grouping';
$string['createingrouping'] = 'Grouping of auto-created groups';
$string['createorphangroup'] = 'Create orphan group';
$string['csvdelimiter'] = 'CSV delimiter';
$string['databaseupgradegroups'] = 'Groups version is now {$a}';
$string['defaultgrouping'] = 'Default grouping';
$string['defaultgroupingname'] = 'Grouping';
Expand All @@ -59,6 +60,7 @@
$string['editusersgroupsa'] = 'Edit groups for "{$a}"';
$string['enablemessaging'] = 'Group messaging';
$string['enablemessaging_help'] = 'If enabled, group members can send messages to the others in their group via the messaging drawer.';
$string['encoding'] = 'Encoding';
$string['enrolmentkey'] = 'Enrolment key';
$string['enrolmentkey_help'] = 'An enrolment key enables access to the course to be restricted to only those who know the key. If a group enrolment key is specified, then not only will entering that key let the user into the course, but it will also automatically make them a member of this group.
Expand Down

0 comments on commit 4cdcf3a

Please sign in to comment.