Merge branch 'MDL-83053-main' of https://github.com/aanabit/moodle

This commit is contained in:
Jun Pataleta 2024-09-16 11:20:54 +08:00
commit dd96cf9e19
No known key found for this signature in database
GPG Key ID: F83510526D99E2C7
3 changed files with 15 additions and 1 deletions

View File

@ -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;
}

View File

@ -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"

View File

@ -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"