Word/Phrase Detection - is it possible?
Hi folks
I've had an idea but I'm not sure it's do-able? I want my users to search through the game scenario and then record all their findings . I've created the Lightbox slide and included a Text Entry control.
However, I want the scoring system to detect words or phrases typed within the Text Entry and apply a score for each word identified.
Hope this is making sense? As an example, I'd like the user to identify and record in their findings 'no key for the filing cabinet'. This will be free text, so it's unlikely that each user will record the exact same sentence. But if they include words 'key', 'secure', 'cabinet', 'lock' etc, then I'd like it to be included in the score.
I've set up the variable to accumulate the score, but I'm now stuck trying to figure out how to detect these individual words/phrases within the Text Entry control. Is it possible?
jo xxx
34 Replies
Hi Jo,
I don't think you can do this just in Storyline. The closest you can get is checking if a text entry field is equal to an exact word or phrase, which wouldn't cut it in this situation.
Instead, you could do it using Javascript:
Note that you'll need the variables
TextEntry
andPoints
set up in Storyline for this to work.Here are some best practices for using JavaScript in Storyline.
I hope that helps.
-----
Edit 22/8:
I've updated the code above so it works in an LMS.
See here for an explanation of how this code works.
Click here for a demo.
And here to download the source files.
Matthew, you a SUPERSTAR!!!!
I've spent all morning trying to figure out javascript after realising there was no feasible way of doing it using variables. This has worked wonderfully!!
If I want to include additional phrases, do I simply copy this section:
var pos = text.toLowerCase().indexOf('cabinet');
while (pos !== -1) {
score++;
pos= text.toLowerCase().indexOf('cabinet', pos + 1);
and replace the word 'cabinet' with 'breach' for example?
jo xxx
Hi Jo,
I'm glad that worked for you.
Yes, you do copy that block of code to add additional words, (but it looks like you missed the closing bracket).
Here's the block of code you can use to add an additional word or phrase:
When you paste this, just make sure it appears above the final:
Thanks.
Thanks Matthew! I really appreciate it xxx
Me again Matthew!
I've had one JS problem...that I've spent a couple of hours trying to resolve myself...that still foxes me :).
Every time the user returns to the Notepad lightbox slide in order to enter more 'findings', the user clicks in to the TextEntry field to show the cursor at the end of the entered text, but all entered text is now selected/highlighted. The problem here is that, if the user doesn't realise the previously entered text is now selected, they press a key and all that data is removed from the field.
I'm trying to find different code to resolve this issue, but I'm wondering if I'm setting the 'Execute JavaScript' trigger correctly?
Action: Execute JavaScript
Script
function addEvent(elem, event, fn){
if(elem.addEventListener){
elem.addEventListener(event, fn, false);
}else{
elem.attachEvent("on" + event,
function(){ return(fn.call(elem, window.event)); });
}}
var element = document.getElementById('el');
addEvent(element,'focus',function(){
var that = this;
setTimeout(function(){ that.selectionStart = that.selectionEnd = 10000; }, 0);
});
When: User Clicks
Object: Text Entry Notepad
I'm wondering if the trigger is the reason why the different JS options aren't working as I'm hope they would.
Any ideas how I can resolve this?
xxx
Hey Jo,
Sorry for the delayed response.
I don't think you will be able to communicate with the text entry field in that way... unfortunately JavaScript can only communicate with Storyline via variables, not interact directly with particular elements.
There is a workaround that may achieve what you are looking for here (depending on how you've set up your course). Are you able to share your .story file here? (or you can email it to me directly if you prefer).
Thanks
Thanks Matt
I've also encountered one more issue...can you believe it...when I review the published content through the 'View Project' option on Storyline, the scoring system works perfectly. Yet, when I load it on to the company's LMS, the score is not working. I've tried this using both IE and Chrome browsers but neither are showing a change in the score. The project has been published using SCORM 1.2 as per the requirements of the LMS.
Although I've tried loading this on to the free SCORM Cloud, the project file is not loading on there accurately. Would you mind checking to see if the file opens when you attempt it?
The score works fine for me on publish, but this score will not be sent to the LMS as only results slides will send scores., are you using cross domain for your LMS that may block the javascript working
Thanks for looking in to this for me Phil
I will amend the publish set-up so that it collates using the results slide. However, I'm actually concerned that the scoring doesn't increase within the module - either when the user types their findings in to the notepad or when they show the final score on the summary slide.
Meanwhile, I will ask the question of the cross domain for the LMS to our LMS account manager. We use LMS provided by a firm specialising in the retail finance industry, so it's not an immediately recognised provider. Fingers crossed that provides the answer I need about the scoring.
Final question for you Phil...did you identify where javascript might improve the notepad so that it doesn't auto-select the text when the user clicks in to the TextEntry field?
jo xxx
The only reason I have seen where the javascript does not work in the LMS is if the Scorm is installed cross dominant the javascript gets blocked.
You will need some additional javascript to set the score inside of Storyline as you cannot adjust the built in results variables
The autoselect is a "feature" of storyline perhaps you could use a concatenate instead so it adds a new feature to the list instead.
Thanks again Phil!
I'll look in to the concatenate option, see if I can make a difference with the list xxx
I'm certain that some days I learn more from the forums than I contribute. :)
I forgot to add this may help towards the concatenate
I know the feeling Crystal! I feel like that most days...
Phil, did you mean to share a sample file or link here?
Jo, do you mean that this JavaScript isn't working when you test it in the LMS? I can't think of any reason why it wouldn't... but I haven't tested it in that environment.
Thanks I did mean to share a linkhttps://www.dropbox.com/s/90r97is1ey9ez9m/FruitList.story?dl=0
Hi Matt
You're right! That's the issue I'm experiencing when I load it on to the LMS. Phil also reviewed the file and said that the scoring was working fine when he reviewed it, so suggested there might be a problem if the SCORM is installed cross dominant and therefore may be blocking the javascript. I'm yet to hear from my LMS account manager to find out if this could be the issue.
Meanwhile, I see now that Phil has included his shared file. Let me see if this helps...
Thank you both for looking in to this for me. Honestly, I'm amazed by the help and support this forum provides. You're all heroes!
xxx
I can't see any reason why that JavaScript wouldn't work in an LMS environment, so I think Phil might be correct re the cross domain scripting. Let us know how you get on Jo.
Me again!
Okay, so I've been investigating the cross-domain problem and this does look to be the culprit that's affecting the blocking of my javascript.
So, I've been googling for some ways to resolve this and they suggest amending the domain name through the url.
I'm so sorry to ask this question, but where would I find the url/server information in the SCORM manifest? I've loaded the published zip on to my lms and this is the url that plays the module:
https://nottingham.e-learningportal.com/courses_scorm/24DAC29B-EC38-2308-DACAE84A97AF4B60/index_lms.html
Unsure what to do or where to go next! xxx
Leave it with me Jo. I'll see if I can figure it out.
Thanks Matt!
I'm currently working my way through SCORM reference manuals in the hope of finding out the answer :) xxx
I almost got it working when I had a look a couple of days ago... but almost doesn't really help you much!
I've asked a colleague who is a lot more experienced with this stuff to take a look but he's on holidays until next week. I'm confident he'll get it figured out.
Also, while SCORM reference manuals are pretty fascinating, I don't think you'll find the answer there - but don't let that discourage you from learning more about SCORM!
Hahahah! These manuals are fabulous bedtime reading :)
Thanks again for getting back to me. I reckon I can stall this until next week, so I'll await further news from you and your colleague xxx
He's back on the 12th I believe Jo. I'll let you know as soon as I hear back from him.