Howdy, Stranger!

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

Supported by

help with jspsych and JATOS

edited June 26 in JATOS

Hi!

I'm recently working on buliding an online perception experiment by using jspsych. However, when I try to put the last lines of javascript:

var jsPsych = initJsPsych({
 show_progress_bar: true,
 on_finish: function() {
  var resultJson = jsPsych.data.get().json();
  jatos.endStudy(resultJson, true);
 }
});

The end page is totally blank, and the JATOS results webpage still shows "not finished yet" in each response...

And if I use the line:

jatos.onLoad(function() {
 var jsPsych = initJsPsych({
  timeline: timeline,
  show_progress_bar: false,
  on_finish: function() {
   var resultJson = jsPsych.data.get().json();
   jatos.endStudy(resultJson, "success");   
  }
 });

Then the whole experiment is blank!

In the beginning, I do put the line "<script src="jatos.js"></script>"..Im suspecting that maybe because I use jspsych 8.2.1 not 7 (because the instructions given on JATOS use jspsych 7 //https://www.jatos.org/jsPsych-and-JATOS.html)?

Im totally a beginner of programming, sorry for my questions sound basic..

Thank you for your help and time!

Comments

  • Hi!

    I took the liberty to format your code examples and I encourage everyone to do the same - it makes it much more readable.

    I'm just looking into jsPsych 8 and there seem to be no difference in how to use it together with JATOS.

    You need three parts (just like written in https://www.jatos.org/jsPsych-and-JATOS.html):

    1) Include the jatos.js library in the <head> section of your HTML file:

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

    2) in initJsPsych the on_finish has to point at jatos.endStudy or a similar function like jatos.startNextComponent:. As far as I understand jsPsych the timeline does not go here.

    var jsPsych = initJsPsych({
      show_progress_bar: true,
      on_finish: () => jatos.endStudy(jsPsych.data.get().json())
    });
    

    3) Wrap jsPsych.run with jatos.onLoad and here goes your jsPsych timeline :

    jatos.onLoad(() => {
      jsPsych.run(timeline);
    });
    

    This should do it.

    Best,

    K.

  • Dear Kri,

    I paste the code you give me, then the whole experiment (from the very first page becomes blank..), its relly weird...

  • Do you get any errors in the browser's console? And can you please post your code here?

Sign In or Register to comment.