Using lab.js and JATOS
Lab meeting 7.5.21
Lea
...start → browser-based
...share experiments (.json)
...use: Builder (+ scripts)
...put studies online (open-lab/JATOS)
...use for online studies → javascript
...mousetrack
...get help (slack)
There might be some initial confusion,
The documentation consists of videos,
Some Javascript (and html) might be necessary!
labjs.felixhenninger.com/
Select one of the invitation options under Einladungen.
I typically use the first one, direct invitation (often with a code sent from i.e. Sona), but you might also want the participants to log in with a code you or they provided.
Simply go to Daten and download either all data or single data files ("laden")
To use JATOS, it is highly recommended to download a local version of JATOS to set up and test your study!
https://www.jatos.org/
To run JATOS locally...
*(you need an account from Dominik, see wiki!)
In JATOS, in the main window of your study, click on Results.
Either select individual rows or export all results via Export Results.
The exported files are .json files. You can read them into R with the code on the right (given the files are all in one folder, adjust path):
require(pacman)
p_load('tidyverse', 'jsonlite')
filelist <- dir("PATH/TO/DATA/", full.names = TRUE)
readfl <- function(fname) {
data <- read_file(fname) %>%
str_split('\n') %>% first() %>%
discard(function(x) x == '') %>%
map_dfr(fromJSON, flatten=T)
}
data <- filelist %>%
map_df(~readfl(.))
<script src="jatos.js"></script>
jatos.onLoad(function() { // initialize and start your JavaScript here });
jatos.submitResultData(resultJson, jatos.startNextComponent); https://www.jatos.org/Adapt-Pre-written-Code-to-run-it-in-JATOS.html
From Sona to Open-Lab/JATOS and back
(incl. automatically booking the participants' credits)
Add "?code=%SURVEY_CODE%" to the end
k
In open-lab, you can simply paste the completion URL from SONA in the field with the yellow arrows in the study set-up!
Replace the "XXXX" at the end with "%PARTICIPANT_CODE%"
You can also find a german instruction for Sona <-> open-lab here: https://open-lab.online/docs/project#integration
In JATOS, you can easily redirect by pasting an URL in the study properties:
However, I haven't figured out how to add the correct URL parameter (the SONA code).
That's why I add code to the study's javascript file (or script components)!
http://www.jatos.org/End-page-after-your-study-finished.html
Add the following code to your first component in lab.js:
this.parameters.jatosid = jatos.workerId;
this.parameters.sonaCode = "";
this.parameters.sonaCode = jatos.urlQueryParameters.code;
jatos.studySessionData["sonaCode"] = this.parameters.sonaCode;
Open the script.js in the study assets folder of your local JATOS with a text editor:
locate the command (at the beginning):
jatos.submitResultData(resultJson, jatos.startNextComponent);
Add the following line (w/ SONA's completion URL):
jatos.endStudyAndRedirect("https://LINK_TO_SONA/?code="+jatos.studySessionData.sonaCode);