Howdy, Stranger!

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

Supported by

"Run if" from OpenSesame to JATOS

Hello! I'm a M1 student and I'm very new to OpenSesame and JATOS.

I'm creating an experiment where participants contribute with tokens. In short, if they reach a total contribution of 30 they win, if not they lose. I put a condition on the display of a "winning sketchpad" and a "losing sketchpad". And it is working on OpenSesame on my computer. But when I run it on a browse the condition is not taken into account anymore (although I do not have any error message).

Here are captures from OpenSesame:

I get at some point that there is a different between inline_script and inline_javascript. I tried to modify the script as follow, but it didn't work either:

set flush_keyboard yes
set description "Lance un certain nombre d'éléments en séquence"
run Contributions_eng_sketchpad True
run Contribution_form_text_input True
run Win_sketchpad vars.get('total') + vars.get('contribution') >= 30
run Lose_sketchpad vars.get('total') + vars.get('contribution') < 30
run Again_eng_form_text_display True
run Experiment_logger True

How can I modify my experiment in order for it to work?

Thanks in advance for any help!


  • Hi @MelieMeric,

    I'm a little puzzled by your attempt to edit the sequence script. You shouldn't modify it, whether you're running your task in OS or in the browser.

    You'd only use Javascript in inline:Javascript objects, not in the script of sequences.

    The initial problem you describe may have to do with the way in which the "Run if" condition is parsed when the task runs under Javascript in the browser. Try using a simpler condition (with only one term) just to see if it then gets processed correctly in the browser. If it does, then the problem may have to do with the use of the summation as part of the condition. You might want to try surrounding it with parentheses.

    Perhaps you can upload a stripped down version of your task to the forum?



    Buy Me A Coffee

  • Hello Fabrice,

    Thank you for your answer. Indeed with a simpler condition it works in the browser. I tried to put parentheses on the condition: it works with OpenSesame but still not in the browser (I tried also brackets but then nothing works).

    I am thinking then about creating a variable which would take the value of total+contribution, so that I would have the condition only with it. But I don't know how to do it or where to create it since I don't want it to be displayed, and I don't manage to find documentation on how to do that (I tried on my own, but it was not concluent...)

    Here is a stripped down version of my experiment:

    (I didn't manage to upload directly my file on the forum, I got a message error saying that it is too heavy, so I created a WeTransfer link, sorry)



  • Hi @MelieMeric,

    Thanks for sending a stripped down version of your task. That's been quite helpful.

    Ok, so we have established that the issue relates to the parsing of the condition under the "Run if" parameter when the experiment is running in OSWeb. That's issue 1.

    This can be easily solved by injecting some Javascript code just before the Win_sketchpad and Lose_Sketphad, to create a new variable adding up total and contribution (you were on the right track there). This is done by inserting an inline_javascript object before these sketchpads and inserting this code the run tab of the inline_javascript object:

    vars.mycondition = + parseInt(vars.contribution)

    This creates a variable (that will show up in the data log) in which we add up the total and the contribution. You can choose to call this variable as you please.

    Note that I'm adding and parseInt(vars.contribution). This is because total is a numerical variable, but contribution comes from a text box and so is treated as an alphanumerical string even if the subject's response is a number (at least in OSWeb; I think that under Python it might recognize it as a number). So, if one of the two variables is treated as a string and you add it to one that is numerical, Javascrupt treats both as alphanumerical. That means that if total is 20 and contribution is 30, + vars.contribution returns "2030" and not "50". So we need to tell Javascript to transform contribution into an integer value (hence the use of the parseInt function).

    You can download the fixed stripped down version of your task here.

    One more observation...

    I also noticed that your text is sometimes a little obstructed by the text box on your forms. Modifying the script doesn't seem to fix under OSWeb (while it works under a Python implementation). In your case, removing the empty lines of text makes everything visible. However if you wanted to have more control over the placement of text etc., you could possibly envisage using the inline_html object and write html / javascript code to create your form.

    Alternatively, you could also use a multiple keyboard inputs strategy to have the participant type digits and then hit enter to validate their response while updating their response on the screen. This is a little different from how you have implemented it but can be useful in some cases. It is more demanding in terms of programming but it can give you more flexibility. Here is a demonstration of the method we used in another case, just to illustrate the method in case you might be interested to use it in the future:

    One advantage of that method is that you could make sure that participants introduce numerical values only. At the moment, in your task as I modified it, if the participant typed "30r" as the contribution, the code would work: parseInt(contribution) would be 30. But if the participant accidentally started their response with an alphanumerical character (e.g., "r30"), parseInt(contribution) would be "Nan" and so would + parseInt(contribution). If you think this might be an issue, you could address it by inserting your Contributions_eng_sketchpad and Contribution_form_text_input into their own sequence, itself places into a loop, all within your game_sequence. You could then use some Javascript to test whether the value entered is numerical, and base on that change the value of a test variable that you'd use in the "Break if" paramater of that loop within the loop. The result would be that if the participant introduced an alphanumerical response, he/she would be asked to reintroduce their response (until it is validated as a numerical response, at which point that loop would be interrupted and the task would move on).

    Hope this helps.



    Buy Me A Coffee

  • Hello,

    Thank you so much Fabrice! It is perfectly working now. And I needed it to be working for this week-end, so you are a life savior!

    I managed to deal with the text being hidden by the text form by playing with the font size and by shortening some sentences. I won't have time to change much things now, but I will definitly take a look at what you sent for next time.

    Again, thank you so much for taking the time to look into all of that.



  • Hi @MelieMeric,

    Great, I'm glad I could help!

    Many thanks for the ☕!



    Buy Me A Coffee

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 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