Skip to content

Commit

Permalink
MDL-70972 format_singleactivity: Show activities when creating course
Browse files Browse the repository at this point in the history
  • Loading branch information
PhMemmel committed May 31, 2024
1 parent be10cd7 commit 4900407
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion course/format/singleactivity/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}
}
}
}
}
Expand Down

0 comments on commit 4900407

Please sign in to comment.