Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'MDL-36107b-23' of git://github.com/srynot4sale/moodle i…

…nto MOODLE_23_STABLE
  • Loading branch information...
commit a82535f068cdcb47836faeab93d2d88af3754f90 2 parents 0d79d96 + 3a15a75
@samhemelryk samhemelryk authored
Showing with 15 additions and 12 deletions.
  1. +15 −12 mod/scorm/lib.php
View
27 mod/scorm/lib.php
@@ -1328,22 +1328,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()) {
- return;
- }
-
$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;
+ }
$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);
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.