MDL-58985 course: Fix display of availability information
The availability info text can be either a one line short text such as "Hidden from students" but it can also be a long HTML formatted text with the list of all restricted access conditions. For the latter, using bootstrap labels was not appropriate. This extends the template context data with some boolean flags that allow to better distinguish the source and meaning of the availability information and display it accordingly. Credit goes to Marina Glancy for the solution idea.
This commit is contained in:
@@ -15,13 +15,47 @@
|
||||
along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
}}
|
||||
{{!
|
||||
Availability info.
|
||||
@template core/availability_info
|
||||
|
||||
Renders the availability info on the course outline page.
|
||||
|
||||
Availability info can be displayed for activity modules or whole course
|
||||
sections. Activity modules can be either hidden from students, or available
|
||||
but not shown on course page (stealth), or the access can be restricted by
|
||||
configured conditions. Sections can be hidden.
|
||||
|
||||
Classes required for JS:
|
||||
* none
|
||||
|
||||
Data attributes required for JS:
|
||||
* none
|
||||
|
||||
Context variables required for this template:
|
||||
* classes String list of CSS classes for the wrapping element
|
||||
* text HTML formatted text with the actual availability information
|
||||
* ishidden Boolean flag indiciating that the item is hidden from students
|
||||
* isstealth Boolean flag indicating that the item is in stealth mode
|
||||
* isrestricted Boolean flag indicating that restricted access conditions apply
|
||||
* isfullinfo Boolean flag indicating that the full list of restricted
|
||||
access conditions is displayed (aka teacher's view).
|
||||
|
||||
Example context (json):
|
||||
{ "classes": "", "text": "This activity is not available" }
|
||||
{
|
||||
"classes": "",
|
||||
"text": "Not available unless: <ul><li>It is on or after <strong>8 June 2012</strong></li></ul>",
|
||||
"ishidden": 0,
|
||||
"isstealth": 0,
|
||||
"isrestricted": 1,
|
||||
"isfullinfo": 1
|
||||
}
|
||||
}}
|
||||
{{#text}}
|
||||
<div class="availabilityinfo {{classes}}">
|
||||
{{^isrestricted}}
|
||||
<span class="label label-info">{{{text}}}</span>
|
||||
{{/isrestricted}}
|
||||
{{#isrestricted}}
|
||||
<span class="label label-info">{{#str}}restricted, core{{/str}}</span> {{{text}}}
|
||||
{{/isrestricted}}
|
||||
</div>
|
||||
{{/text}}
|
||||
|
||||
Reference in New Issue
Block a user