Setting a variable in the story.html file

Aug 28, 2020

Hi all.

I'm hoping some JavaScript experts can help me out on this one.

Firstly, here's what I'm trying to achieve:

We have two versions of a course, one for UK learners and one for international learners. Currently we're using two sets of Storyline files for these (totalling around 100 files), but I'd like to just have one batch of Storyline files and have something tell each module whether they're a UK or international learner when they open it, so it can jump to the relevant content.

I'm thinking this might be achievable if a variable can be set in the HTML file. What I can do is have two Zipfiles with two different HTML files - one setting a 'UK' variable and one setting an 'International' variable. Then the variables will be set up in Storyline to say (for example) 'If UK=true jump to slide 2. If International=true jump to slide 3'. And so on.

The reasoning is that it will be much easier to adjust the HTML files, rather than adjusting content within multiple Storyline files whenever changes need to be made. In theory this should half our workload when making changes.

Is this possible, and how would I do it if so?

Thanks.

4 Replies
Judy Nollet

You could put both versions of a given course in a single Storyline file. 

At the start of the course, ask the learner to click which version they want to view. Have a UK button and an International button. Those buttons would go directly to the designated set of slides. 

FYI: Those buttons could also adjust a Storyline variable.

  • For example, you could set up a T/F variable called choseUK, with an initial value of True. If the user clicks the UK button, that value doesn't change. But if the user clicks the International buttton, it would adjust the value of the choseUK to False before jumping to the appropriate slide.
  • If there's a lot of overlapping content, this method would allow you to use just one set of the slides that share content. Then, when a given slide might jump to either UK or International content, you could add triggers with conditions to the Next button so that it would follow the proper path. 

The caveat with putting multiple versions into one course is how to track completion. Storyline can only track 1 Results slides. So, if the quizzes are different, you wouldn't be able to track the user's score. However, if the actual score isn't important, you could just use a Completion trigger.

Tom W

Ideally I want to avoid having the learner choose. There's other scenarios we may use this in, which involve different versions of courses where we wouldn't want the learner to have access to the other versions. The other issue is that this is a course broken up into many mini modules, and we don't want to have the learner select UK or international at the start of every module.

But your solution is one I'm considering if all else fails.

Walt Hamilton

You can write a simple javascript that sets a variable. Execute it when the first slide opens. Something like this will work:

var player = GetPlayer();
player.SetVar("UK",true);

This requires that the storyline project have a text or T/f variable named exactly UK

Then on the first slide, jump to UK slides if UK=true and Jump to international if UK = false.

I used a T/F variable and set its initial value to true. That way, the system will default to UK, unless this js is executed and changes it.

When you publish it, you will find in the story_content folder a file named user.js, where all your js scripts are stored. That file can be edited with out any other problems or republishing, as long as you don't mess up the IDs.  For UK users, leave it as UK=true, and create a different users.js for international users, changing it to UK=false.

Phil Mayor

It may be easier just to pass the variable in the url

By adding ?variable=value to the end of your url.

I would send numbers for the country.

e.g. ?country=1

https://Yourdomain.com/story.html?country=1

Then in storyline you need to read that variable:

var player = GetPlayer(); 
var player = GetPlayer();
var country = window.location.search.substring(9);
player.SetVar("country",country);

Finally set triggers to show content based off of the variable value. Not tested at all but a simple solution.

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