Restricting input


#1

Is it possible to restrict input for a class activity

ie

restrict input to be an integer between 0,100 only


#2

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.


#3

is there a type() function?

how do I check that the number is not an interger:

errorMessage: when type(numberEntered) != int

?


#4

In your graph (or with CL numericValue) you can check if mod(a,1)=0


#5

should be “not” instead of ‘!=’…


#6

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…


#7

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.


#8

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 ""

Here: integer check • Activity Builder by Desmos


#9

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?


#10

That’s the latex parsing in. When in doubt go into any Desmos calc and type what you want, then copy/paste into CL.


#11

Thank you so much Jay!!


#12

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.