Skip to content

Commit

Permalink
New: Allow course item title to be overridden (fixes #205) (#208)
Browse files Browse the repository at this point in the history
* Allow course title to be overridden

* Schemas docs and readme update
  • Loading branch information
swashbuck authored Mar 28, 2024
1 parent a686de6 commit cd9adf0
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 17 deletions.
26 changes: 24 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,20 +63,42 @@ Add to _course.json_ under _\_globals.\_extensions_.
>> **text** (string): The text of the tooltip
Add to _components.json_, _blocks.json_ or _articles.json_.
Add to _course.json_.

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

> **\_isEnabled** (boolean): Turns **Page Level Progress** on and off. Acceptable values are `true` and `false`.
> **title** (string): Alternate course title to display when using `_showAtCourseLevel: true`.
> **\_isCompletionIndicatorEnabled** (boolean): Adds a completion indicator next to the title of a component, block, article, page or menu. Acceptable values are `true` and `false`.
> **\_isShownInNavigationBar** (boolean): Allows **Page Level Progress** to appear in the navigation bar. Acceptable values are `true` and `false`.
> **\_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.
> **\_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).
> **\_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`.
Add to _contentObjects.json_.

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

> **\_isEnabled** (boolean): Turns **Page Level Progress** on and off. Acceptable values are `true` and `false`.
> **\_isCompletionIndicatorEnabled** (boolean): Adds a completion indicator next to the title of a component, block, article, page or menu. Acceptable values are `true` and `false`.
> **\_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).
> **\_excludeAssessments** (boolean): If true, prevents assessments from being included in calculations for page level progress.
Add to _components.json_, _blocks.json_ or _articles.json_.

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

> **\_isEnabled** (boolean): Turns **Page Level Progress** on and off. Acceptable values are `true` and `false`.
> **\_isCompletionIndicatorEnabled** (boolean): Adds a completion indicator next to the title of a component, block, article, page or menu. Acceptable values are `true` and `false`.
### Accessibility

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).
Expand Down
15 changes: 2 additions & 13 deletions example.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

"_pageLevelProgress": {
"_isEnabled": true,
"title": "",
"_showPageCompletion": true,
"_isCompletionIndicatorEnabled": true,
"_isShownInNavigationBar": true,
Expand All @@ -30,19 +31,7 @@
"_excludeAssessments": false
}

// To go on an article
"_pageLevelProgress": {
"_isEnabled": true,
"_isCompletionIndicatorEnabled": true
}

// To go on a block
"_pageLevelProgress": {
"_isEnabled": true,
"_isCompletionIndicatorEnabled": true
}

// To go on a component
// To go on an article, block or component
"_pageLevelProgress": {
"_isEnabled": true,
"_isCompletionIndicatorEnabled": true
Expand Down
4 changes: 4 additions & 0 deletions js/getPageLevelProgressItems.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ export default function getPageLevelProgressItemsJSON(parentModel) {
});
const availableItems = completionCalculations.filterAvailableChildren(currentPageItems);
const enabledProgressItems = completionCalculations.getPageLevelProgressEnabledModels(availableItems);
const modelPLP = model.get('_pageLevelProgress');
if (modelPLP?.title) {
model.set('altTitle', modelPLP.title);
}
if (!enabledProgressItems.length) {
return {
...model.toJSON(),
Expand Down
10 changes: 10 additions & 0 deletions properties.schema
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,16 @@
"validators": [],
"help": "Controls whether the Page Level Progress extension is enabled or disabled."
},
"title": {
"type": "string",
"required": true,
"default": "",
"title": "Alternate title",
"help": "Alternate title to display for the course",
"inputType": "Text",
"validators": [],
"translatable": true
},
"_showPageCompletion": {
"type": "boolean",
"required": true,
Expand Down
9 changes: 9 additions & 0 deletions schema/course.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,15 @@
"title": "Enable Page Level Progress",
"default": true
},
"title": {
"type": "string",
"title": "Alternate title",
"description": "Alternate title to display for the course",
"default": "",
"_adapt": {
"translatable": true
}
},
"_showPageCompletion": {
"type": "boolean",
"title": "Include overall page completion",
Expand Down
5 changes: 3 additions & 2 deletions templates/pageLevelProgressItem.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export default function PageLevelProgressItem(props) {
_isVisible,
_isComplete,
title,
altTitle,
_id,
_type,
_children
Expand Down Expand Up @@ -55,12 +56,12 @@ export default function PageLevelProgressItem(props) {
_isOptional && `${_globals._extensions._pageLevelProgress.optionalContent}.`,
!_isOptional && _isComplete && `${_globals._accessibility._ariaLabels.complete}.`,
!_isOptional && !_isComplete && `${_globals._accessibility._ariaLabels.incomplete}.`,
compile(a11y.normalize(title))
compile(a11y.normalize(altTitle || title))
])}
>

<span className="pagelevelprogress__item-title drawer__item-title">
<span className="pagelevelprogress__item-title-inner drawer__item-title-inner" dangerouslySetInnerHTML={{ __html: compile(title, props) }}>
<span className="pagelevelprogress__item-title-inner drawer__item-title-inner" dangerouslySetInnerHTML={{ __html: compile(altTitle || title, props) }}>
</span>
</span>

Expand Down

0 comments on commit cd9adf0

Please sign in to comment.