-
Bug
-
Resolution: Fixed
-
Minor
-
3.4.3, 3.5, 3.6
-
MOODLE_34_STABLE, MOODLE_35_STABLE, MOODLE_36_STABLE
-
MOODLE_35_STABLE, MOODLE_36_STABLE
-
MDL-62666-master -
Hi,
we've encountered this bug.
Steps to reproduce
I'll start with the steps to reproduce because this will make it clear what happens:
- Login as an admin
- Go to the setting restore | restore_general_groups, disable it and save
- Go to a course and create a group "Group 1"
- Create a grouping "Grouping 1" and add "Group 1" to this grouping
- Go back to the course home page
- Turn editing on
- Add an assignment:
Title e.g. "Assignment with group condition"
Add an access restriction to this "Group 1" - Save and return to course
- Add another assignment:
Title e.g. "Assignment with grouping condition"
Add an access restriction to this "Grouping 1" - Save and return to course
- Duplicate Assignment with group condition
=> See that the group condition was not duplicated - Duplicate Assignment with grouping condition
=> See that the grouping condition was not duplicated
If you want to you can do the same steps with the setting restore | restore_general_groups enabled and you will have the result that the group and grouping condition will be duplicated as well.
The problem here is that the admin setting which only sets default values has impacts in other places - for example in the duplicating function.
The user cannot change this setting as the duplicating workflow does not present the user nay settings.
Cause
The cause is this function (for the group and grouping condition each):
- https://github.com/moodle/moodle/blob/master/availability/condition/group/classes/condition.php#L142
- https://github.com/moodle/moodle/blob/master/availability/condition/grouping/classes/condition.php#L173
/**
* Include this condition only if we are including groups in restore, or
* if it's a generic 'same activity' one.
*
* @param int $restoreid The restore Id.
* @param int $courseid The ID of the course.
* @param base_logger $logger The logger being used.
* @param string $name Name of item being restored.
* @param base_task $task The task being performed.
*
* @return Integer groupid
*/
public function include_after_restore($restoreid, $courseid, \base_logger $logger,
$name, \base_task $task) {
return !$this->groupid || $task->get_setting_value('groups');
}
If the admin setting ist disabled (and groups are existent in the course), this function will always return a false value and therefore the groups condition will not be handled in the function update_after_restore.
Possible solution(s)
We can imagine 2 possible solutions:
- Fix the function include_after_restore to check if we are operating on the same course and if there are groups to return a true
- Or if the user triggers the duplication button, then all possible restore settings could be activated and ignore the admin settings at this point
Best, Kathrin
- is a regression caused by
-
MDL-34859 General Restore Defaults
- Closed