Using Java Script to identify what has been typed in a free text box in an assessment question

Dec 05, 2016

Hi,

I am currently building an assessment for the end of one of my  courses and one of the questions requires a free text box where the user can type in their answer to the question. The user has two attempts to get the answer correct by typing in the correct list of objects. I was wondering how you would use Java Script to recognise whether the user has typed in the correct words?

For example if the question was; Name four farm animals.

Answer: Pig, cow, chicken, sheep.

If the user typed in Pig, cow, dolphin, unicorn, I want storyline to be able to recognise what they have typed and to know that they got two correct but two wrong so need to try again.

Sorry if that makes little sense! I am getting confused trying to explain it.

If any one has any advice it would be much appreciated.

PS I am not new to Storyline but I am new to Java Script so have no idea how to use it.

6 Replies
Rebecca Carter

Hi Matthew,

As I am completely new to Java I have no idea how to start this tutorial off, I have done the the initial part by creating a text entry box and submit button and converted the slide to freeform text entry etc etc. Now I am on the first of your instructions which is; The first step is to establish communication with storyline:

var player = getPlayer ();

It may be something really obvious but I don't know what to do with this, do I copy and paste it into the 'Execute JavaScript' script section of the variable wizard?

Is this the first line of code?

And the 2nd instruction I am really confused by, do I need to create a new text variable? then fill it with the text that is stored in storylines 'textentry' variable? I have no idea what this means....

Apologies it would appear that I am completely clueless!

thanks,

Rebecca

 

Rebecca Carter

Hi Matthew,

I think this helps! Thank you. When I try to download the source file it just takes me to the tutorial rather than downloading a file?

One more thing, at the end when you say you need to create a 'Points' variable, what kind of variable is this?

You tutorial is really good so no need to worry there, I just got very confused with the use of the word variable!

Thank you for your help and wisdom!

Rebecca Carter

Hi Matthew,

I have been trying to get my head around this all day and I don't think this example is actually what I need to do. I don't want my users to score points when they type the correct words, I want them to be able to type freely into the box to answer the question and when they submit if they have most of the correct words or phrases typed in the box then they are shown the 'correct' feedback slide.

If they don't type enough correct words or phrases I when they submit I want them to be shown the 'try again' feedback slide etc etc.

If they still don't get it right then they will be shown the 'incorrect' feedback slide and shown the correct selection of possible answers.

Do you know anywhere I would be able to watch a tutorial on how to do this? I can't find anything in youtube for storyline with Javascript for this purpose. Or are there any written tutorials for this that you know of? Also the fact that Storyline doesn't allow you to preview the slide to see if the JavaScript has worked is not helpful :( 

thank you,

Rebecca

 

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