Skip to content

Commit cd9adf0

Browse files
authored
New: Allow course item title to be overridden (fixes #205) (#208)
* Allow course title to be overridden * Schemas docs and readme update
1 parent a686de6 commit cd9adf0

6 files changed

+52
-17
lines changed

README.md

+24-2
Original file line numberDiff line numberDiff line change
@@ -63,20 +63,42 @@ Add to _course.json_ under _\_globals.\_extensions_.
6363
6464
>> **text** (string): The text of the tooltip
6565
66-
Add to _components.json_, _blocks.json_ or _articles.json_.
66+
Add to _course.json_.
6767

6868
**\_pageLevelProgress** (object): The Page Level Progress object that contains a value for **\_isEnabled**.
6969

7070
> **\_isEnabled** (boolean): Turns **Page Level Progress** on and off. Acceptable values are `true` and `false`.
7171
72+
> **title** (string): Alternate course title to display when using `_showAtCourseLevel: true`.
73+
7274
> **\_isCompletionIndicatorEnabled** (boolean): Adds a completion indicator next to the title of a component, block, article, page or menu. Acceptable values are `true` and `false`.
7375
7476
> **\_isShownInNavigationBar** (boolean): Allows **Page Level Progress** to appear in the navigation bar. Acceptable values are `true` and `false`.
7577
76-
> **\_showPageCompletion** (boolean): Set to `false` to have the overall progress calculated only from components that have been set to display in **Page Level Progress** (ignoring the completion of those that haven't). This property should be applied only to _course.json_ and _contentObjects.json_; adding it to _components.json_ will have no effect.
78+
> **\_showPageCompletion** (boolean): Set to `false` to have the overall progress calculated only from components that have been set to display in **Page Level Progress** (ignoring the completion of those that haven't).
7779
7880
> **\_showAtCourseLevel** (boolean): Allows **Page Level Progress** to display all content objects and the current page components together, or just the current page components as before. Acceptable values are `true` and `false`.
7981
82+
Add to _contentObjects.json_.
83+
84+
**\_pageLevelProgress** (object): The Page Level Progress object that contains a value for **\_isEnabled**.
85+
86+
> **\_isEnabled** (boolean): Turns **Page Level Progress** on and off. Acceptable values are `true` and `false`.
87+
88+
> **\_isCompletionIndicatorEnabled** (boolean): Adds a completion indicator next to the title of a component, block, article, page or menu. Acceptable values are `true` and `false`.
89+
90+
> **\_showPageCompletion** (boolean): Set to `false` to have the overall progress calculated only from components that have been set to display in **Page Level Progress** (ignoring the completion of those that have not).
91+
92+
> **\_excludeAssessments** (boolean): If true, prevents assessments from being included in calculations for page level progress.
93+
94+
Add to _components.json_, _blocks.json_ or _articles.json_.
95+
96+
**\_pageLevelProgress** (object): The Page Level Progress object that contains a value for **\_isEnabled**.
97+
98+
> **\_isEnabled** (boolean): Turns **Page Level Progress** on and off. Acceptable values are `true` and `false`.
99+
100+
> **\_isCompletionIndicatorEnabled** (boolean): Adds a completion indicator next to the title of a component, block, article, page or menu. Acceptable values are `true` and `false`.
101+
80102
### Accessibility
81103

82104
Several elements of **Page Level Progress** have been assigned a label using the [aria-label](https://github.com/adaptlearning/adapt_framework/wiki/Aria-Labels) attribute: **pageLevelProgress**, **pageLevelProgressIndicatorBar** and **pageLevelProgressMenuBar**. These labels are not visible elements. They are utilized by assistive technology such as screen readers. Should the label texts need to be customised, they can be found within the **globals** object in [_properties.schema_](https://github.com/adaptlearning/adapt-contrib-pageLevelProgress/blob/master/properties.schema).

example.json

+2-13
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
"_pageLevelProgress": {
1818
"_isEnabled": true,
19+
"title": "",
1920
"_showPageCompletion": true,
2021
"_isCompletionIndicatorEnabled": true,
2122
"_isShownInNavigationBar": true,
@@ -30,19 +31,7 @@
3031
"_excludeAssessments": false
3132
}
3233

33-
// To go on an article
34-
"_pageLevelProgress": {
35-
"_isEnabled": true,
36-
"_isCompletionIndicatorEnabled": true
37-
}
38-
39-
// To go on a block
40-
"_pageLevelProgress": {
41-
"_isEnabled": true,
42-
"_isCompletionIndicatorEnabled": true
43-
}
44-
45-
// To go on a component
34+
// To go on an article, block or component
4635
"_pageLevelProgress": {
4736
"_isEnabled": true,
4837
"_isCompletionIndicatorEnabled": true

js/getPageLevelProgressItems.js

+4
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ export default function getPageLevelProgressItemsJSON(parentModel) {
1919
});
2020
const availableItems = completionCalculations.filterAvailableChildren(currentPageItems);
2121
const enabledProgressItems = completionCalculations.getPageLevelProgressEnabledModels(availableItems);
22+
const modelPLP = model.get('_pageLevelProgress');
23+
if (modelPLP?.title) {
24+
model.set('altTitle', modelPLP.title);
25+
}
2226
if (!enabledProgressItems.length) {
2327
return {
2428
...model.toJSON(),

properties.schema

+10
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,16 @@
127127
"validators": [],
128128
"help": "Controls whether the Page Level Progress extension is enabled or disabled."
129129
},
130+
"title": {
131+
"type": "string",
132+
"required": true,
133+
"default": "",
134+
"title": "Alternate title",
135+
"help": "Alternate title to display for the course",
136+
"inputType": "Text",
137+
"validators": [],
138+
"translatable": true
139+
},
130140
"_showPageCompletion": {
131141
"type": "boolean",
132142
"required": true,

schema/course.schema.json

+9
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,15 @@
118118
"title": "Enable Page Level Progress",
119119
"default": true
120120
},
121+
"title": {
122+
"type": "string",
123+
"title": "Alternate title",
124+
"description": "Alternate title to display for the course",
125+
"default": "",
126+
"_adapt": {
127+
"translatable": true
128+
}
129+
},
121130
"_showPageCompletion": {
122131
"type": "boolean",
123132
"title": "Include overall page completion",

templates/pageLevelProgressItem.jsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export default function PageLevelProgressItem(props) {
1414
_isVisible,
1515
_isComplete,
1616
title,
17+
altTitle,
1718
_id,
1819
_type,
1920
_children
@@ -55,12 +56,12 @@ export default function PageLevelProgressItem(props) {
5556
_isOptional && `${_globals._extensions._pageLevelProgress.optionalContent}.`,
5657
!_isOptional && _isComplete && `${_globals._accessibility._ariaLabels.complete}.`,
5758
!_isOptional && !_isComplete && `${_globals._accessibility._ariaLabels.incomplete}.`,
58-
compile(a11y.normalize(title))
59+
compile(a11y.normalize(altTitle || title))
5960
])}
6061
>
6162

6263
<span className="pagelevelprogress__item-title drawer__item-title">
63-
<span className="pagelevelprogress__item-title-inner drawer__item-title-inner" dangerouslySetInnerHTML={{ __html: compile(title, props) }}>
64+
<span className="pagelevelprogress__item-title-inner drawer__item-title-inner" dangerouslySetInnerHTML={{ __html: compile(altTitle || title, props) }}>
6465
</span>
6566
</span>
6667

0 commit comments

Comments
 (0)