From 1beba61e805145f10bc5758d6d2111c4d628a79e Mon Sep 17 00:00:00 2001 From: Jonathon Fowler Date: Mon, 13 Oct 2025 10:24:41 +1000 Subject: [PATCH] MDL-86112 courseformat: avoid a JS error modal when marking as done When viewing an "available but not shown" cm with self-completion set, then clicking the 'Mark as done' button in the activity header. --- public/course/format/classes/external/get_state.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/public/course/format/classes/external/get_state.php b/public/course/format/classes/external/get_state.php index fd52babf4d9..af12fe439a2 100644 --- a/public/course/format/classes/external/get_state.php +++ b/public/course/format/classes/external/get_state.php @@ -105,8 +105,8 @@ class get_state extends external_api { } foreach ($modinfo->cms as $cm) { - if ($cm->is_visible_on_course_page() && $cm->is_of_type_that_can_display()) { - // Only return this course module data if it's visible by current user on the course page. + if (($cm->is_visible_on_course_page() || $cm->is_stealth()) && $cm->is_of_type_that_can_display()) { + // Only return this course module data if it's accessible to the current user on the course page. $section = $sections[$cm->sectionnum]; $cmstate = new $cmclass($courseformat, $section, $cm, istrackeduser: $istrackeduser); $result->cm[] = $cmstate->export_for_template($renderer);