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

ItemsComponentModel useranswers save/restore not index aware #489

Closed
oliverfoster opened this issue Jan 31, 2024 · 1 comment · Fixed by #490
Closed

ItemsComponentModel useranswers save/restore not index aware #489

oliverfoster opened this issue Jan 31, 2024 · 1 comment · Fixed by #490
Assignees

Comments

@oliverfoster
Copy link
Member

oliverfoster commented Jan 31, 2024

Subject of the issue

_index is created but save/restore do not utilise. this can cause issues on restoration:

restoreUserAnswers() {
const booleanArray = this.get('_userAnswer');
if (!booleanArray) return;
this.getChildren().forEach((child, index) => child.set('_isVisited', booleanArray[index]));
}
storeUserAnswer() {
const booleanArray = this.getChildren().map(child => child.get('_isVisited'));
this.set('_userAnswer', booleanArray);
}
setUpItems() {
// see https://github.com/adaptlearning/adapt_framework/issues/2480
const items = this.get('_items') || [];
items.forEach((item, index) => (item._index = index));
this.setChildren(new Backbone.Collection(items, { model: ItemModel }));
}

@oliverfoster oliverfoster self-assigned this Jan 31, 2024
@oliverfoster oliverfoster moved this from New to Needs Reviewing in adapt_framework: The TODO Board Jan 31, 2024
@oliverfoster oliverfoster changed the title ItemsComponentModel useranswers store/restore not index aware ItemsComponentModel useranswers save/restore not index aware Jan 31, 2024
@github-project-automation github-project-automation bot moved this from Needs Reviewing to Recently Released in adapt_framework: The TODO Board Feb 12, 2024
github-actions bot pushed a commit that referenced this issue Feb 12, 2024
## [6.45.6](v6.45.5...v6.45.6) (2024-02-12)

### Fix

* useranswer save/restore _index awareness (fixes #489) (#490) ([55b253f](55b253f)), closes [#489](#489) [#490](#490)
@oliverfoster
Copy link
Member Author

🎉 This issue has been resolved in version 6.45.6 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant