diff --git a/course/format/singleactivity/lib.php b/course/format/singleactivity/lib.php index 6a2dd5220062d..7d5174744e7dd 100644 --- a/course/format/singleactivity/lib.php +++ b/course/format/singleactivity/lib.php @@ -167,7 +167,16 @@ public function course_format_options($foreditform = false) { foreach (array_keys($availabletypes) as $activity) { $capability = "mod/{$activity}:addinstance"; if (!has_capability($capability, $testcontext)) { - unset($availabletypes[$activity]); + if (!$this->categoryid) { + unset($availabletypes[$activity]); + } else { + // We do not have a course yet, so we guess if the user will have the capability to add the activity after + // creating the course. + $categorycontext = \context_coursecat::instance($this->categoryid); + if (!guess_if_creator_will_have_course_capability($capability, $categorycontext)) { + unset($availabletypes[$activity]); + } + } } } }