From: tjhunt Date: Fri, 30 Mar 2007 10:17:16 +0000 (+0000) Subject: Small code cleanup to fix an obscure warning. If you got an error in the middle of... X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=9523cbfcef4ea7bae0b2185691e2fdb8c5f8a7a6;p=moodle.git Small code cleanup to fix an obscure warning. If you got an error in the middle of creating a quiz attempt, you could get an attempt with no states. Then that caused an error when the attempt was deleted. Merged from MOODLE_17_STABLE. --- diff --git a/lib/questionlib.php b/lib/questionlib.php index fd53272d0e..0585b1a30c 100644 --- a/lib/questionlib.php +++ b/lib/questionlib.php @@ -373,11 +373,13 @@ function delete_attempt($attemptid) { global $QTYPES; $states = get_records('question_states', 'attempt', $attemptid); - $stateslist = implode(',', array_keys($states)); - - // delete questiontype-specific data - foreach ($QTYPES as $qtype) { - $qtype->delete_states($stateslist); + if ($states) { + $stateslist = implode(',', array_keys($states)); + + // delete question-type specific data + foreach ($QTYPES as $qtype) { + $qtype->delete_states($stateslist); + } } // delete entries from all other question tables @@ -385,8 +387,6 @@ function delete_attempt($attemptid) { delete_records("question_states", "attempt", $attemptid); delete_records("question_sessions", "attemptid", $attemptid); delete_records("question_attempts", "id", $attemptid); - - return; } /**