]> git.mjollnir.org Git - moodle.git/commitdiff
Small code cleanup to fix an obscure warning. If you got an error in the middle of...
authortjhunt <tjhunt>
Fri, 30 Mar 2007 10:17:16 +0000 (10:17 +0000)
committertjhunt <tjhunt>
Fri, 30 Mar 2007 10:17:16 +0000 (10:17 +0000)
lib/questionlib.php

index fd53272d0e80b96271942343e8156a83dffba7ba..0585b1a30c0ce80a24f323b294a4d2898503ada0 100644 (file)
@@ -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;
 }
 
 /**