Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New: Add option to show course-level progress on PLP nav button (fix #226) #227

Merged
merged 5 commits into from
Jun 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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