--- view.old.php 2008-05-07 14:11:13.199988168 +0200 +++ view.php 2008-05-07 15:58:59.886902328 +0200 @@ -312,23 +312,14 @@ error('Navigation: first page not found'); } /// This is the code for starting a timed test - if(!isset($USER->startlesson[$lesson->id]) && !has_capability('mod/lesson:manage', $context)) { - $USER->startlesson[$lesson->id] = true; - $startlesson = new stdClass; - $startlesson->lessonid = $lesson->id; - $startlesson->userid = $USER->id; - $startlesson->starttime = time(); - $startlesson->lessontime = time(); - - if (!insert_record('lesson_timer', $startlesson)) { - error('Error: could not insert row into lesson_timer table'); - } - if ($lesson->timed) { - lesson_set_message(get_string('maxtimewarning', 'lesson', $lesson->maxtime), 'center'); - } - } + lesson_start_lesson($USER, $lesson, $context); } if ($pageid != LESSON_EOL) { + + // if they're accessing a page provided by a link, and not starting at the beginning, + // then start the lesson now if this their first visit to this lesson + lesson_start_lesson($USER, $lesson, $context); + /// This is the code updates the lessontime for a timed test if ($startlastseen = optional_param('startlastseen', '', PARAM_ALPHA)) { /// this deletes old records not totally sure if this is necessary anymore if ($startlastseen == 'no') {