MDL-87929 output: Display availability expanded in restricted pages
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
issueNumber: MDL-87929
|
||||
notes:
|
||||
theme:
|
||||
- message: >-
|
||||
The `core_courseformat\base` class now includes
|
||||
`set_show_restrictions_expanded()` and `get_show_restrictions_expanded()`
|
||||
to allow course formats to define whether restrictions are displayed
|
||||
as expanded (defaulting to collapsed).
|
||||
type: improved
|
||||
@@ -196,10 +196,15 @@ Feature: Display availability for activities and sections
|
||||
And I am on the "C1" "Course" page logged in as "teacher1"
|
||||
And I turn editing mode on
|
||||
And I add the "Navigation" block if not present
|
||||
# Add a restriction to section 1 (visible to students).
|
||||
# Add a couple of restrictions to section 1 (visible to students).
|
||||
And I edit the section "1"
|
||||
And I set the following fields to these values:
|
||||
| Access restrictions | Grouping: GX1 |
|
||||
And I expand all fieldsets
|
||||
And I press "Add restriction..."
|
||||
And I click on "Date" "button" in the "Add restriction..." "dialogue"
|
||||
And I set the field "direction" to "until"
|
||||
And I set the field "x[year]" to "2020"
|
||||
And I press "Save changes"
|
||||
# Change to student view.
|
||||
And I am on the "Course 1" "Course" page logged in as "student1"
|
||||
@@ -207,7 +212,9 @@ Feature: Display availability for activities and sections
|
||||
When I click on "Section 1" "link" in the "Navigation" "block"
|
||||
# Section 1 should be visible and show info.
|
||||
And I should see "Section 1" in the "page-header" "region"
|
||||
And I should see "Not available unless" in the "region-main" "region"
|
||||
And I should see "It is before end of" in the "region-main" "region"
|
||||
And I should not see "Show more" in the "region-main" "region"
|
||||
And I should not see "Show less" in the "region-main" "region"
|
||||
And "Page 1" "link" should not exist in the "region-main" "region"
|
||||
# Check the logs.
|
||||
And I am on the "C1" "Course" page logged in as "teacher1"
|
||||
@@ -234,9 +241,14 @@ Feature: Display availability for activities and sections
|
||||
| name | course | idnumber |
|
||||
| GX1 | C1 | GXI1 |
|
||||
And I am on the "Glossary 1" "glossary activity editing" page logged in as "teacher1"
|
||||
# Add a restriction to Glossary 1 (visible to students).
|
||||
# Add a couple of restrictions to Glossary 1 (visible to students).
|
||||
And I set the following fields to these values:
|
||||
| Access restrictions | Grouping: GX1 |
|
||||
And I expand all fieldsets
|
||||
And I press "Add restriction..."
|
||||
And I click on "Date" "button" in the "Add restriction..." "dialogue"
|
||||
And I set the field "direction" to "until"
|
||||
And I set the field "x[year]" to "2020"
|
||||
And I press "Save and return to course"
|
||||
And I turn editing mode on
|
||||
And I add the "Navigation" block if not present
|
||||
@@ -247,7 +259,9 @@ Feature: Display availability for activities and sections
|
||||
When I click on "Glossary 1" "link" in the "Navigation" "block"
|
||||
# Glossary 1 should be visible and show info.
|
||||
Then I should see "Glossary 1" in the "page-header" "region"
|
||||
And I should see "Not available unless" in the "region-main" "region"
|
||||
And I should see "It is before end of" in the "region-main" "region"
|
||||
And I should not see "Show more" in the "region-main" "region"
|
||||
And I should not see "Show less" in the "region-main" "region"
|
||||
And "Add a new entry" "link" should not exist
|
||||
# Check the logs.
|
||||
And I am on the "C1" "Course" page logged in as "teacher1"
|
||||
|
||||
@@ -63,6 +63,8 @@ class restricted_section {
|
||||
$context = \context_course::instance($course->id);
|
||||
$format = course_get_format($course->id);
|
||||
$format->set_sectionid($section->id);
|
||||
// We always want to show the restrictions expanded in the restricted section page.
|
||||
$format->set_show_restrictions_expanded(true);
|
||||
$outputclass = $format->get_output_classname('content');
|
||||
$sectionoutput = new $outputclass($format);
|
||||
$PAGE->set_url('/course/section.php', ['id' => $section->id]);
|
||||
|
||||
@@ -81,6 +81,8 @@ abstract class base {
|
||||
protected $singlesection = null;
|
||||
/** @var int|null the sectionid when a single section is selected, null when multiple sections are displayed. */
|
||||
protected $singlesectionid = null;
|
||||
/** @var bool Whether restrictions should be expanded. */
|
||||
protected $showrestrictionsexpanded = false;
|
||||
/** @var course_modinfo the current course modinfo, please use course_format::get_modinfo() */
|
||||
private $modinfo = null;
|
||||
/** @var array cached instances */
|
||||
@@ -664,6 +666,24 @@ abstract class base {
|
||||
return $this->singlesectionid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set whether restrictions should be expanded.
|
||||
*
|
||||
* @param bool $expanded True if restrictions should be expanded, false otherwise.
|
||||
*/
|
||||
public function set_show_restrictions_expanded(bool $expanded): void {
|
||||
$this->showrestrictionsexpanded = $expanded;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get whether restrictions should be expanded.
|
||||
*
|
||||
* @return bool True if restrictions should be expanded, false otherwise.
|
||||
*/
|
||||
public function get_show_restrictions_expanded(): bool {
|
||||
return $this->showrestrictionsexpanded;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the current section number to display.
|
||||
* Some formats has the hability to swith from one section to multiple sections per page.
|
||||
|
||||
@@ -197,6 +197,10 @@ class availability implements named_templatable, renderable {
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->format->get_show_restrictions_expanded()) {
|
||||
$data->showrestrictionsexpanded = true;
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
@@ -34,13 +34,16 @@
|
||||
{{/excerpt}}
|
||||
{{#excerpt}}
|
||||
{{< core/showmore }}
|
||||
{{$defaultstatus}}
|
||||
{{^showrestrictionsexpanded}} collapsed {{/showrestrictionsexpanded}}
|
||||
{{/defaultstatus}}
|
||||
{{$collapsedcontent}}
|
||||
{{#pix}}t/unlock, core{{/pix}} <span class="availability-excerpt"> {{{excerpt}}} ... </span>
|
||||
{{/collapsedcontent}}
|
||||
{{$expandedcontent}}
|
||||
{{#pix}}t/unlock, core{{/pix}} {{{text}}}
|
||||
{{/expandedcontent}}
|
||||
{{$buttonextraclasses}}fw-bold{{/buttonextraclasses}}
|
||||
{{$buttonextraclasses}}fw-bold {{#showrestrictionsexpanded}} d-none {{/showrestrictionsexpanded}}{{/buttonextraclasses}}
|
||||
{{$collapsedextraclasses}}text-truncate pe-2 {{#editing}}mt-2{{/editing}}{{/collapsedextraclasses}}
|
||||
{{$expandedextraclasses}}
|
||||
{{^editing}}py-2{{/editing}}
|
||||
|
||||
@@ -61,7 +61,10 @@
|
||||
{{! Availability }}
|
||||
{{#modavailability}}
|
||||
{{$ core_courseformat/local/content/cm/availability }}
|
||||
{{> core_courseformat/local/content/cm/availability }}
|
||||
{{< core_courseformat/local/content/cm/availability }}
|
||||
{{$buttonextraclasses}} d-none {{/buttonextraclasses}}
|
||||
{{$defaultstatus}} expanded {{/defaultstatus}}
|
||||
{{/core_courseformat/local/content/cm/availability }}
|
||||
{{/ core_courseformat/local/content/cm/availability }}
|
||||
{{/modavailability}}
|
||||
</div>
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
"expandedextraclasses": "bg-secondary"
|
||||
}
|
||||
}}
|
||||
<div class="showmore-container collapsed {{$extraclasses}}{{extraclasses}}{{/extraclasses}}" data-region="showmore">
|
||||
<div class="showmore-container {{$defaultstatus}} collapsed {{/defaultstatus}} {{$extraclasses}}{{extraclasses}}{{/extraclasses}}" data-region="showmore">
|
||||
<button
|
||||
type="button"
|
||||
class="showmore-button btn btn-sm btn-link p-0 {{$buttonextraclasses}}{{buttonextraclasses}}{{/buttonextraclasses}}"
|
||||
|
||||
Reference in New Issue
Block a user