From 6d4858392b879320a11ec4222fbb6a2552b45970 Mon Sep 17 00:00:00 2001 From: Jean-Michel Vedrine Date: Wed, 31 Dec 2014 13:23:09 +0100 Subject: [PATCH] MDL-14730 mod_lesson: allow linking to pages inside a lesson --- mod/lesson/locallib.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/mod/lesson/locallib.php b/mod/lesson/locallib.php index 0fc87b9b679..fa048099bf9 100644 --- a/mod/lesson/locallib.php +++ b/mod/lesson/locallib.php @@ -1255,11 +1255,12 @@ class lesson extends lesson_base { global $USER, $DB; // clock code // get time information for this user - if (!$timer = $DB->get_records('lesson_timer', array ("lessonid" => $this->properties->id, "userid" => $USER->id), 'starttime DESC', '*', 0, 1)) { - print_error('cannotfindtimer', 'lesson'); - } else { - $timer = current($timer); // this will get the latest start time record + $params = array("lessonid" => $this->properties->id, "userid" => $USER->id); + if (!$timer = $DB->get_records('lesson_timer', $params, 'starttime DESC', '*', 0, 1)) { + $this->start_timer(); + $timer = $DB->get_records('lesson_timer', $params, 'starttime DESC', '*', 0, 1); } + $timer = current($timer); // This will get the latest start time record. if ($restart) { if ($continue) {