MDL-37361 completion: automatic completion disabled when overridden
Changes: - Activities with auto completion and a completion status overridden to COMPLETION_COMPLETE are no longer processed by normal completion triggers. - All activities can still be completed by students when their completion status has been overridden to COMPLETION_INCOMPLETE, via either auto or manual triggers. - Completion unit tests updated
This commit is contained in:
+14
-13
@@ -570,9 +570,17 @@ class completion_info {
|
||||
return;
|
||||
}
|
||||
|
||||
// For auto tracking, if the status is overridden to 'COMPLETION_COMPLETE', then disallow further changes,
|
||||
// unless processing another override.
|
||||
// Basically, we want those activities which have been overridden to COMPLETE to hold state, and those which have been
|
||||
// overridden to INCOMPLETE to still be processed by normal completion triggers.
|
||||
if ($cm->completion == COMPLETION_TRACKING_AUTOMATIC && !is_null($current->overrideby)
|
||||
&& $current->completionstate == COMPLETION_COMPLETE && !$override) {
|
||||
return;
|
||||
}
|
||||
|
||||
// For manual tracking, or if overriding the completion state, we set the state directly.
|
||||
if ($cm->completion == COMPLETION_TRACKING_MANUAL || $override) {
|
||||
// For manual tracking, or if overriding the completion state manually,
|
||||
// we set the result directly.
|
||||
switch($possibleresult) {
|
||||
case COMPLETION_COMPLETE:
|
||||
case COMPLETION_INCOMPLETE:
|
||||
@@ -583,15 +591,7 @@ class completion_info {
|
||||
}
|
||||
|
||||
} else {
|
||||
// Automatic tracking.
|
||||
if ($current->overrideby) {
|
||||
// If the current completion state has been set by override, do nothing
|
||||
// as we don't want it to be changed automatically.
|
||||
return;
|
||||
} else {
|
||||
// Get new state.
|
||||
$newstate = $this->internal_get_state($cm, $userid, $current);
|
||||
}
|
||||
$newstate = $this->internal_get_state($cm, $userid, $current);
|
||||
}
|
||||
|
||||
// If changed, update
|
||||
@@ -708,8 +708,9 @@ class completion_info {
|
||||
// Get current completion state
|
||||
$data = $this->get_data($cm, false, $userid);
|
||||
|
||||
// If we already viewed it, don't do anything
|
||||
if ($data->viewed == COMPLETION_VIEWED) {
|
||||
// If we already viewed it, don't do anything unless the completion status is overridden.
|
||||
// If the completion status is overridden, then we need to allow this 'view' to trigger automatic completion again.
|
||||
if ($data->viewed == COMPLETION_VIEWED && empty($data->overrideby)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user