Skip to main content
Quest5639
Known Participant
February 24, 2016
Question

How to create an array at the root level in Captivate using javascript?

I'm trying to create an array using a javascript window in captivate like this:

var questionOrder[20];

questionOrder[1]=1;

questionOrder[2]=2;

etc;

The purpose is to have a dynamic question order for a second attempt at a quiz, so that it will only include questions that the user got wrong on their previous attempt. When the user gets a question wrong, I put that question in the next available slot of the array to form a new question order for second quiz attempt. I do this using the javascript action:

questionOrder[zCount] = window.cpAPIInterface.getVariableValue("cpInfoCurrentSlide");

zCount=zCount+1;

As the action for leaving each slide, I have the following javascript executing:

iCount = iCount+1

window.cpAPIInterface.setVariableValue("cpCmndGotoSlide",questionOrder[iCount]);

This works with literal values, or even just the iCount variable, in place of questionOrder[], but it seems the array is not accessible from all slides.

How do I create an array at the root level so that it is always accessible?

TIA!

gCemb

This topic is closed to new replies. Start a new post to keep the conversation going.