diff --git a/course/format/singleactivity/lib.php b/course/format/singleactivity/lib.php index 95ac3418a89..05799ac60d0 100644 --- a/course/format/singleactivity/lib.php +++ b/course/format/singleactivity/lib.php @@ -22,6 +22,8 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ +use core_courseformat\sectiondelegate; + defined('MOODLE_INTERNAL') || die(); require_once($CFG->dirroot. '/course/format/lib.php'); @@ -338,7 +340,8 @@ class format_singleactivity extends core_courseformat\base { /** * Get the activities supported by the format. * - * Here we ignore the modules that do not have a page of their own, like the label. + * Here we ignore the modules that do not have a page of their own or need sections, + * like the label or subsection. * * @return array array($module => $name of the module). */ @@ -348,6 +351,9 @@ class format_singleactivity extends core_courseformat\base { if (plugin_supports('mod', $module, FEATURE_NO_VIEW_LINK, false)) { unset($availabletypes[$module]); } + if (sectiondelegate::has_delegate_class('mod_' . $module)) { + unset($availabletypes[$module]); + } } return $availabletypes; } diff --git a/course/format/singleactivity/tests/behat/create_course.feature b/course/format/singleactivity/tests/behat/create_course.feature index 1f1e5902822..057709d460e 100644 --- a/course/format/singleactivity/tests/behat/create_course.feature +++ b/course/format/singleactivity/tests/behat/create_course.feature @@ -21,6 +21,7 @@ Feature: Courses can be created in Single Activity mode | moodle/course:manageactivities | allow | | moodle/course:viewparticipants | allow | | moodle/role:assign | allow | + And I enable "subsection" "mod" plugin When I log in as "kevin" And I am on site homepage And I press "Add a new course" @@ -31,6 +32,9 @@ Feature: Courses can be created in Single Activity mode And I press "Update format" Then I should see "Quiz" in the "Type of activity" "field" And I should see "Forum" in the "Type of activity" "field" + # Check that not all the activity types are in the dropdown. + And I should not see "Text and media" in the "Type of activity" "field" + And I should not see "Subsection" in the "Type of activity" "field" And I set the field "Type of activity" to "Quiz" And I press "Save and display" And I should see "New Quiz" diff --git a/course/format/singleactivity/tests/behat/edit_format_course.feature b/course/format/singleactivity/tests/behat/edit_format_course.feature index e20fb38f40c..fff755b6469 100644 --- a/course/format/singleactivity/tests/behat/edit_format_course.feature +++ b/course/format/singleactivity/tests/behat/edit_format_course.feature @@ -14,6 +14,7 @@ Feature: Edit format course to Single Activity format And the following "course enrolments" exist: | user | course | role | | teacher1 | C1 | editingteacher | + And I enable "subsection" "mod" plugin And I log in as "teacher1" And I am on "Course 1" course homepage When I navigate to "Settings" in current page administration @@ -23,5 +24,8 @@ Feature: Edit format course to Single Activity format | Format | Single activity | And I press "Update format" Then I should see "Forum" in the "Type of activity" "field" + # Check that not all the activity types are in the dropdown. + And I should not see "Text and media" in the "Type of activity" "field" + And I should not see "Subsection" in the "Type of activity" "field" And I press "Save and display" And I should see "New Forum"