Howdy, Stranger!

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

Supported by

Batch session synchronization fails

Dear Jatos-team,

just now I updated my local installation to the latest Jatos version (was on Jatos 3.5.5. before) because our Server (run by the IT department) was updated lately too and it was recommended to update the local version as well. Upon testing if my experiment still worked, I find that the batch session data are causing issues.

My study is divided into 3 sessions which is why I am using batch session data. This way I keep track of the session count and also store the session randomization. I have used it like this for the pilot study and it worked without issues. However, now the callback function returns that the Batch session synchronization fails.

I have tested two things:

  1. use the cade as shown above (as always)
  2. assign a value to prolific_ID by hand ("var prolific_ID = "sub01")

That way both conditional statements were tested (i.e. retrieveData is undefined (1. case) and defined (2. case). Apparently jatos.batchSession.set and jatos.batchSession.add do not do their jobs. For "set", nothing happens, no subject entry is created. And for "add" the existing output is not altered. Importantly, in both cases the variables sess_order and last_idx contain the info they are supposed to contain. Do you happen to have any idea what is going wrong?


 var prolific_ID = jatos.urlQueryParameters.PROLIFIC_PID; //"sub01";

 console.log(prolific_ID);

 

 // get all the info from JATOS batch session

 var retrieveData = jatos.batchSession.getAll()[prolific_ID]

console.log(retrieveData)

// if subID does not yet exists, create template

if (retrieveData == undefined){

      var sess_order = (shuffle([5, 6, 7])); // refers to the component positions in jatos

      var last_idx = 0;

      jatos.batchSession.set(prolific_ID, {sess:sess_order, last:last_idx})

       .then(() => console.log("Batch Session was successfully updated"))

       .catch(() => console.log("Batch Session synchronization failed"));

     console.log(sess_order)

     console.log(last_idx)


   } // if subID does exist, update the info in template

else if (retrieveData != undefined) {

     var BatchField = prolific_ID;

     var blockInfo = new Object;

     var sess_order = jatos.batchSession.get(prolific_ID+"/sess") // keep randomization

     var last_idx = jatos.batchSession.get(prolific_ID+"/last") +1 // add one session

     blockInfo["sess"] = sess_order

     blockInfo["last"] = last_idx


     jatos.batchSession.add("/"+BatchField, blockInfo)

       .then(() => console.log("Batch Session was successfully updated"))

       .catch(() => console.log("Batch Session synchronization failed"));

   }



Thanks in advance.

All the best,

Christina

Comments

  • Hi Christina,

    Please use the formatting for code. It makes it so much more readable ;)

    I just tried with my JATOS and the Batch Session seems to work fine:

    jatos.batchSession.set("b", "koala").then(() => console.log("Batch Session was successfully updated")).catch(() => console.log("Batch Session synchronization failed"));
    

    and

    jatos.batchSession.add("/c", "bear").then(() => console.log("Batch Session was successfully updated")).catch(() => console.log("Batch Session synchronization failed"));
    

    Both worked:

    Maybe your new JATOS installation isn't installed correctly. E.g. are WebSockets allowed there? The Batch Session needs them to work. When you open JATOS test page (myjatosdomain/jatos/test) do you see any failed tests?

    Best,

    Kristian

  • Hi Kristian,

    First of all, sorry for the sloppy code pasting!

    Thanks for your response. The issue actually disappeared without any work from my side. Upon retrying after reading your reply, it ran without any issues. So I guess the new installation just needed some time to settle in (I don't know if this makes any sense though).

    In any case, thanks for the great support as always!

    Best,

    Christina

Sign In or Register to comment.