Skip to content

Commit

Permalink
Merged with master
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverfoster committed Jun 12, 2024
2 parents c480f90 + df1ae02 commit 0f37cef
Show file tree
Hide file tree
Showing 11 changed files with 47 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* A sentence describing each fix

### Update
* A sentence describing each udpate
* A sentence describing each update

### New
* A sentence describing each new feature
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,11 @@ Add to _course.json_.
> **\_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).
> **\_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
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "adapt-contrib-pageLevelProgress",
"version": "7.6.1",
"version": "7.9.0",
"framework": ">=5.31.0",
"homepage": "https://github.com/adaptlearning/adapt-contrib-pageLevelProgress",
"bugs": "https://github.com/adaptlearning/adapt-contrib-pageLevelProgress/issues",
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
13 changes: 11 additions & 2 deletions js/PageLevelProgressIndicatorView.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import Adapt from 'core/js/adapt';
import React from 'react';
import ReactDOM from 'react-dom';
import { templates } from 'core/js/reactHelpers';
import ItemsComponentModel from 'core/js/models/itemsComponentModel';

class PageLevelProgressIndicatorView extends Backbone.View {

Expand Down Expand Up @@ -34,7 +35,7 @@ class PageLevelProgressIndicatorView extends Backbone.View {
} else {
this.listenTo(Adapt, 'remove', this.remove);
}
this.listenTo(Adapt.course, 'bubble:change:_isComplete', this.refresh);
this.listenTo(Adapt.course, 'bubble:change:_isComplete bubble:change:_isVisited', this.refresh);
}

setPercentageComplete() {
Expand All @@ -47,7 +48,15 @@ class PageLevelProgressIndicatorView extends Backbone.View {
}

calculatePercentage() {
return this.model.get('_isComplete') ? 100 : 0;
const isPresentationComponentWithItems = (!this.model.isTypeGroup('question') && this.model instanceof ItemsComponentModel);
const isComplete = this.model.get('_isComplete');
if (isComplete) return 100;
if (isPresentationComponentWithItems) {
const children = this.model.getChildren();
const visited = children.filter(child => child.get('_isVisited'));
return Math.round(visited.length / children.length * 100);
}
return 0;
}

render() {
Expand Down
8 changes: 7 additions & 1 deletion 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 All @@ -91,7 +97,7 @@ export default class PageLevelProgressNavigationView extends NavigationButtonVie
onProgressClicked(event) {
if (event && event.preventDefault) event.preventDefault();
this.$el.attr('aria-expanded', true);
drawer.triggerCustomView(new PageLevelProgressView({
drawer.openCustomView(new PageLevelProgressView({
collection: this.collection
}).$el, false, this.model.get('_drawerPosition'));
}
Expand Down
2 changes: 1 addition & 1 deletion js/adapt-contrib-pageLevelProgress.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class PageLevelProgress extends Backbone.Controller {
'router:contentObject': this.renderNavigationView
});

this.listenTo(Adapt.course, 'bubble:change:_isComplete', this.onCompletionChange);
this.listenTo(Adapt.course, 'bubble:change:_isComplete bubble:change:_isVisited', this.onCompletionChange);
}

onCompletionChange(event) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "adapt-contrib-pageLevelProgress",
"version": "7.6.1",
"version": "7.9.0",
"framework": ">=5.31.0",
"homepage": "https://github.com/adaptlearning/adapt-contrib-pageLevelProgress",
"bugs": "https://github.com/adaptlearning/adapt-contrib-pageLevelProgress/issues",
Expand Down
13 changes: 11 additions & 2 deletions properties.schema
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@
"title": "Show page completion",
"inputType": "Checkbox",
"validators": [],
"help": "Controls whether the progress calculations are based on all components - or only those that are set to be displayed in Page Level Progress."
"help": "When enabled, the overall course progress will be calculated for all components. When disabled, only components that are set to be displayed in Page Level Progress will be included in the calculations. Defaults to enabled."
},
"_isCompletionIndicatorEnabled": {
"type": "boolean",
Expand Down 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 Expand Up @@ -201,7 +210,7 @@
"title": "Show page completion",
"inputType": "Checkbox",
"validators": [],
"help": "Controls whether the progress calculations for this page are based on all components and the overall page - or only the components that are set to be displayed in Page Level Progress."
"help": "When enabled, the overall progress for this page will be calculated for all components. When disabled, only components that are set to be displayed in Page Level Progress will be included in the calculations. Defaults to enabled."
},
"_isCompletionIndicatorEnabled": {
"type": "boolean",
Expand Down
2 changes: 1 addition & 1 deletion schema/contentobject.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"_showPageCompletion": {
"type": "boolean",
"title": "Include overall page completion",
"description": "Controls whether the progress calculations for this page are based on all components and the overall page - or only the components that are set to be displayed in Page Level Progress",
"description": "When enabled, the overall progress for this page will be calculated for all components. When disabled, only components that are set to be displayed in Page Level Progress will be included in the calculations. Defaults to enabled.",
"default": true
},
"_isCompletionIndicatorEnabled": {
Expand Down
8 changes: 7 additions & 1 deletion schema/course.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@
"_showPageCompletion": {
"type": "boolean",
"title": "Include overall page completion",
"description": "Controls whether the progress calculations are based on all components - or only those that are set to be displayed in Page Level Progress",
"description": "When enabled, the overall course progress will be calculated for all components. When disabled, only components that are set to be displayed in Page Level Progress will be included in the calculations. Defaults to enabled.",
"default": true
},
"_isCompletionIndicatorEnabled": {
Expand All @@ -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 0f37cef

Please sign in to comment.