control session variables - longitudinal studies

36 views
Skip to first unread message

María da Fonseca

unread,
Oct 26, 2020, 1:53:03 PM10/26/20
to ja...@googlegroups.com
Hi Elisa and Kristian,

The experiment I am coding is a longitudinal one and I need to add conditions over the session number. Specifically, each participant will have his/her personal link, and the exp will have 10 sessions per participant. There is a component with a report where questions on even sessions have to be different from questions on odd sessions. Besides, I want to add a practice component to be executed only in the first session, if it is possible. Could you please tell me how to conditionate over the session number for these examples?

Best,

María

Elisa Filevich

unread,
Oct 26, 2020, 4:43:48 PM10/26/20
to JATOS
Hi María, 

If each participant has their own personal link, then the answer is pretty straightforward. All you have to do is use the Batch Session.
You can set the session number by using jatos.batchSession.set (http://www.jatos.org/jatos.js-Reference.html#jatosbatchsessionset) and jatos.batchSession.get (http://www.jatos.org/jatos.js-Reference.html#jatosbatchsessionget). The batch session outlives all study runs and is available to all participants (so make sure that you do not store any identifying or personal information there, just the necessary anonymised IDs). 

You then can use a simple if statement: If the session number is even, do A. Otherwise do B. 
But the specifics of how to implement this depends on how you've written your code. I can help if you give me a bit more details 

Best
Elisa
 



--
You received this message because you are subscribed to the Google Groups "JATOS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jatos+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jatos/CABHfF7XRf_HicS8tL%2B8dirCeLWn8ZbAK-aHZ3TmuZfo6L7J-cA%40mail.gmail.com.

María da Fonseca

unread,
Nov 8, 2020, 12:34:51 PM11/8/20
to ja...@googlegroups.com
Hi Elisa,

Thanks for your answer! As I understand through jatos.batchSession I can store and read data to be used in the code. The exp I am coding is longitudinal, each participant is going to have a personal link and played several times. If I understood well, I need to create Personal Multiple link in this case. Depending on the session number, the exp will behave differently, for example: if the session number = 1, the exp will display a practice round, if the session number is even ..., etc. Here is the logic I have used, but when I generate a Personal Multiple link, the batchSession didn't re-start (stores the last batch number used) and I need to control the session number of each participant via his/her own link:

in component 1:
var session_number;           
jatos.onLoad(function () {
                if (jatos.batchSession.get("session")) session_number=jatos.batchSession.get("session");
                else {
                    session_number = 1;
                    jatos.batchSession.set("session",1);
                }
               if (session_number % 2 == 1) {
                    ....
               }
              else
              .....

in last component:
var currect_session_number;
var next_session_number;
jatos.onLoad(function () {
           currect_session_number = jatos.batchSession.get("session");
            next_session_number = currect_session_number + 1;
            jatos.batchSession.set("session",next_session_number);
           ....

If I create 2 Personal Multiple links, that is to be used by 2 different players and run both links, by doing "jatos.batchSession.set("session",next_session_number);", the session number is actualized jointly as 2 sessions of the same player. But, what I need is to control the session number of each participant apart. How could I control it?

Best,

María

Elisa Filevich

unread,
Nov 8, 2020, 4:33:06 PM11/8/20
to ja...@googlegroups.com
Hi María, 

The batch session data can be accessed in rather detailed ways (with pointers), you don't need to overwrite the whole thing. So for example you could do this:

jatos.batchSession.add(ID, subjParams);

Where subjParams is an object that contains information like:
subjParams = {
lastSession : 1,
timeStamp : date.now()
}

And anything else you want.

This is what we tried to explain in the example in the docs (http://www.jatos.org/jatos.js-Reference.html#jatosbatchsessionset), where you can write independently into different fields of the batch session data:

If the Batch Session is {"a": 1234} and you execute

var b = jatos.batchSession.set("b", "koala"); 

then after the Batch Session is successfully updated the new object is {"a": 1234, "b": "koala"}. 


This way you can write independently (for each subject) into the same batch session, just into different fields that are easily identified with the ID. This will work as long as your ID are strings. 

Best
Elisa


María da Fonseca

unread,
Nov 8, 2020, 10:30:40 PM11/8/20
to ja...@googlegroups.com
Thanks, Elisa!

I am still missing something here and it is the way to control the session flow. At first, there is nothing in the batchSession variables.

The batchSession ID could be set as the workerID which would be the participant ID if I understood well. Then, there is the sessionID (or session number or subjSession) that you suggested to store if the batchSession ID corresponds to the participant ID. In the last component, I actualize the subjSession incrementing it by one. But, I still have the problem of initializing the subjSession. Because, by doing:

in the first component:
            if (~ jatos.batchSession.defined("/"+jatos.workerId)){
                jatos.batchSession.add("/"+jatos.workerId, {"subjSession":1});
            }

in the last component:

            current_subjSession = jatos.batchSession.find("/"+jatos.workerId+"/subjSession");
            jatos.batchSession.replace("/"+jatos.workerId+"/subjSession", current_subjSession+1);

and creating 2 links as Personal Multiple, the first time I used one link it behaves as I expected, but when I use the same link to play again as the same participant but the second session,  "/"+jatos.workerId+"/subjSession" set to 1 again. If I don't use the link (workerID=1 by default), the subjSession actualizes correctly. But I still need to actualize it for each user. I really don't know what I am missing.

Best,

María

Elisa Filevich

unread,
Nov 9, 2020, 3:50:33 AM11/9/20
to ja...@googlegroups.com
Hi María, 

Hm, off the top of my head I don't know (i agree that what you've written sounds in principle reasonable). 
This is easy to debug, though. If you send me a minimal version of your study (the exported .jzip file) I can try to have a look. 

Best
Elisa

María da Fonseca

unread,
Nov 9, 2020, 1:15:16 PM11/9/20
to ja...@googlegroups.com
Hi Elisa,

Thank you for your reply! Here I attach one of the examples from jatos documentation that has 4 components where I stored the user ID and session ID, but the session ID turns into 1 playing again with the same Personal Multiple link as I mentioned in the last email.

Best,

María

Elisa Filevich

unread,
Nov 9, 2020, 4:26:15 PM11/9/20
to ja...@googlegroups.com
Hi María, 

I think you just had a small bug in the way you defined your if statement in the first component. By setting a breakpoint in the console it was easy to see that you always entered the if statement, even if the subject was indeed defined. 

I replaced the lines

if (~ jatos.batchSession.defined("/"+jatos.workerId)){
jatos.batchSession.add("/"+jatos.workerId, {"subjSession":1});

for:

if (jatos.batchSession.test("/"+jatos.workerId, undefined)){
jatos.batchSession.add("/"+jatos.workerId, {"subjSession":1});
}

And that worked for me. (I.e., now the session number does not get overwritten)

there is also a small bug somewhere: I think that you update too quickly the session number, and I get a subjSession:2 even when I'm on session 1. But I'm not sure if that's intended so I didn't check that,

Best
Elisa



Elisa Filevich

unread,
Nov 9, 2020, 4:43:36 PM11/9/20
to ja...@googlegroups.com
(Also I missed this somehow in your previous email. Note that in JS you negate things with !, not ~) 

Best

María da Fonseca

unread,
Nov 9, 2020, 7:02:20 PM11/9/20
to ja...@googlegroups.com
Thanks, Elisa! It worked for me too. The idea behind using jatos.batchSession.defined was because, the doc says that returns true if it was previously defined and false on the contrary. But, with jatos.batchSession.test works fine!

Best,

María

Reply all
Reply to author
Forward
0 new messages