MDL-74752 question regrading: implement the required hooks

This commit implements the necessary core hooks to ensure we only
allow a regrade of a quetion attempt to take place if the new and old
versions of the question are sufficiently similar.

It will be followed by commits to each question type where the
new method needs to be implemented.

Automated tests will be included in the first of those (mulitple choice)
becuse we need a question type that implements the hooks to test
the core changes.
This commit is contained in:
Tim Hunt
2022-05-31 09:22:50 +01:00
parent b81a2f80f7
commit ca4ac3e8b6
9 changed files with 164 additions and 26 deletions
+12
View File
@@ -875,9 +875,21 @@ class question_usage_by_activity {
$this->observer->notify_attempt_modified($qa);
}
/**
* Verify if the question_attempt in the given slot can be regraded with that other question version.
*
* @param int $slot the number used to identify this question within this usage.
* @param question_definition $otherversion a different version of the question to use in the regrade.
* @return string|null null if the regrade can proceed, else a reason why not.
*/
public function validate_can_regrade_with_other_version(int $slot, question_definition $otherversion): ?string {
return $this->get_question_attempt($slot)->validate_can_regrade_with_other_version($otherversion);
}
/**
* Regrade a question in this usage. This replays the sequence of submitted
* actions to recompute the outcomes.
*
* @param int $slot the number used to identify this question within this usage.
* @param bool $finished whether the question attempt should be forced to be finished
* after the regrade, or whether it may still be in progress (default false).