Skip to content

Commit

Permalink
MDL-20636 make upgradehelper able to reset badly upgraded attempts
Browse files Browse the repository at this point in the history
Obviously, these are the ones where it most important to be able to redo the upgrade.
  • Loading branch information
timhunt committed May 19, 2011
1 parent ffe4d23 commit 2db6fba
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 4 additions & 1 deletion local/qeupgradehelper/afterupgradelib.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ protected function get_resettable_attempts($quiz) {
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));
}

Expand Down Expand Up @@ -123,6 +123,9 @@ protected function reset_attempt($quiz, $attempt) {
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;
Expand Down
3 changes: 2 additions & 1 deletion local/qeupgradehelper/locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 2db6fba

Please sign in to comment.