Howdy, Stranger!

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

Supported by

jsPsych Study with Abort Button

Hi all,

I want to add a Cancel button to my jsPsych study. When using the methods described here, it works fine. However, I would like to use the jatos.addAbortButton() function to reduce the code (it also looks nicer and prompts the do you really want to quit question). I have tried numerous ways to include it in the jsPsych study, but none of it seems to work.

Can someone give advice on where/how to use jatos.addAbortButton() in a jsPsych study?

Thanks in advance!

Comments

  • Hi,

    You can basically put this jatos.addAbortButton() anywhere where code is executed. So right next to where you call jatos.onLoad should do fine.

    jatos.addAbortButton();
    
    jatos.onLoad(function() {
      jsPsych.init( {
        // ...
      });
    });

    Best,

    Kristian

  • Strange -- I tried to do exactly that (for starters, I just added this to the go/nogo example from the JATOS example studies), but I don't see any abort button (neither in my local JATOS or if I export it to an online instance of it). Any ideas of what I might be missing?

    jatos.addAbortButton();
    
    
    /* start the experiment */
    jatos.onLoad(function () {
         jsPsych.init({
              timeline: timeline,			
    	  on_finish: function() {
              var resultJson = jsPsych.data.get().json();
                    jatos.submitResultData(resultJson, jatos.startNextComponent);
                }
        });


    Thanks,

    Tobias

  • Hi Tobias,

    You seem to be right. I just tried the jatos.addAbortButton with jsPsych and it was not added. Somehow jsPsych seems to prevent adding of new elements to the DOM. Weird. I have to have a closer look at this.

    Best,

    Kristian

  • I also tried adding it using the on_load command for separate elements of the jspsych study but this also did not work, for instance:

    var welcome = {
            type: "html-keyboard-response",
            on_load: jatos.addAbortButton(),
    	stimulus: "Welcome to the experiment. Press any key to begin."
        };
        timeline.push(welcome);

    (just wanted to let you know in case this helps)

  • It actually helped :). Just not the on_load but the on_trial_start callback function. But this is not the only thing - I had to change jatos.js a bit this will only be part of the next release 3.5.5. (should come out in a couple days). The problem with jsPsych is that each trial seems to clear the whole body element. That means that the abort button has to be added each trial anew.

    But then you can get an abort button in jsPsych with something like this:

    jsPsych.init({
                timeline: timeline,
                on_trial_start: jatos.addAbortButton,
                ...

    Best,

    Kristian

  • Hi Kristian,

    somehow missed your response but this looks perfect! Looking forward to the new release (and not having to manually implement an abort button in every timeline element :)

    Cheers,

    Tobias

  • Hi Tobias,

    yes, I miss messages here too although I'm subscribed. Sometimes I just don't get the email. Luckily this happens seldom.

    Release will come out in a couple days. We are still testing. There are a couple other jatos.js changes and changes in jatos.js are always delicate.

    Best,

    Kristian

  • Hi Kristian,

    I just downloaded the latest version of JATOS and tried again with the addAbortButton command, but can't get it to work for some reason. I've seen that there has been a commit on Github which seems to implement that change -- is it just not embedded within the downloadable version of Jatos yet? I am just wondering whether I am missing something / doing something wrong.

    Best,

    Tobias

  • Hi Tobias,

    I just tried and it worked with my jsPsych study. Maybe there is something in jsPsych that I don't really understand. I put this block in my code:

      jatos.onLoad(function() {
        jsPsych.init({
          timeline: timeline,
          on_trial_start: jatos.addAbortButton,
          on_finish: function() {
            /* Changed for JATOS: submit result data to JATOS and start next component */
            var resultJson = JSON.stringify(jsPsych.data.getData());
            jatos.submitResultData(resultJson, jatos.startNextComponent);
          }
        });
      });

    Best,

    Kristian

  • Hi Kristian,

    ah, I see. I did not add the on_trial_start command but now it works fine. Thanks a lot!

    Tobias

  • Nice!

  • Hi,

    thanks for your contributions to this topic. I am also using jspsych and I would like to implement a combination of the jatos.abortStudy-function and the jatos.startLastComponent function. The idea is, that participants should see a button where they can finish the study but nevertheless they should be able to see the information for how they can claim their reimbursement which is embedded in the last component. How can this be achieved?

    Thanks in advance,

    Anne

  • Hi Anne,

    Right now there is no proper way to do that with the abortStudy function. What you could do instead is overwrite your result data with an empty string '[]', and jump to the last component. Something like this:

    jatos.startLastComponent("[]", "participant aborted the study");


  • Hi Elisa,

    thanks for your answer. I have difficulties implementing the code you suggested and hope that you can help.

    I can either implement the AbortButton as suggested above

    timeline: timeline,
          on_trial_start: jatos.addAbortButton,
          on_finish: function() {

    Then I see a cancel button in the lower right corner and when clicking on it the study finishes. When I put your line of code instead the component stops immediately. However, I would like to have something like a button to click on so that participants can decide whether they want to leave the study early. Where would I have to put your code so that I can let participants choose whether they want to continue or whether they want to leave?

  • Hi Anne!

    This is more of a jsPsych/JavaScript problem and not a JATOS one. But anyway, you could just take jatos.js' code for addAbortButton and change it a bit so it does a go-to-last-component:

    var myAbortButton = function (config) {
       var buttonText = (config && typeof config.text == "string") ?
             config.text : "Cancel";
       var confirm = (config && typeof config.confirm == "boolean") ?
             config.confirm : true;
       var confirmText = (config && typeof config.confirmText == "string") ?
             config.confirmText : "Do you really want to cancel this study?";
       var tooltip = (config && typeof config.tooltip == "string") ?
             config.tooltip : "Cancels this study and deletes all already submitted data";
       var msg = (config && typeof config.msg == "string") ?
             config.msg : "Worker decided to abort";
       var style = 'color:black;' +
             'font-family:Sans-Serif;' +
             'font-size:20px;' +
             'letter-spacing:2px;' +
             'position:fixed;' +
             'margin:2em 0 0 2em;' +
             'bottom:1em;' +
             'right:1em;' +
             'opacity:0.6;' +
             'z-index:100;' +
             'cursor:pointer;' +
             'text-shadow:-1px 0 white, 0 1px white, 1px 0 white, 0 -1px white;';
       if (config && typeof config.style == "string") style += ";" + config.style;
    
       var text = document.createTextNode(buttonText);
       var buttonDiv = document.createElement('div');
       buttonDiv.appendChild(text);
       buttonDiv.style.cssText = style;
       buttonDiv.setAttribute("title", tooltip);
       buttonDiv.addEventListener("click", function () {
          if (!confirm || window.confirm(confirmText)) {
             // jatos.abortStudy(msg);
             jatos.startLastComponent();
          }
       });
    
       document.body.appendChild(buttonDiv);
    };

    Then you can add this code in jsPsych, e.g.:

      jatos.onLoad(function() {
        jsPsych.init({
          timeline: timeline,
          on_trial_start: myAbortButton,
          on_finish: function() {
            /* Changed for JATOS: submit result data to JATOS and start next component */
            var resultJson = JSON.stringify(jsPsych.data.getData());
            jatos.submitResultData(resultJson, jatos.startNextComponent);
          }
        });
      });

    I didn't try this code but I'm pretty confident that it can work this way ;)

    Best,

    Kristian

  • Hello Kristian,

    thanks for your detailed response. I wanted to implement it but have a very stupid question now: where will I find the jatos.js-file? I assumed it would be in my local jatos installation but did not succeed to find it there and also didn't find information on this in the JATOS documentation.

    I was assuming the jatos library would be stored in a similar way as the jspsych files but even searching for jatos.js in all folders on my computer didn't reveal it to me. Therefore, I would be really happy if you could clearify where I can actually make changes to jatos.js

    Thanks!

    Anne

  • Hi Anne,

    you don't add this code to jatos.js - you add it to your normal JavaScript where you do the jsPsych stuff. Just put it somewhere. And don't forget to add the 'on_trial_start: myAbortButton' to your jsPsych.init.

    Best,

    Kristian

  • Great, now it is working. Thanks a lot!

    Best,

    Anne

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