Forum Discussion
StefanKoler-a6f
2 years agoCommunity Member
Restart Course, but keep value of one variable
I have a course with a lot of variables in use. Resetting all used variables manually is error prone, so I am using the "restart course"-trigger that sets back everything. It is kind of a quiz w...
StefanKoler-a6f
Community Member
Hi Jürgen,
Thank you.
That works well.
Unfortunately, if I reload the page also variables stored in the global window are restored to there initial value. Can I store them somewhere else?
The project is part of an exam, so users should really only have a defined number of attempts.
Jürgen_Schoene_
2 years agoCommunity Member
here is an example where the counter is permanently saved in localStorage
trigger on button click restart
var value = GetPlayer().GetVar("var1");
localStorage.setItem("countTest12345", value);
trigger on start timeline ot the first slide
var value = localStorage.getItem("countTest12345");
if( value !== null ){
GetPlayer().SetVar("var1", parseInt(value) );
}
https://360.articulate.com/review/content/3c4845c0-6b8b-46d8-b25f-a3f581b53752/review
this remains until you delete the Local Storage manually
CAUTION: the solution does not protect against manipulation by the learner - you can simply overwrite the value in the browser