Skip to content

Commit

Permalink
MDL-82574 mod_subsection: Remove module from activity chooser
Browse files Browse the repository at this point in the history
* Fix behat tests to take into consideration the new add subsection
workflow
  • Loading branch information
laurentdavid committed Aug 21, 2024
1 parent ad3548a commit b4d251a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
18 changes: 18 additions & 0 deletions mod/subsection/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -300,3 +300,21 @@ function mod_subsection_get_fontawesome_icon_map() {
'mod_subsection:i/subsection' => 'fa-rectangle-list',
];
}

/**
* Get the course content items for the subsection module.
*
* This function is called when the course content is being generated for the activity chooser.
* However, here this module is never shown in the activity chooser so we return an empty array.
*
* @param \core_course\local\entity\content_item $contentitem
* @param stdClass $user
* @param stdClass $course
* @return array
*/
function mod_subsection_get_course_content_items(
core_course\local\entity\content_item $contentitem,
stdClass $user,
stdClass $course): array {
return [];
}
8 changes: 3 additions & 5 deletions mod/subsection/tests/behat/subsection_limit.feature
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,14 @@ Feature: Teacher can only add subsection when certain conditions are met
| teacher1 | C1 | editingteacher |

@javascript
Scenario: The activity chooser filter subsections when section limit is reached
Scenario: We cannot add subsections when maxsections is reached
Given the following config values are set as admin:
| maxsections | 10 | moodlecourse |
And I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
And I click on "Add content" "button" in the "Section 1" "section"
And I click on "Activity or resource" "button" in the ".dropdown-menu.show" "css_element"
And I should see "Subsection" in the "Add an activity or resource" "dialogue"
And I click on "Subsection" "link" in the ".dropdown-menu.show" "css_element"
When the following config values are set as admin:
| maxsections | 4 | moodlecourse |
And I am on "Course 1" course homepage
Then I click on "Add an activity or resource" "button" in the "Section 1" "section"
And I should not see "Subsection" in the "Add an activity or resource" "dialogue"
And I should see "You have reached the maximum number of sections allowed for a course."

0 comments on commit b4d251a

Please sign in to comment.