Skip to content

Commit 1f5a188

Browse files
committed
Check cmid exists in course
1 parent 0f4a30c commit 1f5a188

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

block_my_feedback.php

+13
Original file line numberDiff line numberDiff line change
@@ -123,15 +123,28 @@ public static function fetch_marking(stdClass $user): ?array {
123123
}
124124

125125
$modinfo = get_fast_modinfo($course->id);
126+
$mods = $modinfo->get_cms();
127+
// Mod ids array to check cmid exists.
128+
$cmids = [];
129+
foreach ($mods as $mod) {
130+
$cmids[] = $mod->id;
131+
}
126132

127133
// Loop through assessments for this course.
128134
foreach ($summatives as $summative) {
129135

130136
// Check this is a course mod.
131137
if ($summative->cmid != 0) {
138+
// Skip mods where cmid is not in the course.
139+
if (!in_array($summative->cmid, $cmids)) {
140+
continue;
141+
}
142+
143+
// Begin to build mod data for template.
132144
$cmid = $summative->cmid;
133145
$mod = $modinfo->get_cm($cmid);
134146

147+
135148
// Skip hidden mods.
136149
if (!$mod->visible) {
137150
continue;

0 commit comments

Comments
 (0)