From 2db6fbad978020b9c9eb5f6dbac4e13bb7d0a445 Mon Sep 17 00:00:00 2001 From: Tim Hunt Date: Thu, 19 May 2011 20:16:47 +0100 Subject: [PATCH] MDL-20636 make upgradehelper able to reset badly upgraded attempts Obviously, these are the ones where it most important to be able to redo the upgrade. --- local/qeupgradehelper/afterupgradelib.php | 5 ++++- local/qeupgradehelper/locallib.php | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/local/qeupgradehelper/afterupgradelib.php b/local/qeupgradehelper/afterupgradelib.php index d043067f8c0..5799b3972fa 100755 --- a/local/qeupgradehelper/afterupgradelib.php +++ b/local/qeupgradehelper/afterupgradelib.php @@ -85,7 +85,7 @@ class local_qeupgradehelper_attempt_upgrader extends question_engine_attempt_upg WHERE quiza.preview = 0 AND quiza.needsupgradetonewqe = 0 - AND oldtimemodified.time >= newtimemodified.time + AND (newtimemodified.time IS NULL OR oldtimemodified.time >= newtimemodified.time) AND quiza.quiz = :quizid", array('quizid' => $quiz->id)); } @@ -123,6 +123,9 @@ class local_qeupgradehelper_attempt_upgrader extends question_engine_attempt_upg foreach ($slotlayout as $slot) { if (array_key_exists($slot, $slottoquestionid)) { $oldlayout[] = $slottoquestionid[$slot]; + } else if (in_array($slot, $questionids)) { + // OK there was probably a problem during the original upgrade. + $oldlayout[] = $slot; } else { $ok = false; break; diff --git a/local/qeupgradehelper/locallib.php b/local/qeupgradehelper/locallib.php index 4c829ab8820..572070eba1c 100755 --- a/local/qeupgradehelper/locallib.php +++ b/local/qeupgradehelper/locallib.php @@ -344,7 +344,8 @@ function local_qeupgradehelper_get_resettable_quiz($quizid) { SUM(CASE WHEN quiza.needsupgradetonewqe = 0 AND oldtimemodified.time IS NOT NULL THEN 1 ELSE 0 END) AS convertedattempts, SUM(CASE WHEN quiza.needsupgradetonewqe = 0 AND - oldtimemodified.time >= newtimemodified.time THEN 1 ELSE 0 END) AS resettableattempts + newtimemodified.time IS NULL OR oldtimemodified.time >= newtimemodified.time + THEN 1 ELSE 0 END) AS resettableattempts FROM {quiz_attempts} quiza JOIN {quiz} quiz ON quiz.id = quiza.quiz