thexerteproject / xerteonlinetoolkits

Xerte Online Toolkits
www.xerte.org.uk
Apache License 2.0
62 stars 61 forks source link

State handling in Nottigham template #990

Open torinfo opened 3 years ago

torinfo commented 3 years ago

I thought we already had an issue for this, but I cannot find it.

If your have more than one instance of a certain pagetype in a Nottingham LO, the answers and state of these instances influence each other. @JohnSmith-LT I thought we already discussed this somewhere.

In this case it propped up fro the x of y page type. An answer of instance 1 is accepted as a corret answers for instance 2.

Do we have a good strategy (codewise) to prevent this?

JohnSmith-LT commented 3 years ago

Hi @torinfo,

We discussed at a developer day and I demonstrated the issue and a possible fix but unfortunately it hasn't moved on much simply due to severe lack of time on my part.... I think it was captured in issue #916

There is a branch called xenith_maintain_state that has the suggestions in it. Basically it creates a complete new model for each page in an array. I think I only perhaps got the drag drop page working but even that will now have moved on since we made later changes to that to fix hotspot issues etc...

torinfo commented 3 years ago

Hi @JohnSmith-LT,

Thank you. I'll have a look. This issue was discussed here:

https://github.com/thexerteproject/xerteonlinetoolkits/issues/915#issuecomment-664855424

I'll see what we can do...

FayCross commented 3 years ago

@torinfo The old way of dealing with this was to save any data that is needed later & might be changed by other pages to an element on the page & then reference it via that element when needed. See the interactive text page for an example: there's a var groupInfo which is used but also saved to $('#pageContents').data('groupInfo') (you could do this in leavePage function if the value of the variable changes). When the page is returned to & pageChanged function is called, the value of groupInfo is reset to the value of $('#pageContents').data('groupInfo') in case it was changed by a different page. It's not a tidy way of doing things but does work & might be a quick fix for you until something better like John's work can be properly implemented.

torinfo commented 3 years ago

@FayCross Thank you for this. Good to know. The quick (very dirty) fix I did now is reset everything in the pageChanged......