Assigning participants to different loops in OSWeb
Hi there,
I used OSWeb for an experiment last year and my solution worked just fine, but now it doesn't work.
I've got 2 experimental conditions/lists that I realized by creating different loops, and I would like to randomly assign my participants to one of these 2 conditions.
The solution I'm using is inline Javascript:
if(vars.subject_nr%2==0) {
vars.subject_group = 'A'
} else {
vars.subject_group = 'B'
}
console.log('subject_group', vars.subject_group)
+ adding subject_group = 'A' to the "run if" of one loop and = 'B' to the "run if" of the other.
The experiment has a first part with a questionnaire which seems to be working just fine, but then the page goes blank and participants are not directed to either of the loops.
Is it because my inline code messes with the new set_subject_nr(nr)? How do I make it work?
Also, minor: now that the log all variables is not allowed in OSWeb anymore, how do I add a custom variable to the logger for keyboard responses to my sketchpads? I am not interested in RTs, just in the responses, but I don't see where I can rename the response variable to make sure it's logged. I'm sorry I'm such a newbie ahah. I'll buy coffee to whoever helps 🙈
Eleonora
Comments
Update: I tried deleting the inline code and putting just
in the "run if" section of one loop and 'odd' in the "run if" section of the other but it doesn't work either.
Hi @ellie,
You could use Javascript code but in your case, you don't strictly need it. If you set up OSWeb to pick randomly a subject number between 0 and 1, you can use the subject_nr variable to condition the presentation of a loop.
Here's how to condition the presentation of a loop to subjects 0 or 1:
Now, if you do want some dummy variable to save a condition label, you can do so too, using code, and include that variable in the list of logged variables. You can insert that code early in the program:
if (vars.subject_nr==0) { vars.subject_group="A" } else { vars.subject_group="B" }To insert the vars.subbject_group in the list of logged variables, you need to add it as a custom variable (by definition, a variable you created through code is not one that Open Sesame's automatically created variables and so it won't show in the variables inspector):
As for saving the response in each trial, if you have a single keyboard event, the response is saved in
vars.response(and the RT invars.response_time). The score (0/1) is saved invars.correct. In the example above, the keyboard object is called kb_response. You'll see that avars.kb_responseandvars.kb_response_timeare created by OS. I've included these in the log so that you can see that in this case, they store the same information asvars.responseandvars.response_time.I attach a basic task with the above so that you can see it working:
Now, note that since we created a vars.subject_group variable, we could also use that one to condition the presentation of the loop. Not sure why it does not work in your example, but it might because you only you call upon that variable before it is defined (hard to tell without seeing your program).
In the my example, I set up the
vars.subject_groupearly on, ahead of themeta_sequencethat contains loops A and B:So, if you wanted, you could then use that variable to set the "run if" parameters inside the
meta_sequence:It achieves the same as the first method.
Here's a version using
vars.subject_group:Hope this helps!
Best,
Fabrice.
Thank you so much @Fab, it seems to be working now.
I still had to duplicate the logger in order to have all of the responses, though the software seem to advise against it. Well deserved coffee coming your way!
Best,
Eleonora
Hi @ellie,
Glad it now works and many thanks for the ☕️!
Duplicating the logger isn't an issue if you're talking about creating a linked copy of the logger (linked copies of an object refer to the same object), but creating two distinct loggers might mess things up.
Good luck with your experiment!
Fabrice.