Skip to content

_isLocked set via _lockType is overridden by trickle #584

Closed
@oliverfoster

Description

Subject of the issue

We have a plugin that shows blocks in an article where the article has _lockType: sequential on its block models, the article also has trickle enabled at the article level.

The block models are set to _isLocked: true initially:

child.set('_isLocked', isLockedByPreviousChild);

Trickle then overrides the block models when it comes to set the _isLocked attributes on the course descendants:
https://github.com/adaptlearning/adapt-contrib-trickle/blob/6a84eb56fef11116860c4fabdd0d41281498fd14/js/models.js#L239

  // Apply only changed locking states
  Object.entries(locks).forEach(([ id, isModelLocked ]) => {
    const model = modelsById[id];
    const wasLocked = model.get('_isLocked');
    if (wasLocked === isModelLocked) return;
    model.set('_isLocked', isModelLocked);
  });

This can be fixed using the lockedAttributes for the AdaptModel, allowing trickle and core to force the model attribute to _isLocked: true until the same plugin unlocks it. Core essentially overrides trickle at the attribute level until core is ready to unlock the model.

Metadata

Assignees

Labels

Type

No type

Projects

  • Status

    Recently Released

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions