Linking random variables from a note box to a text box


I have a note box which contains this code.

r = randomGenerator()

a =,20)
b =,9)

content: “Determine the volume of a cylinder with a height of {a} cm and a radius of {b} cm. Enter your final answer below and show your work on your submitted sheet”

I would like to then have a math input where the students type the answer, but I want the text input to check the answer for the students so that they know if they were correct. How do I link the randomly generated variables to the math input?

You can access a variable created in Component 1 in Component 2 using this general format:

newVarNameHere = component1.script.varName

So if your note was Note1:

a= Note1.script.a

Then do whatever you need with a and b within your component. I generally prefer to create random variables where my calculations live, so if I decide to make changes I don’t need to switch back and forth between components. I’d personally use the above method to import into a note component, since they’re really just for display purposes, but it comes down to personal preference.

1 Like