# Trying to check students answers for slope

I’m trying to write the code for students to get immediate feedback on whether they found their slope correctly from a table of values that they create. I am super new to this and have no clue where to start. I will include a link to my activity

If the students are filling in the table, what I’d do is call the table something like table1

On the slide where they find the slope, write something like

y2=table1.cellcontent(2,2)
x2=table1.cellcontent(2,1)

y1=table.cellcontent(1,2)
x1=table.cellcontent(1,1)

m=numericValue("\frac{(${y2} -${y1})} {(${x2} -${x1})}

Correct= when numericValue(input.latex)=m "correct" otherwise  "incorrect"


If you don’t have an answer in the morning I’ll make an actual slide with the code

something like this.

Thank you so much for the help…I have it so that the students submit and get feedback, however I can’t get the feedback to be accurate…it always assumes answer is wrong…

Also, the data will be messy so students will have to round to 2 decimals for their slope…guess I should use a float function for that?

added the rounding option. Since they are only putting in two points I only focused on the slope being derived from the first two points put in the table. When they enter them then go to the next slide, the points will be there and it is accurately assessing for correctness. I have it rounded answers to the tens and hundredths place being accepted.

You can really clean up the rounding check by checking the difference instead of all the specific rounded values… (4 less lines of code)

correct=when numericValue("\abs(${slopevalue.latex}-${m})")<0.01 "correct"
otherwise "incorrect"

1 Like

So simple and clean. I’m definitely going to steal that for the future!

Thank you Daniel, I used that in two of my slides. Ive done a lot of cleaning up of this thing thanks to you guys. Another question…Is there a way to populate the students last input on slide 6 into the slope column in the table on slide 8?

I think what messes most of us up is the backticks to get the latex to display properly.

cellContent(1,3): "\${inputName.latex}"