Closed ebithell closed 2 years ago
The issue comes from line 73 of mod/choicegroup/backup/moodle2/restore_choicegroup_stepslib.php:
$data->groupid = $this->get_mappingid('group', $data->groupid);
If the backup package contains the records for the course groups, this returns an appropriate value of the groupid. This applies to a full course backup. The group references are not included in an activity-level backup (Recycle Bin or activity duplication), so the mappingid return value is false and a zero-valued groupid record is written to mdl_choicegroup_options.
Expected behaviour for different scenarios would be:
Logically the restore process should:
The attached patch would apply this logic and fix the issue: choicegroup.patch.txt
This fix might be considered a change to the behaviour of the activity, but the PHP error messages and the groupid=0 records in mdl_choicegroup_options make me lean towards classifying the behaviour as a bug.
Thanks @ebithell for spotting this, working it out and sharing your fix.
I completely agree with your logic and quickly tested your patch, which I have just integrated. This will be released along with the upcoming version officially supporting Moodle 4.0.
Hello Nicolas,
it seems that this problem is back. I am testing with moodle 3.9.18 + mod_choicegroup 1.38 (2022092202) and after restoring a course backup with mod_choicegroup with group selection set, the restored course shows the activity without the group selection of the original course (groups are being restored correctly at course level, but as ebithell said, the selected groups for the activity are not restored).
The same is true in 1.37. Before we were using 1.33 with moodle 3.9.15 and it was fine.
I hope you can check it out.
Regards
EDIT: Sorry, I think it was already reported here: https://github.com/ndunand/moodle-mod_choicegroup/issues/168
Hello, I have continued testing and I see that in the restored course, even though the selected groups field, in the activity settings, is empty, the student still sees as eligible the original groups and only the original ones and they can still make the selection. If the course had more groups not included in the original activity, they are not shown eligible in the restored activity. This is fine, however, in the settings, the selected groups field becomes empty and could be a problem or be confusing for the teacher.
This behavior occurs both in choicegroup 1.38 with moodle 3.9.18 and moodle 3.11.11.
Regards
I would like to see this fixed
Seen in Moodle 3.5.18 (mod_groupchoice version 1.15), 3.9.11 (version 1.33) and 3.11.6 (version 1.33).
When a Group Choice activity is restored from the Course Recycle Bin, the allocated Groups for the activity are not restored.
Steps to reproduce:
Expected result:
Actual result:
Course backup & restore operate as expected but activity duplication also loses its groups setting, with the same PHP messages.
(description of cause and proposed solution with patch following in comments)