mirror of
https://github.com/moodle/moodle.git
synced 2025-04-22 17:02:03 +02:00
Merge branch 'MDL-81798-main' of https://github.com/ferranrecio/moodle
This commit is contained in:
commit
5f37f860e2
@ -277,8 +277,11 @@ class content_item_service {
|
||||
return course_allowed_module($course, explode('_', $parents[$contentitem->get_component_name()])[1], $user);
|
||||
});
|
||||
|
||||
$format = course_get_format($course);
|
||||
$maxsectionsreached = ($format->get_last_section_number() >= $format->get_max_sections());
|
||||
|
||||
// Now, check there is no delegated section into a delegated section.
|
||||
if (is_null($sectioninfo) || $sectioninfo->is_delegated()) {
|
||||
if (is_null($sectioninfo) || $sectioninfo->is_delegated() || $maxsectionsreached) {
|
||||
$availablecontentitems = array_filter($availablecontentitems, function($contentitem){
|
||||
return !sectiondelegate::has_delegate_class($contentitem->get_component_name());
|
||||
});
|
||||
|
31
mod/subsection/tests/behat/subsection_limit.feature
Normal file
31
mod/subsection/tests/behat/subsection_limit.feature
Normal file
@ -0,0 +1,31 @@
|
||||
@mod @mod_subsection
|
||||
Feature: Teacher can only add subsection when certain conditions are met
|
||||
In order to limit subsections
|
||||
As an teacher
|
||||
I need to create subsections only when possible
|
||||
|
||||
Background:
|
||||
Given I enable "subsection" "mod" plugin
|
||||
And the following "users" exist:
|
||||
| username | firstname | lastname | email |
|
||||
| teacher1 | Teacher | 1 | teacher1@example.com |
|
||||
And the following "courses" exist:
|
||||
| fullname | shortname | category | numsections | initsections |
|
||||
| Course 1 | C1 | 0 | 5 | 1 |
|
||||
And the following "course enrolments" exist:
|
||||
| user | course | role |
|
||||
| teacher1 | C1 | editingteacher |
|
||||
|
||||
@javascript
|
||||
Scenario: The activity chooser filter subsections when section limit 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 an activity or resource" "button" in the "Section 1" "section"
|
||||
And I should see "Subsection" in the "Add an activity or resource" "dialogue"
|
||||
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"
|
Loading…
x
Reference in New Issue
Block a user