Creating a range of values for self correcting problems

I am (of course) new to CL and I am trying to adapt another teacher’s self-correcting activity to my use. Students are supposed to enter a numeric value, but some students may reasonably round values to different places. How can I take

correct = this.numericValue = 0.40625

and change it so that it will code anything between 0.4 and 0.41 as correct?

There’s a few ways:
correct = this.numericValue >= 0.4 and this.numericValue <= 0.41

or within (in this example) 0.01 of 0.41:
correct = numericValue("\abs(0.41-${this.numericValue})") <= 0.01
(Edit: I like the above because you can see the value intended as well as the tolerance desired. You could also have a variable instead of 0.41, so you could reuse the code and only have to change said variable. As opposed to the one below, because you may need to calculate the 0.41 somehow which would then require a similar rounding format making it a bit clunky looking.)

If you wanted correct rounding to 2 decimal places:
correct = numericValue("\round(${this.numericValue},2)") = 0.41

1 Like

Thank you! Post must be at least 20 characters long.

1 Like

Haha! Post must be at least 20 characters long.

As another thought, I got around this most of the time by requiring students to round to a certain level of precision by adding the following to the math input:
errorMessage: when not(numericValue("\operatorname{mod}\left(${missingAngle1.numericValue},1\right)") = 0) "Enter a number rounded to the nearest whole!" otherwise""

Change the 1 to 0.1, 0.01, etc. for whatever level of precision you’re looking for.

Thanks for the option!

JM

you could also use >0 instead of not(...= 0)