From b667abd06b2aef9c637ec0198213f880f387e962 Mon Sep 17 00:00:00 2001 From: Michael Milette Date: Mon, 16 Dec 2024 10:14:29 -0500 Subject: [PATCH] #312: ifactivitycompleted now works correctly with passed quiz. --- CHANGELOG.md | 5 ++++- classes/text_filter.php | 12 ++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3f6f4e0..9c7936b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,11 +1,14 @@ # Change Log All notable changes to this project will be documented in this file. -## [2.6.2] 2024-12-14 (dev) +## [2.6.2] 2024-12-16 (dev) +### Added - Performance optimization: Now caches login state. - New {firstnamephonetic} tag. - New {lastnamephonetic} tag. - New {middlename} tag. +### Updated +- Fix-312: ifactivitycompleted now works correctly with passed quiz. ## [2.6.1] 2024-11-20 ### Update diff --git a/classes/text_filter.php b/classes/text_filter.php index 47b7521..30a3e60 100644 --- a/classes/text_filter.php +++ b/classes/text_filter.php @@ -4006,8 +4006,8 @@ function ($matches) use ($USER) { if (($cm = \get_coursemodule_from_id('', $cmid, 0)) !== false) { // Get the completion data for this activity if it exists. try { - $data = $completion->get_data($cm, true, $USER->id); - $iscompleted = ($data->completionstate == COMPLETION_COMPLETE); + $data = $completion->get_data($cm, false, $USER->id); + $iscompleted = ($data->completionstate > COMPLETION_INCOMPLETE); // A completed state. } catch (\moodle_exception $e) { // Handle Moodle-specific exceptions. unset($e); @@ -4051,15 +4051,15 @@ function ($matches) use ($USER) { // Only process valid IDs. if (($cm = \get_coursemodule_from_id('', $cmid, 0)) !== false) { - // Get the completion data for this activity. + // Get the completion data for this activity if it exists. try { - $data = $completion->get_data($cm, true, $USER->id); - $iscompleted = ($data->completionstate == COMPLETION_COMPLETE); + $data = $completion->get_data($cm, false, $USER->id); + $iscompleted = ($data->completionstate > COMPLETION_INCOMPLETE); // A completed state. } catch (\moodle_exception $e) { // Handle Moodle-specific exceptions. unset($e); continue; - } catch (Exception $e) { + } catch (\Exception $e) { unset($e); continue; }