Input Values of a Table--Shows correctness for more than just numbers


I am trying to use a table to show the correctness of inputting a number, but the CL code is marking both -7 and -7x as correct. Not sure how to fix this, but here’s my code for the table:

cellContent(1,3): when table1.cellNumericValue(1,2)= 1 “:white_check_mark:” OTHERWISE “No”
cellContent(2,3): when table1.cellNumericValue(2,2)= -7 “:white_check_mark:” OTHERWISE “No”
cellContent(3,3): when table1.cellNumericValue(3,2)= -4 “:white_check_mark:” OTHERWISE “No”

correct: table1.cellNumericValue(1,2)= 1 and table1.cellNumericValue(2,2)= -7 and table1.cellNumericValue(3,2)= -4
cellDisableEvaluation(2,2): true
hidden: turnin.pressCount>0

I am not sure how to adjust my coding so that only the inputted numbers are marked correct and not extra variables. thank you.

Hi! One solution could be to check if the letter ‘x’ shows up in the latex of any of the cells. Here is an implementation of that based on examples from the February ('23) CL Newsletter:

This could be easily adapted to check for multiple letters, but it would be extremely tedious to check all letters. I’m curious if anyone has ideas for another approach :thinking:

Just check that it’s not an expression of any type - it’s simpler and guards against any type of variable.

Something like this works. I used a math input instead of a table but the same logic applies:

correct: this.numericValue=7 and


I like using patterns for this. You want to check that the value entered matches with the “number” pattern, which will filter out any letters or other symbols.


Thank you for this! It worked as you mentioned. I noticed that it fixed the problem with adding an x, but students who added another variable after the number got it marked correct too. Seems like an odd feature to have that marked correct. I appreciate the help!

Thank you! I appreciate the help–this is what I needed.

Thank you for this example! I will keep this in mind.

I’ve used:

 isDefined(simpleFunction(input)) and isDefined(simpleFunction(input, `y`))

For the first, any variable other than x used will be undefined, same if x is used in the second, so any variable will be false without having to be so specific.

Also, to answer your query, it’s marked correct to allow for the use of units of some sort, so it is a feature, not a bug. :smile: