| Reference | Downloads | Github

Creating survey component


I’m very excited about Psychopy 3 allowing online research, and I am looking into writing a survey component for it. I already have experience creating an online survey tool which generates a survey from a csv file. I was thinking a similar approach would work with Psychopy, but before I started trying to make this component wanted to check a couple of things:

  1. Is there any currently developing/developed survey component already available? I haven’t yet found one, but maybe I’ve overlooked it.
  2. My approach would be to make this work for local experiments with python code first, before worrying about making it exportable to html. Is there a reason to not go with this approach?
  3. Anything else I should bear in mind? For example, am I underestimating how hard it is to read in a .csv file with the survey features into a component? The csv would look something like
question_text| question_type  | options
Gender       | multiple_choice| male,female



Hi @anthonyhaffey, thank you for your post, it is a great idea and something we have recently discussed. It would be great to collaborate on the design and creation of the new survey component.

  1. No, not yet, but it has been discussed as being needed
  2. Yes, correct, although I think we should keep Ilixa in the loop too. They’ll have ideas as well I think and we also want to make sure that what we do can be ported easily to JS
  3. Reading in the csv file will be easy. PsychoPy uses camelCase rather than snake_case for arguments, and we’ll need to work out the optimal set of headers but, yes, that’s roughly the idea

Maybe I can provide a starting point in terms of how the structure and rendering might work (e.g. a class supporting a virtual window and scrollbar that you can be used to contain the questions) and you guys can work on what the right set of “options” will be?

This commit (to a separate branch at github psychopy/psychopy) shows the basics of how it could work:

1 Like

In terms of the options I would suggest we start with, in the software I worked on previously we used the following headers for each of the columns in the survey’s csv

item_name: a brief description, for example, when I ran the Autism Quotient, each item name would be AQ1, AQ2 etc.
text: What text the participant sees associated with the item
type : What type of input the question takes, e.g. text, number, likert, checkbox etc.
answers : If it’s multiple choice (e.g. likert), then which options can the participant choose
values: If it’s multiple choice, what is the value for each option. If the answers cell has “yes|no” the values cell could have “1|0”
score: [variableName] : This column identifies how (or if) this item contributes to a total score, with the associated [variableName] . If the cell has 1, then add the value as it stands to the variable. If the cell has r1, then reverse the value and then add it to the score. For example, if the values for a question with answers strongly agree|agree|disagree|strongly were 0|1|2|3, then the reversed values would be 3|2|1|0.
optional: Whether the participant can complete the survey without answering a question. The default is “yes”, but putting “no” in this cell would prevent the participant proceeding until an answer is given to that item.

The above columns allowed us decent flexibility for creating different item types as we coded them in, and any scores generated from the survey were calculated and included in the participants’ data file automatically.

Any thoughts about whether these headers are okay as a starting list? Any other headers need to be added in the long term? I think the scoring functionality will have to wait until we have multiple choice functionality, which may not be practical for the first iteration of a “form” or “survey” component.