Howdy, Stranger!

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

Supported by

[Solved] Using javascript variables in a loop for OsWeb experiment

edited October 26 in OSWeb

Dear all,

I want to make a simple n-back task using digits in a pseudorandomized order: The sequence is fixed, but which set of digits becomes a target, lure, or nontarget is randomized for each participant. In the offline version, I can randomize the digits in an inline_script element, store it as a variable, and call the digit in my loop that will be run sequentially. This works just fine. However, if I adapt this approach using an inline_javascript element, my browser screen would become stuck like in the screenshot below:



Any idea what went wrong? I attach the experiment for your reference.

Best,

Wisnu

Comments

  • Hi @wdhany,

    I had a quick look at the task you uploaded and I can see several problems.

    First, you have some Python code in an inline_script object in the unused items. That fails the OSWeb compatibility check, preventing the task from even starting. Make sure to empty that folder.

    Second, your logger is set to log all variables. That's a second reason why the OSWeb compatibility check fails. Uncheck that option and introduce manually the variables you want logged. The "Log all variables" option is great when running the task in OS, but when executed in a browser and over the internet, logging everything requires quite a bit of bandwidth and slows things down.

    Third, the key reason why you got stuck on the "Building experiment structure" has to do with the content of the digit column in your loop table. Expressions like "=vars.lures[0]" won't work inside a loop. To call upon the content of a variable, you should use something like "[lure]", that is using a variable and not an array.

    I haven't checked your javascript code, but assuming it is doing what you want to do, you'd need to add some Javascript code in the trial sequence to implement a trial counter per condition and then pull the appropriate element from the appropriate arrays to populate a variable (e.g., vars.luredigit = ...), and then use that in your loop table: "[luredigit]".

    Have a look at these examples to see how this works: 

    https://forum.cogsci.nl/discussion/comment/23977#Comment_23977

    https://forum.cogsci.nl/discussion/comment/24005#Comment_24005

    https://forum.cogsci.nl/discussion/comment/23974#Comment_23974

    Hope this helps!

    Fabrice.

    Buy Me A Coffee

  • It works perfectly now! Just out of curiosity, I have used =var.lure[0] (instead of var.lure1 = lure[0]) in a loop file the offline version of OpenSesame before and it works just fine (see the screenshot below). Why does this not work in OsWeb? Is the explanation somewhat relate to the different syntaxes between python and javascript?

    Again, thanks for your help!

    Wisnu

  • Hi @wdhany,

    To tell you the truth, I'm not sure. I had to work it out by elimination from your script. But yes, I assume it has to do with the translation of the experiment in Javascript to run in the browser.

    Glad it works, though!

    Good luck with your experiment!

    Fabrice.

    PS: when replying in the forum, you can use your correspondent's handle, that way he/she gets notified that you sent a message. You just need to type @ followed by the first letters of the correspondent's name and a pull-.down menu will appear. Example:

    Buy Me A Coffee

  • Hi @wdhany and @Fab ,


    By prepending an = character to variables that you use in the interface (rather than in an inline_script) you force OpenSesame to interpret it as Python code instead of OpenSesame syntax. Python code does work offline, but not online, so I suppose that explains why Wisnu's experiment still worked on the PC.


    For more information, see here:



    Cheers,


    Lotje

    Did you like my answer? Feel free to Buy Me A Coffee :)

  • Thanks @Fab and @lvanderlinden for your explanations!

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