Skip to content

Commit

Permalink
Fix: Return correct calculation for presentation components with items (
Browse files Browse the repository at this point in the history
fixes #228) (#229)

* Fix incorrect calculation for presentation components with items

* Update js/PageLevelProgressIndicatorView.js

Co-authored-by: Oliver Foster <[email protected]>

* Update js/PageLevelProgressIndicatorView.js

Co-authored-by: Oliver Foster <[email protected]>

* Update js/PageLevelProgressIndicatorView.js

Co-authored-by: Oliver Foster <[email protected]>

---------

Co-authored-by: Oliver Foster <[email protected]>
  • Loading branch information
swashbuck and oliverfoster authored Jun 7, 2024
1 parent ab3b4a4 commit b327bb7
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion js/PageLevelProgressIndicatorView.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,14 @@ class PageLevelProgressIndicatorView extends Backbone.View {

calculatePercentage() {
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 this.model.get('_isComplete') ? 100 : 0;
return 0
}

render() {
Expand Down

0 comments on commit b327bb7

Please sign in to comment.