Conditional statements for psychopy forms

Hi all,

Currently, I have set up five different forms for 5 different flavours of chocolate. At the beginning of the experiment, I have asked participants to rate their favourite chocolate.

Problem:
How do I make conditional statements where participants will complete forms of their favourite and least favourite flavours of chocolate?

This is what the data looks like with the ratings:

Thanks a lot!

Hi,

To clarify, participants are 1st asked 5 questions (rate each chocolate type) and then issued only the forms for their least and most favourite chocolate?

A couple of questions:

  1. how are the initial ratings obtained?
  2. have you tried any particular approaches yet that we can rule out so far :slight_smile:

Thanks,
Becca

Dear Becca,

That is correct. They are first asked 5 questions to rate each chocolate flavour.

To answer your questions:

  1. I am thinking that the variable “rating” I saw in the data is the variable that obtains the ratings, but I’m not sure yet. I guess I can also create another variable of my own to record the ratings, but I haven’t done so yet.

  2. I thought perhaps I can create a variable to identify minimum of and maximum of the ratings, min(ratings) ; max(ratings). Afterwards, I could perhaps create a selectblock code that minimum rating goes to A block (their least favourite chocolate); max rating goes to B block (their favourite chocolate). This is the logic, what do you think? But I’m not sure how to do it yet.

Best,
Diana

Hi,

So for 1. are you using the slider component? Also, do you always ask the first set of ratings in the same order or a different order?

The logic of 2 sounds the way I would choose to go :slight_smile:

To get you started here is a demo with some code snippets that might help https://gitlab.pavlovia.org/lpxrh6/selectfromrating. Here you have a predefined list of strings (‘file 1’, ‘file 2’ and so on), a set of ratings are then gathered and the file corresponding to the lowest and highest rating are printed to the stdout.

Hope this helps,
Becca

Dear Becca,

The rating questions should be alternated.

Thanks a lot for your help! I have just a one question, I can see the list you have provided, but can I add excel sheets in it? Excel sheets that have all of the variables needed for psychopy forms.

Kind regards,
Diana

No worries,

I didn’t add excel sheets to keep the demo generic. You can replace the strings (‘file 1’ etc) with the filenames of your own excel sheets. That then serves as input to your form component :blush:

Dear Becca,

The code works :slight_smile: Although right now, after the rating I still have to do all 5 forms, where can I insert the code in which I only want to do the highest rated form and lowest rated form?

Many thanks!

Hi! you can create only two form components and in the field that asks for a path you use the code that currently prints out the selected file paths i.e.

formList[(sliderResponses.index(min(sliderResponses)))]