From 7f7e18c3a21b78bfaeec4f1a8f5d3129affce08e Mon Sep 17 00:00:00 2001 From: Ankit Agarwal Date: Thu, 3 Jan 2013 14:40:03 +0800 Subject: [PATCH] MDL-36855 scorm: update to api get_scorm_question_count() get_scorm_question_count() should return 0 not 1 when no attempt is made in a scorm by any student --- mod/scorm/report/reportlib.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/mod/scorm/report/reportlib.php b/mod/scorm/report/reportlib.php index 8ea55254bf5..21aa8515cec 100644 --- a/mod/scorm/report/reportlib.php +++ b/mod/scorm/report/reportlib.php @@ -68,14 +68,16 @@ function get_scorm_question_count($scormid) { $params[] = "cmi.interactions_%.id"; $rs = $DB->get_recordset_select("scorm_scoes_track", $select, $params, 'element'); $keywords = array("cmi.interactions_", ".id"); - foreach ($rs as $record) { - $num = trim(str_ireplace($keywords, '', $record->element)); - if (is_numeric($num) && $num > $count) { - $count = $num; + if ($rs->valid()) { + // Done as interactions start at 0 (do only if we have something to report). + $count++; + foreach ($rs as $record) { + $num = trim(str_ireplace($keywords, '', $record->element)); + if (is_numeric($num) && $num > $count) { + $count = $num; + } } } - //done as interactions start at 0 - $count++; $rs->close(); // closing recordset return $count; } -- 2.43.0