Forum Discussion

DavidRoberts592's avatar
DavidRoberts592
Community Member
7 months ago

JavaScript to access Storyline quiz/survey values

Hey e-learning heroes!

I'm new to using JavaScript with Storyline, but I have a lot of experience with JavaScript/CSS/HTML.

I have found many examples online how to getVar and setVar in Storyline using JavaScript. But I can't find any examples of how to lookup/access the values that a learner has submitted into a quiz/survey so far.

The closest I could find were references to a g_listQuizzes variable, which doesn't work for me.

If getVar can be used for this, I can't find where the correct variable names are for the survey questions I want to access. Closest I've found is someone using surveyController.getResponse('Sur1_res1'); Again, this didn't seem to work either (that said, their example never instantiated that surveyController variable anywhere).

Is there a guru who has successfully accessed quiz/survey entries before?

I need a hero!

Thanks in advance,

David

  • Make sure you use a custom variable when setting it on a question/quiz/survey. Then you can easily access them.
    Another trick i recently found was adding a custom data-attribute instead of variables. The big plus of that is you donot need a mass of variables. Each element can have the same custom attribute with different values.

    • DavidRoberts592's avatar
      DavidRoberts592
      Community Member

      Thank you Math for coming back to me! Do you know if there's any guidance on using a custom variable? Or adding a custom data-attributes? I've googled these and come up with nothing.

      I've discovered I can change variable names associated with fields by going to 'Insert > Reference', but that doesn't seem to work for Radio Buttons or Survey pages (with Radio Buttons). Any more clues you can give me as to how to do what you're suggesting? Thanks again!

  • On this LinkedIN post im showing how to use custom data-attributes.

    Using custom variables in Storyline is as simple as making your own variable, and then on the Radio Buttons add a trigger setting that custom variable to the appropriate value.

    Hope that helps.