diff --git a/admin/tool/uploadcourse/classes/course.php b/admin/tool/uploadcourse/classes/course.php index 2812a7feda0..27817458bf7 100644 --- a/admin/tool/uploadcourse/classes/course.php +++ b/admin/tool/uploadcourse/classes/course.php @@ -56,6 +56,9 @@ class tool_uploadcourse_course { /** @var array errors. */ protected $errors = array(); + /** @var int the ID of the course that had been processed. */ + protected $id; + /** @var array containing options passed from the processor. */ protected $importoptions = array(); @@ -71,6 +74,9 @@ class tool_uploadcourse_course { /** @var bool set to true once we have prepared the course */ protected $prepared = false; + /** @var bool set to true once we have started the process of the course */ + protected $processstarted = false; + /** @var array course import data. */ protected $rawdata = array(); @@ -221,8 +227,8 @@ class tool_uploadcourse_course { */ protected function delete() { global $DB; - $id = $DB->get_field_select('course', 'id', 'shortname = :shortname', array('shortname' => $this->shortname), MUST_EXIST); - return delete_course($id, false); + $this->id = $DB->get_field_select('course', 'id', 'shortname = :shortname', array('shortname' => $this->shortname), MUST_EXIST); + return delete_course($this->id, false); } /** @@ -321,6 +327,18 @@ class tool_uploadcourse_course { return $newdata; } + /** + * Return the ID of the processed course. + * + * @return int|null + */ + public function get_id() { + if (!$this->processstarted) { + throw new coding_exception('The course has not been processed yet!'); + } + return $this->id; + } + /** * Get the directory of the object to restore. * @@ -648,7 +666,10 @@ class tool_uploadcourse_course { throw new coding_exception('The course has not been prepared.'); } else if ($this->has_errors()) { throw new moodle_exception('Cannot proceed, errors were detected.'); + } else if ($this->processstarted) { + throw new coding_exception('The process has already been started.'); } + $this->processstarted = true; if ($this->do === self::DO_DELETE) { if ($this->delete()) { @@ -659,10 +680,12 @@ class tool_uploadcourse_course { return true; } else if ($this->do === self::DO_CREATE) { $course = create_course((object) $this->data); + $this->id = $course->id; $this->status('coursecreated', new lang_string('coursecreated', 'tool_uploadcourse')); } else if ($this->do === self::DO_UPDATE) { $course = (object) $this->data; update_course($course); + $this->id = $course->id; $this->status('courseupdated', new lang_string('courseupdated', 'tool_uploadcourse')); } else { // Strangely the outcome has not been defined, or is unknown! diff --git a/admin/tool/uploadcourse/classes/processor.php b/admin/tool/uploadcourse/classes/processor.php index 800daf85d94..3fd57fe420b 100644 --- a/admin/tool/uploadcourse/classes/processor.php +++ b/admin/tool/uploadcourse/classes/processor.php @@ -213,6 +213,7 @@ class tool_uploadcourse_processor { $deleted++; } + $data = array_merge($data, $course->get_data(), array('id' => $course->get_id())); $tracker->output($this->linenb, true, $status, $data); } else { $errors++; diff --git a/admin/tool/uploadcourse/classes/step1_form.php b/admin/tool/uploadcourse/classes/step1_form.php new file mode 100644 index 00000000000..d6b9fb25ae3 --- /dev/null +++ b/admin/tool/uploadcourse/classes/step1_form.php @@ -0,0 +1,70 @@ +. + +/** + * 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')); + } +} \ No newline at end of file diff --git a/admin/tool/uploadcourse/classes/step2_form.php b/admin/tool/uploadcourse/classes/step2_form.php new file mode 100644 index 00000000000..be9e9d4c5ed --- /dev/null +++ b/admin/tool/uploadcourse/classes/step2_form.php @@ -0,0 +1,263 @@ +. + +/** + * Bulk course upload step 2. + * + * @package tool_uploadcourse + * @copyright 2011 Piers Harding + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +defined('MOODLE_INTERNAL') || die(); + +require_once($CFG->libdir.'/formslib.php'); + +/** + * Specify course upload details. + * + * @package tool_uploadcourse + * @copyright 2011 Piers Harding + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +class tool_uploadcourse_step2_form extends moodleform { + + /** + * The standard form definiton. + * @return void. + */ + public function definition () { + global $CFG, $COURSE, $DB; + + $mform = $this->_form; + $data = $this->_customdata['data']; + $courseconfig = get_config('moodlecourse'); + + // Upload settings and file. + $mform->addElement('header', 'generalhdr', get_string('general')); + + $choices = array( + tool_uploadcourse_processor::MODE_CREATE_NEW => get_string('ccoptype_addnew', 'tool_uploadcourse'), + tool_uploadcourse_processor::MODE_CREATE_ALL => get_string('ccoptype_addinc', 'tool_uploadcourse'), + tool_uploadcourse_processor::MODE_CREATE_OR_UPDATE => get_string('ccoptype_addupdate', 'tool_uploadcourse'), + tool_uploadcourse_processor::MODE_UPDATE_ONLY => get_string('ccoptype_update', 'tool_uploadcourse') + ); + $mform->addElement('select', 'options[mode]', get_string('mode', 'tool_uploadcourse'), $choices); + + $choices = array( + tool_uploadcourse_processor::UPDATE_NOTHING => get_string('nochanges', 'tool_uploadcourse'), + tool_uploadcourse_processor::UPDATE_ALL_WITH_DATA_ONLY => get_string('ccupdatefromfile', 'tool_uploadcourse'), + tool_uploadcourse_processor::UPDATE_ALL_WITH_DATA_OR_DEFAUTLS => get_string('ccupdateall', 'tool_uploadcourse'), + tool_uploadcourse_processor::UPDATE_MISSING_WITH_DATA_OR_DEFAUTLS => get_string('ccupdatemissing', 'tool_uploadcourse') + ); + $mform->addElement('select', 'options[updatemode]', get_string('updatemode', 'tool_uploadcourse'), $choices); + $mform->setDefault('options[updatemode]', tool_uploadcourse_processor::UPDATE_NOTHING); + $mform->disabledIf('options[updatemode]', 'mode', 'eq', tool_uploadcourse_processor::MODE_CREATE_NEW); + $mform->disabledIf('options[updatemode]', 'mode', 'eq', tool_uploadcourse_processor::MODE_CREATE_ALL); + + $mform->addElement('selectyesno', 'options[allowdeletes]', get_string('allowdeletes', 'tool_uploadcourse')); + $mform->setDefault('options[allowdeletes]', 0); + $mform->disabledIf('options[allowdeletes]', 'mode', 'eq', tool_uploadcourse_processor::MODE_CREATE_NEW); + $mform->disabledIf('options[allowdeletes]', 'mode', 'eq', tool_uploadcourse_processor::MODE_CREATE_ALL); + + $mform->addElement('selectyesno', 'options[allowrenames]', get_string('allowrenames', 'tool_uploadcourse')); + $mform->setDefault('options[allowrenames]', 0); + $mform->disabledIf('options[allowrenames]', 'mode', 'eq', tool_uploadcourse_processor::MODE_CREATE_NEW); + $mform->disabledIf('options[allowrenames]', 'mode', 'eq', tool_uploadcourse_processor::MODE_CREATE_ALL); + + $mform->addElement('selectyesno', 'options[allowresets]', get_string('allowresets', 'tool_uploadcourse')); + $mform->setDefault('options[allowresets]', 0); + $mform->disabledIf('options[allowresets]', 'mode', 'eq', tool_uploadcourse_processor::MODE_CREATE_NEW); + $mform->disabledIf('options[allowresets]', 'mode', 'eq', tool_uploadcourse_processor::MODE_CREATE_ALL); + + $mform->addElement('selectyesno', 'options[reset]', get_string('reset', 'tool_uploadcourse')); + $mform->setDefault('options[reset]', 0); + $mform->disabledIf('options[reset]', 'mode', 'eq', tool_uploadcourse_processor::MODE_CREATE_NEW); + $mform->disabledIf('options[reset]', 'mode', 'eq', tool_uploadcourse_processor::MODE_CREATE_ALL); + + // Default values. + $mform->addElement('header', 'defaultheader', get_string('defaultvalues', 'tool_uploadcourse')); + $mform->setExpanded('defaultheader', true); + + $mform->addElement('text', 'options[shortnametemplate]', get_string('shortnametemplate', 'tool_uploadcourse'), 'maxlength="100" size="20"'); + $mform->setType('options[shortnametemplate]', PARAM_RAW); + $mform->addHelpButton('options[shortnametemplate]', 'shortnametemplate', 'tool_uploadcourse'); + $mform->disabledIf('options[shortnametemplate]', 'mode', 'eq', tool_uploadcourse_processor::MODE_CREATE_OR_UPDATE); + $mform->disabledIf('options[shortnametemplate]', 'mode', 'eq', tool_uploadcourse_processor::MODE_UPDATE_ONLY); + + $displaylist = coursecat::make_categories_list('moodle/course:create'); + $mform->addElement('select', 'defaults[category]', get_string('coursecategory'), $displaylist); + $mform->addHelpButton('defaults[category]', 'coursecategory'); + + $choices = array(); + $choices['0'] = get_string('hide'); + $choices['1'] = get_string('show'); + $mform->addElement('select', 'defaults[visible]', get_string('visible'), $choices); + $mform->addHelpButton('defaults[visible]', 'visible'); + $mform->setDefault('defaults[defaults]', $courseconfig->visible); + + $mform->addElement('date_selector', 'defaults[startdate]', get_string('startdate')); + $mform->addHelpButton('defaults[startdate]', 'startdate'); + $mform->setDefault('defaults[startdate]', time() + 3600 * 24); + + $courseformats = get_sorted_course_formats(true); + $formcourseformats = array(); + foreach ($courseformats as $courseformat) { + $formcourseformats[$courseformat] = get_string('pluginname', "format_$courseformat"); + } + $mform->addElement('select', 'defaults[format]', get_string('format'), $formcourseformats); + $mform->addHelpButton('defaults[format]', 'format'); + $mform->setDefault('defaults[format]', $courseconfig->format); + + if (!empty($CFG->allowcoursethemes)) { + $themeobjects = get_list_of_themes(); + $themes=array(); + $themes[''] = get_string('forceno'); + foreach ($themeobjects as $key => $theme) { + if (empty($theme->hidefromselector)) { + $themes[$key] = get_string('pluginname', 'theme_'.$theme->name); + } + } + $mform->addElement('select', 'defaults[theme]', get_string('forcetheme'), $themes); + } + + $languages[] = array(); + $languages[''] = get_string('forceno'); + $languages += get_string_manager()->get_list_of_translations(); + $mform->addElement('select', 'defaults[lang]', get_string('forcelanguage'), $languages); + $mform->setDefault('defaults[lang]', $courseconfig->lang); + + $options = range(0, 10); + $mform->addElement('select', 'defaults[newsitems]', get_string('newsitemsnumber'), $options); + $mform->addHelpButton('defaults[newsitems]', 'newsitemsnumber'); + $mform->setDefault('defaults[newsitems]', $courseconfig->newsitems); + + $mform->addElement('selectyesno', 'defaults[showgrades]', get_string('showgrades')); + $mform->addHelpButton('defaults[showgrades]', 'showgrades'); + $mform->setDefault('defaults[showgrades]', $courseconfig->showgrades); + + $mform->addElement('selectyesno', 'defaults[showreports]', get_string('showreports')); + $mform->addHelpButton('defaults[showreports]', 'showreports'); + $mform->setDefault('defaults[showreports]', $courseconfig->showreports); + + if (!empty($CFG->legacyfilesinnewcourses)) { + if (empty($course->legacyfiles)) { + $choices = array('0' => get_string('no'), '2' => get_string('yes')); + } + $mform->addElement('select', 'defaults[legacyfiles]', get_string('courselegacyfiles'), $choices); + $mform->addHelpButton('defaults[legacyfiles]', 'courselegacyfiles'); + if (!isset($courseconfig->legacyfiles)) { + $courseconfig->legacyfiles = 0; + } + $mform->setDefault('defaults[legacyfiles]', $courseconfig->legacyfiles); + } + + $choices = get_max_upload_sizes($CFG->maxbytes); + $mform->addElement('select', 'defaults[maxbytes]', get_string('maximumupload'), $choices); + $mform->addHelpButton('defaults[maxbytes]', 'maximumupload'); + $mform->setDefault('defaults[maxbytes]', $courseconfig->maxbytes); + + $choices = array(); + $choices[NOGROUPS] = get_string('groupsnone', 'group'); + $choices[SEPARATEGROUPS] = get_string('groupsseparate', 'group'); + $choices[VISIBLEGROUPS] = get_string('groupsvisible', 'group'); + $mform->addElement('select', 'defaults[groupmode]', get_string('groupmode', 'group'), $choices); + $mform->addHelpButton('defaults[groupmode]', 'groupmode', 'group'); + $mform->setDefault('defaults[groupmode]', $courseconfig->groupmode); + + $mform->addElement('selectyesno', 'defaults[groupmodeforce]', get_string('groupmodeforce', 'group')); + $mform->addHelpButton('defaults[groupmodeforce]', 'groupmodeforce', 'group'); + $mform->setDefault('defaults[groupmodeforce]', $courseconfig->groupmodeforce); + + // Restore. + $mform->addElement('header', 'restorehdr', get_string('restoreafterimport', 'tool_uploadcourse')); + $mform->setExpanded('restorehdr', true); + + $courseshortnames = $DB->get_records('course', null, $sort='shortname', 'id,shortname,idnumber'); + $formccourseshortnames = array('' => get_string('none')); + foreach ($courseshortnames as $course) { + $formccourseshortnames[$course->shortname] = $course->shortname; + } + $mform->addElement('select', 'options[templatecourse]', get_string('coursetemplatename', 'tool_uploadcourse'), $formccourseshortnames); + $mform->addHelpButton('options[templatecourse]', 'coursetemplatename', 'tool_uploadcourse'); + $mform->setDefault('options[templatecourse]', 'none'); + + $contextid = $this->_customdata['contextid']; + $mform->addElement('hidden', 'contextid', $contextid); + $mform->setType('contextid', PARAM_INT); + $mform->addElement('filepicker', 'options[restorefile]', get_string('templatefile', 'tool_uploadcourse')); + + // Hidden fields. + $mform->addElement('hidden', 'iid'); + $mform->setType('iid', PARAM_INT); + + $mform->addElement('hidden', 'previewrows'); + $mform->setType('previewrows', PARAM_INT); + + $this->add_action_buttons(true, get_string('uploadcourses', 'tool_uploadcourse')); + + $this->set_data($data); + } + + /** + * Add actopm buttons. + * + * @param bool $cancel whether to show cancel button, default true + * @param string $submitlabel label for submit button, defaults to get_string('savechanges') + * @return void + */ + function add_action_buttons($cancel = true, $submitlabel = null){ + $mform =& $this->_form; + $buttonarray = array(); + $buttonarray[] = &$mform->createElement('submit', 'previewbutton', get_string('preview', 'tool_uploadcourse')); + $buttonarray[] = &$mform->createElement('submit', 'submitbutton', $submitlabel); + $buttonarray[] = &$mform->createElement('cancel'); + $mform->addGroup($buttonarray, 'buttonar', '', array(' '), false); + $mform->closeHeaderBefore('buttonar'); + } + + /** + * Server side validation. + * @param array $data - form data + * @param object $files - form files + * @return array $errors - form errors + */ + public function validation($data, $files) { + global $DB; + + $errors = parent::validation($data, $files); + $columns = $this->_customdata['columns']; + $optype = $data['options']['mode']; + + // Look for other required data. + if ($optype != tool_uploadcourse_processor::MODE_UPDATE_ONLY) { + if (!in_array('fullname', $columns)) { + if (isset($errors['mode'])) { + $errors['mode'] .= ' '; + } + $errors['mode'] .= get_string('missingfield', 'error', 'fullname'); + } + if (!in_array('summary', $columns)) { + if (isset($errors['mode'])) { + $errors['mode'] .= ' '; + } + $errors['mode'] .= get_string('missingfield', 'error', 'summary'); + } + } + + return $errors; + } +} diff --git a/admin/tool/uploadcourse/classes/tracker.php b/admin/tool/uploadcourse/classes/tracker.php index 3adca675a5c..4c307ea221f 100644 --- a/admin/tool/uploadcourse/classes/tracker.php +++ b/admin/tool/uploadcourse/classes/tracker.php @@ -175,14 +175,14 @@ class tool_uploadcourse_tracker { } else { $outcome = $OUTPUT->pix_icon('i/invalid', ''); } - echo html_writer::start_tag('tr', array('class' => 'r' . $this->rownb)); + echo html_writer::start_tag('tr', array('class' => 'r' . $this->rownb % 2)); echo html_writer::tag('td', $line, array('class' => 'c' . $ci++)); echo html_writer::tag('td', $outcome, array('class' => 'c' . $ci++)); - echo html_writer::tag('td', $status, array('class' => 'c' . $ci++)); echo html_writer::tag('td', isset($data['id']) ? $data['id'] : '', array('class' => 'c' . $ci++)); echo html_writer::tag('td', isset($data['shortname']) ? $data['shortname'] : '', array('class' => 'c' . $ci++)); echo html_writer::tag('td', isset($data['fullname']) ? $data['fullname'] : '', array('class' => 'c' . $ci++)); echo html_writer::tag('td', isset($data['idnumber']) ? $data['idnumber'] : '', array('class' => 'c' . $ci++)); + echo html_writer::tag('td', $status, array('class' => 'c' . $ci++)); echo html_writer::end_tag('tr'); } } @@ -208,12 +208,12 @@ class tool_uploadcourse_tracker { 'summary' => get_string('uploadcoursesresult', 'tool_uploadcourse'))); echo html_writer::start_tag('tr', array('class' => 'heading r' . $this->rownb)); echo html_writer::tag('th', get_string('csvline', 'tool_uploadcourse'), array('class' => 'c' . $ci++, 'scope' => 'col')); - echo html_writer::tag('th', get_string('outcome', 'tool_uploadcourse'), array('class' => 'c' . $ci++, 'scope' => 'col')); - echo html_writer::tag('th', get_string('status'), array('class' => 'c' . $ci++, 'scope' => 'col')); + echo html_writer::tag('th', get_string('result', 'tool_uploadcourse'), array('class' => 'c' . $ci++, 'scope' => 'col')); echo html_writer::tag('th', get_string('id', 'tool_uploadcourse'), array('class' => 'c' . $ci++, 'scope' => 'col')); echo html_writer::tag('th', get_string('shortname'), array('class' => 'c' . $ci++, 'scope' => 'col')); echo html_writer::tag('th', get_string('fullname'), array('class' => 'c' . $ci++, 'scope' => 'col')); echo html_writer::tag('th', get_string('idnumber'), array('class' => 'c' . $ci++, 'scope' => 'col')); + echo html_writer::tag('th', get_string('status'), array('class' => 'c' . $ci++, 'scope' => 'col')); echo html_writer::end_tag('tr'); } } diff --git a/admin/tool/uploadcourse/course_form.php b/admin/tool/uploadcourse/course_form.php deleted file mode 100644 index 3f17cc79c01..00000000000 --- a/admin/tool/uploadcourse/course_form.php +++ /dev/null @@ -1,350 +0,0 @@ -. - -/** - * Bulk course upload forms - * - * @package tool_uploadcourse - * @subpackage uploadcourse - * @copyright 2007 Dan Poltawski - * @copyright 2011 Piers Harding - * @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. - * - * @copyright 2007 Petr Skoda {@link http://skodak.org} - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ -class admin_uploadcourse_form1 extends moodleform { - /** - * The standard form definiton - * @return object $form - */ - 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')); - } -} - - -/** - * Specify course upload details - * - * @copyright 2007 Petr Skoda {@link http://skodak.org} - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ -class admin_uploadcourse_form2 extends moodleform { - /** - * The standard form definiton - * @return object $form - */ - public function definition () { - global $CFG, $COURSE, $DB; - - $mform = $this->_form; - $columns = $this->_customdata['columns']; - $data = $this->_customdata['data']; - $courseconfig = get_config('moodlecourse'); - - // I am the template course, why should it be the administrator? we have roles now, other ppl may use this script ;-). - $templatecourse = $COURSE; - - // Upload settings and file. - $mform->addElement('header', 'settingsheader', get_string('settings')); - - $choices = array(CC_COURSE_ADDNEW => get_string('ccoptype_addnew', 'tool_uploadcourse'), - CC_COURSE_ADDINC => get_string('ccoptype_addinc', 'tool_uploadcourse'), - CC_COURSE_ADD_UPDATE => get_string('ccoptype_addupdate', 'tool_uploadcourse'), - CC_COURSE_UPDATE => get_string('ccoptype_update', 'tool_uploadcourse')); - $mform->addElement('select', 'cctype', get_string('ccoptype', 'tool_uploadcourse'), $choices); - - $choices = array(CC_UPDATE_NOCHANGES => get_string('nochanges', 'tool_uploadcourse'), - CC_UPDATE_FILEOVERRIDE => get_string('ccupdatefromfile', 'tool_uploadcourse'), - CC_UPDATE_ALLOVERRIDE => get_string('ccupdateall', 'tool_uploadcourse'), - CC_UPDATE_MISSING => get_string('ccupdatemissing', 'tool_uploadcourse')); - $mform->addElement('select', 'ccupdatetype', get_string('ccupdatetype', 'tool_uploadcourse'), $choices); - $mform->setDefault('ccupdatetype', CC_UPDATE_NOCHANGES); - $mform->disabledIf('ccupdatetype', 'cctype', 'eq', CC_COURSE_ADDNEW); - $mform->disabledIf('ccupdatetype', 'cctype', 'eq', CC_COURSE_ADDINC); - - $mform->addElement('selectyesno', 'ccallowrenames', get_string('allowrenames', 'tool_uploadcourse')); - $mform->setDefault('ccallowrenames', 0); - $mform->disabledIf('ccallowrenames', 'cctype', 'eq', CC_COURSE_ADDNEW); - $mform->disabledIf('ccallowrenames', 'cctype', 'eq', CC_COURSE_ADDINC); - - $mform->addElement('selectyesno', 'ccallowdeletes', get_string('allowdeletes', 'tool_uploadcourse')); - $mform->setDefault('ccallowdeletes', 0); - $mform->disabledIf('ccallowdeletes', 'cctype', 'eq', CC_COURSE_ADDNEW); - $mform->disabledIf('ccallowdeletes', 'cctype', 'eq', CC_COURSE_ADDINC); - - $mform->addElement('selectyesno', 'reset', get_string('reset', 'tool_uploadcourse')); - $mform->setDefault('ccallowdeletes', 0); - $mform->disabledIf('ccallowdeletes', 'cctype', 'eq', CC_COURSE_ADDNEW); - $mform->disabledIf('ccallowdeletes', 'cctype', 'eq', CC_COURSE_ADDINC); - - $mform->addElement('selectyesno', 'ccstandardshortnames', get_string('ccstandardshortnames', 'tool_uploadcourse')); - $mform->setDefault('ccstandardshortnames', 1); - - // Default values. - $mform->addElement('header', 'defaultheader', get_string('defaultvalues', 'tool_uploadcourse')); - $displaylist = array(); - $parentlist = array(); - make_categories_list($displaylist, $parentlist, 'moodle/course:create'); - $mform->addElement('select', 'cccategory', get_string('category'), $displaylist); - $mform->addHelpButton('cccategory', 'category'); - - $mform->addElement('text', 'ccshortname', get_string('ccshortnametemplate', 'tool_uploadcourse'), - 'maxlength="100" size="20"'); - $mform->addHelpButton('ccshortname', 'shortnamecourse', 'tool_uploadcourse'); - $mform->disabledIf('ccshortname', 'cctype', 'eq', CC_COURSE_ADD_UPDATE); - $mform->disabledIf('ccshortname', 'cctype', 'eq', CC_COURSE_UPDATE); - - $courseformats = get_plugin_list('format'); - $formcourseformats = array(); - foreach ($courseformats as $courseformat => $formatdir) { - $formcourseformats[$courseformat] = get_string('pluginname', "format_$courseformat"); - } - $mform->addElement('select', 'format', get_string('format'), $formcourseformats); - $mform->addHelpButton('format', 'format'); - $mform->setDefault('format', $courseconfig->format); - - for ($i = 0; $i <= $courseconfig->maxsections; $i++) { - $sectionmenu[$i] = "$i"; - } - $mform->addElement('select', 'numsections', get_string('numberweeks'), $sectionmenu); - $mform->setDefault('numsections', $courseconfig->numsections); - - $mform->addElement('date_selector', 'startdate', get_string('startdate')); - $mform->addHelpButton('startdate', 'startdate'); - $mform->setDefault('startdate', time() + 3600 * 24); - - $choices = array(); - $choices['0'] = get_string('hiddensectionscollapsed'); - $choices['1'] = get_string('hiddensectionsinvisible'); - $mform->addElement('select', 'hiddensections', get_string('hiddensections'), $choices); - $mform->addHelpButton('hiddensections', 'hiddensections'); - $mform->setDefault('hiddensections', $courseconfig->hiddensections); - - $options = range(0, 10); - $mform->addElement('select', 'newsitems', get_string('newsitemsnumber'), $options); - $mform->addHelpButton('newsitems', 'newsitemsnumber'); - $mform->setDefault('newsitems', $courseconfig->newsitems); - - $mform->addElement('selectyesno', 'showgrades', get_string('showgrades')); - $mform->addHelpButton('showgrades', 'showgrades'); - $mform->setDefault('showgrades', $courseconfig->showgrades); - - $mform->addElement('selectyesno', 'showreports', get_string('showreports')); - $mform->addHelpButton('showreports', 'showreports'); - $mform->setDefault('showreports', $courseconfig->showreports); - - $choices = get_max_upload_sizes($CFG->maxbytes); - $mform->addElement('select', 'maxbytes', get_string('maximumupload'), $choices); - $mform->addHelpButton('maxbytes', 'maximumupload'); - $mform->setDefault('maxbytes', $courseconfig->maxbytes); - - if (!empty($course->legacyfiles) or !empty($CFG->legacyfilesinnewcourses)) { - if (empty($course->legacyfiles)) { - // 0 or missing means no legacy files ever used in this course - new course or nobody turned on legacy files yet. - $choices = array('0'=>get_string('no'), '2'=>get_string('yes')); - } else { - $choices = array('1'=>get_string('no'), '2'=>get_string('yes')); - } - $mform->addElement('select', 'legacyfiles', get_string('courselegacyfiles'), $choices); - $mform->addHelpButton('legacyfiles', 'courselegacyfiles'); - if (!isset($courseconfig->legacyfiles)) { - // In case this was not initialised properly due to switching of $CFG->legacyfilesinnewcourses. - $courseconfig->legacyfiles = 0; - } - $mform->setDefault('legacyfiles', $courseconfig->legacyfiles); - } - - if (!empty($CFG->allowcoursethemes)) { - $themeobjects = get_list_of_themes(); - $themes=array(); - $themes[''] = get_string('forceno'); - foreach ($themeobjects as $key => $theme) { - if (empty($theme->hidefromselector)) { - $themes[$key] = get_string('pluginname', 'theme_'.$theme->name); - } - } - $mform->addElement('select', 'theme', get_string('forcetheme'), $themes); - } - $courseshortnames = $DB->get_records('course', null, $sort='shortname', 'id,shortname,idnumber'); - $formccourseshortnames = array('none' => get_string('none')); - foreach ($courseshortnames as $course) { - $formccourseshortnames[$course->shortname] = $course->shortname; - } - $mform->addElement('select', 'templatename', get_string('coursetemplatename', 'tool_uploadcourse'), $formccourseshortnames); - $mform->addHelpButton('templatename', 'coursetemplatename', 'tool_uploadcourse'); - $mform->setDefault('templatename', 'none'); - - $contextid = $this->_customdata['contextid']; - $mform->addElement('hidden', 'contextid', $contextid); - $mform->addElement('filepicker', 'restorefile', get_string('templatefile', 'tool_uploadcourse')); - - enrol_course_edit_form($mform, null, get_context_instance(CONTEXT_SYSTEM)); - - $mform->addElement('header', '', get_string('groups', 'group')); - - $choices = array(); - $choices[NOGROUPS] = get_string('groupsnone', 'group'); - $choices[SEPARATEGROUPS] = get_string('groupsseparate', 'group'); - $choices[VISIBLEGROUPS] = get_string('groupsvisible', 'group'); - $mform->addElement('select', 'groupmode', get_string('groupmode', 'group'), $choices); - $mform->addHelpButton('groupmode', 'groupmode', 'group'); - $mform->setDefault('groupmode', $courseconfig->groupmode); - - $choices = array(); - $choices['0'] = get_string('no'); - $choices['1'] = get_string('yes'); - $mform->addElement('select', 'groupmodeforce', get_string('groupmodeforce', 'group'), $choices); - $mform->addHelpButton('groupmodeforce', 'groupmodeforce', 'group'); - $mform->setDefault('groupmodeforce', $courseconfig->groupmodeforce); - - // Default groupings selector. - $options = array(); - $options[0] = get_string('none'); - $mform->addElement('select', 'defaultgroupingid', get_string('defaultgrouping', 'group'), $options); - - $mform->addElement('header', '', get_string('availability')); - - $choices = array(); - $choices['0'] = get_string('courseavailablenot'); - $choices['1'] = get_string('courseavailable'); - $mform->addElement('select', 'visible', get_string('availability'), $choices); - $mform->addHelpButton('visible', 'availability'); - $mform->setDefault('visible', $courseconfig->visible); - - $mform->addElement('header', '', get_string('language')); - - $languages=array(); - $languages[''] = get_string('forceno'); - $languages += get_string_manager()->get_list_of_translations(); - $mform->addElement('select', 'lang', get_string('forcelanguage'), $languages); - $mform->setDefault('lang', $courseconfig->lang); - - // Hidden fields. - $mform->addElement('hidden', 'iid'); - $mform->setType('iid', PARAM_INT); - - $mform->addElement('hidden', 'previewrows'); - $mform->setType('previewrows', PARAM_INT); - - $this->add_action_buttons(true, get_string('uploadcourses', 'tool_uploadcourse')); - - $this->set_data($data); - } - - /** - * Form tweaks that depend on current data. - */ - public function definition_after_data() { - $mform = $this->_form; - $columns = $this->_customdata['columns']; - - foreach ($columns as $column) { - if ($mform->elementExists($column)) { - $mform->removeElement($column); - } - } - - } - - /** - * Server side validation. - * @param array $data - form data - * @param object $files - form files - * @return array $errors - form errors - */ - public function validation($data, $files) { - global $DB; - - $errors = parent::validation($data, $files); - $columns = $this->_customdata['columns']; - $optype = $data['cctype']; - - // Look for other required data. - if ($optype != CC_COURSE_UPDATE) { - if (!in_array('fullname', $columns)) { - if (isset($errors['cctype'])) { - $errors['cctype'] .= ' '; - } - $errors['cctype'] .= get_string('missingfield', 'error', 'fullname'); - } - if (!in_array('summary', $columns)) { - if (isset($errors['cctype'])) { - $errors['cctype'] .= ' '; - } - $errors['cctype'] .= get_string('missingfield', 'error', 'summary'); - } - } - if (!empty($data['templatename']) && $data['templatename'] != 'none') { - if (!$template = $DB->get_record('course', array('shortname' => $data['templatename']))) { - $errors['templatename'] = get_string('missingtemplate', 'tool_uploadcourse'); - } - } - - return $errors; - } - - /** - * Used to reformat the data from the editor component - * - * @return stdClass - */ - public function get_data() { - $data = parent::get_data(); - - if ($data !== null and isset($data->description)) { - $data->descriptionformat = $data->description['format']; - $data->description = $data->description['text']; - } - - return $data; - } -} diff --git a/admin/tool/uploadcourse/index.php b/admin/tool/uploadcourse/index.php index e92749fa7a9..7dc08643051 100644 --- a/admin/tool/uploadcourse/index.php +++ b/admin/tool/uploadcourse/index.php @@ -15,170 +15,91 @@ // along with Moodle. If not, see . /** - * Bulk course registration script from a comma separated file + * Bulk course registration script from a comma separated file. * * @package tool_uploadcourse - * @copyright 2004 onwards Martin Dougiamas (http://dougiamas.com) * @copyright 2011 Piers Harding * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -require('../../../config.php'); -require_once($CFG->libdir.'/adminlib.php'); -require_once($CFG->libdir.'/csvlib.class.php'); -require_once($CFG->dirroot.'/course/lib.php'); +require(__DIR__ . '/../../../config.php'); +require_once(__DIR__ . '/locallib.php'); +require_once($CFG->libdir . '/adminlib.php'); +require_once($CFG->libdir . '/clilib.php'); +require_once($CFG->libdir . '/coursecatlib.php'); +require_once($CFG->libdir . '/csvlib.class.php'); require_once($CFG->dirroot . '/backup/util/includes/backup_includes.php'); require_once($CFG->dirroot . '/backup/util/includes/restore_includes.php'); -require_once($CFG->libdir . '/filelib.php'); -require_once('locallib.php'); -require_once('course_form.php'); + +admin_externalpage_setup('tooluploadcourse'); $iid = optional_param('iid', '', PARAM_INT); $previewrows = optional_param('previewrows', 10, PARAM_INT); -require_login(); -admin_externalpage_setup('tooluploadcourse'); $returnurl = new moodle_url('/admin/tool/uploadcourse/index.php'); -$bulknurl = new moodle_url('/admin/tool/uploadcourse/index.php'); -$std_fields = tool_uploadcourse_std_fields(); - if (empty($iid)) { - $mform1 = new admin_uploadcourse_form1(); - - if ($formdata = $mform1->get_data()) { + $mform1 = new tool_uploadcourse_step1_form(); + if ($form1data = $mform1->get_data()) { $iid = csv_import_reader::get_new_iid('uploadcourse'); $cir = new csv_import_reader($iid, 'uploadcourse'); - $content = $mform1->get_file_content('coursefile'); - - $readcount = $cir->load_csv_content($content, $formdata->encoding, $formdata->delimiter_name); + $readcount = $cir->load_csv_content($content, $form1data->encoding, $form1data->delimiter_name); unset($content); - if ($readcount === false) { print_error('csvfileerror', 'tool_uploadcourse', $returnurl, $cir->get_error()); } else if ($readcount == 0) { print_error('csvemptyfile', 'error', $returnurl, $cir->get_error()); } - // Test if columns ok. - $filecolumns = tool_uploadcourse_validate_course_upload_columns($cir, $std_fields, $returnurl); - // Continue to form2. - } else { echo $OUTPUT->header(); - echo $OUTPUT->heading_with_help(get_string('uploadcourses', 'tool_uploadcourse'), 'uploadcourses', 'tool_uploadcourse'); - $mform1->display(); echo $OUTPUT->footer(); - die; + die(); } } else { $cir = new csv_import_reader($iid, 'uploadcourse'); - $filecolumns = tool_uploadcourse_validate_course_upload_columns($cir, $std_fields, $returnurl); } -$frontpagecontext = context_course::instance(SITEID); -$mform2 = new admin_uploadcourse_form2(null, - array('contextid' => $frontpagecontext->id, - 'columns' => $filecolumns, - 'data' => array('iid'=>$iid, 'previewrows'=>$previewrows))); +// Data to set in the form. +$data = array('iid' => $iid, 'previewrows' => $previewrows); +if (!empty($form1data)) { + // Get options from the first form to pass it onto the second. + foreach ($form1data->options as $key => $value) { + $data["options[$key]"] = $value; + } +} +$context = context_system::instance(); +$mform2 = new tool_uploadcourse_step2_form(null, array('contextid' => $context->id, 'columns' => $cir->get_columns(), + 'data' => $data)); // If a file has been uploaded, then process it. -if ($formdata = $mform2->is_cancelled()) { +if ($form2data = $mform2->is_cancelled()) { $cir->cleanup(true); redirect($returnurl); -} else if ($formdata = $mform2->get_data()) { - // Print the header. +} else if ($form2data = $mform2->get_data()) { + + $options = (array) $form2data->options; + $defaults = (array) $form2data->defaults; + $processor = new tool_uploadcourse_processor($cir, $options, $defaults); + echo $OUTPUT->header(); - echo $OUTPUT->heading(get_string('uploadcoursesresult', 'tool_uploadcourse')); - - $tmpdir = $CFG->tempdir . '/backup'; - if (!check_dir_exists($tmpdir, true, true)) { - throw new restore_controller_exception('cannot_create_backup_temp_dir'); - } - $filename = restore_controller::get_tempdir_name(SITEID, $USER->id); - $restorefile = $tmpdir . '/' . $filename; - if (!$mform2->save_file('restorefile', $restorefile)) { - $restorefile = null; - } - $bulk = isset($formdata->ccbulk) ? $formdata->ccbulk : 0; - - tool_uploadcourse_process_course_upload($formdata, $cir, $filecolumns, $restorefile); - - echo $OUTPUT->box_end(); - - if ($bulk) { - echo $OUTPUT->continue_button($bulknurl); + if (isset($form2data->showpreview)) { + echo $OUTPUT->heading(get_string('uploadcoursespreview', 'tool_uploadcourse')); + $processor->preview($previewrows, new tool_uploadcourse_tracker(tool_uploadcourse_tracker::OUTPUT_HTML)); + $mform2->display(); + echo $OUTPUT->footer(); } else { + echo $OUTPUT->heading(get_string('uploadcoursesresult', 'tool_uploadcourse')); + $processor->execute(new tool_uploadcourse_tracker(tool_uploadcourse_tracker::OUTPUT_HTML)); echo $OUTPUT->continue_button($returnurl); } - echo $OUTPUT->footer(); - die; + +} else { + $processor = new tool_uploadcourse_processor($cir, $form1data->options, array()); + echo $OUTPUT->header(); + $mform2->display(); } -// Print the header. -echo $OUTPUT->header(); - -echo $OUTPUT->heading(get_string('uploadcoursespreview', 'tool_uploadcourse')); - -// NOTE: this is JUST csv processing preview, we must not prevent import from here if there is something in the file!! -// this was intended for validation of csv formatting and encoding, not filtering the data!!!! -// we definitely must not process the whole file! - -// Preview table data. -$data = array(); -$cir->init(); -$linenum = 1; // Column header is first line. -while ($linenum <= $previewrows and $fields = $cir->next()) { - $linenum++; - $rowcols = array(); - $rowcols['line'] = $linenum; - foreach ($fields as $key => $field) { - $rowcols[$filecolumns[$key]] = s($field); - } - $rowcols['status'] = array(); - - if (isset($rowcols['shortname'])) { - $stdshortname = clean_param($rowcols['shortname'], PARAM_MULTILANG); - if ($rowcols['shortname'] !== $stdshortname) { - $rowcols['status'][] = get_string('invalidshortnameupload'); - } - if ($courseid = $DB->get_field('course', 'id', array('shortname'=>$stdshortname))) { - $rowcols['shortname'] = html_writer::link(new moodle_url('/course/view.php', - array('id' => $courseid)), - $rowcols['shortname']); - } - } else { - $rowcols['status'][] = get_string('missingshortname'); - } - - $rowcols['status'] = implode('
', $rowcols['status']); - $data[] = $rowcols; -} -if ($fields = $cir->next()) { - $data[] = array_fill(0, count($fields) + 2, '...'); -} -$cir->close(); - -$table = new html_table(); -$table->id = "ccpreview"; -$table->attributes['class'] = 'generaltable'; -$table->tablealign = 'center'; -$table->summary = get_string('uploadcoursespreview', 'tool_uploadcourse'); -$table->head = array(); -$table->data = $data; - -$table->head[] = get_string('cccsvline', 'tool_uploadcourse'); -foreach ($filecolumns as $column) { - $table->head[] = $column; -} -$table->head[] = get_string('status'); - -echo html_writer::tag('div', html_writer::table($table), array('class'=>'flexible-wrap')); - -// Print the form. -$mform2->display(); echo $OUTPUT->footer(); -die; - diff --git a/admin/tool/uploadcourse/lang/en/tool_uploadcourse.php b/admin/tool/uploadcourse/lang/en/tool_uploadcourse.php index 30a68570a8a..29eee6950bc 100644 --- a/admin/tool/uploadcourse/lang/en/tool_uploadcourse.php +++ b/admin/tool/uploadcourse/lang/en/tool_uploadcourse.php @@ -24,7 +24,9 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -$string['invalidshortname'] = 'Invalid shortname'; +$string['allowdeletes'] = 'Allow deletes'; +$string['allowrenames'] = 'Allow renames'; +$string['allowresets'] = 'Allow resets'; $string['cannotdeletecoursenotexist'] = 'Cannot delete a course that does not exist'; $string['cannotgenerateshortnameupdatemode'] = 'Cannot generate a shortname when updates are allowed'; $string['cannotreadbackupfile'] = 'Cannot read the backup file'; @@ -56,8 +58,11 @@ $string['courseshortnameincremented'] = 'Course shortname incremented {$a->from} $string['courseshortnamegenerated'] = 'Course shortname generated: {$a}'; $string['coursetorestorefromdoesnotexist'] = 'The course to restore from does not exist'; $string['courseupdated'] = 'Course updated'; +$string['csvdelimiter'] = 'CSV delimiter'; $string['csvfileerror'] = 'There is something wrong with the format of the CSV file. Please check the number of headings and columns match, and that the delimiter and file encoding are correct: {$a}'; $string['csvline'] = 'Line'; +$string['defaultvalues'] = 'Default values'; +$string['encoding'] = 'Encoding'; $string['errorwhilerestoringcourse'] = 'Error while restoring the course'; $string['errorwhiledeletingcourse'] = 'Error while deleting the course'; $string['generatedshortnameinvalid'] = 'The generated shortname is invalid'; @@ -71,26 +76,40 @@ $string['invalidencoding'] = 'Invalid encoding'; $string['invalidmode'] = 'Invalid mode selected'; $string['invalideupdatemode'] = 'Invalid update mode selected'; $string['invalidroles'] = 'Invalid role names: {$a}'; +$string['invalidshortname'] = 'Invalid shortname'; $string['missingmandatoryfields'] = 'Missing value for mandatory fields: {$a}'; $string['missingshortnamenotemplate'] = 'Missing shortname and shortname template not set'; -$string['outcome'] = 'Outcome'; -$string['updatemodedoessettonothing'] = 'Update mode does not allow anything to be updated'; -$string['uploadcoursesresult'] = 'Upload courses results'; +$string['mode'] = 'Upload mode'; +$string['preview'] = 'Preview'; +$string['reset'] = 'Reset course after upload'; +$string['result'] = 'Result'; +$string['restoreafterimport'] = 'Restore after import'; +$string['rowpreviewnum'] = 'Preview rows'; +$string['shortnametemplate'] = 'Shortname template'; +$string['shortnametemplate_help'] = 'The short name of the course is displayed in the navigation. You may use template syntax here (%f = fullname, %i = idnumber), or enter an initial value that is incremented.'; $string['unknownimportmode'] = 'Unknown import mode'; +$string['updatemode'] = 'Update mode'; +$string['updatemodedoessettonothing'] = 'Update mode does not allow anything to be updated'; +$string['uploadcourses'] = 'Upload courses'; +$string['uploadcourses_help'] = 'Courses may be uploaded via text file. The format of the file should be as follows: + +* Each line of the file contains one record +* Each record is a series of data separated by commas (or other delimiters) +* The first record contains a list of fieldnames defining the format of the rest of the file +* Required fieldnames are shortname, fullname, summary and category'; +$string['uploadcoursesresult'] = 'Upload courses results'; + + + + -$string['allowdeletes'] = 'Allow deletes'; -$string['allowrenames'] = 'Allow renames'; -$string['csvdelimiter'] = 'CSV delimiter'; -$string['defaultvalues'] = 'Default values'; $string['deleteerrors'] = 'Delete errors'; -$string['encoding'] = 'Encoding'; $string['errors'] = 'Errors'; $string['invalidinput'] = 'You must specify a valid combination of --action and --mode'; $string['nochanges'] = 'No changes'; $string['pluginname'] = 'Course upload'; $string['renameerrors'] = 'Rename errors'; $string['requiredtemplate'] = 'Required. You may use template syntax here (%l = lastname, %f = firstname, %u = coursename). See help for details and examples.'; -$string['rowpreviewnum'] = 'Preview rows'; $string['uploadpicture_badcoursefield'] = 'The course attribute specified is not valid. Please, try again.'; $string['uploadpicture_cannotmovezip'] = 'Cannot move zip file to temporary directory.'; $string['uploadpicture_cannotprocessdir'] = 'Cannot process unzipped files.'; @@ -104,13 +123,7 @@ $string['uploadpicture_courseskipped'] = 'Skipping course {$a} (already has a pi $string['uploadpicture_courseupdated'] = 'Picture updated for course {$a}.'; $string['uploadpictures'] = 'Upload course pictures'; $string['uploadpictures_help'] = 'Course pictures can be uploaded as a zip file of image files. The image files should be named chosen-course-attribute.extension, for example course1234.jpg for a course with coursename course1234.'; -$string['uploadcourses'] = 'Upload courses'; -$string['uploadcourses_help'] = 'Courses may be uploaded (and optionally enrolled in courses) via text file. The format of the file should be as follows: -* Each line of the file contains one record -* Each record is a series of data separated by commas (or other delimiters) -* The first record contains a list of fieldnames defining the format of the rest of the file -* Required fieldnames are coursename, password, firstname, lastname, email'; $string['uploadcoursespreview'] = 'Upload courses preview'; $string['courseuptodate'] = 'Course up-to-date'; $string['courseupdated'] = 'Course updated'; @@ -133,7 +146,7 @@ $string['coursenotrenamedoff'] = 'Course not renamed - renaming off'; $string['coursenotrenamedadmin'] = 'Course not renamed - no admin'; $string['invalidvalue'] = 'Invalid value for field {$a}'; $string['shortnamecourse'] = 'Shortname'; -$string['shortnamecourse_help'] = 'The short name of the course is displayed in the navigation. You may use template syntax here (%f = fullname, %i = idnumber), or enter an initial value that is incremented. See help for details and examples.'; + $string['idnumbernotunique'] = 'idnumber is not unique'; $string['ccbulk'] = 'Select for bulk operations'; $string['ccbulkall'] = 'All courses'; @@ -143,7 +156,7 @@ $string['cclegacy1role'] = '(Original Student) typeN=1'; $string['cclegacy2role'] = '(Original Teacher) typeN=2'; $string['cclegacy3role'] = '(Original Non-editing teacher) typeN=3'; $string['ccnoemailduplicates'] = 'Prevent email address duplicates'; -$string['ccoptype'] = 'Upload type'; + $string['ccoptype_addinc'] = 'Add all, append number to shortnames if needed'; $string['ccoptype_addnew'] = 'Add new only, skip existing courses'; $string['ccoptype_addupdate'] = 'Add new and update existing courses'; @@ -151,13 +164,12 @@ $string['ccoptype_update'] = 'Update existing courses only'; $string['ccpasswordcron'] = 'Generated in cron'; $string['ccpasswordnew'] = 'New course password'; $string['ccpasswordold'] = 'Existing course password'; -$string['reset'] = 'Reset course after upload'; $string['ccstandardshortnames'] = 'Standardise shortnames'; $string['ccupdateall'] = 'Override with file and defaults'; $string['ccupdatefromfile'] = 'Override with file'; $string['ccupdatemissing'] = 'Fill in missing from file and defaults'; $string['ccupdatetype'] = 'Existing course details'; -$string['ccshortnametemplate'] = 'Shortname template'; + $string['ccfullnametemplate'] = 'Fullname template'; $string['ccidnumbertemplate'] = 'Idnumber template'; $string['missingtemplate'] = 'Template not found';