From e9210ec9fc07f5cd4533bd31f54bd4b5eb03e221 Mon Sep 17 00:00:00 2001 From: Paul Holden Date: Mon, 2 Dec 2024 10:41:16 +0000 Subject: [PATCH] MDL-83844 mod_scorm: avoid SQL reserved words retrieving SCO timing. --- mod/scorm/locallib.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/mod/scorm/locallib.php b/mod/scorm/locallib.php index cb2cfa4b9e1..4b3d58075df 100644 --- a/mod/scorm/locallib.php +++ b/mod/scorm/locallib.php @@ -704,7 +704,7 @@ function scorm_get_sco_runtime($scormid, $scoid, $userid, $attempt=1) { global $DB; $params = array('userid' => $userid, 'scormid' => $scormid, 'attempt' => $attempt); - $sql = "SELECT min(timemodified) as start, max(timemodified) as finish + $sql = "SELECT MIN(timemodified) AS timemin, MAX(timemodified) AS timemax FROM {scorm_scoes_value} v JOIN {scorm_attempt} a on a.id = v.attemptid WHERE a.userid = :userid AND a.scormid = :scormid AND a.attempt = :attempt"; @@ -712,9 +712,12 @@ function scorm_get_sco_runtime($scormid, $scoid, $userid, $attempt=1) { $params['scoid'] = $scoid; $sql .= " AND v.scoid = :scoid"; } - $timedata = $DB->get_record_sql($sql, $params); - if (!empty($timedata)) { - return $timedata; + + if ($timedata = $DB->get_record_sql($sql, $params)) { + return (object) [ + 'start' => $timedata->timemin, + 'finish' => $timedata->timemax, + ]; } else { $timedata = new stdClass(); $timedata->start = false;