Total Correct Yields Only Undefined

I am trying to compute the total slides that are correct in this activity on slide 13. The result is always undefined. What did I do wrong? Help.

So, I think the reason actually for the NAN error is that you have an extra “+” at the end of your summation statement on slide 13. Taking that out eliminates the error… but…

I still don’t think this is going to work the way you intend. Your statements correct = 1 are going to contribute 1 to the tally no matter the correctness of the screen. You want to tally a +1 only IF the screen is correct, but correct = 1 is giving a variable “correct” the value 1, it is not checking against the correctness check.

So I just played around a little bit, and there is probably a better way, lol… but this ought to work.

In the component, for example the first math input, I put:

check1 = c1graph.number(“I_c”) = 1

correct: check1

sum1 = when check1 1 otherwise 0

So check1 is the test for correctness, and then the correct sink will be true if check1 is true and 0 otherwise. (I always prefer to do correctness checks this way - in a separate variable - because then that script can be called wherever needed.) So then you can also USE the script check1 to “tally” the score in the variable sum1.

Now in the note on screen 13, I used:
total = numericValue("{c1input.script.sum1}+{c2table.script.sum2}")

(I only fiddled with the first 2 screens, but you get the idea, and I was able to test it and it seems to work - no NAN error.)

You are amazing! Thank you for your help!

1 Like