Forum Discussion
Text entry must contain
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
- JerryBeaucaireCommunity Member
Attached is an example of how I solved this on one question.
- The slide is just a multiple choice. I will actually set the answer to correct or wrong based on what they do in the fake interaction... see next.
- There is an extra layer in this question where the interaction actually occurs. Here there is a textentry box and javascript that examines the user's input when they submit it.
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.
- MicahAlvordCommunity Member
This is amazing. A simple solution that one can tweak easily to suit other Storyline needs (as from my experience!). Genius. Thank you!!!!
- ErinSadlerCommunity Member
Aaah Javascript to the rescue! Thank you both, I shall check those both out :) x
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 😊
- Steven_HaighCommunity Member
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?
- JerryBeaucaireCommunity Member
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 - succeededCoolant - succeeded
Drain Coolant - succeeded
Cat - failed
Dog - failed
Put it down the drain - succeeded
- Steven_HaighCommunity Member
Hi Jerry. Thank you for this. I'll give it a ho again.
- JerryBeaucaireCommunity Member
In each of my tests, I just typed some content in the box and clicked the Submit icon in the lower right corner.
- Steven_HaighCommunity Member
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);
} - Steven_HaighCommunity Member
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.
- MichelleWhite-dCommunity Member
This tutorial is gone.
Related Content
- 8 months ago
- 10 years ago
- 2 years ago