CL to evaluate whether expression is correct

I would like students to type an expression into a maths box (collecting like terms) such as 13a+13b, and be able to check they have entered the correct expression.

I thought if I subsituted values into the expression and checked their expression gives the correct answer it would work.

My code so far is for the maths box ans1 is : (which I’m trying to adapt from this activity CL Scavenger Hunt Example 28 • Activity Builder by Desmos)

capture(“E”): simpleFunction(ans1.latex,“a”,“b”).evaluateAt(2,100)

check1= when this.numericValue=1326 1 otherwise 0

correct: check1=1

but at the moment its not taking the expression I type into the box

Sorted it :

disableEvaluation: true

capture(“E”): simpleFunction(ans1.latex,“a”,“b”).evaluateAt(2,100)

check1 = when(ans1.lastValue(“E”))=1326 1 otherwise 0

correct: check1=1

I’ve been using the above method to check whether students have expanded brackets correctly. However when I use the code below in a note box that asks the question it displays 5x^3(5x+1), I want it to display the cubed as a superscript. How would I do this?

content: “{message} {feedback}”

message = "Expand content: “{message} {feedback}”

message = “Expand 5x^3(5x+1)”

feedback = when ans4.submitted and ans4.script.check4=1 “\n\n\n✅Good work ! !”
when ans4.submitted “\n\n\n❌Wrong answer. Please try again.”
otherwise “”

"

feedback = when ans4.submitted and ans4.script.check4=1 “\n\n\n✅Good work ! !”
when ans4.submitted “\n\n\n❌Wrong answer. Please try again.”
otherwise “”

"Expand `5x^{3}(5x+1)`"

Using backticks instructs Desmos to use latex in the string. Exponents in CL need to be in curly braces.

1 Like

Just tagging on to add that _{} is latex code for subscript as well.

e.g. f_{1}=2x^{3}+3

1 Like