From 01259692effa6463985fa8fb7faf288d0896cdc3 Mon Sep 17 00:00:00 2001 From: Aaron Barnes Date: Fri, 19 Oct 2012 00:13:40 +1300 Subject: [PATCH] MDL-36107 scorm: Fix non-static method call --- mod/scorm/lib.php | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/mod/scorm/lib.php b/mod/scorm/lib.php index 55754661efc..c641e1f2d99 100644 --- a/mod/scorm/lib.php +++ b/mod/scorm/lib.php @@ -1326,22 +1326,25 @@ function scorm_dndupload_handle($uploadinfo) { * @param array $grades grades array of users with grades - used when $userid = 0 */ function scorm_set_completion($scorm, $userid, $completionstate = COMPLETION_COMPLETE, $grades = array()) { - if (!completion_info::is_enabled()) { + $course = new stdClass(); + $course->id = $scorm->course; + $completion = new completion_info($course); + + // Check if completion is enabled site-wide, or for the course + if (!$completion->is_enabled()) { return; } - $course = new stdClass(); - $course->id = $scorm->course; - $cm = get_coursemodule_from_instance('scorm', $scorm->id, $scorm->course); - if (!empty($cm)) { - $completion = new completion_info($course); - if (empty($userid)) { //we need to get all the relevant users from $grades param. - foreach ($grades as $grade) { - $completion->update_state($cm, $completionstate, $grade->userid); - } - } else { - $completion->update_state($cm, $completionstate, $userid); + if (empty($cm) || !$completion->is_enabled($cm)) { + return; + } + + if (empty($userid)) { //we need to get all the relevant users from $grades param. + foreach ($grades as $grade) { + $completion->update_state($cm, $completionstate, $grade->userid); } + } else { + $completion->update_state($cm, $completionstate, $userid); } }