Correct response count and re-doing the trial

Hi all,

Im trying to set the coder to tell participants to do the same trial again if they didn’t get 80% correct and do tell participants what their percentages were during the trial. I have written this code and was wondering if anyone can check:

  1. if its correct
  2. if im missing anything
  3. how to add into the text the percentage the participants got

Thanks,
Screenshot 2021-11-16 at 13.41.18

You seem to be using CorrResp as both an array to store the scores for each trial and the trials themselves. You are also then comparing this array with a number.

The easiest way to calculate the proportion of correct responses is to have two numeric variables: one that increments every trial and one that only increments on a correct response.

Would you be able to let me know which code id need to do that? Thanks

If CorrResp is the score for a trial then you could do the following.

nTrials = 0
nCorrect = 0



nTrials += 1
if CorrResp:
     nCorrect +=1


if (nCorrect / nTrials) >= .80:
     GreenPractice.finished = True

Hi, thanks for your help so far its been really helpful. I implemented the code you said but im getting a CorrResp is not defined unless I add it above the nTrials section but if I do it doesn’t stop you if you get less than 80% correct it just lets you carry on.

Also, how to I tell participants how many they got right? Like what code is needed in the sentence to tell them this is the percentage of correct scores?

Thanks so much

Now you’ve shown more of you code, I can see that you don’t need CorrResp at all. Just put nCorrect += 1 in the line below where you save CorrResp to the data file. (line 3 of your code in the image).

nCorrect = 0 and nTrials = 0 needs to go before your trials loop starts.

Ive moved everything around but it still just continues on to the next section.

I’m not used to coding direct but GreenPractice.quit doesn’t look correct. Try replacing it with break

However, you might also want to add a minimum number of practice trials.

Or you need an outer loop that repeats your GreenPractice loop and you should put the reset and checking code in that.