Text entry must contain
Sep 12, 2019
By
Erin Sadler
Hallo - I've been trying to find or think up a workaround for this but I can't! Can anybody help?
I have a text entry field that I want users to complete - they can write anything at all, but it must contain specific words (let's say, for example; "Specific Words"!).
I don't want them to be limited to writing 'Specific Words' (although they would still pass if they did) - I want to encourage them to write more, but be judged correctly if 'Specific Words' is included in the text.
Is there any way I could do this?
13 Replies
Attached is an example of how I solved this on one question.
In my javascript I check for the word "Plug" or the word "blind", if either word is anywhere in the typed response, the script then changes the multiple choice on the base layer to the correct answer.
Check it out.
Aaah Javascript to the rescue! Thank you both, I shall check those both out :) x
This is amazing. A simple solution that one can tweak easily to suit other Storyline needs (as from my experience!). Genius. Thank you!!!!
So glad that this conversation was able to help you as well, Micah. Thanks for popping in to share and welcome to E-Learning Heroes 😊
Hi all, I am trying to do exactly this on a project that I am working on but it is not working. I'm assuming that it is due to me having the Java script incorrect.
Would it be possible for someone to take a quick look to see if there is anything obvious going on?
Steven,
I published your story and it seems to be working.
https://360.articulate.com/review/content/f65a30ab-1ce5-43b5-9873-04164ed7fe33/review
My tests were:
Drain - succeeded
Coolant - succeeded
Drain Coolant - succeeded
Cat - failed
Dog - failed
Put it down the drain - succeeded
Hi Jerry. Thank you for this. I'll give it a ho again.
In each of my tests, I just typed some content in the box and clicked the Submit icon in the lower right corner.
Hi Jerry, Not sure if you can help again. I am trying to get the java scrip to include upper case and lower case, so I have just copied and pasted the line relating to the word and changed the first letter to upper case. This now only accepts the upper case word and ignores the lower case. Are you able to help?
var player = GetPlayer();
var str = player.GetVar("draincoolant");
var n = str.search("drain");
var n = str.search("Drain");
var m = str.search("coolant");
var m = str.search("Coolant");
if(n >= 0){
player.SetVar("draincoolant", "Drain coolant");
}else if(m >= 0){
player.SetVar("draincoolant", "Drain coolant");
}else{
player.SetVar("draincoolant", str);
}
I've also tried changing the Var n to a different letter as I appreciate that a duplicate of the letter will confuse it. So:
var n = str.search("drain");
var o = str.search("Drain");
var p = str.search("coolant");
var q = str.search("Coolant");
etc...
And then updated the second part accordingly, but this still didn't work. I'm sure that there is a simple solution.
This tutorial is gone.
Steven,
These lines won't work, because the second one changes what the first one did, so the lower case is never searched for.
var n = str.search("drain");
var n = str.search("Drain");
The attempt with two separate variables probably works, but these lines change the SL variable to the upper case regardless of which one is found.
player.SetVar("draincoolant", "Drain coolant");
}else if(m >= 0){
player.SetVar("draincoolant", "Drain coolant");
}else{
Try var str = player.GetVar("draincoolant").toLowerCase(); if you want to ignore case. The problem is that the answer is changed to all lower case, which is only a problem if you come back at the end and reset the SL variable. In that case, I would use strOri to store the original value, then use str = strOri.toLowerCase(); Search str, and use strOri to write to SL.
Michelle
There is a sample that uses the same principles that Matthew does at this post: https://community.articulate.com/discussions/articulate-storyline/free-sample-check-essay-questions-for-concepts-not-words