From b3ccc054e752384187f8e24079246ddf7a42363c Mon Sep 17 00:00:00 2001 From: gustav_delius Date: Mon, 23 May 2005 20:52:55 +0000 Subject: [PATCH] Upgrade all attempts at a quiz to the Moodle 1.5 model on attempts.php and report.php --- mod/quiz/attempts.php | 10 ++++++++++ mod/quiz/report.php | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/mod/quiz/attempts.php b/mod/quiz/attempts.php index 3411a0b18e6..c0e84ec79bf 100644 --- a/mod/quiz/attempts.php +++ b/mod/quiz/attempts.php @@ -45,6 +45,16 @@ redirect('edit.php?quizid='.$quiz->id); } + // Upgrade any attempts that have not yet been upgraded to the + // Moodle 1.5 model (they will not yet have the timestamp set) + if ($attempts = get_records_sql("SELECT a.*". + " FROM {$CFG->prefix}quiz_attempts a, {$CFG->prefix}quiz_states s". + " WHERE a.quiz = '$quiz->id' AND s.attempt = a.id AND s.timestamp = 0")) { + foreach ($attempts as $attempt) { + quiz_upgrade_states($attempt); + } + } + add_to_log($course->id, "quiz", "attempts", "attempts.php?id=$cm->id", "$quiz->id", "$cm->id"); /// Define some strings diff --git a/mod/quiz/report.php b/mod/quiz/report.php index abe9d9475b2..d7bc760325e 100644 --- a/mod/quiz/report.php +++ b/mod/quiz/report.php @@ -46,6 +46,16 @@ redirect('edit.php?quizid='.$quiz->id); } + // Upgrade any attempts that have not yet been upgraded to the + // Moodle 1.5 model (they will not yet have the timestamp set) + if ($attempts = get_records_sql("SELECT a.*". + " FROM {$CFG->prefix}quiz_attempts a, {$CFG->prefix}quiz_states s". + " WHERE a.quiz = '$quiz->id' AND s.attempt = a.id AND s.timestamp = 0")) { + foreach ($attempts as $attempt) { + quiz_upgrade_states($attempt); + } + } + add_to_log($course->id, "quiz", "report", "report.php?id=$cm->id", "$quiz->id", "$cm->id");