Check for Any Number vs Text

Is there a way to check that students have entered a number in a table, without specifying what number? I just want to check that they have entered a number and not other text. If I use isblank the dashboard will display a check mark if students enter any text, but I only want it counted correct if they enter a number.

checkNum= countNumberUsage(this.cellContent(1,2))=1

This would check if there is one number entered. It can be an integer or decimal, but not a fraction which uses two numbers. It would still accept an expression like 2x also, so you may want to pair it with something else. There’s also patterns. Something like this. I’m not sure how inclusive/exclusive each thing is. I’d test with what you do and don’t want to accept

p=patterns
checkNum=p.anyOf(p.number, p.integer, p.fraction(p.number,p.number))
check1=checkNum.matches(this.cellContent(1,2))
1 Like

I always forget about countNumberUsage, thanks!

I thought I had the solution, but as always students find issues with my CL faster than I can. Both count number usage and patterns work until students put commas or dollar signs in their answer. For example 245678 is correct while 245,678 or $245678 are marked incorrect. I guess I could put an error message if a $ or , is typed but is there a way to change my code so those things are still marked correct?

It’s screen 13 here: Compound Interest Project • Activity Builder by Desmos

1 Like

So, have you tried putting an error message?

1 Like