diff --git a/lib/questionlib.php b/lib/questionlib.php index 5920033af78..5016837dd3b 100644 --- a/lib/questionlib.php +++ b/lib/questionlib.php @@ -1133,7 +1133,8 @@ function question_process_responses(&$question, &$state, $action, $cmoptions, &$ // Check for unchanged responses (exactly unchanged, not equivalent). // We also have to catch questions that the student has not yet attempted $sameresponses = $QTYPES[$question->qtype]->compare_responses($question, $action, $state); - if ($state->last_graded->event == QUESTION_EVENTOPEN && question_isgradingevent($action->event)) { + if (!empty($state->last_graded) && $state->last_graded->event == QUESTION_EVENTOPEN && + question_isgradingevent($action->event)) { $sameresponses = false; }