How to check units

I want to check a students input for correctness including units.(answer is 126 cm squared)

This is what I am trying but its not working:

disableEvaluation: true

check20= when this.latex =126{\cm^2} 1 otherwise 0
correct: check20=1

It might not totally fix the problem, but you should have 126\cm^{2}

1 Like

You’re unlikely to be able to check units in this way.
Desmos does not handle units well(at all really) in the Math Input field.

You might try asking a follow on question about units, but keep the units out of this particular field.


You can check by turning the student input into a function in terms of c and m and evaluating for a few pairs of values:

target= simpleFunction(`126cm^2`,"c","m")
ans= simpleFunction(this.latex,"c","m")
check20= target.evaluateAt(2,3)=ans.evaluateAt(2,3) 
and target.evaluateAt(3,2)=ans.evaluateAt(3,2)

Fixed now, but forgot the variables in the second function.

1 Like

You could include a hidden multiple choice option for units separately that appears after they’ve submitted their numerical answer. Not pretty, but solid workaround.


Hi thanks. I’ve used your code which works when I specify the object ans20. however I use check20 on slide 1 to get a total score using this code:

content: “You got ${total} out of 20 questions correct.”

and am now getting the error message:

“Unexpected type in latex interpolation : boolean”

previously this code was working.

Without looking into your activity, I can see one potential problem:

numericValue needs this format:


Note the quotes around the whole expression!

The code in the () brackets is actually already enclosed by`` - they just don’t show up when copied over. When I delete

the code works. The problem started to occur when I changed the code on slide 20 (as Daniel suggested) that checks for correctness of both number and units of length.

Ah, ok!

You are using Daniel’s code on slide 20 now, right? Your original check20 was a number, but Daniel’s is a boolean, which would explain your problem. You could just add another variable to add instead, like

thingToAdd = when check20 1 otherwise 0
1 Like

Yes, seems to be expecting number. Will try that thanks

Thanks Aether , that solved it. Was getting myself confused that just because I was giving a value of 1 or 0 to check20 previously that it was boolean!! DUH


Yes. Given that is practically impossible for students to correctly enter metric units into a maths field, since metric unit symbols must always be in upright case (and separated from the numeric part by a space or product dot), it’s better to not have them enter them at all.

Units is an area where students commonly stuff up - I really wish Desmos and other platforms would put some serious thought in how we can do this better.

1 Like