Checking student input

I am attempting to check if a student enters the correct response for a pythagorean theorem problem. Right now I am using the code:

ans=simpleFunction("\sqrt{a^2+b^2}",“a”,“b”).evaluateAt(exp6.numericValue,exp7.numericValue)

correct: exp10.numericValue=ans

This code works fine if the answer is a perfect square! It does not work if the answer is irrational . Suggestions on how I can handle this? I would like it to tag the answer as correct if the student enters the EXACT value as a square root into the input box.

You can either round both the answer and the key to a few decimal places or check for exact latex if you are concerned about simplest radical form. Both methods have advantages and drawbacks

Thanks Jay. What is the best way to round values in CL? I assume its simpleFunction but that does not seem to work. I am using this set of commands to first calculate the answer and then round that answer. I copied the Latex for the round command directly from Desmos.

ans=simpleFunction("\sqrt{a^2+b^2}",“a”,“b”).evaluateAt(exp6.numericValue,exp7.numericValue)

round=simpleFunction("\operatorname{round}\left(k,2\right)",“k”).evaluateAt(ans)

I was able to solve my problem. It looks like when I copied the ‘round’ command from Desmos, I got too many symbols. Namely the ‘\left’ and ‘\right’.

The commands below successfully check a students answer to two decimal places based on the previous inputs exp6 and exp7.

ans=simpleFunction("\sqrt{a^2+b^2}",“a”,“b”).evaluateAt(exp6.numericValue,exp7.numericValue)

round=simpleFunction("\operatorname{round}(k,2)",“k”).evaluateAt(ans)

1 Like

Here is the completed activity I was creating with this functionality.

2 Likes

I am trying to have the students find the percent error of a number and then it tell them if they are correct. I am missing the coding for determining if the student is correct and any help in this area would be awesome.