In the previous few post we discussed about moving information from Storyline to HTML/ PHP etc.
2. Storyline to PHP via JavaScript
One may notice that in all these cases, the data flows one way, i.e., you can pass the information from Storyline to HTML or PHP, but not vice-versa.
Let us discuss the same today:
Recently I made a course where I pushed the value from HTML (that was embedded in the Storyline) to pass values to Storyline player.
Click on the picture to view the demo
For this –
Step 1: I put the following code in the Javascript section of HTML <head>(in a function).
function story() {
var player = window.parent.GetPlayer();
var pass = 1;
player.SetVar("pass",pass);
}
Step 2: Call the function in the body of the HTML. For example on clicking a button–
This will push the value into a Storyline variable called ‘pass’ when a button is clicked.
Step 3: Upload the HTML and related files to server. (I haven’t yet tried including web object from local system)
Step 4: Now I create a variable in Storyline named “pass”.
Step 5: Add the webpage as a web object in Storyline.
And you are done! Publish and upload the output to the server.
This method has opened a box of opportunities.
For example – I can now save player scores in a CSV. Later I can pull the data from the CSV and create leader board.
How would you use this method?
Do you have example storylines for these?
Hi, how can I pass values to storyline? For example, I want to pass the username to storyline when users learn the course.
Hi,
I believe you can get the relevant support on this post:
https://community.articulate.com/discussions/articulate-storyline/retrieve-lms-user-name-as-variable
Hi,
This works fantastically thank you very much.
I do have a slight problem though. When I try to open the HTML5 story output in chrome browser it does not work.
Does anyonehave an idea why it works in Firefox but does not work in Chrome?
Thank again.
Hi Greg,
Chrome updates regularly and quite frequently. As a result, some of the older Storyline outputs fail to render correctly.
In such cases, I look if there is any recent update in my Storyline version. In most cases, Articulate releases the patch pretty soon.
Once updated my new published output renders fine.
let me know if I can help you.
Cheers!