Index: lib.php =================================================================== RCS file: /cvsroot/moodle/moodle/mod/lesson/lib.php,v retrieving revision 1.41.2.3 diff -u -r1.41.2.3 lib.php --- lib.php 24 Jan 2008 20:29:33 -0000 1.41.2.3 +++ lib.php 12 Feb 2008 13:28:48 -0000 @@ -162,11 +162,44 @@ $return->info = get_string("gradeis", "lesson", $max_grade); } } else { - $return->info = get_string("no")." ".get_string("attempts", "lesson"); + + if (! $return = lesson_user_attempted_branch_only($user->id,$lesson->id)){ + $return->info = get_string("no")." ".get_string("attempts", "lesson"); + } } return $return; } +/* + * Checks if student attempted lesson consisting only from branches + * If yes, records first attempt time + * #MDL-12194 + * + *@param int $userid + *@param int $lessonid + * + *@return object->info,object->time or nothing + */ +function lesson_user_attempted_branch_only($userid,$lessonid){ + global $CFG; + $sql = " SELECT lb.id,lb.timeseen + FROM {$CFG->prefix}lesson_branch lb + LEFT JOIN {$CFG->prefix}lesson_pages lp ON lp.id = lb.pageid + WHERE lb.userid = $userid + AND lb.lessonid = $lessonid + AND lp.qtype = 20 + AND lp.nextpageid = 0 + ORDER BY lb.timeseen ASC"; + + $return = ''; + + if ($record = get_record_sql($sql)){ + $return->info = get_string("lessonattempted", "lesson"); + $return->time = $record->timeseen; + } + return $return; +} + /*******************************************************************/ function lesson_user_complete($course, $user, $mod, $lesson) { /// Print a detailed representation of what a user has done with @@ -225,7 +258,11 @@ } } } else { - echo get_string("no")." ".get_string("attempts", "lesson"); + if ($return = lesson_user_attempted_branch_only($user->id,$lesson->id)){ + echo "
".get_string("lessonattempted","lesson")." : ".userdate($return->time)."
"; + }else{ + echo "".get_string("no")." ".get_string("attempts", "lesson")."
"; + } }