Correct answers in the conditions file not loading on Pavlovia and the Feedback is always wrong

URL of experiment: Kartikeya Dhagat / REET · GitLab
OS: Win10
PsychoPy version: v2020.2.1
Description of the problem: Working perfectly in PsychoPy (offline). On Pavlovia, the incomplete participant’s output file shows the input keys (VTrialResp.keys.keys) but not the correct answers stored in the conditions file (VcorrAns). I believe that the the correct answers are not being loaded and hence always shows the feedback to be wrong as VTrialResp.corr = 0.
VcorrAns, the correct answers, are in an array in the conditions file.

What I’m trying to do: An individual is to simply memorize the sequence of colors and, at its end, must reproduce it during the limited response time. This loops a couple of times.
What’s going wrong: Array of correct answers not being imported for any sequence, feedback shows as wrong every time

What Have I tried:

  1. Reinstalled PsychoPy
  2. Tried name ‘corrAns’.
  3. Uploaded as a new project.
  4. Tried changing values to string
  5. Adding / Removing brackets and apostrophes [ " / ’ ]
  6. Sacrificed a goat (jk)

Please help me!

@wakecarter Hey, I see you extremely active on so many forums, and you have almost always managed to come up with a possible solution. Could you help me out here, if possible? Don’t want to take too much time of yours but I’m desperate at the moment.
Thank you!

Two possibilities:

  1. Remove the square brackets from the cells in your spreadsheet. The commas will probably already be indicating an array.

  2. Have a separate column for each correct answer so you can enter right, left, etc without quotes and build the array in PsychoPy.

@wakecarter That’s perfect, so I tried the first option and now it shows in the output file. The only problem I’m having now is that the .keys has brackets around it and the VcorrAns does not. Any idea how I can remove the brackets in the VTrialResp.keys / add brackets in VcorrAns in the output CSV file such that it is able to correlate.

As per my crib sheet, you can’t compare whole arrays in Pavlovia, you have to compare individual elements.

You could define a function to compare arrays in Before Experiment list this:

def compareArrays(list1,list2):
     outcome = True
     if len(list1) == len(list2):
          for Idx in range(len(list1)):
               if list1[Idx] != list2[Idx]:
                    outcome = False
     else:
          outcome = False
     return outcome

Then you could add

score = compareArrays(VTrialResp.keys,VcorrAns)
thisExp.addData('Score',score)

@wakecarter Hey! I tried this but its now saying compareArrays not defined. Would it be possible for you check out the code here? Sign in · GitLab
The task seems so simple, I don’t know why I’m unable to get it to work. The function is not being defined. Is there something wrong in the translation?

I don’t have access to your code.

Did you put the def compareArrays in a Before Experiment tab?

Please could you show screenshots of where you define it and where you use it?

I reset my cache and now it shows this.

@wakecarter
Here is the code, now public: DT.js · master · Kartikeya Dhagat / DISK · GitLab
Here are the screenshots of where I define it and use it.


Thank you so much for your help. I was feeling lost.

It looks like the function is working but you should be checking the score in End Routine. In Begin Routine the response keys aren’t defined because no key has been pressed yet.

Alright, it is working now but I’m running into the same problem I was, i.e., VTrialResp.corr is always 0 and the data file looks like this. The code didn’t solve the problem. Any other ideas? Thank you.


DT.js · master · Kartikeya Dhagat / Disco · GitLab (pavlovia.org)

Where is your column called Score?

My bad, I used the older screen shot. Here you go. The score is still saying false. What should I do?


If you could please do something on your end, I’d be grateful. Thank you!

Please could you add

print('Does ',VTrialResp.keys,' equal ',VcorrAns,'?')

next to the compareArrays call and then look at the Browser console to see what you get?

Here you go. It’s showing it cannot read the property.


Are you making edits direct to the JS file instead of via the Builder?

Since your VTrialResp routine has a duration you need to only compare arrays if at least one key has been pressed.

e.g.

print('Does ',VTrialResp.keys,' equal ',VcorrAns,'?')
if VTrialResp.keys != undefined:
      score = compareArrays(VTrialResp.keys,VcorrAns)
else:
      score = '.'
thisExp.addData('Score',score)

I was in fact making direct edits to the JS file. Doing it on the builder makes it work again. Sadly, the score still shows false. I have attached the console log as well as the output file. Thank you for your assistance. I feel it’s extremely close to working.
Let me know if I could message you personally or is the forum a better method of communication for you.