A fill-in-the-blank question using random numbers

Hello,

   I've been able to find how to give a variable a random number, but I'm not sure how to incorporate variables into quizzing.   I would like to have a question like "what is the sum of [random#1] and [random#2] ?" with [random#1] and [random#2] being some integer between 1 and 10, and have the correct answer be [random#1] + [random#2].

   So, maybe the student sees "what is the sum of 3 and 7?" and the accepted answer is "10".   The next time the student takes the quiz, maybe the student sees "what is the sum of 2 and 5?" and the accepted answer is "7".   Can this be done with SL?

Thanks!

Mike

13 Replies
Josh Uhlig

If you have the random number figured out, then you should be able to accomplish this by doing the following.

  1. Create a third variable (perhaps randomSum).
  2. Assing random numbers to random#1 and random#2 
  3. Adjust randomSum to equal random#1
  4. Add a second trigger under the last to adjust randomSum again to add the variable random#2 to its current value
  5. Check that the value entered by the user (a fourth variable) is equal to randomSum

In order to actually create a graded quiz question out of this, you may need to add some additional variables and functionality that basically sets a true/false question to true when randomSum equals what the user entered and false when it is not.  To the user it will look like a fill in the blank question, but it will be a true/false question behind the scenes.

Hope that makes sense.  Attached is a example (though I was not able to get my Javascript random number generator to work).

Mike Hull

Hello,

   Thank you for your quick replies and, Josh, thanks so much for making that example for me!   For some reason, however, the numbers remain at the default values of 2 and 4, no matter how many times I open the published program.   Similarly, when I publish according to these instructions:

https://player.vimeo.com/video/145576547

I see that I just get the text box to display whatever the default value of randnum is... I checked to make sure that javascript is enabled in the browser that I'm using to open the published story.html file... any thoughts?

Thank you!

Cheers,

Mike

Mike Hull

Hi Josh,

   Thanks for your quick reply again!   Actually, I just now saw your reply - the first replies I got were sent to my e-mail, so I assumed that reply would be as well?

   I have tried both files.   My computer runs them with the identical problem.   And, if I run it once, exit, and run it again, I get

"Resume: Would you like to resume where you left off?"

If I say "yes", it takes me to the results slide.   If I say "no", I always see 2 + 4...

Including when I try using Internet Explorer :(

Thanks,

Mike

I am attaching a simpler file that should just generate a random number on the first slide.   For me, though, it's always the default number of "1".   Maybe this can be used to diagnose what my problem is?

Mike Hull

Hmm, that wouldn't surprise me.   I feel like normally my browser will tell me when that is going on, though.   Is there a way for me to check and find out?  

And, perhaps more seriously, if my student CHOOSES to disable scripts or something, they will also always see "2+4", right?   So an easy way to cheat would be for a student to make an answer key saying "the answer is 6, but you must disable scripts".   If that's the case, then that might be something for Articulate to think about, because I think many educators want problems that are randomized to prevent such answer keys from getting made... or is there a way to make it such that the publication doesn't load at all unless scripts are enabled?

Thanks for all your help,

Mike

Josh Uhlig

If you are running the presentation from an LMS or webserver, I believe the scripts will typically be enabled.  It really comes down to your internet security settings though.  There isn't anything Articulate can do about it since it a preference a user can choose on his own.  Articulate is never going to be able to override a computer's security settings.  It is probably best to add some instruction on enabling scripts if you feel it is a problem.

You could always keep the presentation from advancing based on whether the values have changed for a variable.  For example, you have javascript that randomly gives a value of 1 to10 to a specific variable on the first slide.  Initially set the value of that variable to 99.  Then on one of the first slides you can check if the value is still 99.  If so, lightbox a slide that tells the user he must enable scripts and restart the presentation.  You could even lock the ability to advance to the next slide by adding a condition to the 'next slide' trigger that the variable is not equal to 99.

Mike Hull

Hello,

   OK, some success!   Sure enough, when I post on Blackboard, the random number generator works!   Well, it works for the simple random number generator I sent you.   For some reason, I'm still getting 2+4 for both of the files you posted :(

   However, there is another issue that I've realized.   Is there a way to do the addition inside of javascript, instead of having two triggers, one to assign and one to add?   Suppose we had a problem of, instead of addition, something like "what is [random1] raised to the [random2] power?"   (Like 2^3, 3^6, etc.)   So even if javascript doesn't have exponentiation built into it (I've never programmed in js before), presumably we could solve the problem with loops (loop from 1 to [random2], each time multiply [answer] by [random1]).

   I hate to keep bothering you, but I wonder if there is a sample .story file that does this addition inside of javascript instead of via triggers?

Thank you very much!