Scan short answer for keywords
Dec 08, 2015
Hello Everyone,
I am currently working on an assessment for a project. One of the questions require the learners to type in their response, however, the response needs to contain three keywords to make it correct.
I know this can be done using javascript but i do not know how.
What I have done:
1. I created two variables on storyline "quizanswer" and "res"
2. wrote this script in javascript
var player = GetPlayer();
var quizanswer = player.GetVar("quizanswer");
var resp = answer.match(/interacting|interdependent|unified whole/gi);
player.SetVar ("res", resp);
3. added a trigger to show correct if res != null and show incorrect if res = null
but it is not working.
Please help! :'(
3 Replies
Hi, Ademola -- Thanks for reaching out with your question! I will need to defer to the community to chime in with their advice on using JavaScript (as that is something for which we do not provide support), however, I wanted to be sure to provide our JS Best Practices sheet in case you'd like to keep it handy. Best of luck with your project. :)
Thank you Matthew,
I noticed that and corrected it and somehow managed to get it to work but the logic in between the keywords is 'or' which would pass if either of the keywords are available. I wanted it to be 'and' i.e all keywords must be present.
Secondly if the question is passed, it does not change the overall test score. I don't know why. Can you please help?
Hello Matthew.
I am guessing this would solve the AND logic problem i am having.
Many thanks
This discussion is closed. You can start a new discussion or contact Articulate Support.