# Number from numberList

Hello CL Community,

I don’t know why I cannot wrap my head around the coding for what I want to do. I need some help.

I want to make a quiz that randomly assigns all students a different problem. In a graph, I made two lists. The first was D=[1,2,4,8] and the second was N=[1…10]. I would like to randomly choose a value from D called d_1 and another from D I would call d_2. Similarly, i would choose two values from N. Then, in a Note, I could present those values as a fraction edition problem (n_1/d_1) + (n_2/d_2) for the students to solve. Students could then write their answer in a math input component to be checked against the answer I compute through the graphing component. How would I do this, or where can I find CL documentation and examples to mimic.

Thank You in Advanced,
Richard Punches

It sounds like you just needed help with lists in the graph, so here’s an example of what you described. From here, you can call on the numerator and denominator variables in the note.

1 Like

Thank you for the example. That gives me some extra ideas with which to work. When I looked at your use of shuffle, it always gave me the same values for each variable. I tried to open the code multiple times to see if it would change, but it did not. Where can I locate syntax for shuffle in the desmos calculator component? I don’t see anything about shuffle in the CL documentation online.

The shuffle function is part of the graphing calculator, so you won’t find it in the CL documentation. There are two ways to re-shuffle your lists. The easiest way is to just press the wavy arrows at the top of the expression list. Each press will shuffle the lists. The second way is to pass a second parameter to the function. Here’s an example of this from the original graph from before.

1 Like

That new parameter is cool. Thanks for the help.

I was just thinking, and maybe I misunderstood your original post, but if you are looking to have students try several problems per screen, you don’t need to rely on the graphing calculator. If you use a note component and a math input, you can accomplish the same task. In the note component, use this code:

r = randomGenerator(input.submitCount)

numerator1 = when input.timeSinceSubmit>0 input.lastValue("numerator1") otherwise r.int(1,10)
denominator1 = when input.timeSinceSubmit>0 input.lastValue("denominator1") otherwise numericValue(2^{${r.int(0,3)}}) numerator2 = when input.timeSinceSubmit>0 input.lastValue("numerator2") otherwise r.int(1,10) denominator2 = when input.timeSinceSubmit>0 input.lastValue("denominator2") otherwise numericValue(2^{${r.int(0,3)}})

problemDisplay = \frac{${numerator1}}{${denominator1}}+\frac{${numerator2}}{${denominator2}}


In the input component, use this code to capture the random values.

capture("numerator1"): note.script.numerator1
capture("numerator2"): note.script.numerator2
capture("denominator1"): note.script.denominator1
capture("denominator2"): note.script.denominator2


I think you hit it right on the nose with that bit of CL. While you were doing that, I did the following:

In the desmos graph I put:

In the graph CL:

a=randomGenerator()
k1=a.int(1,9)
n_1=graph1.numberList(N).elementAt(k1)
k2=a.int(1,9)
n_2=graph1.numberList(N).elementAt(k2)
k3=a.int(1,5)
d_1=graph1.numberList(D).elementAt(k3)
k4=a.int(1,5)
d_2=graph1.numberList(D).elementAt(k4)

In the Note component:

content: "{graph1.script.n_1}, {graph1.script.n_2}, {graph1.script.d_1}, {graph1.script.d_1}

\frac{${graph1.script.n_1}}{${graph1.script.d_1}} + \frac{${graph1.script.n_2}}{${graph1.script.d_2}} ="

in the Math Input component:

disableEvaluation: true

n1=graph1.script.n_1
n2=graph1.script.n_2
d1=graph1.script.d_1
d2=graph1.script.d_2

myans=this.numericValue

ans1=simpleFunction("\frac{a}{b}+\frac{c}{d}",“a”,“b”,“c”,“d”).evaluateAt(n1,d1,n2,d2)

suffix: when isUndefined(myans) “” when myans=ans1 “yay” otherwise “Try again.”

You can check it out here.

Richard Punches
Britton Middle School
669-253-6216

1 Like