My experiment won't run even as a pilot

Here is what the code looks like now:

if Resp1_key.corr == 1:
    Correct.text = 'Correct!'
else: Incorrect.text = 'Incorrect!'
sound_1.play()

The result is both ‘Correct!’ and ‘Incorrect!’ are displayed at the same time and the sound…well, it sounds like TV static from hell. The disabled component you can see in the screencap called Feedback was part of an attempt to make one text component that would display different text depending on whether the response was correct/not.

For the attempt using this component I added the following code to the Begin Routine tab because I was worried that it was showing the same response over and over because it had not retrieved the necessary info from the Response screeen:

Resp1_key = event.getKeys(keyList=['l', 'a'])

if 'l' in Resp1_key:
    Resp1_key.corr == True
else: Resp1_key.corr == False

And this was the code in Each Frame:

if Resp1_key.corr == 1:
    msg= "Correct!"
else: msg= "Incorrect!"
sound_1.play()

‘msg’ refers to what I put in the text of Feedback.text, ‘$msg’, which was set to each frame rather than constant. But of course, this workaround didn’t work either, it only ever displays ‘Incorrect!’ no matter what the response was.

I’m wondering whether the issue is that you aren’t putting your else statements tabbed on the following lines.

That is because you have two text stimuli, and are giving each one a different message, so both will be displayed. Instead, just have one text stimulus, and set its content to whatever you want to be shown.

That was it! One Enter key was all it took to fix it, at least locally. I ended up overlaying polygons to cover the text, and I changed the opacity to reveal the appropriate message that matched the key pressed by the participant. I know this thread is dead since I took 2 months off to work on my other uni work, but I’m so close to making the experiment run, so please forgive me for pestering you again.

My code component that I used to make feedback of ‘correct’ and ‘incorrect’ depending on a key press seems to prevent my experiment from running online. Locally it works perfectly, and I know that it’s the code component breaking it because when I remove it, the experiment runs online. Would you please take a look? I don’t know what’s going wrong between Builder and Pavlovia.

In ‘Begin Routine’:

P_Resp2_key = event.getKeys(keyList=['l', 'a'])

In ‘Each Frame’:

if 'a' in P_Resp1_key:
    Correct_1.text='Correct!'
    Correct_Cover_1.opacity = 0 
else: 
    Incorrect_1.text='Incorrect!'
    Incorrect_Cover_1.opacity = 0
    import psychtoolbox as pygame
    from psychopy import sound
    mySound = sound.Sound(value='Error_Sound.wav', secs=3, sampleRate=44100, bits=16, name='error_sound', autoLog=True, loops=0, stereo=True, hamming=False)
    mySound.play()
    mySound.setVolume(0.5, log=True)
    

Pavlovia comes up with the error message: TypeError: event is undefined

As per my crib sheet I always put event=psychoJS.eventManager;
in code_JS

However, you should getKeys every frame and it doesn’t accept a key list (which is fine because your code will ignore unwanted keys)

I checked your crib sheet and after following the instructions it no longer gets stuck on ‘initialising experiment’ which is great! Now, it gets stuck when I try to respond to the second trial. It gives me the error message: “TypeError: P_Resp2_key.stop is not a function”

P_Resp2_key is the name of the keyboard component for when you respond to the second trial. I haven’t used the stop function on this component, or anywhere else in my experiment file, so I have no idea what it’s referring to. I tried adding event.clearEvents() to Begin Routine in the feedback slide, within the code component I described above, but that didn’t seem to help.

Please could you show a screenshot of this component plus any code that refers to it?

You could search for stop in the JS file

Nevermind, turns out I misnamed one of the components and the code component for that routine wasn’t at the top of the order in Builder.

1 Like

With the pilot working perfectly online, I decided to go ahead and create the experiment files for the 8 different versions of the real experiment and sync them to projects on Pavlovia. In the process of trying to do this, I realised I’d forgotten how I got my pilot onto Pavlovia in the first place. Long story short, I ended up accidentally overwriting my pilot project file on Pavlovia with a different file, so I had to re-upload it.

After doing this, when I attempt to run my pilot it comes up with an ‘unknown resource’ error message and won’t display any of my images. The path for each image is the same as it’s always been: ‘filename.jpg’, with no full path since all of the images are in the same folder as the experiment file. I noticed that every time I sync the experiment on Builder to the project on Pavlovia, a folder is generated in the same folder as my experiment file and it is called ‘resources’. Any image that is supposed to be displayed in the pilot is copied and put in this folder. I am not creating this resources folder, it just appears when I press sync. Why is this happening?

Edit: Even when I got rid of the copies of the images made during the sync and put all of my images into a resources folder (what I thought Pavlovia wanted), when I pressed sync it then made ANOTHER resources folder WITHIN the resources folder it had made before. What a nightmare!

I realised I hadn’t added my images to ‘Additional resources’ in the Online section of the experiment settings, but after adding them it still didn’t work. Still the same ‘unknown resource’ error. The Gitlab setup looks fine, my image path should be fine. Bu then I noticed that in both the JS code AND in my code component there are little boxes with the letters LF in them next to every line. That wasn’t there before. Have I completely broken my experiment??

I also get 2 errors in the Runner when syncing to Pavlovia:

ERROR     unexpected EOF while parsing (<unknown>, line 1)
ERROR     EOL while scanning string literal (<unknown>, line 1)

For anyone who might see this, somehow the problem was fixed by typing ‘html’ in the ‘output path’ section of the ‘Online’ tab in Settings. I still have a resources folder within a resources folder, but while it may look silly it works online now! I got this solution from another thread:

So thanks to user Sabinosaurus for sharing their solution!