Array variables and indexing in storyline

Aug 10, 2012

New to storyline and trying to figure out how to make it work for me, I am trying to create a timed quiz that gives the learner randomized tasks in an animated setting (think tetris with tasks instead of blocks falling, and the user has to solve each of them before they hit the bottom). I solved the timing and the animation, but the variables needed to display the different tasks and record the reactions multiply with each additional scenario (task & possible solutions), along with the triggers needed to handle it all. This would be so much simpler to do with indexed array-type variables, i.e.,

variable(n) instead of

variable1, variable2, variable3...

(I have about ten connected variables that I need somewhere between 20 and 100 instances of; programming all that by multiplying variables and triggers is going to be tedious and a nightmare to debug and maintain...)

I found elsewhere in this forum that the JavaScript integration is not useable in this context, but maybe I got that wrong.

Any help would be greatly appreciated, and of course I apologize if I've overlooked something that's already out there.

7 Replies
Steve Flowers

That's a brain twister. It's certainly possible to use the channel between Storyline's player and JavaScript to do some really cool things. During the beta one of the Articulate developers built a board game (Othello I think) that leveraged communication between JavaScript and Storyline. Very clever work.

I think it's possible to have some semi-randomness added to elements that appear on screen from an external configuration. For example, if you wanted to feed in your challenges via XML file, it's possible to do that. 

It all depends on the mechanics you want to see. Can you describe a little bit more about what the participant would see, do, and the type of feedback they'd receive?

Kai R

Thanks for your response, Steve. Actually I used your proposed solution from elsewhere to create the counter that makes my challenge tick...

I've gotten the javascript random number generator

  • var number=Math.floor(Math.random()*11);
  • GetPlayer().SetVar("RandNum",number);

to work thanks to a suggestions from another thread (here, found it there, too, thanks Colin and Adrian). Had to move my testing from preview and local viewing to a web server. Phew. OK.

Now, to the rest of the JS stuff...

For the time being I'm aiming at

  • having a challenge selected from a number of predefined ones (20-100, not sure how many I can get together, and I'll certainly only be able to handle 20 or so unless I can outsource the logic to JS)
  • for the challenge mode, each task consists of a title, a description, and four choices
  • each choice is assigned a number value (0-3, with 0 a clear fail)
  • the title is displayed in a tetris-tile (only one shape for the moment) that starts falling
  • when the user clicks on the tile, the description and choices are displayed as text and buttons
  • when the user clicks on one of the choices the value is stored, the tile is added to the pile at the bottom if the choice was the failure and a new challenge is selected and launched
  • the user only has time to solve each task until the tile hits the pile at the bottom, at which time the current task is registered as failure and the next task is launched
  • the game ends when all tasks are solved or the pile of failures has grown to the top of the screen

The number of triggers has already grown (three test challenges) to a level that is difficult to maintain, so I'm really looking for a JS solution to the whole thing, otherwise I have to finish this in one session in order not to lose concentration, and then never look back, which obviously is not the cleverest thing to do.

So, approaching this from a maximum-JS perspective, I wonder whether a JS could run in the background so that variables I use there are persistent, or whether I have to pass all info back and forth every time I launch the script and have to let the script parse the "what happened so far" input every time it launches.

In the "train" mode the user would get feedback on their choice and could then either confirm their choice or go back to choose again. This should be comparably simple to add on to the challenge mode once I've got that running.

The whole thing is somewhat daunting as I haven't done any JS programming since JS first came out in the nineties...but it's exhilarating at the same time...

Looking forward to more insight and discussion!

Thanks again, Steve!

Gerry Palmer

Hi Kai,

Really cool idea. I threw something together that I think might help.  You can see the published output at the address below:

http://articulate.gerry.s3.amazonaws.com/falling/output/story.html

To accomplish this, I used a lot of javascript actions, variable triggers, states, and variable text references.  The questions are defined in falling.js and displayed in flash using variable references.  I did have to make one change to the published output to make this work.  I had to copy the file falling.js to the story_content folder and modify story.html adding a reference to this file immediately before the reference to user.js. Below are links to the project file and the zipped output. 

http://articulate.gerry.s3.amazonaws.com/falling/falling_output.zip

http://articulate.gerry.s3.amazonaws.com/falling/falling_src.zip

Best Regards,

Gerry

Kai R

Now...I think I got my thick head around how it works. Found that it doesn't finish cleanly, though. When you run out of questions it seems to repeat the last question once before stopping.

I made a few changes to fix it, although I'm not completely sure why especially the first fix was necessary:

  • changed the condition that checks whether we've run out of questions to read "if (g_nCurrentQuestion >= g_arrQuestions.length-1 || g_nFailCount > 12)"
  • added the condition into the ChoiceSelected function for the case of a correct selection
  • added a function GameOver() that switches an additional layer in the story on to simply say that the game is over (in preparation of a results display)

(see attached modified version of the JS; I've commented out most of the questions for easier testing, the actual number of questions has no effect it seems)

@Gerry: any thoughts?

Further I'd be extremely interested whether we might not get the question data from an XML file instead of handling it in the JS, so that translation might be easier. Anyone?

Kai R

So...tweaked things a bit and it looks like it's doing what I need it to do now...

I've

- randomized the questions

- added scoring instead of simple pass/fail

There is some more stuff happening behind the scenes I may build on later. Detailed feedback is not implemented yet.

I've attached the sources and the output.zip of my latest version. Happy about any feedback!

@Gerry: when I ran your original (shoulders of giants, thanks again!) to the very end and selected the correct answer for the last question, there was the side effect that I tried to fix in my previous post.

Next stop: import of data from xml or json. Any takers?

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