MDL-70972 format_singleactivity: Show activities when creating course

Co-authored-by: Laurent David <[email protected]>
This commit is contained in:
Philipp Memmel
2024-06-04 04:29:06 +00:00
co-authored by Laurent David
parent bcd8e0d6ed
commit 63c0495c86
+10 -1
View File
@@ -157,7 +157,16 @@ class format_singleactivity extends core_courseformat\base {
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]);
}
}
}
}
}