What are you using Javascript in Storyline For???

May 27, 2015

Lots of hits to the effect "how do I get JavaScript to run in my Storyline project" but what I'm curious about is are examples of what people are using JavaScript to do in Storyline that can't already be done with the functionality built into Storyline.

 

10 Replies
Jordan Ash

Hi John,

 

Something I have used JavaScript for is adding an element of randomisation in a course so that every time someone goes on a course it will be slightly different. Using a random number generator in JavaScript you can set different paths depending on the number generated. You can also use this on maths questions so the answer is always different.

 Here is an example of a word game I have made which contains JavaScript. I have used random number generators to decide what letters will appear. 

www.googledrive.com/host/0B9vyCAnccpPWfmhxV1pUNXBUTXNDSHU1R09SbGpfa1FlanRNOW0yb2JOcVJ6ejN5eGpiOTQ?ltmpl=drive

Steve Flowers

Here are a few things I use JS for regularly that SL doesn't support natively:

  • Custom submission to the LMS. Storyline tracks two conditions. One is a slide visit. The other is a single result slide. If you wanted to make sure the user visited a certain number of slides, attempted or achieved an activity, or scored an average of X on three separate assessments, you're out of luck without a Javascript trigger. When using a javascript trigger to override score and status, make sure you set the Story tracking up as Slides visited and make a slide that can't ever be reached. You don't want Storyline to override your custom behavior.
  • Complex calculations. There is quite a bit you can do with the simple math operations in Storyline. But the more complicated the math, the more triggers you'll need. There's also a limit. If you want to run complex math operations or calculations like amortization, JavaScript is the way to go.
  • Submitting values to a custom endpoint like a Google Form and / or bringing data in from an external data source.
  • Submitting custom interaction values or submitting / retrieving comments or other objects from the SCORM data model.
  • Submitting visits / values to Google Analytics for tracking views within the Storyline output.
  • Custom counters and timers. I once used a simple JavaScript function to create a score counter. Whenever a value was added to a score (10 additional points) the counter made the values animate UP or DOWN to the new value from the current value. Neat effect.
  • Custom libraries and functions. Let's say you wanted to show the user something different if they accessed the course without logging into an LMS. You could publish one output and use it in multiple contexts. Or if you wanted to detect when the user lost an internet connection and let them know. Or if you wanted to grab the user's current coordinates or their current time and customize the display of information based on where / when they were at the time.
  • Generation of custom HTML through dynamic script. I've used this to generate a printable certificate in a new window using nothing but a JavaScript trigger. You could do the same thing to generate score sheets and checklists.
  • Customizing the presentation to personalize it a bit. You can easily use JavaScript to pull the user's LMS username into the Storyline output. "Hello John, thanks for joining us on this adventure!"
  • Calling external web services. You could bring in things like stock quotes, weather, parts of a company RSS feed, or even call services like Vocalware for real-time text to speech engine processing.
  • In some browsers, you can use voice commands as an input. This could be useful in some cases where you have consistency in your user's browser version / brand.
  • Communicating with a window or parent.
  • Communicating back and forth between a custom Flash movie and the Storyline player. The only reliable way to do this is using storyline variables and the GetVar & SetVar methods.

Those are off the top of my head:) A few of which I've used in production work. Others in experiments.

Jackson Hamner

I've used JavaScript to:

  • Let the user print or email custom notes that they've taken through the course to themselves.
  • Set background music that plays in the background of the whole course, not just in a single slide. The user could change songs and adjust the volume as well.
  • Send variables to a Google Docs spreadsheet.
  • Send a prompt message so the learner can easily copy and paste a large piece of text.
  • Evaluate harder Maths that would be a huge pain to set up in triggers

 

Alexandros Anoyatis

Yup, Soundmanager works great this way, and you can even embed volume controls or do your own fade ins/outs. The only drawback I've found so far is that you can't control it through the stock volume slider, which essentially means you have to rid yourself of both to maintain consistency. But users can use the OS volume control so no biggie.

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