From bb6c9786a0b85b8432a91b677b21ff8e8bde835a Mon Sep 17 00:00:00 2001 From: Michiel Boerman Date: Tue, 14 Jan 2025 14:50:51 +0100 Subject: [PATCH] processes subcourse completion condition --- lib.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib.php b/lib.php index 4d780a3..2376047 100644 --- a/lib.php +++ b/lib.php @@ -364,7 +364,7 @@ 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; @@ -387,6 +387,12 @@ function subcourse_get_coursemodule_info($coursemodule) { $info->content = format_module_intro('subcourse', $subcourse, $coursemodule->id, false); } + // Populate the custom completion rules as key => value pairs, but only if the completion mode is 'automatic'. + if ($coursemodule->completion == COMPLETION_TRACKING_AUTOMATIC) { + $info->customdata->customcompletionrules['completioncourse'] = $subcourse->completioncourse; + } + + return $info; }