passing variables between storyline courses with Javascript

Feb 23, 2015

Hi,

I am posting this up as an example of how to pass a variable between storyline courses using Javascript, as I was unable to find a simple example of this. Hopefully this will help others.

So it is fairly simple to pull in a variable that is appended to an html request from one Storyline course to another (for example with a Jump to URL trigger like this: ../story.html?myVariableExternal=true) using a javascript that executes when the timeline starts in the Storyline course that is being navigated to.

It would look something like this:

var query = window.location.search.substring(1);
var readVar = query.split('=');
var player=GetPlayer();

if (readVar[0] == "myVariableExternal"){
player.SetVar("myVariable_main",readVar[1]);
}

The problem I was having was when I navigated to a different Storyline course and then back to the original the variables are all reset to their original state, so only one variable could be updated at a time.

The solution is to create a cookie to store the variable data.

Attached is a super simple example of this.

Note: this won't run locally... you'll need to deploy from an external server or virtual machine.

Enjoy!

 Mark

5 Replies
David McGhee

Hi Mark,

I'm wondering if you have any ideas on this.

I want to load data from delimited file/database/... into storyline variables? I'm building a game like interaction with 5 variables that should populate those 5 variables. The variable would come into storyline from some sourse(delimitedfile/database/... think spreadsheet 50 rows 5 columns.

I'll have to test the source doc(spreadsheet) for which row to draw from too.

Can Storyline 2 do this?

Thanks for any comment you have.

- DAvid

Jordan Orzolek

I have tried the process which the OP used and I have only been able to get the project to store one variable. If the OP is still subscribed to the thread any help would be greatly appreciated!

What I am trying to do is have what is basically a project map that the learners visit modules and they are marked as completed by check marks, this is only working for the first variable.

I am attaching the project in case anyone can take a look for me!

This discussion is closed. You can start a new discussion or contact Articulate Support.