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

multilanguage course: not restoring learners' answers to questions on language change #2977

Closed
moloko opened this issue Nov 17, 2020 · 2 comments · Fixed by #2979
Closed
Labels

Comments

@moloko
Copy link
Contributor

moloko commented Nov 17, 2020

Subject of the issue/enhancement/features

In earlier versions of Adapt, if the learner changed language when _languagePicker._restoreStateOnLanguageChange: true, the responses the learner gave to questions was restored.

Tested as working v5.1.0 - but I think should still work OK up until v5.7.0, at which point it looks like #2846 broke it

Your environment

  • FW v5.7.1
  • languagePicker v4.1.1

Steps to reproduce

Setup a course with multiple languages. In config.json, set _languagePicker._restoreStateOnLanguageChange: true. Build & run the course, answer a question, change languages.

Expected behaviour

The answer you gave in the original language should be restored

Actual behaviour

The question shows as completed but the answer is not restored

Findings

It looks like the issue was introduced by the addition of this check of Adapt.get('_isStarted') - which causes restoreUserAnswers to be invoked pretty much immediately when switching language, instead of waiting for the 'adapt:initialize' to be triggered.

(In Adapt v5.6.1, this particular bit of code was in questionModel.js and did not contain the same check for Adapt.get('_isStarted').)

The addition of the check for Adapt.get('_isStarted') causes the execution order to change so that restoreUserAnswers now runs before the 'app:dataLoaded' event is triggered - which means that restoreUserAnswers won't actually do anything because _isSubmitted is still set to false - on account of how languagePickerModel.setTrackableState now doesn't restore the state of _isSubmitted until after restoreUserAnswers has run.

Commenting out the check for Adapt.get('_isStarted') so that restoreUserAnswers doesn't run until the 'adapt:initialize' event is triggered certainly fixes this issue for me - I just wasn't sure of potential knock-on impact of changing this... @oliverfoster could do with your thoughts on this if you have a moment?

@moloko moloko added the bug label Nov 17, 2020
moloko added a commit that referenced this issue Nov 20, 2020
@oliverfoster
Copy link
Member

This check is so that you can create new models after the initial data loading process.
Such as with cloning. The alternative would be to set _isStarted to false when switching languages.

@moloko
Copy link
Contributor Author

moloko commented Nov 20, 2020

This check is so that you can create new models after the initial data loading process.
Such as with cloning. The alternative would be to set _isStarted to false when switching languages.

Ah OK - no problem I'll try something along those lines next week.

@moloko moloko changed the title multilanguage course: not restoring user's answers to questions on language change multilanguage course: not restoring learners' answers to questions on language change Dec 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants