From 865d28441027cf330a6d6d953550f92dc0f23a47 Mon Sep 17 00:00:00 2001 From: Sara Arjona Date: Fri, 12 Apr 2019 12:41:58 +0200 Subject: [PATCH] MDL-39261 mod_lesson: get the existing attemptid when reviewing --- mod/lesson/locallib.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/mod/lesson/locallib.php b/mod/lesson/locallib.php index f394a46a57e..a12beefe80e 100644 --- a/mod/lesson/locallib.php +++ b/mod/lesson/locallib.php @@ -4141,6 +4141,16 @@ abstract class lesson_page extends lesson_base { // Increase the number of attempts made. $nattempts++; } + } else { + // When reviewing the lesson, the existing attemptid is also needed for the filearea options. + $params = [ + 'lessonid' => $attempt->lessonid, + 'pageid' => $attempt->pageid, + 'userid' => $attempt->userid, + 'answerid' => $attempt->answerid, + 'retry' => $attempt->retry + ]; + $attempt->id = $DB->get_field('lesson_attempts', 'id', $params); } // "number of attempts remaining" message if $this->lesson->maxattempts > 1 // displaying of message(s) is at the end of page for more ergonomic display