Skip to content

Commit

Permalink
New: Add option to show course-level progress on PLP nav button (fixes
Browse files Browse the repository at this point in the history
…#226) (#227)

* Add course level completion option to nav button

* Allow _showAtCourseLevel to be false when using course level for the nav bar

* Documentation and schemas

* Update new property name to _useCourseProgressInNavigationButton
  • Loading branch information
swashbuck authored Jun 7, 2024
1 parent a0941e0 commit af6fbab
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 2 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ Add to _course.json_.
> **\_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). Defaults to `true`.
> **\_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`.
> **\_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`. Defaults to `false`.
> **\_useCourseProgressInNavigationButton** (boolean): Allows **Page Level Progress** to use course-level completion for the navigation button instead of page-level completion. Defaults to `false`.
Add to _contentObjects.json_.

Expand Down
3 changes: 2 additions & 1 deletion example.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
"_showPageCompletion": true,
"_isCompletionIndicatorEnabled": true,
"_isShownInNavigationBar": true,
"_showAtCourseLevel": false
"_showAtCourseLevel": false,
"_useCourseProgressInNavigationButton": false
}

// To go on a contentObject
Expand Down
6 changes: 6 additions & 0 deletions js/PageLevelProgressNavigationView.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ export default class PageLevelProgressNavigationView extends NavigationButtonVie
}

_getPageCompletionPercentage() {
const courseConfig = Adapt.course.get('_pageLevelProgress');

if (courseConfig._useCourseProgressInNavigationButton) {
return completionCalculations.calculatePercentageComplete(Adapt.course);
}

return completionCalculations.calculatePercentageComplete(this.pageModel, true);
}

Expand Down
9 changes: 9 additions & 0 deletions properties.schema
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,15 @@
"inputType": "Checkbox",
"validators": [],
"help": "Controls whether to display all content objects and the current page components together, or just the current page components."
},
"_useCourseProgressInNavigationButton": {
"type": "boolean",
"required": true,
"default": false,
"title": "Use course-level progress on navigation button",
"inputType": "Checkbox",
"validators": [],
"help": "When enabled, the navigation button will show course-level progress rather than page-level progress. Defaults to disabled."
}
}
}
Expand Down
6 changes: 6 additions & 0 deletions schema/course.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,12 @@
"title": "Display all content objects and the current page components",
"description": "Controls whether to display all content objects and the current page components together, or just the current page components",
"default": false
},
"_useCourseProgressInNavigationButton": {
"type": "boolean",
"title": "Use course-level progress on navigation button",
"description": "When enabled, the navigation button will show course-level progress rather than page-level progress. Defaults to disabled.",
"default": false
}
}
}
Expand Down

0 comments on commit af6fbab

Please sign in to comment.