Merge branch 'MDL-74257-master' of https://github.com/ferranrecio/moodle

This commit is contained in:
Jun Pataleta 2022-03-28 14:45:14 +08:00
commit 53fc54cce5
2 changed files with 75 additions and 3 deletions

View File

@ -217,6 +217,7 @@ abstract class base {
// In case somebody keeps the reference to course format object.
self::$instances[$courseid][$format]->course = false;
self::$instances[$courseid][$format]->formatoptions = array();
self::$instances[$courseid][$format]->modinfo = null;
}
unset(self::$instances[$courseid]);
}
@ -1639,9 +1640,30 @@ abstract class base {
throw new moodle_exception('sectionactionnotsupported', 'core', null, s($action));
}
return ['modules' => $this->get_section_modules_updated($section)];
}
/**
* Return an array with all section modules content.
*
* This method is used in section_action method to generate the updated modules content
* after a modinfo change.
*
* @param section_info $section the section
* @return string[] the full modules content.
*/
protected function get_section_modules_updated(section_info $section): array {
global $PAGE;
$modules = [];
// Load the cmlist output.
if (!$this->uses_sections() || !$section->section) {
return $modules;
}
// Load the cmlist output from the updated modinfo.
$renderer = $this->get_renderer($PAGE);
$modinfo = $this->get_modinfo();
$coursesections = $modinfo->sections;
if (array_key_exists($section->section, $coursesections)) {
foreach ($coursesections[$section->section] as $cmid) {
@ -1649,8 +1671,7 @@ abstract class base {
$modules[] = $renderer->course_section_updated_cm_item($this, $section, $cm);
}
}
return ['modules' => $modules];
return $modules;
}
/**

View File

@ -0,0 +1,51 @@
@core @core_courseformat
Feature: Varify section visibility interface.
In order to edit the course sections visibility
As a teacher
I need to be able to see the updateds visibility information
Background:
Given the following "course" exists:
| fullname | Course 1 |
| shortname | C1 |
| category | 0 |
| numsections | 3 |
And the following "activities" exist:
| activity | name | intro | course | idnumber | section |
| assign | Activity sample 1 | Test assignment description | C1 | sample1 | 1 |
And the following "users" exist:
| username | firstname | lastname | email |
| teacher1 | Teacher | 1 | teacher1@example.com |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
Given I am on the "C1" "Course" page logged in as "teacher1"
And I turn editing mode on
@javascript
Scenario: Activities available but not shown on course page only apply to hidden sections.
Given I hide section "1"
And I open "Activity sample 1" actions menu
And I click on "Make available" "link" in the "Activity sample 1" "activity"
And I should see "Available but not shown on course page" in the "Activity sample 1" "activity"
When I show section "1"
Then I should not see "Available but not shown on course page" in the "Activity sample 1" "activity"
@javascript
Scenario: Hide a section also hides the activities.
When I hide section "1"
Then I should see "Hidden from students" in the "Topic 1" "section"
And I should see "Hidden from students" in the "Activity sample 1" "activity"
And I show section "1"
And I should not see "Hidden from students" in the "Topic 1" "section"
And I should not see "Hidden from students" in the "Activity sample 1" "activity"
@javascript
Scenario: Hiden activities in hidden sections stay hidden when the section is shown.
Given I open "Activity sample 1" actions menu
And I click on "Hide" "link" in the "Activity sample 1" "activity"
And I should see "Hidden from students" in the "Activity sample 1" "activity"
And I hide section "1"
And I should see "Hidden from students" in the "Activity sample 1" "activity"
When I show section "1"
Then I should see "Hidden from students" in the "Activity sample 1" "activity"