On a further note, returning to the very first topic in this long and meandering thread, I am again having trouble with the timer component. I want page-level timers for the “Social Intelligence Test” survey component, but although I’ve implemented them in the survey using quiz mode, and I can see them at the bottom of the json code:
if surveyResponse['block_1/Consent'] == '0'
psychoJS.setRedirectUrls(myCompletedURL, myCancelledURL)
You need to set ‘myCompletedURL’ and ‘myCancelledURL’ to the URLs that you want to use.
I understood that the above routine will not be executed if consent is given. I have changed this so that the routine is executed when there is no consent.
Well, I do not know what you want to show in that routine. But if you put the command in the End routine tab everything in your routine will be executed. You can add a message to the quit-command.
I was using Wake’s code from the Survey Test, and what he has in there is to only execute the routine if the participant does NOT consent, and then shows them a message saying that they needed to check all the items. But this doesn’t actually quit the experiment. This is his code (in the “Begin Routine” tab in an AutoJS code component):
surveyResponse = consent.getResponse()
if surveyResponse['block_1/consent']:
if len(surveyResponse['block_1/consent']) == 4:
continueRoutine = False
So it only executes the routine (shows some text) if the participant has not ticked all 4 consent boxes.
Unrelated, could someone please reply about the issue with the timers? This is fairly crucial to this experiment.
What do you want? Would you like to end the experiment for participants who do not consent, or would you like to display a message to these participants?
The latter could be achieved in the survey. It seems rather complicated to me to ask for consent in the survey, collect the survey responses in PsychoPy and then display a message telling them that they have to answer all four consent questions in order to proceed. How do your participants get back to the survey?
Sorry, but I don’t know anything about timers in surveys.
I’d like to end the experiment for participants who don’t consent - but ideally with a message acknowledging that they did not consent. The code above isn’t mine, it’s from Wakefield’s demo, so this is how he dealt with non-consent in his survey.
Thanks again - @wakecarter, could you please weigh in about the timers?
OK, the code by @wakecarter ends the routine when consent is given. Place it in the ‘Begin Routine’ tab of the code component of your consent routine. Move the code-component to the top row. In the consent routine, add a text component with a start time (or make the onset conditional on continueRoutine) and display your no-consent message for a period of time. In the ‘End routine’ tab of your code component, add the following code. Set the code type to JavaScript or both. Leave the Python side empty. I assume that you want to run the experiment online.
if (continueRoutine) {
psychoJS.experiment.nextEntry();
return psychoJS.quit({message: 'Thank you for your participation.', isCompleted: false});
}
If you do not want to display a second message, simply delete the ‘message section’. If you enter both a complete and an incomplete URL in the ‘Experiment Options’ section, PsychoPy/Pavlovia should redirect your participants to the intended website.
Thanks for this. I tried the code as you provided it, but it does not quit the experiment - it just proceeds to the next part. Is this perhaps because I don’t have the completed and incomplete URLs set up yet, because we haven’t linked with Prolific? I did try entering a random URL to test this, but it didn’t seem to help.
I’m not quite sure what you mean by “move the code-component to the top row”. It’s definitely in the top part of the window:
I checked the code I posted above and noticed that the ‘continueRoutine’ variable is set to ‘false’ in the ‘End Routine’ tab. This is because some other component that appeared earlier ended the routine. Sorry for misleading you. I have attached a small experiment which demonstrates the logic for continuing or ending an experiment.
We are trying to run this now via Prolific and we are again encountering the above error code. I think there is something wrong with the Shelf method of counterbalancing.
As we are paying the Prolific participants from my student’s very limited budget, this is URGENT.
The Shelf list currently reads [11,6, 3] - there are only 2 groups, so I’m not sure why the third number has gone up to 3. I have tried resetting it to 0 but it doesn’t seem to be helping.
UPDATE: I have just seen, buried in one of the linked posts, this sentence: “This method is not suitable if a significant proportion of the participants are likely to start the study at the same time.” Is this likely to be the problem, since we’re running the study on Prolific? We are able to limit the number of participants doing the study at one time - will this fix the problem?
I do think this should be included in the main tip. We have wasted a fair bit of my student’s money today.
Yes I am. But my student says she was getting multiple emails that the experiment quit with the error message “RangeError: Invalid array length”. We have lost at least 14 participants so far that we will have to pay via Prolific.
AHHH OK I think I have worked out the issue. For some reason, the participant field for each participant is showing as {{PROLIFIC_ID}} instead of their actual prolific ID. Weirdly this has worked for the first participant but not for subsequent ones. The data also contains a column called “PROLIFIC_PID” so I’m assuming that field is what we should be using in the redirect link.
Here’s the relevant code in the counterbalancing segment:
groupAllocations = await psychoJS.shelf.getListValue({key: ["group_allocations"], defaultValue: []}); // Get values
if ((incrementWhenPiloting || (! PILOTING))) {
groupAllocationsCheck = await psychoJS.shelf.getListValue({key: ["group_allocations"], defaultValue: []}); // Update list from shelf
if (groupAllocationsCheck.length) {
groupAllocations = groupAllocationsCheck;
groupAllocations[0] += 1;
}
else {
groupAllocations[0] = 1; // First participant
}
groupAllocations[group] += 1;
await psychoJS.shelf.setListValue({key: ["group_allocations"], value: groupAllocations}) // Await needed here
}
And the Shelf entry is as I posted above. But I don’t think it is an accurate reflection of how many participants have done each condition, because I have 26 and it only lists 17??
[17 6 11]
The study redirect link in Prolific is currently this:
As per my daisy chaining tip, I would recommend that you send the PROLIFIC_PID as participant and, potentially, the SESSION_ID as session rather than using the Prolific default variable names.
The variable names in the URL can definitely be edited in Prolific.
As to why the shelf entry is incorrect. The likely answer is because you reset the count.
Yeah, I had come to this conclusion myself. Unfortunately I am not in control of the Prolific end of things, but I’ve emailed my student to edit it as above.
Your guides all say to use “PROLIFIC_ID”, which we were doing for the participant field (see above), but apparently it’s now “PROLIFIC_PID” so you might want to update that in the guides.
The shelf count was inaccurate before I reset it, but I think it might be caused by the participant ID not registering correctly. Hopefully this will fix it.
Was the code otherwise OK? I copied it exactly from your recommended code.
I have updated the Shelf entry to reflect the actual number of participants who have completed each condition - we have 8 for Condition 1 and 18 for Condition 2, so the Shelf entry now reads [26 8 18] - will this end up balancing the conditions correctly?
Also, does your comment in the other thread still apply - that this method will not work if many participants start at the same time? Because we can limit the number of participants doing the experiment at one time, but this will slow our data collection.
As an addendum, I don’t understand why I have now “consumed” 99 credits when I have set the experiment not to save incomplete data, and I only have 26 data files to download. Could you let me know what has happened here? This is starting to be a very expensive exercise.
The code looks okay. I would expect all participants in your next batch to be allocated to group 1 to redress the imbalance. This is why most of the second batch went to group 2 – there were fewer in group 2 at that point.
I’m not sure what is causing so many credits to be consumed. You could look at the credits tab to work out when the extra ones were used.