MDL-71659 completion: Consider modules without grade_item incomplete

Activity modules may not have the associated grade_item created yet. It
used to throw fatal error in that case - even when trying to view the
course or edit the activity. So there was no easy way to recover from
this situation.

The patch is based on reasoning that an activity without grade item is
same as activity without any grades. And as such it is considered
incomplete.

A new unit test is added to cover this specific scenario. The existing
unit test is modified and it does not expect the exception any more.
There does not seem to be any good reason why this situation should be
exceptional.
This commit is contained in:
David Mudrák
2021-05-18 20:59:51 +02:00
parent 3da88a7664
commit a949a151f3
2 changed files with 39 additions and 4 deletions
-3
View File
@@ -769,9 +769,6 @@ class completion_info {
item '{$item->id}', user '{$userid}'");
}
return self::internal_get_grade_state($item, reset($grades));
} else {
$this->internal_systemerror("Cannot find grade item for '{$cm->modname}'
cm '{$cm->id}' matching number '{$cm->completiongradeitemnumber}'");
}
return COMPLETION_INCOMPLETE;