Variable naming best practice
Oct 18, 2019
By
Ian Buxton
Newbie just looking for a pointer here.
What is the best practice for naming variables involved in short answer and essay questions where the person's responses will be stored on the LMS.
Is it necessary to uniquely name each stored variable (when they exist on different slides and are submitted at different points) - or is the LMS going to handle the difference between them?
In short - will varAns001 on slide X get confused with varAns001 on slide Y?
Or should it be varAns001 and varAns002 to be safe?
Clear as mud? Told you I was new to this?
4 Replies
I reuse variables all the time. I use a trigger on timeline start to reset the value to blank or 0 or flash when the timeline loads.
For example I use a lot of carousels and use the same variable "Scroll" to control them.
I do not use the var prefix I don't see the need for it, I do ensure I Camel code the name.
Also wherever possible I do not use variables, I will try and only use them if I am passing data between slides. Not sure it has any effect, but in the initial beta for SL1 the suggestion was not to use variables unless you had to! This has stuck with me.
Just to be clear, are you referring to StoryLine variables or JavaScript variables?
I think I've been getting myself confused over the purpose of variables in Storyline and the storage of user answers on the LMS. Like I said - I'm new to this.
Your answers have helped me get things a lot straighter. Long story short - I'm sorted.
Phil - I like your approach to the use of variables and will adopt it.
This discussion is closed. You can start a new discussion or contact Articulate Support.