Tutorial: Search a Text Entry Field for Keywords or Phrases
Have you ever wanted to check if certain keywords or phrases have been typed into a Storyline text entry field?
Maybe you want to count how many important terms have been included in a learner's response to ensure that they have a solid grasp on the subject matter? Or perhaps you want to check if they've used a particular phrase as part of their response?
In this tutorial, we will look at how to use JavaScript to analyse the text entered into a Storyline text entry field and count how many times particular keywords are mentioned.
Click here to see a demo and here to download the source file.
Let me know if you have any questions.
16 Replies
Hi Mat,
I have a text entry exercise where the different response will be displayed based on what a user will type. In other words, the text entry will be validated. I want to validate if the entry contains certain keywords I am looking for, regardless the cases (Storyline 360 has this function), or spaces before or after the keywords, or plural forms, or other synonyms, or a full sentence, as long as it contains two keywords.
I do not know much about JavaScript. Looked at your demo and source file, don't think your solution solves my need. Can you or anyone help?
Almost like Susan, I'm looking to set triggers when a text entry contains all or part of a word. For example, own, owner, ownership. It is my understanding this is not available, which is a shame. Please tell me I'm wrong? Can JavaScript help?
Susan, sorry for not responding to you earlier. While we may need to modify the code a bit, this should do what you wanted to do (last year!). Yell out if you still need help with this.
Kelly, you can use this code to do that. In the demo, you can see that I've set the keywords to be
one
,two
,skip a few
- but these could just as easily beown
,owner
,ownership
.Would you need to track how many times these words are used? Or just check if the words have been used at least once?
Kelly, is this the kind of thing you had in mind?
Here is a demo.
Here is the source file.
Here is the JavaScript that is triggered when Submit is pressed:
You'll need two variables in your course for this to work. One called
TextEntry
- which is a text variable and is attached to the text entry field. And another calledPoints
(which is a number variable and will show how many times the wordown
is used).Hope this all makes sense!
Hi Matthew,
Thank you so much for your response. I have watched your tutorial - and it may be very close to what I'm looking for. In stead of counting use of a word however I'd like something to be triggered on a future slide.
Here is what I'd really like to have happen: I'd like the learner to type a word in a textenrtry box on slide 1, say 'own'. Then on slide 2 I'd like the system to recognize the typed word and if the typed word contains any part of a word, say 'ownership' a trigger fires.
For context, I'm writing a script that will ask the learner to text enter one word characteristics of a good csr experience. They might enter things like: "knowledgeable", "courteous", "timely". If they typed any part of the characteristics words I have on the review slide (slide 2), I want those words to be underlined.
Learner text entry slide 1: Informative
(trigger: if text entry contains 'inform' change state of 'Kept me informed' to Normal)
Review slide 2: Kept me informed
Really looking forward to a 'contains' option within Triggers!
Thanks again for your help,
Kelly
I think you could do that with the code I shared above.
You'd just have a trigger on slide 2 that checks if the Points variable is greater than 0.
Ok, I think I have this working for one word scenario. var Points does not = 0 trigger slide var. But I think I'm looking less for the number of times something occurs and more for a value/contains statement.
If slide 1 textentry1 contains 'own' show layer 4 on Slide 2.
If slide 1 textentry2 contains 'polite' show layer 6 on Slide 2
If this can't be done using separate textentry boxes, I would consider using one textentry for all.
Sorry this is so difficult for me to explain.
Thanks,
Kelly
This post was removed by the author
Hi Kelly,
See if this does the trick.
In this version, there is one text entry field that looks for the two words and a third phrase.
Here is the source file.
Here is the JavaScript used. Note that this assumes you have a Text variable called
TextEntry
and three True/False variables calledOwn
Polite
andSomethingElse
And here is another version. In this one, there are separate text entry fields for each word of interest.
Here is the source file.
And here is the JavaScript used for the first text entry field. Note that this assumes you have a Text variable called
TextEntry1
and a True/False variable calledOwn
And here is the JavaScript used for the second text entry field. Note that this assumes you have a Text variable called
TextEntry2
and a True/False variable calledPolite
Hope that helps!
You sir ARE an absolute hero!!!! Worked splendidly!
Thank you,
Kelly
Sounds like a really cool application of Matthew's code, Kelly. Would love to hear how the course turns out.
Glad I could help Kelly.
i would like a trigger to navigate user to go to slide XX if the value of the a "password" is "a valid password"
this works fine as expected.... but if the value of the password is "not a valid password" then to show a layer "this is not a valid password" similar to qbanks which show an incorrect response
i am guessing the above java could do it, but would appreciate knowing if i am on the right track and any guidance you suggest.....
this function could be simpler and would work seamlessly if articulate had opportunity for a choice in the trigger conditions of
....if value
... contains "text string"
.... does not contain "text string
max
Max, here is one way to add a password to your course.
to
thunder from down under:
wow! that's alot of very careful work from a very knowledged user.
what workflow do you suggest to provide functionality to keep a list of valid users' passwords so that the program can ascertain if user input is valid....could it be like a xls file living online which is a single column containing the "password" which java magic would check if the password is correct not just having -1- pw - "fourwordsalluppercase"
thanks
from
max from up and over
Hi Max,
That is not something that I've looked into. While it is possible to do something like you mentioned, it's not a very secure solution.
Thanks