Skip to content

Commit

Permalink
Fix: Correctly calculate effective completion on blocks (fixes #63) (#64
Browse files Browse the repository at this point in the history
)

* Fix: Correctly calculate effective completion on blocks (fixes #63)

* Changed variable names for clarity
  • Loading branch information
oliverfoster authored Sep 2, 2024
1 parent 1d237a7 commit 220aadd
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions js/adapt-contrib-branching.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,12 +150,14 @@ class Branching extends Backbone.Controller {
* @param {Backbone.model} model
*/
checkIfIsEffectivelyComplete(model) {
const childModel = model.getParent();
if (!childModel) return;
const isBranchChild = childModel.get('_isBranchChild');
const blockModel = model.get('_type') === 'component'
? model.getParent()
: model;
if (!blockModel) return;
const isBranchChild = blockModel.get('_isBranchChild');
if (!isBranchChild) return;
const containerModel = childModel.getParent();
const set = this.getSubsetByModelId(containerModel.get('_id'));
const articleModel = blockModel.getParent();
const set = this.getSubsetByModelId(articleModel.get('_id'));
if (!set?.isEffectivelyComplete) return;
// Allow assessment to complete at the end, before the last trickle button is clicked
set.enableParentCompletion();
Expand Down

0 comments on commit 220aadd

Please sign in to comment.