display endPage.html for more than a flash
Hi!
I'm writing a study in jsPsych and JATOS, and at several points we want to be able to end the study based on users' responses (failing to consent, sharing information that makes them ineligible to participate). JsPsych and JATOS both theoretically have methods for displaying a page after the study is over, explaining to participants why they've been abruptly booted.
However, the simple html page I wrote (endPage.html, according to what JATOS docs suggested) just flashes on the screen for less than a second before the tab closes.
Is there a way to keep endPage.html up until the user closes the tab?
Thanks,
-E
Relevant code snippets
JATOS endStudy calls:
jatos.onLoad(function(){ var jsPsych = initJsPsych({ on_close: function() { var resultData = jsPsych.data.get().ignore('internal_node_id'); jatos.endStudy(resultData.csv()); }, on_finish: function() { var resultData = jsPsych.data.get().ignore('internal_node_id'); jatos.submitResultData(resultData.csv(),jatos.endStudy); } });
A sample trial that ends study early:
var info = { type: jsPsychHtmlButtonResponse, stimulus: '<h2>Participant Consent</h2><p>Please download and read <a href="CONSENT.pdf" target="_blank">this consent form</a>.</p><p>By continuing, you are consenting to this study.</p>', choices: ['Could not download','Agree to participate'], on_finish: function(data) { if(data.response == 0){ jsPsych.endExperiment(endmessage,data); } } }
Comments
Hi!
I just tried the endPage.html with my local JATOS but without jsPsych and it worked. So, I'm pretty sure it has something to do with jsPsych messing with jatos.js' endStudy. I assume there is nothing in your endPage.html that closes the tab, e.g. like
window.close()
?I see that you call
jatos.endStudy
twice once fromon_close
and once fromon_finish
. I'm not so familiar with jsPsych but maybe this is not necessary and actually might cause your blip. Have you tried to use only one of the two callbacks?I hope this helps already and if not keep asking.
Best,
Kristian
Hi Kristian,
You were correct in assuming that endPage.html didn't have anything like window.close(). :)
Your suggestion of calling jatos.endStudy only once seems to have worked on a very cursory test. I just commented out the full on_close portion and tried running it again. The behaviour looked exactly the same if I used the "run" button within the JATOS interface (it flashed the end screen then redirected to the JATOS study view immediately), but if I copied a study link and ran it in a new tab, endPage.html did just what I wanted it to.
I'd like to find a way to keep both the on_close and on_finish statements, though. It happens sometimes that participants close the tab before the data gets sent to JATOS, and I want to avoid losing that information if possible. Still, this is a good enough fix for now, and that's a separate issue, so if I can't figure it out I guess I'll start a separate issue.
Thanks so much,
-Elise
Hi Elise,
The behaviour looked exactly the same if I used the "run" button within the JATOS interface (it flashed the end screen then redirected to the JATOS study view immediately), but if I copied a study link and ran it in a new tab, endPage.html did just what I wanted it to.
Ah, yes, if you start a study with 'Run' button in JATOS' GUI / study page, the endPage.html won't show. This happens only if you use a proper study link. Obvious reason is that the first one is for development and people usually want to get back to JATOS' GUI.
I'd like to find a way to keep both the on_close and on_finish statements, though. It happens sometimes that participants close the tab before the data gets sent to JATOS, and I want to avoid losing that information if possible.
I'm still lost here. I could imagine that somehow by defining both jsPsych callbacks the study is finished twice. But JATOS should just ignore the second call and the first call should proceed as expected and redirect to the endPage.html. Not sure what happens there. But I can't work on it without being able to reproduce it in my JATOS :/.
Best,
Kristian