Help with text questions

Jul 23, 2023

Issues I am having: 

  • slides move forward without answering if I press enter
    • I've tried removing the free form to regular slide
    • removing the submit button from free form
  • the 50 minimum for text entries isn't working with all of them
    • honestly, the java scrept I put is .50length. . . not entirely sure what that means. 

Hello, I am new to storyline. I've tried some javascript to help with trying to install a word minimum before continuing. Could you help me figure out why I am having the issues listed above? 

 

4 Replies
Jose Tansengco

Hello Lorena, 

Thanks for sharing a copy of your project file! 

I tried replicating the behavior with the 'Enter' key, but I found that the only way I could move forward with this key was if I clicked inside the text input box first. Is this the same behavior you're experiencing as well? For your reference, you can check out this link so you can test if you'll encounter the same behavior that I did using the same project file. 

Additionally, it appears that your 'Error' layers would only activate if a certain variable was set to a specific value, but this variable didn't have any triggers associated with it that could adjust its value. Please see the screenshot here, referencing Q1_ERROR

Was this by design? Note that variables are global resources, which means that their values will be true across all of the slides. Please take this into consideration when using variables in your project.

As for the Javascript issue, I'll let other members of the community who are experts in Javascript chime in with their thoughts on your code. They might spot something that you can change to make it work!

Also, I wanted to invite you to our tips and tricks webinars. Once each month at 11am ET, our training team hops on a live call to answer top questions from our customers.

It's super casual (and they're super smart!), so it's a great place to get expert tips and answers to frequently asked questions from our online community. In short, everything you need to create incredible online learning! You can register for the next call here: https://articulate.fyi/3ZiKgu9

And don't worry if you can't make it, because everyone who registers will get a recording sent to them afterwards! There's also a huge list of on-demand past trainings available.

Hope to see you there!

Walt Hamilton

Joe referenced your problem with the variables, but here's a more detailed explanation.

You are using two variables to do the work of one, and they are not collaborating well. Consider what could happen. The learner makes a valid entry. The JS sets Q1_Valid to true, and all works well. Then on the next question, they make an invalid answer. The JS sets Q1_Error to true, but doesn't change Q1_VALID, so now they are both true. You can see how confusion as to which path to follow would ensue.

Additionally, If Q1_VALID is true, and the JS determines the answer is valid, it sets Q1_VALID to true and passes it back to SL. But SL doesn't consider setting a true variable to true as a change, so that trigger doesn't fire. What you need for the .story, and the JS is one variable, like Q1_VALID. Then have the JS set it as either true or false, and use that in your conditions.

There are two things you can't predict. One is what the variable is from the previous slide, and the other is what the learner will do with it. So you can never predict if it will change or not. For that reason, you need to attach decisions (triggers) to actions you know will occur. "When user clicks Submit" is a good choice; in this instance, "When variable changes" is not.

Joe's comment about global variables means that once you set a variable, it will have that value forever, unless you change it. So you need to be careful if you use the same variable for different functions, like checking if different answers are valid. There is always a danger you will be using a value left over from a previous slide.

In this case, you can get away with it if you change your JS to:

if (Q1_INPUT.length < 50){
player.SetVar("Q1_VALID",false);
} else {
player.SetVar("Q1_VALID",true);
}

If you do that and always execute the JS before you check the value of Q1_VALID, the JS will always set it correctly.

Any questions, please ask.