From 4e9e64230f5b43000520c1eb54d45eea9d44dd94 Mon Sep 17 00:00:00 2001 From: gbateson Date: Sat, 13 Jan 2007 11:46:33 +0000 Subject: [PATCH] fixed typo in SQL query when starting a new HotPot attempt --- mod/hotpot/lib.php | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/mod/hotpot/lib.php b/mod/hotpot/lib.php index 15d5b63d9c..13c7b62cc5 100644 --- a/mod/hotpot/lib.php +++ b/mod/hotpot/lib.php @@ -1232,24 +1232,29 @@ function hotpot_scale_used ($hotpotid, $scaleid) { function hotpot_add_attempt($hotpotid) { global $db, $CFG, $USER; + // get start time of this attempt + $time = time(); + // set all previous "in progress" attempts at this quiz to "abandoned" - $db->Execute(" - UPDATE - {$CFG->prefix}hotpot_attempts a - SET - a.timefinish = '".time()."', - a.status = '".HOTPOT_STATUS_ABANDONED."', - WHERE - a.hotpot='$hotpotid' - AND a.userid='$USER->id' - AND a.status='".HOTPOT_STATUS_INPROGRESS."' - "); + if ($attempts = get_records_select('hotpot_attempts', "hotpot='$hotpotid' AND userid='$USER->id' AND status='".HOTPOT_STATUS_INPROGRESS."'")) { + foreach ($attempts as $attempt) { + if ($attempt->timefinish==0) { + $attempt->timefinish = $time; + } + if ($attempt->clickreportid==0) { + $attempt->clickreportid = $attempt->id; + } + $attempt->status = HOTPOT_STATUS_ABANDONED; + update_record('hotpot_attempts', $attempt); + } + } // create and add new attempt record + $attempt = new stdClass(); $attempt->hotpot = $hotpotid; $attempt->userid = $USER->id; $attempt->attempt = hotpot_get_next_attempt($hotpotid); - $attempt->timestart = time(); + $attempt->timestart = $time; return insert_record("hotpot_attempts", $attempt); } -- 2.39.5