Is it possible to restrict input for a class activity
ie
restrict input to be an integer between 0,100 only
Is it possible to restrict input for a class activity
ie
restrict input to be an integer between 0,100 only
Absolutely. Use the errorMessage sink in a math input or cellErrorMessage in a table. Set the condition and th warning you want it to display and leave otherwise as an empty string. The sink will spit out a message and prevent submission.
is there a type() function?
how do I check that the number is not an interger:
errorMessage: when type(numberEntered) != int
?
In your graph (or with CL numericValue) you can check if mod(a,1)=0
should be ānotā instead of ā!=āā¦
mod function is not defined in CL. Does that mean I need to make my own function to do this?
errorMessage:
when not(mod(studentNumber,1) = 0) āinput must be an integerā
otherwise " "
sorry very new to thisā¦
Yeah not in CL. If you have a graph Iād recommend putting it in there, defining it as a number and then pulling into CL. If not you can put almost any function from the calc into CL by using numericValue(ācopy/paste function hereā).
Donāt forget:
Interpolate the variable into the string with ${}
Add in a second backslash wherever you see one.
Itāll look something like this:
numericValue("\\operatorname{mod}\\left(${input.numericValue},1\\right)")
when that equals 0 you have an integer so if you want to restrict to integers you can do something like:
errorMessage: when not(numericValue("\\operatorname{mod}\\left(${input.numericValue},1\\right)") = 0) "Enter an integer." otherwise ""
Right! Iām very close.
errorMessage:
when not(numericValue(āmod(${studentNumber},1)ā) = 0) āinput must be an integerā
otherwise " "
[^^ gives me error message but for every input ]
whats with the operatorname left right business?
Thatās the latex parsing in. When in doubt go into any Desmos calc and type what you want, then copy/paste into CL.
Thank you so much Jay!!
Clever use of mod, that is definitely a cleaner way of checking for integers than what I was doing. I would subtract the rounded version of the variable (i.e a - round(a)) to see if it equals zero or not.