This fix rids warnings that used to come when a student for the first time attempts a quiz with the option "Each attempt builds on the last" = Yes (attemptonlast).
Now the option is not in effect when a student attempts a quiz for the first time, i.e. when there is no last attempt to build on.
$result = NULL; // Default
$questions = NULL; // Default
- if ($quiz->attemptonlast) {
+ if ($quiz->attemptonlast && !empty($attempts)) {
$latestfinishedattempt->attempt = 0;
foreach ($attempts as $attempt) {
if ($attempt->timefinish