Skip to content

Commit

Permalink
MDL-43127 tool_uploadcourse: Empty enrolment method is acceptable
Browse files Browse the repository at this point in the history
Without the patch a course would not be created if it contained
an enrolment method column with an empty value. e.g.:

shortname,fullname,category,enrolment_1,enrolment_1_disable
courserestored,Course restored,1,,
courserestored2,Course restored 2,manual,1
  • Loading branch information
Frederic Massart committed Nov 26, 2014
1 parent 58aabfc commit 480c254
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
5 changes: 4 additions & 1 deletion admin/tool/uploadcourse/classes/helper.php
Expand Up @@ -164,7 +164,10 @@ public static function get_enrolment_data($data, &$errors = array()) {
if (!empty($enrolmethods)) {
$enrolmentplugins = self::get_enrolment_plugins();
foreach ($enrolmethods as $key => $method) {
if (!array_key_exists($method, $enrolmentplugins)) {
if (empty($method)) {
// The enrolment method is not specified, we skip it.
continue;
} else if (!array_key_exists($method, $enrolmentplugins)) {
// Unknown enrolment method.
$unknownmethods[] = $method;
continue;
Expand Down
1 change: 1 addition & 0 deletions admin/tool/uploadcourse/tests/helper_test.php
Expand Up @@ -79,6 +79,7 @@ public function test_get_enrolment_data() {
'enrolment_5_test2' => 'test2',
'enrolment_5_test1' => 'test1',
'enrolment_5' => 'flatfile',
'enrolment_6' => '',
);
$expected = array(
'self' => array(
Expand Down

0 comments on commit 480c254

Please sign in to comment.