Howdy, Stranger!

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

Supported by

Transferring studySessionData from OSWeb to a subsequent component

Hi there,

I wasn't sure where this topic would fit best - feel free to send it over to JATOS if this makes more sense.

I am trying to install an experiment with 3 components on JATOS: a survey (SurveyJS), the actual experiment in OSWeb and a final page, where participants can see their results and share them on social media (simply to recruit more participants).

Of course, it is fairly easy to display the results in OpenSesame, but implementing the social media buttons seems not to be possible (correct me if I am wrong!) - hence the last page. Here's the issue:

I managed to import the jatos.studySessionData from the preceding survey to the OSWeb experiment, but I can't figure out how to send the variables from OSWeb to the subsequent component.

Here is what I have:

Exporting from survey:

survey.onComplete.add(function (result) {

        jatos.studySessionData.subject_number = survey.data.subject_number;

        if (survey.data.session_number == null){
            jatos.studySessionData.session_number = 1;}
        else {jatos.studySessionData.session_number = survey.data.session_number;}

            jatos.submitResultData(JSON.stringify(result.data), jatos.startNextComponent);
        });

Importing to OSWeb (works):

vars.code_number = jatos.studySessionData.subject_number

vars.sess_nr = jatos.studySessionData.session_number

Exporting from OSWeb (does not work):

jatos.studySessionData.accuracy = vars.acc

jatos.studySessionData.rt = vars.avg_rt

How can I transfer the data from OSWeb to the last component - and how can I implement it there?

Many thanks for your responses and I hope others will find this useful aswell :)


Best,

Tim

Comments

  • Hi Tim,

    As far as I understand your experiment has 3 components, one survey, one OSWeb and one 'last' component. Actually the code to get your data from the study session in the third component is just

    var accuracy = jatos.studySessionData.accuracy;

    var avg_rt = jatos.studySessionData.avg_rt;

    I guess you tried this already. What are the errors you get?

    Best,

    Kristian

  • Hi Kristian,

    this is exactly what I have and it returns "undefined". The console doesn't show any error messages.

    I tested it with studySessionData set in OSWeb (as described above) and the data automatically set by OSWeb:

    <script type="text/javascript">
          var accuracy = jatos.studySessionData.accuracy;
          var rt = jatos.studySessionData.rt;
          var acc = jatos.studySessionData.acc;
          var avg_rt = jatos.studySessionData.avg_rt;
        console.log(accuracy);
        console.log(rt);
        console.log(acc);
        console.log(avg_rt);
    </script>
    

    I am not very familiar with JS/HTML. Does it have to be in the head? Do I need more than

    <script src="jatos.js"></script>
    

    in the .html?


    Best,

    Tim

  • Hi Tim,

    It looks like you forgot to initialize jatos.js. Have a look in http://www.jatos.org/Write-your-own-Study-Basics-and-Beyond.html#mandatory-lines-in-your-components-html.

    Basically before you can start with using features from jatos.js (like the study session) you have to wait for it to be initialized with jatos.onLoad :

    jatos.onLoad(function() {
          var accuracy = jatos.studySessionData.accuracy;
          var rt = jatos.studySessionData.rt;
          var acc = jatos.studySessionData.acc;
          var avg_rt = jatos.studySessionData.avg_rt;
    });
    

    Best,

    Kristian

  • Hi Kristian,

    many thanks for your help, I really appreciate that.

    I did actually already try it with "jatos.onload()" and it didn't work either. But in this case I did indeed get an error message stating that "accuracy" (because it is the first of the four, I guess) was not defined. Without the function I would just get the value "undefined" when calling the variable.

    Could it be that OSWeb somehow doesn't transfer the studySessionData, i.e. "ends" the session?


    Best,

    Tim

  • Could it be that OSWeb somehow doesn't transfer the studySessionData, i.e. "ends" the session?

    Maybe I should add that I just put the .html files to a subfolder in the zipped OSWeb files. This worked flawlessly for the survey as first component though. Might this be the issue?

  • Hi Tim!

    Could it be that OSWeb somehow doesn't transfer the studySessionData, i.e. "ends" the session?

    This is handled by jatos.js. So OSWeb can't 'end' the session. Maybe there are problems with starting the last component of yours. How do you start it? Do you use one of the jatos.js functions like jatos.startNextComponent?

    Maybe I should add that I just put the .html files to a subfolder in the zipped OSWeb files. This worked flawlessly for the survey as first component though. Might this be the issue?

    Putting it in the zip file is fine. As long as you add the new component to the study properties too.

    Kristian

  • Hi Kristian,

    no I didn't, as I expected OSWeb to automatically transition to the next component. I tried to add it in an inline_script in OpenSesame, but the results are the same: the last component starts, but it seems like it can't fetch studySessionData. As I said, I just added a .html which looks something like this to a folder in the osweb-zip-file:

    <!doctype html>
    <html lang="de">
     <head>
       <script src="jatos.js"></script>
       <title>Thank you!</title>
     </head>
    <body>
    
    <script type="text/javascript">
    jatos.onLoad(function() {
         var accuracy = jatos.studySessionData.accuracy;
    });
    </script> 
    
    <!--Test:-->
    <script type="text/javascript">
       console.log(accuracy);
    </script>
    
    </body>
    </html>
    
    

    Returns "accuracy is not defined" in the console. Calling "jatos.studySessionData.accuracy" at the end of the OpenSesame experiment works fine.

    As long as you add the new component to the study properties too.

    This sounds like something I didn't do; what exactly do you mean by that? I mean, I did add the file as a new component, but I did not change any properties.

    Many thanks!


    Best,

    Tim

  • Hi Tim!

    Try putting the logging within the onLoad function too, like:

    <script type="text/javascript">
    jatos.onLoad(function() {
         var accuracy = jatos.studySessionData.accuracy;
         console.log(accuracy);
    });
    </script> 
    

    The way you have it, console.log is called right in the start when jatos.js is not yet initialized.

    But you have to add your third component to the study. When you open your study in JATOS, how many components do you have there? It should be three: survey, OSWeb experiment, and third component. If the third is missing you have to add it.

    Best,

    Kristian

  • Hi Kristian,

    I'm a little confused because I could swear I've tried this before, but somehow it has worked now - thank you! This does not really belong here, but is there a way to initialize JATOS (i.e. load the variables) before the HTML is loaded (e.g. to dynamically create content)?

    In any case, thank you very much for the help and the post can be marked as solved :)


    Best,

    Tim

  • Hi Tim!

    That's great to hear!

    And about your other question: 'is there a way to initialize JATOS (i.e. load the variables) before the HTML is loaded (e.g. to dynamically create content)?'. I don't think that is possible since jatos.js loads data asynchronous from the server. But you can always add content dynamically to your HTML. It's actually quite common to do that. E.g. you could wait for jatos.js to initialize and then add some HTML to you r DOM dynamically.

    Best,

    Kristian

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