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

?

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.

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.