I’ve been following the Articulate e-Learning challenges for several years and decided it was finally time to jump into the water. The theme for last week's challenge was to use Javascript in SL to create random words. I developed this as something simple to showcase, but also to be usable in an introductory course for Healthcare Informatics. This will serve as a reinforcement of medical prefixes and suffixes.
Here is a link to the online version
Here is a link to the original SL3 file
I added a JS trigger to a button on the Storyline slide. In the code below you will see that I created an array of medical suffixes and prefixes. The first fifteen words are suffixes and the rest of the words are prefixes. The program randomizes the words. Then on line 4 below, it retrieves the index value of the random word. This index value will tell us if the value of wordNumber is 0-14 (a suffix) or 15 and higher (a prefix). The conditional checking for which slide layer to display (correct or incorrect) is added to a button trigger event on the main slide.
- var player = GetPlayer();
- var words = ["algia","cyte","gen","graphy","ism","natal","oid","osis","penia","phobia","pnea","stasis",
"uria","oma","ectomy","ab","circum","dia","dys","epi","extra","hemi","iso",
"neo","pan","pre","retro","sub"]; - var wordChoice = words[Math.floor(Math.random() * words.length)];
- var wordNumber=words.indexOf(wordChoice); player.SetVar("randomWord",wordChoice);
- player.SetVar("arrayNumber",wordNumber);
Credit:
- I used a medical template provided by the E-Learning Heroes community
https://community.articulate.com/download/storyline-2-medical-theme-tabs-template - It was very helpful to follow Matthew Bibby’s tutorial on integrating Javascript with Storyline. Much of my code is adopted from his tutorial: http://matthewbibby.com/random/
