From 220aadd2832cea37409c361f75c31ca7e0024f5f Mon Sep 17 00:00:00 2001 From: Oliver Foster Date: Mon, 2 Sep 2024 11:48:31 +0100 Subject: [PATCH] Fix: Correctly calculate effective completion on blocks (fixes #63) (#64) * Fix: Correctly calculate effective completion on blocks (fixes #63) * Changed variable names for clarity --- js/adapt-contrib-branching.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/js/adapt-contrib-branching.js b/js/adapt-contrib-branching.js index f6efa06..e27eb79 100644 --- a/js/adapt-contrib-branching.js +++ b/js/adapt-contrib-branching.js @@ -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();