Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

MDL-34644 SCORM fix completion when only completion on view is selected.

  • Loading branch information...
commit cf0387ff080eb8f3993db5fd3436340abf5aa2ca 1 parent 935c3d5
@simoncoggins simoncoggins authored danmarsden committed
Showing with 31 additions and 27 deletions.
  1. +31 −27 mod/scorm/lib.php
View
58 mod/scorm/lib.php
@@ -1183,33 +1183,37 @@ function scorm_get_completion_state($course, $cm, $userid, $type) {
if (!$scorm = $DB->get_record('scorm', array('id' => $cm->instance))) {
print_error('cannotfindscorm');
}
-
- // Get user's tracks data
- $tracks = $DB->get_records_sql(
- "
- SELECT
- id,
- element,
- value
- FROM
- {scorm_scoes_track}
- WHERE
- scormid = ?
- AND userid = ?
- AND element IN
- (
- 'cmi.core.lesson_status',
- 'cmi.completion_status',
- 'cmi.success_status',
- 'cmi.core.score.raw',
- 'cmi.score.raw'
- )
- ",
- array($scorm->id, $userid)
- );
-
- if (!$tracks) {
- return completion_info::aggregate_completion_states($type, $result, false);
+ // Only check for existence of tracks and return false if completionstatusrequired or completionscorerequired
+ // this means that if only view is required we don't end up with a false state.
+ if ($scorm->completionstatusrequired !== null ||
+ $scorm->completionscorerequired !== null) {
+ // Get user's tracks data.
+ $tracks = $DB->get_records_sql(
+ "
+ SELECT
+ id,
+ element,
+ value
+ FROM
+ {scorm_scoes_track}
+ WHERE
+ scormid = ?
+ AND userid = ?
+ AND element IN
+ (
+ 'cmi.core.lesson_status',
+ 'cmi.completion_status',
+ 'cmi.success_status',
+ 'cmi.core.score.raw',
+ 'cmi.score.raw'
+ )
+ ",
+ array($scorm->id, $userid)
+ );
+
+ if (!$tracks) {
+ return completion_info::aggregate_completion_states($type, $result, false);
+ }
}
// Check for status
Please sign in to comment.
Something went wrong with that request. Please try again.