psychopy.org | Reference | Downloads | Github

Drag & drop end trial subject to specific condition

Hello,

I am looking for some help with the code element of my experiment. Perhaps someone can help.

I am designing an experiment in the Builder where in each trial participants will be presented with 3 images at a time & need to place each one of these images in a designated space (there are 3 spaces i.e. polygons).


Participants aren’t permitted to progress onto the next trial unless the 3 images have been placed correctly.

I’ve implemented the drag & drop design (Drag & Drop Stimuli) which allows me to drag the images & place them anywhere I want at the moment & without restrictions. What I am missing is a condition (presuming in the ‘End routine’ tab of my code element) which specifies that unless the images have been placed in the correct spot the next trial won’t begin. I have a condition file from which images are randomly selected. I have also included a column per image (image1corPos, image1corPos, image3corPos) which specifies its designated position (corresponds with the 3 polygons).


I have read numerous posts but was unable to find a suitable line of code. Solutions which I have come across all specify the position of the mouse as a prompt to begin the next trial. I can’t see how that would work here since I have 3 images which need to be placed in the exact location before the next trial can commence. But again I have no coding experience.

Any help/suggestions would be appreciated.
Many thanks!

No, you want this code in the “each frame” tab, as the code in the “end routine” tab already presumes that the routine is ending. There is no way to stop it ending at that stage.

How is the end of the routine supposed to be initiated? e.g. does the subject push a key, or click a button, or should it be triggered automatically by the last stimulus being placed in the correct position? (If the latter, it probably needs to be integrated with your current drag-and-drop code.)

Hi Michael,

Thank you for responding so quickly.

Point about the location of the code noted - thank you.

Preferably I would like for the trial to cease once all 3 images have been placed correctly (without my participants having to push any other button i.e. continue or next) and then for the next trial to commence. Ideally after each trial I would like to include a ‘correct!’ text, but this can be skipped if it complicates things. In another task I’ve implemented correct/incorrect feedback but this was done by including another routine in the loop with a text and code element - not sure whether that would mess things up here so the positive feedback upon correct placement of all 3 items can be skipped. My main priority is ending each trial once 3 items are in their designated location.

Currently this is the only code I have:




Any suggestions on how to implement it would be much appreciated.

Thank you!

Hi,

  • You might want to look at this thread, because this sort of code can fail if the subject moves the mouse quite quickly:
  • You will need to implement some sort of “snap to grid” feature, as you can’t rely on the subject being able to exactly drop the stimulus in the precise location you need in order to be able to check in code if it is in the correct place:
  • Lastly, it is best to share your code by pasting in the text rather than using screenshots. From a screenshot, a person can’t make small modifications to your code without typing it all out from scratch.