Merge branch 'MDL-82619-main-cr' of https://github.com/ferranrecio/moodle

This commit is contained in:
Sara Arjona 2024-08-19 12:08:19 +02:00
commit 7e0bd1b12b
No known key found for this signature in database
5 changed files with 70 additions and 1 deletions

View File

@ -177,6 +177,11 @@ abstract class sectiondelegatemodule extends sectiondelegate {
$cmrecord['availability'] = $sectionrecord->availability;
}
if (isset($sectionrecord->visible) && $sectionrecord->visible !== $this->cm->visible) {
$cmrecord['visible'] = $sectionrecord->visible;
$cmrecord['visibleold'] = $sectionrecord->visible;
}
if (empty($cmrecord)) {
return;
}

View File

@ -1,5 +1,5 @@
@core @core_courseformat
Feature: Varify section visibility interface
Feature: Verify section visibility interface
In order to edit the course sections visibility
As a teacher
I need to be able to see the updated visibility information

View File

@ -265,6 +265,9 @@ XPATH
.//li[contains(concat(' ', normalize-space(@class), ' '), ' section ')][./descendant::*[self::h3]
[normalize-space(.) = %locator%][contains(concat(' ', normalize-space(@class), ' '), ' sectionname ') or
contains(concat(' ', normalize-space(@class), ' '), ' section-title ')]] |
.//li[contains(concat(' ', normalize-space(@class), ' '), ' section ')][./descendant::*[self::h4]
[normalize-space(.) = %locator%][contains(concat(' ', normalize-space(@class), ' '), ' sectionname ') or
contains(concat(' ', normalize-space(@class), ' '), ' section-title ')]] |
.//div[contains(concat(' ', normalize-space(@class), ' '), ' sitetopic ')]
[./descendant::*[self::h2][normalize-space(.) = %locator%] or %locator% = 'frontpage']
XPATH

View File

@ -78,6 +78,7 @@ function subsection_add_instance($moduleinstance, $mform = null) {
$id,
(object)[
'name' => $moduleinstance->name,
'visible' => $moduleinstance->visible,
'availability' => $cmavailability,
]
);

View File

@ -0,0 +1,60 @@
@mod @mod_subsection
Feature: Subsection visibility should work as a module
In order to hide and show subsections
As a teacher
I need subsections to behave as any other module
Background:
Given I enable "subsection" "mod" plugin
And the following "course" exists:
| fullname | Course 1 |
| shortname | C1 |
| category | 0 |
| numsections | 2 |
| initsections | 1 |
And the following "users" exist:
| username | firstname | lastname |
| teacher1 | Teacher | 1 |
| student1 | Student | 1 |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
| student1 | C1 | student |
And I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
@javascript
Scenario: Subsections created on a hidden section behave like a normal module when parent visibility is toggled
Given I should not see "Hidden from student"
When I hide section "Section 1"
And I should see "Hidden from students" in the "Section 1" "section"
# We cannot use generators because they don't check the parent section visibility.
And I add a subsection activity to course "Course 1" section "1" and I fill the form with:
| Name | Subsection 1 |
And I add a assign activity to course "Course 1" section "1" and I fill the form with:
| Assignment name | Hidden assignment name |
| ID number | assign1 |
| Description | Hidden assignment description |
| assignsubmission_onlinetext_enabled | 1 |
Then I should see "Hidden from students" in the "Subsection 1" "section"
And I should see "Hidden from students" in the "Hidden assignment name" "activity"
And I show section "Section 1"
And I should see "Hidden from students" in the "Subsection 1" "section"
And I should see "Hidden from students" in the "Hidden assignment name" "activity"
@javascript
Scenario: Subsections created on a visible section behave like a normal module when parent visibility is toggled
Given I should not see "Hidden from student"
And the following "activities" exist:
| activity | name | course | idnumber | section |
| subsection | Subsection 1 | C1 | subsection1 | 1 |
| page | Page 1 | C1 | page1 | 1 |
When I am on "Course 1" course homepage
And I should not see "Hidden from students" in the "Subsection 1" "section"
And I should not see "Hidden from students" in the "Page 1" "activity"
Then I hide section "Section 1"
And I should see "Hidden from students" in the "Subsection 1" "section"
And I should see "Hidden from students" in the "Page 1" "activity"
And I show section "Section 1"
And I should not see "Hidden from students" in the "Subsection 1" "section"
And I should not see "Hidden from students" in the "Page 1" "activity"