Howdy, Stranger!

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

Supported by

Integration with Sona?

JATOS now works with AMT and Prolific. Any plan for integrating JATOS with Sona (http://www.sona-systems.com)?

Comments

  • Hi nya,

    yes, it's on our todo list. I haven't looked into Sona in detail but I have a hunch that it works already with JATOS and that JATOS doesn't need to be changed for this. It looks like Sona just needs the study link URL from JATOS (similar to Prolific with JATOS: http://www.jatos.org/Use-Prolific.html). But I have to check this and write some documentation.

    Best,

    Kristian

  • We are trying to resolve this too. We can pass the sona participant id to jatos by adding &id=%SURVEY_CODE% to the study URL, and if we have an inline javascript entry that says:

    vars.subject_nr = jatos.urlQueryParameters.id

    the id is happily recorded in the subject_nr variable in the logged data.

    What we cannot do is pass the id back to sona to award credit.

    When we try to append the id to the return url with this:

    jatos.endStudyAndRedirect('https://uopsop.sona-systems.com/services/SonaAPI.svc/WebstudyCredit?experiment_id=3963&credit_token=72fb455fe0d0414cbf6c93433559a08c&survey_code=''+jatos.urlQueryParameters.id)

    then JATOS gives us 'Uncaught SyntaxError: Invalid or unexpected token' and advises us to look in the console, where it says FAIL. The Study Log thinks it all finished fine though, and the results data is there.

    (It does not work if we try to append vars.subject_nr either).

  • The lack of a closing semicolon on the final line has just been pointed out.... and the mismatched quotes. This works:

    jatos.endStudyAndRedirect('https://uopsop.sona-systems.com/services/SonaAPI.svc/WebstudyCredit?experiment_id=3963&credit_token=72fb455fe0d0414cbf6c93433559a08c&survey_code='"+jatos.urlQueryParameters.id);

  • So, you got Sona + JATOS working for you!?

  • yes - first participant has signed up through sona, completed task, and received credit!

  • Nice :)

  • @jmplym Thanks, I was looking for a way to do this myself, actually.

  • edited March 2021

    great -, thanks! I'm now embedding these lines within a try/catch statement so that if there are no URL parameters supplied it (e.g., if used locally) it does not crash:

    try{
            vars.participant_URL_ID = jatos.urlQueryParameters.id
            } 
    catch(e){
            vars.participant_URL_ID = 0
            }
    


    and then at the end, for robustness:

    try{
         jatos.endStudyAndRedirect("https://uopsop.sona-systems.com/webstudy_credit.aspx?experiment_id=xxxx&credit_token=xxxxxxxxxxxxxxxxxxxxxxx&survey_code=" + vars.participant_URL_ID);
         } 
    catch(e){}
    


    Of course, there should always be an id, even if it is zero, so the error should never fire, and if there is no id supplied then the participant ends up at a confused SONA page which says it has never heard of them, but that is immaterial. You could revise that second line to send them somewhere else in the final catch(e){} if you wanted to be nicer.

  • Hi @jmplym and @kri ,

    I found out that this solution, i.e. explicitly calling jatos.endStudyAndRedirect() , has the unfortunate side-effect of bypassing the data transfer that happens at the end of the experiment. Data is also stored incrementally, every time that a logger item is called, but this is not foolproof. Therefore, at the end of the experiment all data is sent again, and this also includes some additional 'context' information. And this is missing now, because jatos.endStudyAndRedirect() closes the study prematurely.

    Have you run into this as well, and perhaps have a workaround?

    — Sebastiaan

  • Hi Sebastian,

    jatos.endStudyAndRedirect() shouldn't close the study prematurely but I'm not sure what you mean with 'bypassing the data transfer that happens at the end of the experiment'. But jatos.js ensures that everything you send via jatos.submitResultData or jatos.appendResultData before calling jatos.endStudyAndRedirect() is actually sent.

    E.g.

    jatos.appendResultData("one");
    jatos.appendResultData("two");
    jatos.endStudyAndRedirect("https://www.myredirect.url")
    jatos.appendResultData("three");
    

    ensures that "one" and "two" are stored in JATOS database before the redirect happens. "three" is likely lost.

    Best,

    Kristian

  • Hi @kri ,

    The reason that things go wrong (if I'm correct) is that jatos.endStudyAndRedirect() is executed in an inline_javascript item that is part of the experiment. And once this function is called, the connection with JATOS is over, right? That's why in your example the "three" would be lost. In the case of OSWeb, this means that the call to jatos.submitResultData() , which happens after the experiment has ended and therefore after the call to jatos.endStudyAndRedirect() , doesn't have any effect anymore.

    All of this makes perfect sense, and it's not a bug in JATOS or OSWeb as such. But it makes it problematic to automatically grant credit to SONA participants and have the experiment end gracefully at the same time. Hence my nudge in the issue tracker ;-)

    Or am I missing something?

    -- Sebastiaan

  • @sebastiaan , I have not had any problems losing data. Maybe my loggers are doing their job and whatever the 'final data transfer' you need is not relevant to my studies. I do not need the context information so don't ask for it when using Opensesame to translate the json file to csv; if it isn't there I have not notice.! I do remember that trying to read the json file directly in R using jsonlite failed so maybe it isn't terminated properly and Opensesame is able to cope with this.

    The only problem is when participants get to the debriefing screen and then close their browser window before the study actually finishes, in which case I have all their data but the survey_code id is not returned to sona and they don't get their credit. I have to compare id numbers in my jatos data against my sign-up list and manually credit these few.

  • @sebastiaan Anyway, issue https://github.com/JATOS/JATOS/issues/224 shouldn't be too difficult to implement and it might be nice to have for other things too.

Sign In or Register to comment.