Checking Correctness of Table Entries

You bet. In the sketch, type this: readOnly: true.

For this input, try this:

correct = firstDefinedValue(this.numericValue=80)

correct: correct

suffix: "degrees"

This allows for a label but also will ignore if a student attempts to type “degrees.” I would try to avoid checking latex because extra spaces will automatically cause the problem to be incorrect.

Thanks so much!!!

If you don’t mind me asking… to avoid using latex, how would you go about coding for question 3 (slide 3)?

You’ve so helpful!

You’re welcome! I would use parseEquation for that one. Add this to the input (don’t forget to mark the sketch as readOnly):

correct = parseEquation(this.latex).differenceFunction("w").evaluateAt(52)=0

correct: correct

The parseEquation reads the latex as an equation and the difference function subtracts the left side and the right side of the equation. Since there should be a “w” variable, if we substitute 52, the difference should be 0. This will allow for different iterations of the equation too i.e. w+w+76=180.

You could also toss in an errorMessage to make sure the correct variable is being used. This goes in the input too.

ev1 = simpleFunction(parseEquation(this.latex).lhs, "w").evaluateAt(52)
ev2 = simpleFunction(parseEquation(this.latex).rhs, "w").evaluateAt(52)

errorMessage: when isUndefined(ev1) or isUndefined(ev2) "Only use the w variable" otherwise ""

Could you alternatively have a variable for the differenceFunction, then use that for both the correctness check and for the undefined check?


correct: d=0
errorMessage: when isUndefined(d) "Only use the w variable" otherwise""

I was trying to do something like that, but couldn’t get it to work. That looks like it should do the trick.

You’re AMAZING!!!

Do you ever put on any clinics or is there a book that has all these commands and what they do? How did you learn all this? I really enjoy creating these activities and want to learn more.

I have one last question for now… how about code to check an expression?

I learned from @Jay! I started by doing the CL scavenger hunt and then just kept learning by making activities. There are webinars that @jay has hosted that are archived somewhere in this forum.

For your question, don’t forget to mark the sketch as readOnly: true. For the input, try this:

correct = simpleFunction(this.latex, "a", "b").evaluateAt(5,5)=5 and countNumberUsage(this.latex,2)=1 and countNumberUsage(this.latex,3)=1 and countNumberUsage(this.latex)=2

For the evaluateAt, I just chose to sub 5 for a and b, which happens to evaluate to 5. You can pick other numbers too. I also look for one 3, one 2 (countNumberUsage only looks for positive values), and two numbers total.

The @Jay’s webinars are in the Announcements section, but here’s all 5:

Yep! We’re also running clinics by appointment:

And hosting webinars daily:

(for a limited time)


I have quick follow up for you about this code for checking an equations most of my students wrote down the correct equations which was 2x+76=180, but I had a kid write w=52, which is technical correct but I was hoping to have it in a form “something” = 180 (or 180 = “something”) Do you have any suggestions on how to get it in that format?

Include something like this

correct = countNumberUsage(parseEquation(inputName.latex).lhs,180)=1 or countNumberUsage(parseEquation(inputName.latex).rhs,180)=1

or if you just want to check for the 180

That will just count the numbers on either side. You want to make sure that the side evaluates to 180 always. SimpleFunction on both sides checking that it’s evaluated amount always comes out to 180 should do it.

I just meant in addition to his current check, and was just answering how to check for the “=180”.

Perfect. The complete line of code shared made it seem like a complete check.

Here is an activity where students can either click to drag labels to the correct spots in an image (slide 2) or, where they can enter the correct text label name into a table (in slide 1).

In the table in slide 1, how does the code need to change so that the 3rd column shows a green checkmark when the correct text is entered in the proper cell of the table? Also, is there any way to get the “cell content” command to disregard whether the student puts a word in as uppercase or lowercase? (I will just include in the directions to use all lowercase if not).

By the way, when I get rid of the word “when,” an error occurs.

Code used:
cellContent(1,3): when table1.cellContent(1,2)= “label 1 name here” “:white_check_mark:” OTHERWISE “N”

Thanks for any help.

For slide 1, you need to change “label 1 name here”, “label 2”, etc. to whatever correct answer you’re looking for. You can add an or in to include capitalized.
Here, my intended label is “frog”:

cellContent(1,3): when table1.cellContent(1,2)= "frog" or 
         table1.cellContent(1,2)= "Frog" "✅" otherwise "N"

Thank you. Is it true you cannot have “spaces” in your cell content for the check mark to register- such as in label 2? If I change it to “frog height,” the check mark does not appear, but if I change it to “frog,” it does appear. If so, is there a way to trigger the checkmark for responses that have spaces in them?

Oh I see- I would need to put a second column in the table if there is a second word. Thank you.

As a note, when I did enter a second column in the table (it is now on slide 7, for the 4th row in the table), it is not picking up that “ground” in the first column and “water” in the second column is correct. I am not sure why.

Can you share your activity link? I think I’d actually need to look at it to help with the last question.

No, you don’t need another column. It should be okay if you change it to “frog height”. The answer just has to exactly match the text intended. So, if you want “frog” and a student accidentally enters a space at the beginning or end of “frog” it will be marked incorrect. There shouldn’t be a problem with “frog height”.