Skip to content

Commit

Permalink
#312: ifactivitycompleted and ifnotactivitycompleted now works correc…
Browse files Browse the repository at this point in the history
…tly with graded activities.
  • Loading branch information
michael-milette committed Dec 16, 2024
1 parent 0bcea9d commit fc86c12
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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 and ifnotactivitycompleted now works correctly with graded activities.

## [2.6.1] 2024-11-20
### Update
Expand Down
12 changes: 6 additions & 6 deletions classes/text_filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit fc86c12

Please sign in to comment.