diff --git a/mod/scorm/locallib.php b/mod/scorm/locallib.php index 17c662e42c4..7e0e4f9eb50 100644 --- a/mod/scorm/locallib.php +++ b/mod/scorm/locallib.php @@ -812,8 +812,9 @@ function scorm_get_last_completed_attempt($scormid, $userid) { $sql = "SELECT MAX(attempt) FROM {scorm_scoes_track} WHERE userid = ? AND scormid = ? - AND (value='completed' OR value='passed')"; - $lastattempt = $DB->get_field_sql($sql, array($userid, $scormid)); + AND (".$DB->sql_compare_text('value')." = ".$DB->sql_compare_text('?')." OR ". + $DB->sql_compare_text('value')." = ".$DB->sql_compare_text('?').")"; + $lastattempt = $DB->get_field_sql($sql, array($userid, $scormid, 'completed', 'passed')); if (empty($lastattempt)) { return '1'; } else {