How can I code a table to check if a student input is evaluated in the given expression?

Here is my activity. Evaluate using a table

I know how to code it to have exact correct answers in a table but I do not know how to have it evaluate at any input a student may choose for their x value.

Try this in your table component.

f = simpleFunction(`2x+3`, `x`)

cellContent(1,3):
  when isBlank(this.cellContent(1,1)) or isBlank(this.cellContent(1,2)) ""
  when f.evaluateAt(this.cellNumericValue(1,1))=this.cellNumericValue(1,2) "βœ…"
  otherwise "❌"
1 Like

You can also use the graph for the sketch that is on the screen already.

2 Likes

You guys are awesome! They both work great. Thank you so much :smiling_face_with_three_hearts: :smiling_face_with_three_hearts: :smiling_face_with_three_hearts:

I might also add the suggestion to expand the second line so that it won’t display the correctness until after they click outside of the cells for the coordinates. That will discourage them from fishing for a checkmark.

f = simpleFunction(`2x+3`, `x`)

cellContent(1,3):
  when isBlank(this.cellContent(1,1)) or isBlank(this.cellContent(1,2)) or this.cellHasFocus(1,1) or this.cellHasFocus(1,2) ""
  when f.evaluateAt(this.cellNumericValue(1,1))=this.cellNumericValue(1,2) "βœ…"
  otherwise "❌"
2 Likes

Do you always have to use a simple function when student input is not a numerical value? Is there a way to just check the input being something like x^{2}+5 ??