bdecentgmbh / moodle-format_kickstart

Kickstart adds a powerful course template engine to moodle – create courses easily and produce high quality courses, consistently.
http://bdecent.de/kickstart
5 stars 3 forks source link

Kickstart "import course" (old course) in Moodle 4.1 remove "manual enrolments" method #48

Open peho72 opened 1 year ago

peho72 commented 1 year ago

We have updated Moodle to version 4.1. Kickstart Version 1.3 (2023050801) In test we had no issues, but when we did final upgrade, after that when importing old course the registration method "Manual enrolments" will be removed. I have even changed from kickstart "General restore options": Keep current roles and enrolments = Yes Keep current groups and groupings = Yes

Now the groups are OK but the "Manual enrolments" registration method still will be removed on the import (log: "Enrolment instance remoced"). This leave only disabled "Guest Access" on the enrolment methods.

I hope help or fix to this.

B.R. Petri

phakkin commented 1 year ago

I can confirm the bug, Kickstart settings Keep current roles and enrolments = Yes Keep current groups and groupings = Yes does not work as expected, importing template or old course removes course participants and enrolment methods before restore.

I think that the reason is incorrect key names in $settings array https://github.com/bdecentgmbh/moodle-format_kickstart/blob/main/classes/course_importer.php#L135

        if (get_config('format_kickstart', 'restore_replace_keep_roles_and_enrolments') < 2) {
            $settings['role_assignments'] =
                (bool)get_config('format_kickstart', 'restore_replace_keep_roles_and_enrolments');
            $settings['enrolments'] = (bool) (get_config('format_kickstart', 'restore_replace_keep_roles_and_enrolments') == 1)
                ? \backup::ENROL_ALWAYS : \backup::ENROL_NEVER;
        }

        if (get_config('format_kickstart', 'restore_replace_keep_groups_and_groupings') < 2) {
            $settings['groups'] =
                (bool)get_config('format_kickstart', 'restore_replace_keep_groups_and_groupings');
        }

They should be

$settings['keep_roles_and_enrolments']
$settings['keep_groups_and_groupings']

See restore_controller->execute_plan() function https://github.com/moodle/moodle/blob/MOODLE_401_STABLE/backup/controller/restore_controller.class.php#L380

Workaround for this bug if you want to keep enrolment methods and groups:

  1. Edit system wide restore defaults Site administration > Courses > Backups > General restore defaults Keep current roles and enrolments: Yes Keep current groups and groupings: Yes
  2. Change Kickstart general settings Keep current roles and enrolments: Use default restore setting Keep current groups and groupings: Use default restore setting
stefanscholz commented 1 year ago

Hi @phakkin and @peho72,

thanks for using Kickstart and reporting this issue. We're currently looking into it and will get back to you here soon.

Best Stefan