Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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
  • Loading branch information...
commit 40652808e3866d10ffc73e626e6fc0f7ffec8990 1 parent 9da506c
@ankitagarwal ankitagarwal authored
Showing with 8 additions and 6 deletions.
  1. +8 −6 mod/scorm/report/reportlib.php
View
14 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;
}
Please sign in to comment.
Something went wrong with that request. Please try again.