Type an expression into a table

Good day.

I’m creating table in which students can check their answers. Some of the answers are numbers and some are expressions. How to write the line for variable expression input?

Here are some of the lines for the number check. But I desire a line that would check 2r, as an example:

submitButtonText:“Check my work.”

isCorrect1=table3.cellNumericValue(1,2)=14 and table3.cellNumericValue(1,3)>43.8 and table3.cellNumericValue(1,3)<44
isCorrect2=table3.cellNumericValue(2,1)=13.4 and table3.cellNumericValue(2,3)>84 and table3.cellNumericValue(2,3)<84.2
isCorrect3=table3.cellNumericValue(3,1)=13 and table3.cellNumericValue(3,2)=26

something like:

isCorrect4=simpleFunction(table3.cellContent(4,2).latex,“r”).evaluateAt(1)=2 and simpleFunction(table3.cellContent.latex(4,2),“r”).evaluateAt(2)=4

in simpleFunction, first parameter is whatever expression you want. Following that are any variables in the expression in quotes. evaluateAt() does what it sounds like. You need as many parameters as there are variable parameters in the simpleFunction.
Then, if it was supposed to be “2r”, I’m saying if you evaluate at r=1, then it should be 2 and if you evaluate at r=2, it should be 4.
You can clean up the above code by setting a variable for the function.

exp4=simpleFunction(table3.cellContent(4,2).latex, “r”)

isCorrect4=exp4.evaluateAt(1)=2 and exp4.evaluateAt(2)=4

If you have a graph component, there are other methods to calculate in the graph.

So… I tried the suggestion at the end of this post and the .latex isn’t working in the table. How can I check a table for the correct expression with one variable?
Here’s a picture of the table:

I’ve got some code in it currently that checks the content in quotes , but I want that’s too limiting. Suggestions?

I’ve learned a bit since then. Take out the .latex and I think it should work as is. If not, try it inside “${ }”.

I tried it without the .latex and it didn’t show an error on the CL, but it also didn’t show correct in the table. Where should the ${…} go? Other suggestion?

exp1=simpleFunction(this.cellContent(2,2),"3x+9")
isCorrect1=exp1.evaluateAt(1)=12 and exp1.evaluateAt(2)=15
cellSuffix(2,2): when isCorrect1 "✅" otherwise ""

Take out “3x+9” in the simpleFunction.

1 Like

Sweet! That totally worked! TY!

The second part of simpleFunction is for what variables your function is in terms of:

recArea=simpleFunction("l*w","l","w")
circArea=simpleFunction("\pi*r^2","r")

If there is no second parameter, it defaults to in terms of x.