Skip to content

Commit

Permalink
fix the display of completion conditions on the course page
Browse files Browse the repository at this point in the history
Refs #86
  • Loading branch information
usqfowlerj committed Jan 5, 2025
1 parent 91afe59 commit 5bdb84a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
8 changes: 6 additions & 2 deletions classes/completion/custom_completion.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function get_state(string $rule): int {
// Check if the referenced course is completed.
$coursecompletion = new \completion_completion(['userid' => $this->userid, 'course' => $subcourse->refcourse]);

return $coursecompletion->is_complete();
return $coursecompletion->is_complete() ? COMPLETION_COMPLETE : COMPLETION_INCOMPLETE;
}

/**
Expand All @@ -78,6 +78,10 @@ public function get_custom_rule_descriptions(): array {
* @return array
*/
public function get_sort_order(): array {
return ['completioncourse'];
return [
'completionview',
'completionusegrade',
'completioncourse',
];
}
}
9 changes: 7 additions & 2 deletions lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,8 @@ function subcourse_get_coursemodule_info($coursemodule) {
global $CFG, $DB;

$subcourse = $DB->get_record('subcourse', ['id' => $coursemodule->instance],
'id, name, intro, introformat, instantredirect, blankwindow, coursepageprintgrade, coursepageprintprogress');
'id, name, intro, introformat, instantredirect, blankwindow, coursepageprintgrade, coursepageprintprogress, ' .
'completioncourse');

if (!$subcourse) {
return null;
Expand All @@ -387,6 +388,10 @@ function subcourse_get_coursemodule_info($coursemodule) {
$info->content = format_module_intro('subcourse', $subcourse, $coursemodule->id, false);
}

if ($coursemodule->completion == COMPLETION_TRACKING_AUTOMATIC) {
$info->customdata->customcompletionrules['completioncourse'] = $subcourse->completioncourse;
}

return $info;
}

Expand Down Expand Up @@ -433,7 +438,7 @@ function subcourse_update_grades($subcourse, $userid=0, $nullifnone=true) {
// Prevent empty referenced course id coding error.
return GRADE_UPDATE_FAILED;
}

if ($refgrades && $refgrades->grades) {
if (!empty($refgrades->localremotescale)) {
// Unable to fetch remote grades - local scale is used in the remote course.
Expand Down

0 comments on commit 5bdb84a

Please sign in to comment.