MDL-82541 core_courseformat: improve orphan section visualitzation

This commit is contained in:
ferranrecio 2024-09-12 15:55:45 +02:00
parent 393d4f6043
commit 9795add527
6 changed files with 27 additions and 2 deletions

View File

@ -142,6 +142,11 @@ class availability implements named_templatable, renderable {
['id' => $this->section->id, 'showonly' => 'availabilityconditions'] ['id' => $this->section->id, 'showonly' => 'availabilityconditions']
); );
$info = ['editurl' => $editurl->out(false)]; $info = ['editurl' => $editurl->out(false)];
if ($section->is_orphan()) {
$info['editing'] = false;
}
if (!$section->visible) { if (!$section->visible) {
return []; return [];
} else if (!$section->uservisible) { } else if (!$section->uservisible) {

View File

@ -277,6 +277,7 @@ class controlmenu extends basecontrolmenu {
} }
} }
if ( if (
!$isstealth &&
has_any_capability([ has_any_capability([
'moodle/course:movesections', 'moodle/course:movesections',
'moodle/course:update', 'moodle/course:update',

View File

@ -76,6 +76,10 @@ class visibility implements named_templatable, renderable {
$data->editing = $this->format->show_editor(); $data->editing = $this->format->show_editor();
if ($this->section->is_orphan()) {
$data->editing = false;
}
$data->notavailable = false; $data->notavailable = false;
$data->hiddenfromstudents = true; $data->hiddenfromstudents = true;
if ($data->editing && $this->is_section_visibility_editable()) { if ($data->editing && $this->is_section_visibility_editable()) {

View File

@ -83,6 +83,7 @@
"insertafter": true, "insertafter": true,
"numsections": 42, "numsections": 42,
"sitehome": false, "sitehome": false,
"isstealth": false,
"highlightedlabel" : "Highlighted" "highlightedlabel" : "Highlighted"
} }
}} }}
@ -163,6 +164,11 @@
<div id="coursecontentcollapse{{num}}" <div id="coursecontentcollapse{{num}}"
class="content {{^iscoursedisplaymultipage}}{{^sitehome}}{{^displayonesection}}course-content-item-content collapse {{^contentcollapsed}}show{{/contentcollapsed}}{{/displayonesection}}{{/sitehome}}{{/iscoursedisplaymultipage}}"> class="content {{^iscoursedisplaymultipage}}{{^sitehome}}{{^displayonesection}}course-content-item-content collapse {{^contentcollapsed}}show{{/contentcollapsed}}{{/displayonesection}}{{/sitehome}}{{/iscoursedisplaymultipage}}">
<div class="{{#hasavailability}}description{{/hasavailability}} my-3" data-for="sectioninfo"> <div class="{{#hasavailability}}description{{/hasavailability}} my-3" data-for="sectioninfo">
{{#isstealth}}
<div class="alert alert-warning">
{{#str}} orphansectionwarning, core_courseformat {{/str}}
</div>
{{/isstealth}}
{{#summary}} {{#summary}}
{{$ core_courseformat/local/content/section/summary }} {{$ core_courseformat/local/content/section/summary }}
{{> core_courseformat/local/content/section/summary }} {{> core_courseformat/local/content/section/summary }}

View File

@ -67,6 +67,7 @@ $string['courseindex'] = 'Course index';
$string['courseindexoptions'] = 'Course index options'; $string['courseindexoptions'] = 'Course index options';
$string['maxsectionaddmessage'] = 'You have reached the maximum number of sections allowed for a course.'; $string['maxsectionaddmessage'] = 'You have reached the maximum number of sections allowed for a course.';
$string['nobulkaction'] = 'No bulk actions available'; $string['nobulkaction'] = 'No bulk actions available';
$string['orphansectionwarning'] = 'This section and its content are not part of the course structure and are not visible to students. To use any of this content, move it to a different section.';
$string['preference:coursesectionspreferences'] = 'Section user preferences for course {$a}'; $string['preference:coursesectionspreferences'] = 'Section user preferences for course {$a}';
$string['privacy:metadata:preference:coursesectionspreferences'] = 'Section user preferences like collapsed and expanded.'; $string['privacy:metadata:preference:coursesectionspreferences'] = 'Section user preferences like collapsed and expanded.';
$string['section_hide_feedback'] = 'Course section {$a->name} hidden.'; $string['section_hide_feedback'] = 'Course section {$a->name} hidden.';

View File

@ -38,6 +38,8 @@ Feature: Courses should not lose subsection contents when mod_subsection is disa
And "Move" "link" should not exist in the "Subsection1" "core_courseformat > Section actions menu" And "Move" "link" should not exist in the "Subsection1" "core_courseformat > Section actions menu"
And "View" "link" should exist in the "Subsection1" "core_courseformat > Section actions menu" And "View" "link" should exist in the "Subsection1" "core_courseformat > Section actions menu"
And "Delete" "link" should exist in the "Subsection1" "core_courseformat > Section actions menu" And "Delete" "link" should exist in the "Subsection1" "core_courseformat > Section actions menu"
And "Permalink" "link" should not exist in the "Subsection1" "core_courseformat > Section actions menu"
And I should see "This section and its content are not part of the course structure" in the "Subsection1" "section"
Scenario: Students should not see orphaned subsections Scenario: Students should not see orphaned subsections
When I log in as "student1" When I log in as "student1"
@ -54,6 +56,7 @@ Feature: Courses should not lose subsection contents when mod_subsection is disa
And I should see "Subsection1" in the "page-content" "region" And I should see "Subsection1" in the "page-content" "region"
And I should see "Subactivity" in the "Subsection1" "section" And I should see "Subactivity" in the "Subsection1" "section"
And "Section 2" "section" should appear before "Subsection1" "section" And "Section 2" "section" should appear before "Subsection1" "section"
And I should see "This section and its content are not part of the course structure"
When I enable "subsection" "mod" plugin When I enable "subsection" "mod" plugin
And I am on "Course 1" course homepage with editing mode on And I am on "Course 1" course homepage with editing mode on
Then I should see "Activity Sample" in the "Section 1" "section" Then I should see "Activity Sample" in the "Section 1" "section"
@ -66,6 +69,7 @@ Feature: Courses should not lose subsection contents when mod_subsection is disa
And "Move" "link" should exist in the "Subsection1" "core_courseformat > Section actions menu" And "Move" "link" should exist in the "Subsection1" "core_courseformat > Section actions menu"
And "View" "link" should exist in the "Subsection1" "core_courseformat > Section actions menu" And "View" "link" should exist in the "Subsection1" "core_courseformat > Section actions menu"
And "Delete" "link" should exist in the "Subsection1" "core_courseformat > Section actions menu" And "Delete" "link" should exist in the "Subsection1" "core_courseformat > Section actions menu"
And I should not see "This section and its content are not part of the course structure"
@javascript @javascript
Scenario: Deleting the subsections with mod_subsection disabled should not break the course Scenario: Deleting the subsections with mod_subsection disabled should not break the course
@ -104,14 +108,18 @@ Feature: Courses should not lose subsection contents when mod_subsection is disa
And I press "Save changes" And I press "Save changes"
And I should see "Not available unless: You belong to a group in GX1" And I should see "Not available unless: You belong to a group in GX1"
And I disable "subsection" "mod" plugin And I disable "subsection" "mod" plugin
When I am on the "C1 > Subsection1" "course > section" page When I am on "Course 1" course homepage with editing mode on
And I turn editing mode on And I should see "This section and its content are not part of the course structure" in the "Subsection1" "section"
And I should see "Not available unless: You belong to a group in GX1"
And I should not see "Edit restrictions"
And I am on the "C1 > Subsection1" "course > section" page
And I click on "Edit" "icon" in the "[data-region='header-actions-container']" "css_element" And I click on "Edit" "icon" in the "[data-region='header-actions-container']" "css_element"
And I choose "Delete" in the open action menu And I choose "Delete" in the open action menu
And I click on "Delete" "button" in the "Delete section?" "dialogue" And I click on "Delete" "button" in the "Delete section?" "dialogue"
And I enable "subsection" "mod" plugin And I enable "subsection" "mod" plugin
Then I am on "Course 1" course homepage Then I am on "Course 1" course homepage
And I should see "Not available unless: You belong to a group in GX1" And I should see "Not available unless: You belong to a group in GX1"
And I should see "Edit restrictions"
@javascript @javascript
Scenario: Visibility is restored when a subsection is deleted while mod_subsection is disabled Scenario: Visibility is restored when a subsection is deleted while mod_subsection is disabled