returning inline string in OSweb (vs. OpenSesame)
I've got a congruency task I'm using to test expectancy violation and, while I'm sure someone would probably look at it and point out how inelegant the program is (I'm getting a messy logger warning), it's my first RT program and I have no real python experience (nor have time with a year to tenure to learn it--the OpenSesame tutorials were about as much time as I've got to learn). I tried looking for a task template to use, but couldn't find one (certainly would welcome one).
Anyways, I've got the osexp file, I'm working on getting an IRB-compliant server from IT services to run JATOS, and I want to be able to run the study on the web, using SONA Systems as a recruitment tool and wrapping it with Qualtrics.
As of now, I'm linking from Qualtrics (has consent) to the OSWeb experiment. At the end of the osexp, I've got an inline script that returns a random validation code in the sketchpad so I can append the OS data with the Qualtrics data. The code returns fine when I run the study in OpenSesame.
However when I test it in a browser, I get the following:
This is the code I've got in the inline script:
import random import string def randomStringDigits(stringLength=6): """Generate a random string of letters and digits """ lettersAndDigits = string.ascii_letters + string.digits return ''.join(random.choice(lettersAndDigits) for i in range(stringLength)) # store code exp.set("code", randomStringDigits(8))
And in the sketchpad:
set duration keypress set description "Displays stimuli" draw textline center=1 color=white font_bold=no font_family=sans font_italic=no font_size=30 html=yes show_if=always text="Thank you for taking the time to participate in our study!<br><br>We appreciate your effort!<br><br>Please take note of the following validation code:" x=0 y=-128 z_index=0 draw textline center=1 color=white font_bold=no font_family=sans font_italic=no font_size=50 html=yes show_if=always text="[code]" x=0 y=75 z_index=0 draw textline center=1 color=white font_bold=no font_family=sans font_italic=no font_size=30 html=yes show_if=always text="and press any key to continue.<br />(You will not be able to go backwards.)" x=0 y=224 z_index=0
How do I correct this so the code is returned in the OSWeb experiment so I can concatenate the two data sets? (Also, will OS log the code output so I have that info? How do I ensure that gets done?)
Alternately, does anyone have a more elegant way to pass an embedded data field in qualtrics (eg, a participant ID in SONA gets pulled into Qualtrics, passed through to OSWeb when they click on the link, and validated when they return to Qualtrics to complete the instrument and be awarded credit in SONA?
Comments
Hi S. Ross Marketing,
The inline_javascript item works similarly to the regular inline_script item, except that it runs JavaScript instead of Python code. So you have to 'translate' your script.
For further information see here.
Cheers,
Stephan
@DahmSF Aha, thanks.
So basically, I need to get IT to hurry up setting up a an IRB data-compliant server so I can post the study online and then translate to js and then test it all?
They just have to figure how to patch the XSS vulnerability on either JATOS or OS for me first...
Okay, I've got the study up on JATOS and I see the inline_javascript, but I'm unclear:
a) how to get a random string validation code. At best, I've found this and input it in the input_javascript prepare tab
b) I still have the inline_script in the prepare tab (see above). Do I still leave it, concurrent with the inline_javascript? Where/how do I translate the python into javascript?
c) How do I modify my sketchpad then to output the code?
ALTERNATELY
Is there a simple means/procedure to get a random alphanumeric string code to output to participants in my sketchpad on OSWeb (per above)?
Still stuck.
I've got this:
this:
and this:
Instead of getting this
, all I want is for some unique alphanumeric identifier string to appear in OSweb (and log in the data) at the end of the RT study so participants can take the identifier string from OSweb and go enter it in Qualtrics (so I can append the RT data to the Qualtrics data).
I understand there's something about translating from python in OpenSesame to javascript in OSweb, but this is pretty much my only painpoint left to launch my study and I don't have much in the way of programming skills. If anyone could help with some handholding, it would be extremely appreciated.
Replaced the inline_javascript function with a different one
which removed the application error in OSweb. However, now nothing seems to be calling the function in OSweb and therefore the variable isn't being set nor displayed via the sketchpad.
FWIW to anyone looking at this in the future:
What we did was add an inline_javascript_identifier item at the beginning. It incorporated the javascript:
In the sketchpad where we wanted the code at the end of the study, we added the following:
We have a 9 character code (anticipating 300 participants and having timestamped data, the probability of two participants getting the same one was sufficient for us to not modify the JS).
The study fails to run client-side, but the server-side application generates the code and writes it to the results.
And now, participants can take the study online, get the code, it writes to results, they enter the code in Qualtrics, and we can use it to concatenate datasets!
Hi @srossmktg
I have learned many tips in my study from your post: "returning inline string in OSweb (vs. OpenSesame)" in our study. Our study is the international study organized by Psychological Science Accelerator. You will see the details in this webpage: https://psysciacc.org/002-object-orientation/
Before the global pandemic, we run this study in the lab room. Now we turned the script to OSWEB. Because this study is bundled with the other PSA study: https://psysciacc.org/003-gendered-prejudice/ We run this study on Qualtrics and this brought us a new challenge.
Based on our registered plan, we run 002 and 003 studies in a randomized sequence. Some will run 002 then 003, and others will run 003 then 002. We have the problems how Qualtrics and JATOS exchange the participant's id and session id. Would you share your experience?
Hi,
I might be a little off here, but maybe the JATOS crew can help here as well. Is that so, @kri ?
Eduard
Hi CSC, Hi Eduard
it's always a bit difficult to arrive in a thread that was going on for a while: I'll try. I think CSC's questions is only loosely related to srossmktg original question. So I'll only answer this one.
You seem to have 2 problems:
1) In JATOS each of your experiments, 002 and 003, can be a component in a study. Additionally you would need a component before those that does the randomization. We have an example study "Randomize Tasks Between Workers" that does something similar and probably can be adapted to your use case.
2) In JATOS's docs is a page about this: http://www.jatos.org/Use-Prolific.html. From Qualtrics you can pass on any parameter via URL query parameters. Then when you study run is finished you have to redirect back to Prolific with the link that Prolific gives you (again better explained in the docs).
Hope this helped.
Kristian