Checking for correct answer

I need help! I hate coding and am so bad at it.
I am trying to have my students type in an answer to the math input box. Then when they click submit, it will tell them if they are correct or not. I am trying to do this on slide 5. Once I get a slide figured out It will be easy to copy it and change it for more slide.

Thank you!!

Slide 5 is currently “Explain your thinking.” Not really any way to check that without exhaustively matching their string. Virtually impossible for such an open-ended question. Otherwise, I assume you mean what is now Slide 6. I use the following in an input’s CL as a pretty standard input check (without using a separate note for feedback), but you could modify it for a note if you really wanted it:

check= this.numericValue=2
correct: check
suffix: when not(this.submitted) ""
        when check "âś…"
        otherwise "❌"

I do a similar cellSuffix for tables to eliminate the need for another column, although sometimes it can clutter a cell with longer answers or if evaluation isn’t disabled.

Thank you so much! I did mean slide 6, my bad.

So if you look at my other slides. Like slides 1-4 when there is the table, can I use the same code to only check the answers after they click submit? I think I would first need to add a Try it button. But then I could use this similar code on the CL for the button?

You can add a button. I usually do something like this (though you do need to click away from the table to see feedback on the last one):

check3= this.numericValue=2
checkAll= check1 and check2 and check3...
correct: checkAll 
cellSuffix(3,2): when isBlank(this.cellContent(3,2)) or this.cellHasFocus(3,2) ""
        when check3 "âś…"
        otherwise "❌"

Do you place this in the table CL or the button CL?

In the table CL. The above would be without the need for a button.
If you want a button change the first “when” condition:

...
cellSuffix(3,2): when not(yourButtonName.timeSincePress()>0) ""
...

(I only did “not” because I don’t remember if timeSincePress is undefined when it’s reset).

1 Like