lab.js icon indicating copy to clipboard operation
lab.js copied to clipboard

Document code-based integration with JATOS

Open ZeroPie opened this issue 4 years ago • 3 comments

What would you like or expect to see?

How to export studies into a format that i can upload to JATOS when coding them from scratch

What is currently happening?

No information about it, the documentation just describes how to do it with the builder

Please describe the steps needed to reproduce this phenomenon

const instructions1 = new lab.html.Screen({
  title: 'Title',
  content: `
  <p> ETC </p>
  `,

  responses: {
    'keypress(Enter)': 'response',
  },
})

const instructions2 = new lab.html.Screen({})
const instructions3 = new lab.html.Screen({})

const study = new lab.flow.Sequence({
  content: [
    instructions1,
    instructions2,
    instructions3
  ],
  events: {
    visibilitychange: function (event) {
      if (document.hidden) {
        alert(`Please don't change windows while the experiment is running`)
      }
    },
  },
})

study.run()

ZeroPie avatar Jun 28 '20 19:06 ZeroPie

Hi @ZeroPie, and many thanks for your great question! Please be very warmly invited to join our support channel, where there's many more folks around to discuss this kind of question; we try to focus on technical issues here in the repository, and we check quite as often.

As for your question, we haven't documented this process yet, as you noticed -- would you be interested in putting together a short tutorial? My first step would be to look at what the builder does to generate studies for JATOS, and that's two steps if I'm not mistaken:

  • First, replace the study.run() with jatos.onLoad(() => study.run())
  • Second, hook up data storage to the end of the experiment, my adding the following lines to the study component:
  messageHandlers: {
    'epilogue': () => {
      var resultJson = study.options.datastore.exportJson();
      jatos.submitResultData(resultJson, jatos.startNextComponent)
    }
  }

Ok, I think with those two steps you should be good to go -- please let me know how things work out, and I'd love to support you in documenting this formally!

Kind regards,

-Felix

FelixHenninger avatar Jul 06 '20 18:07 FelixHenninger

Hi Felix,

Thank you for the kind message and for the pointers. I will look into it, get it working and then i willl gladly document the process formally for others.

Thank you for your work and time.

ZeroPie avatar Jul 08 '20 07:07 ZeroPie

That would be way awesome, thank you so much! Please be warmly invited to ping me if you could use help along the way, I'm always happy to help document things!

Happy experimenting, -Felix

FelixHenninger avatar Jul 08 '20 12:07 FelixHenninger