diff --git a/README.md b/README.md index 37be619..b0d1c45 100644 --- a/README.md +++ b/README.md @@ -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_. diff --git a/example.json b/example.json index 8be68f9..4dfecf2 100644 --- a/example.json +++ b/example.json @@ -20,7 +20,8 @@ "_showPageCompletion": true, "_isCompletionIndicatorEnabled": true, "_isShownInNavigationBar": true, - "_showAtCourseLevel": false + "_showAtCourseLevel": false, + "_useCourseProgressInNavigationButton": false } // To go on a contentObject diff --git a/js/PageLevelProgressNavigationView.js b/js/PageLevelProgressNavigationView.js index b3129ff..85341cc 100644 --- a/js/PageLevelProgressNavigationView.js +++ b/js/PageLevelProgressNavigationView.js @@ -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); } diff --git a/properties.schema b/properties.schema index e9df3b8..8aac358 100644 --- a/properties.schema +++ b/properties.schema @@ -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." } } } diff --git a/schema/course.schema.json b/schema/course.schema.json index 370657b..52668a8 100644 --- a/schema/course.schema.json +++ b/schema/course.schema.json @@ -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 } } }