Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

checkCompletionStatusFor completes when all child models are unavailable #448

Open
danielghost opened this issue Oct 3, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@danielghost
Copy link
Contributor

As Array.every returns true when invoked on an empty array, the following lines will set models to _isComplete: true if all child models are unavailable (_isAvailable: false):
https://github.com/adaptlearning/adapt-contrib-core/blob/master/js/models/adaptModel.js#L319
https://github.com/adaptlearning/adapt-contrib-core/blob/master/js/models/adaptModel.js#L326-L328

@oliverfoster
Copy link
Member

oliverfoster commented Oct 3, 2023

It's not so much an issue with every necessarily, perhaps more that we haven't defined the behaviour of completion when there are no _isAvailable = true children, which should probably become its own return early statement.

Are we saying that an "empty" parent should not automatically complete? Whereas an empty parent does currently complete.

checkCompletionStatusFor(completionAttribute = '_isComplete') {
let completed = false;
const children = this.getAvailableChildModels();
const requireCompletionOf = this.get('_requireCompletionOf');

Something like:

 checkCompletionStatusFor(completionAttribute = '_isComplete') { 
   let completed = false; 
   const children = this.getAvailableChildModels(); 
   const hasNoAvailableChildren = (!children.length);
   if (hasNoAvailableChildren) return Adapt.checkedCompletion();
   const requireCompletionOf = this.get('_requireCompletionOf'); 

@danielghost
Copy link
Contributor Author

Yes, the problem can be seen when using a plugin which modifies the available children, like a role selector. If a user switches roles, the models which previously had all its children set to _isAvailable: false will be marked as completed.

Preventing completion on models without available children solves this issue, but it can cause a potential problem with trickle where the trickle button is added to an optional last block, which would have previously not been added as the block would be set to completed. Setting "_showEndOfPage": false will resolve this, but requires either a change to the default value, or for the JSON config to be amended accordingly for affected courses.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

No branches or pull requests

2 participants