Howdy, Stranger!

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

Supported by

Turning an online experiment into an offline one


A few months ago, I created an online Opensesame experiment with the help of some great people on the forum. The experiment allowed pseudorandomization for so many things (order of the tasks, language, and so on). Now that we have decided to run the experiment in the lab, is there a way to convert this online-shaped experiment into an offline OpenSesame experiment with all scripts working as intended?

Thanks in advance


  • Hi @reversemoonwalk ,

    The main and possible only thing that prevents you from running this experiment on the desktop is that the inline_javascript items use some ECMA 6 syntax, which a recent version of JavaScript that OpenSesame doesn't support yet when running on the desktop. At least the generateRandomArr() function in the set_task_order item would need to be rewritten so that it's compatible with ECMA 5.1 syntax.

    See also:

    — Sebastiaan

    Buy Me A Coffee

  • FabFab
    edited August 2022

    Hi @reversemoonwalk,

    I'm pressed for time at the moment and so I haven't tried the whole task, but here's some code you can use to replace some of the existing bits in the set_task_order object:

    / picks 4 digits between 1 and 5 and stores them in an array
    var numbers = [1,2,3,4];
    function shuffleArray(array) {
    for (var i = array.length - 1; i > 0; i--) {
    var j = Math.floor(Math.random() * (i + 1));
    var temp = array[i];
    array[i] = array[j];
    array[j] = temp;
    return array;
    vars.listsarray = shuffleArray(numbers).join('');
    console.log ("listsarray: "+vars.listsarray)

    That code is ES5 compatible and will run when you execute the task in Open Sesame.

    The code basically shuffles an array containing the values 1, 2, 3, 4, so that each digit appears once. I seem to remember that this is what you wanted to achieve a random order of presentation of blocks/conditions.

    I haven't had the time to try the whole task to check the rest runs smoothly, so do check carefully.

    Here's my modified version:

    Hope this helps,


    Buy Me A Coffee

  • Thank you @sebastiaan ! Now that I know that is different for local experiments, I will create future experiments accordingly.

    Thank you @Fab ! The experiment seems to work with this new code; I will test the whole experiment and let you know. You are great!

  • Hello again @ Fab!

    Your version of the experiment gives the following error after the practice part.

    The error might be related to "increment_taskcounter" code. Any suggestions?

    Thanks in advance!

  • @Fab I have tried several things but failed to make the experiment work. Since the error says "listundefined.csv", I think it might be related to the code you created to randomize list numbers in the set_task_order part.

  • Hi @reversemoonwalk,

    Sorry for the delay in getting back to you. I only just saw your more recent message (the handle in the first one didn't get picked up -you used "@ Fab" with a space in between- and so I did not receive notification).

    I had a look at the task and it looks as if the problem is that the task doesn't seem to treat the listarray variable as an array. This is likely to be due to the way it is built (after the change of method we introduced to make the task compatible with ECMA 5.1).

    So the following line...


    ... fails because the use of the [] characters to access a specific column withing an array does not work(because the task does not consider the listarray variable to be an array to start with).

    After investigating it and trying different things, I found a way around it that allows you to keep the Javascript generating the random order of list in a way that will work with ECMA 5.1.

    I modified bits of the code within the increment_taskcounter object to set up a temporary variable (temparray) that contains a string version of the listarray variable plus an empty character. It then becomes possible to use Javascript's Slice function to isolate a single character in that string, which I do using the taskcounter variable).

    slice() extracts a part of a string and returns the extracted part in a new string. The method takes 2 parameters: start position, and end position (end not included). hence, for example,. slice(0,1) extracts the 1st character of a string, while slice(1,2) extracts the second, etc.

    Using this method, it is now possible to isolate the digit from the listarray that correspond to the taskcounter and use it to specify which csv file should be used.

    Here's the new code with some console.log events just to keep monitoring what's going on in the console.

    console.log ("Test phase starts here ________________________________")
    // allocate csv files to the current task, basd on previously randomy picked list
    console.log("List array:"+vars.listsarray)
    console.log ("Sets up temporary string containing the list")
    let temparray = vars.listsarray.toString()+" "
    console.log ("List loaded up for this condition is: "+vars.task_list)
    console.log ("taskcounter: "+vars.taskcounter)

    I tried it out up until the second test block but not further. Incidentally, I notice that your list1.csv file contained an error. You had a column header reading "q" instead of "targetldt_tur". I corrected it and uploaded the correct list.csv to the file pool.

    I attach my modified version. Hopefully it'll work. Just make sure to run the whole task to the end to check it ruins correctly to the end.

    Good luck!


    Buy Me A Coffee

  • Thanks again @Fab ! I cannot thank you enough. Along with your most beneficial help, you are also helping me to understand what went wrong. I have been testing the new experiment so far, but there is one little problem. Correct answers should be indicated with green lines but I see red lines for some correct answers. When I checked the log file, I saw that some of the correct answers were marked wrong. Can that be related to the code we included for determining correct answers (define_correctresponse)?

    if (vars.category=="word"){
    } else {

    This is what I did to determine the type of category for each task:

    if (vars.task_info=="Türkçe Sözcüksel Karar Görevi" && vars.subject_nr%2==0){ "[primeldt1_en]" "[targetldt_tur]"
    vars.category= "[category_ldt]"
    if (vars.task_info=="Türkçe Sözcüksel Karar Görevi" && vars.subject_nr%2==1){ "[primeldt2_en]" "[targetldt_tur]"
    vars.category= "[category_ldt]"

    The code above was used in increment_taskcounter to determine the target and prime types for each task and alternate two prime conditions. These seem to work fine.

    Also, I added 'vars.category= "[category_ldt]"'' part to set the correct answers for that specific list. In my lists, this columns refer to the values "word" and "nonword". But the first code I wrote here seems to fail to differentiate correct answers from wrong ones.

  • Hi @reversemoonwalk,

    Took me a little while to work out what's going on there (I first tried to work out whether the issue was specific to a particular condition or csv file, etc.), but I think I found the issue.

    I started by adding some code to output to the console what the category and correct responses were, and I then realized what the task scored a correct was based not on what was happening on the current trial but on the previous one. When I started to respond based on what the correct response was on the previous trial, then the red vs green feedback indicated my response was correct every time. Once I realized that, it became easier to spot the problem.

    Basically, the code defining the correct answer is correct but the problem is that it was executed at the wrong time. It turns out that when a trial runs, the correct response variable is set when the sequence is prepared, not when it is run. That means that if you run the code when the trial runs, it will store the correct response but that will only be used the next time the trial sequence is prepared (i.e., on the next trial).

    So, the fix is to make sure that the code defining the correct response is executed when the trial sequence is being prepared, which is done by placing that code in the "prepare" section of the inline_javascript object like this:

    I think this solves the issue.



    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