mirror of
https://github.com/moodle/moodle.git
synced 2025-08-06 01:16:44 +02:00
MDL-74257 core_courseforrmat: fix make available badge
This commit is contained in:
parent
34ce1463cc
commit
b4f62d2426
2 changed files with 75 additions and 3 deletions
|
@ -217,6 +217,7 @@ abstract class base {
|
||||||
// In case somebody keeps the reference to course format object.
|
// In case somebody keeps the reference to course format object.
|
||||||
self::$instances[$courseid][$format]->course = false;
|
self::$instances[$courseid][$format]->course = false;
|
||||||
self::$instances[$courseid][$format]->formatoptions = array();
|
self::$instances[$courseid][$format]->formatoptions = array();
|
||||||
|
self::$instances[$courseid][$format]->modinfo = null;
|
||||||
}
|
}
|
||||||
unset(self::$instances[$courseid]);
|
unset(self::$instances[$courseid]);
|
||||||
}
|
}
|
||||||
|
@ -1639,9 +1640,30 @@ abstract class base {
|
||||||
throw new moodle_exception('sectionactionnotsupported', 'core', null, s($action));
|
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 = [];
|
$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;
|
$coursesections = $modinfo->sections;
|
||||||
if (array_key_exists($section->section, $coursesections)) {
|
if (array_key_exists($section->section, $coursesections)) {
|
||||||
foreach ($coursesections[$section->section] as $cmid) {
|
foreach ($coursesections[$section->section] as $cmid) {
|
||||||
|
@ -1649,8 +1671,7 @@ abstract class base {
|
||||||
$modules[] = $renderer->course_section_updated_cm_item($this, $section, $cm);
|
$modules[] = $renderer->course_section_updated_cm_item($this, $section, $cm);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return $modules;
|
||||||
return ['modules' => $modules];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
51
course/format/tests/behat/section_visibility.feature
Normal file
51
course/format/tests/behat/section_visibility.feature
Normal 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"
|
Loading…
Add table
Add a link
Reference in a new issue