diff --git a/lib/filebrowser/file_info_context_course.php b/lib/filebrowser/file_info_context_course.php index 4c8b7977075..c766acaccda 100644 --- a/lib/filebrowser/file_info_context_course.php +++ b/lib/filebrowser/file_info_context_course.php @@ -528,16 +528,15 @@ class file_info_context_course extends file_info { $params1 = ['contextid' => $this->context->id, 'emptyfilename' => '.', 'contextlevel' => CONTEXT_MODULE, - 'depth' => $this->context->depth + 1, - 'pathmask' => $this->context->path . '/%']; + 'course' => $this->course->id]; $sql1 = "SELECT ctx.id AS contextid, f.component, f.filearea, f.itemid, ctx.instanceid AS cmid, " . context_helper::get_preload_record_columns_sql('ctx') . " FROM {files} f INNER JOIN {context} ctx ON ctx.id = f.contextid + INNER JOIN {course_modules} cm ON cm.id = ctx.instanceid WHERE f.filename <> :emptyfilename - AND ctx.contextlevel = :contextlevel - AND ctx.depth = :depth - AND " . $DB->sql_like('ctx.path', ':pathmask') . " "; + AND cm.course = :course + AND ctx.contextlevel = :contextlevel"; $sql3 = ' GROUP BY ctx.id, f.component, f.filearea, f.itemid, ctx.instanceid, ctx.path, ctx.depth, ctx.contextlevel ORDER BY ctx.id, f.component, f.filearea, f.itemid';