Adding a point for each correct entry in a table

I am trying to add a point each time a table entry is correct.

Is this a simple syntax error, or am I doing something totally wrong?
I thought I copied someone else’s code correctly, but it does not seem to work.

1 Like

Remove the quotes for the 1’s and 0’s, then they’ll be recognized as numeric values instead of strings.

This will do what you want in a more compact fashion:

c1 = when t.cellContent(1,1)="y" 1 otherwise 0 
c2 = when t.cellContent(2,1)="y" 1 otherwise 0 
c3 = when t.cellContent(3,1)="y" 1 otherwise 0 
c4 = when t.cellContent(4,1)="y" 1 otherwise 0 

PointsEarned = numericValue(`${c1} + ${c2} + ${c3} + ${c4}`)

But I wouldn’t recommend this. If someone types " y" or “Y” or "y " or any other slight difference from “y” and only that, it’ll get marked wrong. That might be what you want but…

There are a few other things maybe to think about but start there i’d say

thanks…I am just playing around with the code…eventually they will put more complicated stuff in the table…I just used ‘y’ so that i could quickly test the code!!

I still don’t see what the problem with my code was…

And thanks for helping me out so quickly!!

Amazing how quickly you guys help out…thanks again…removing the quotes did it.

Ok…now I would like to put those “points earned” in a table at the end of the activity, and then total them up…

Here is an abbreviated version of the activity.

The first slide will be filled out, but we have done these slides in class many times, so they know what to put in the boxes. I was toying with a way to give an assessment. I feel like I am pretty close!

I got it…
thanks again!

The issue was your initial point outputs were “1” and “0”, which are strings. Strings, numericValues, latex, etc. are all different types of inputs/outputs. When you were calculating in numericValue, it didn’t want to accept strings. It needed to be either latex or a numeric value.

Got it! Sort of…I appreciate the help…I have it working pretty well…

Now I am trying to “capture” a student’s score, and then allow them to go back and look at the questions.

This is an abbreviated version of the assessment.

Thanks again for the help…