Forum Discussion
How do I get my quiz score and leaderboard score to be the same variable?
Greetings, Heros
This is embarrassing, but....
I am prototyping a game for a class, and I managed to build a Leaderboard, which uses a variable userScore in Javascript (This will be on the first slide of the file I've attached). I used the directions here: https://www.linkedin.com/pulse/how-create-leaderboard-elearning-using-google-sheets-storyline-ariff/ I'm quite proud of myself for being able to make it, but its causing problems.
The quiz questions I am asking, however, use a different variable. I'm not great with variables, and have no idea how to make the learner's score be the same variable.
I don't like leaderboards - I find them demotivating, but they go over well in the class, so I'd like to have one. I'm happy to rebuild one if need be.
Can anyone point in the right direction for solving this dilemma? Any help would be greatly appreciated.
- SamHillSuper Hero
Hi Judith, you've done really well to get so far with this.
When you build quizzes with a results slide in Storyline it defines it's own variables as you've probably found. You can see these in the variables view "Built-in" tab. For each quiz, there are fours variables (where QuizName is the name you define on the results configuration): "Quizname.PassPercent", "Quizname.PassPoints", "Quizname.ScorePercent", "Quizname.ScorePoints". These variables cannot be accessed via JavaScript, and have to be assigned to a user defined variable so they can be. So what you could do in your instance is assign "Quiz1.ScorePoints" to "userScore". Add this to your results slide so the userScore is updated when the Results slide is processed.
- SamHillSuper Hero
Hi Judith, I think you will also need to move the JavaScript onto you 1.8 leaderboard slide to make sure it picks up the current users attempt/score. The script is currently processing before the user has attempted the quiz and userScore will be "0" at this stage.
See attached file for a correction in functionality. The summary of changes are:
- Assign Quiz1.ScorePoints to userScore on timeline start of the results slide
- Move the JavaScript to the leaderboard slide so that when the leaderboard variable is assigned a value, it includes the latest value of userScore.
- JudithReymon104Community Member
Thanks so much Sam! This is so helpful - I'm trying to build an AR-enhanced game for a class in mobile learning, and the leaderboard would really impress my professor. i can't believe I still care about that!
- SamHillSuper Hero
Sounds very interesting. I think your professor would be flattered.