Free response questions and answers

I am designing an e-learning module with a free response question. It would be great if once the learner answers the question, their answer is compared to a bank of key words checking for accuracy. If the learner's answer includes the key words, "correct" appears; if their answer does not include the key words, "incorrect" and the correct response appears.

Is there a way to do this in Articulate?

9 Replies
Matthew Bibby

Sure, you just need a trigger set to to check if TextEntry1 (or whatever your variable is called) is equal to ignore case term one or equal to ignore case term two, or equal to ignore case term three.  If so, you'd show a layer with the word Correct on it. 

You also want a second trigger that checks if the variable is not equal to those terms, this would be used if the learner answers incorrectly. 

Does that make sense?

Louise Lindop

Thanks Matthew,

I wondered about Javascript but unfortunately only know it well enough to hack other peoples code! This is very useful. Thanks so much for posting the sample and the source.

I don't suppose you know a way to check the contents of a text entry field without needing to click a button or press a key? Maybe using a listener or some such thing?

Thanks again
Louise

Matthew Bibby

It can be done, but the issue is that the variable isn't saved by Storyline until the text entry box loses focus. So at the very least you need to click away from the text entry box for it to work. 

If you want to do it all in real time then you would have to create your own text entry field as part of a web object.

Matthew Bibby

Here is an update to the JavaScript used in the above example. This fixes the issue with case sensitivity, so now 'TOMATO', 'tomato' or 'ToMaTo' are all considered acceptable answers.

var result = undefined; 
var player = GetPlayer();
var string = player.GetVar("Text");
var lcString=string.toLowerCase();
if( lcString.indexOf ("tomato") >= 0) {
result = "Yes"
player.SetVar("Result",result);
} else {
result = "No"
player.SetVar("Result",result);
}

I've updated the files linked above

Christie Pollick

Great discussion here! I just wanted to stop in and note for those who may not be aware, if you opt to use JS, that is not something for which we would be able to provide support, but we have lots of members here in the community who are typically more than happy to assist. Here also is our JS Best Practices sheet, as well. :)