Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

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

    //option 1 	
    var code = function () 
    {
     return Math.random().toString(36).substr(2);
    }
    

    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:

    define inline_script validation_code_script
    	set description "Executes Python code"
    	set _run ""
    	___prepare__
    	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 identifier
    	var.set("identifier", randomStringDigits(8))
    	__end__
    

    this:

    define inline_javascript new_inline_javascript
    	set description "Executes JavaScript code (ECMA 5.1)"
    	set _run ""
    	___prepare__
    	//option 1 	
    	var identifier = function  () 
    	{
    	  return Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);
    	}
    	end
    

    and this:

    define sketchpad end_of_experiment_code
    	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="[identifier]" 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 />(This will return you to the Qualtrics survey instrument.<br>You will not be able to go return here.)" x=0 y=224 z_index=0
    

    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

    function randomStringDecimal() {
    var chars = [];
    var str = '';
    
    
    for( var i = 48; i <= 57; i++ ) {
    chars.push(String.fromCharCode( i ));
    }
    for( var i = 65; i <= 90; i++ ) {
    chars.push(String.fromCharCode( i ));
    }
    for( var i = 97; i <= 122; i++ ) {
    chars.push(String.fromCharCode( i ));
    }
    
    
    for ( var i = 0; i <=7; i++ ) {
    str += chars[Math.floor(Math.random()*chars.length)];
    }
    vars.identifier = str;
    }
    

    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:

    vars.identifier = Math.random().toString(36).substr(2, 9);
    // alert (vars.identifier);
    

    In the sketchpad where we wanted the code at the end of the study, we added the following:

    draw textline center=1 color=white font_bold=no font_family=sans font_italic=no font_size=50 html=yes show_if=always text="[identifier]" x=0 y=75 z_index=0
    

    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

    Buy Me A Coffee

  • 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. 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.
    2. We have the problems how Qualtrics and JATOS exchange the participant's id and session id.

    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

Sign In or Register to comment.

agen judi bola , sportbook, casino, togel, number game, singapore, tangkas, basket, slot, poker, dominoqq, agen bola. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 50.000 ,- bonus cashback hingga 10% , diskon togel hingga 66% bisa bermain di android dan IOS kapanpun dan dimana pun. poker , bandarq , aduq, domino qq , dominobet. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 10.000 ,- bonus turnover 0.5% dan bonus referral 20%. Bonus - bonus yang dihadirkan bisa terbilang cukup tinggi dan memuaskan, anda hanya perlu memasang pada situs yang memberikan bursa pasaran terbaik yaitu http://45.77.173.118/ Bola168. Situs penyedia segala jenis permainan poker online kini semakin banyak ditemukan di Internet, salah satunya TahunQQ merupakan situs Agen Judi Domino66 Dan BandarQ Terpercaya yang mampu memberikan banyak provit bagi bettornya. Permainan Yang Di Sediakan Dewi365 Juga sangat banyak Dan menarik dan Peluang untuk memenangkan Taruhan Judi online ini juga sangat mudah . Mainkan Segera Taruhan Sportbook anda bersama Agen Judi Bola Bersama Dewi365 Kemenangan Anda Berapa pun akan Terbayarkan. Tersedia 9 macam permainan seru yang bisa kamu mainkan hanya di dalam 1 ID saja. Permainan seru yang tersedia seperti Poker, Domino QQ Dan juga BandarQ Online. Semuanya tersedia lengkap hanya di ABGQQ. Situs ABGQQ sangat mudah dimenangkan, kamu juga akan mendapatkan mega bonus dan setiap pemain berhak mendapatkan cashback mingguan. ABGQQ juga telah diakui sebagai Bandar Domino Online yang menjamin sistem FAIR PLAY disetiap permainan yang bisa dimainkan dengan deposit minimal hanya Rp.25.000. DEWI365 adalah Bandar Judi Bola Terpercaya & resmi dan terpercaya di indonesia. Situs judi bola ini menyediakan fasilitas bagi anda untuk dapat bermain memainkan permainan judi bola. Didalam situs ini memiliki berbagai permainan taruhan bola terlengkap seperti Sbobet, yang membuat DEWI365 menjadi situs judi bola terbaik dan terpercaya di Indonesia. Tentunya sebagai situs yang bertugas sebagai Bandar Poker Online pastinya akan berusaha untuk menjaga semua informasi dan keamanan yang terdapat di POKERQQ13. Kotakqq adalah situs Judi Poker Online Terpercayayang menyediakan 9 jenis permainan sakong online, dominoqq, domino99, bandarq, bandar ceme, aduq, poker online, bandar poker, balak66, perang baccarat, dan capsa susun. Dengan minimal deposit withdraw 15.000 Anda sudah bisa memainkan semua permaina pkv games di situs kami. Jackpot besar,Win rate tinggi, Fair play, PKV Games