Skip to content

Commit

Permalink
Fix: Added logging switch and do not applyLocks on completion reset w…
Browse files Browse the repository at this point in the history
…hen not reset (fixes adaptlearning#174) (adaptlearning#175)

Fix: Added logging switch and do not applyLocks on completion reset when not reset (fixes adaptlearning#174) (adaptlearning#175)
  • Loading branch information
oliverfoster authored Nov 28, 2022
1 parent 0dc1242 commit 426c583
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 2 deletions.
1 change: 1 addition & 0 deletions example.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,6 @@
// trickle button should be displayed
// Put in config.json
"_trickle": {
"_logState": false,
"_completionAttribute": "_isInteractionComplete|_isComplete", //(default=_isComplete)
}
1 change: 1 addition & 0 deletions js/TrickleButtonModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ export default class TrickleButtonModel extends ComponentModel {
*/
checkIfResetOnRevisit() {
if (this.isFinished() && !this.isStepLockedOnRevisit()) return;
if (!this.get('_isComplete') && !this.get('_isInteractionComplete')) return;
this.set({
_isComplete: false,
_isInteractionComplete: false
Expand Down
2 changes: 1 addition & 1 deletion js/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class TrickleController extends Backbone.Controller {
});
}

async onDataReady() {
async onDataReady() {
const trickleConfig = Adapt.config.get('_trickle');
if (trickleConfig?._isEnabled === false) return;

Expand Down
3 changes: 2 additions & 1 deletion js/models.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,9 @@ export function applyLocks() {
subsequentLockingModels.forEach((model, index) => {
const id = model.get('_id');
const isButtonModel = (model instanceof TrickleButtonModel);
const isTrickled = model.get('_isTrickled');
// Do not stop at TrickleButtonModels
model.set('_isTrickled', !isButtonModel);
if (isTrickled !== isButtonModel) model.set('_isTrickled', !isButtonModel);
// Store the new locking state of each model in the locks variable
// Don't unlock anything that was locked in a previous group
modelsById[id] = model;
Expand Down
9 changes: 9 additions & 0 deletions properties.schema
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,15 @@
"validators": [],
"help": "Controls whether the Trickle extension is enabled or disabled."
},
"_logState": {
"type": "boolean",
"required": true,
"default": false,
"title": "Log state",
"inputType": "Checkbox",
"validators": [],
"help": "Controls whether the Trickle extension logs its state to the browser console."
},
"_completionAttribute": {
"type": "string",
"required": false,
Expand Down
6 changes: 6 additions & 0 deletions schema/config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@
"title": "Trickle",
"default": {},
"properties": {
"_logState": {
"type": "boolean",
"title": "Log state",
"default": false,
"description": "Controls whether the Trickle extension logs its state to the browser console."
},
"_completionAttribute": {
"type": "string",
"title": "Completion attribute",
Expand Down

0 comments on commit 426c583

Please sign in to comment.