MDL-55955 mod_quiz: ensure duplicated override events are removed
authorMark Nelson <markn@moodle.com>
Thu, 22 Dec 2016 04:41:32 +0000 (12:41 +0800)
committerMark Nelson <markn@moodle.com>
Thu, 22 Dec 2016 04:41:32 +0000 (12:41 +0800)
mod/quiz/lib.php

index fd2b579..21b158f 100644 (file)
@@ -1194,8 +1194,11 @@ function quiz_update_events($quiz, $override = null) {
                    'instance'=>$quiz->id);
     if (!empty($override)) {
         // Only load events for this override.
-        $conds['groupid'] = isset($override->groupid)?  $override->groupid : 0;
-        $conds['userid'] = isset($override->userid)?  $override->userid : 0;
+        if (isset($override->userid)) {
+            $conds['userid'] = $override->userid;
+        } else {
+            $conds['groupid'] = $override->groupid;
+        }
     }
     $oldevents = $DB->get_records('event', $conds);