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.
This commit is contained in:
Jonathon Fowler
2026-03-03 11:39:50 +10:00
parent dcf942624d
commit febfc32d9b
+2 -2
View File
@@ -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);