Skip to content

Commit

Permalink
MDL-34644 SCORM fix completion when only completion on view is selected.
Browse files Browse the repository at this point in the history
  • Loading branch information
simoncoggins authored and danmarsden committed Sep 13, 2012
1 parent 935c3d5 commit cf0387f
Showing 1 changed file with 31 additions and 27 deletions.
58 changes: 31 additions & 27 deletions mod/scorm/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit cf0387f

Please sign in to comment.