[Help please!] Basic Calculator with Click to generate random number and user inputting a number

Jan 28, 2021

Hi,

I am trying to create a module that will contain:

1. A box to generate a random number 

2. A second box for user input for a number
3. Complete a calculation and display the output (rounding up without a decimal point). 

Can anyone give advice or tips/provide a video on how to do this?

 

Attached, please find a skeleton of for reference.

Thank you!

3 Replies
Walt Hamilton

Check slide 1 in the attached sample. You can do all the math in SL, except for rounding, and that has to be done in javascript. If you are going to repeat the action on the second slide, you need to use new variables, or reset the variables when the slide timeline starts.

You can do all the math in javascript, but I did it in SL, because it may be more obvious what is happening.

Walt Hamilton

The box with the random number is a text box. Any text that starts with and ends with % and contains the name of a Variable between them is a variable reference. When the project is run, the value of the variable will show in its place. The textbox has a trigger that sets the variable to a random number when it is clicked.

The box for the learner input is a numeric input box. They are designed to store the input value into a variable when they lose focus ( press return, click elsewhere on the slide, hit tab).

The Submit button has triggers that add the two number variables together, multiply them by 2.3, and execute the javascript, which you can read if you edit the trigger.

The javascript (which runs only in the published version), does the rounding.

Studying the triggers and understanding what they do, and when is the best way to understand the process, which will help you be able to replicate it.

If you have questions, I will be glad to answer them.