MDL-87492 mod_quiz: 'autosubmit' quiz attempt handling fix

Some quiz attempts throw an exception when they are being processed and
are stuck in a 'submitted' state. This change wraps the process in a
transaction so that there are no partial changes made in such cases.
This commit is contained in:
Michael Kotlyar
2026-02-06 14:16:01 +00:00
committed by Conn Warwicker
parent ac802ad804
commit 34e60be48e
+3
View File
@@ -1618,6 +1618,7 @@ class quiz_attempt {
* @param bool $studentisonline is the student currently interacting with Moodle?
*/
public function handle_if_time_expired($timestamp, $studentisonline) {
global $DB;
$timeclose = $this->get_access_manager($timestamp)->get_end_time($this->attempt);
@@ -1652,8 +1653,10 @@ class quiz_attempt {
// Transition to the appropriate state.
switch ($this->quizobj->get_quiz()->overduehandling) {
case 'autosubmit':
$transaction = $DB->start_delegated_transaction();
$this->process_submit($timestamp, false, $studentisonline ? $timestamp : $timeclose, $studentisonline);
$this->process_grade_submission($studentisonline ? $timestamp : $timeclose);
$transaction->allow_commit();
return;
case 'graceperiod':