Hey @FelixHenninger ! I've been testing the labjs integration, and there are a few tweaks to make so that the experiment will function properly!
jquery
should be added in the basic header of index.html, like this -->
https://github.com/expfactory/builder-labjs/blob/master/experiments/stroop-task/index.html#L7
I found the expfactory modifier script, https://github.com/FelixHenninger/lab.js/blob/master/packages/builder/src/logic/io/export/modifiers/expfactory.js and maybe we could have it added with a function in here? I'm not familiar with the setup so wanted to discuss with you.
response
This isn't required, but it's a suggestion to show the response even if it's not perfect, because it's needed for debugging. I added an "else" that prints the response if it's not ok --> https://github.com/expfactory/builder-labjs/blob/master/experiments/stroop-task/index.html#L46
bug in transmit
When I submit the data to /save, I get a 400 BAD REQUEST. I think this is because of the format of the data that is being submit? It is coming from lab.plugins.Transmit
:
{
"type": "lab.plugins.Transmit",
"url": "/save",
"updates": {
"staging": false,
"headers": {"X-CSRFToken": csrf_token}
},
"callbacks": {
"full": function full(response) {
if (response && response.ok) {
console.log(response);
window.location = '/next';
} else {
console.log(response);
}
}
}
And this I think is generated from here? https://github.com/FelixHenninger/lab.js/blob/master/packages/library/src/plugins/transmit.js#L3
The above doesn't show me how the submit is being done, and I'd like to better understand the format of the data being transmit to properly debug. For expfactory experiments, I typically just submit json to the endpoint, and I use ajax since the header for the csrf_token is added that way, like this:
$.ajax({
type: "POST",
url: '/save',
data: { "data": data },
success: function(){ document.location = "/next" },
dataType: "application/json",
// Endpoint not running, local save
error: function(err) {
if (err.status == "200"){
document.location = "/next";
} else {
// if error, assume local save
jsPsych.data.localSave('breath-counting-experiment_results.csv', 'csv');
}
}
});
We need some tweaking somewhere to get this finished up!
And exciting things to share (that will help you to possibly debug this issue!) I have the basic "expfactory labjs builder" finished up, and once the experiment is fully working I can do the little writeup. It works that you literally export the LabJS experiment, and drop it in a folder, and you're done :) Here is the repo:
So - to run this experiment on your computer with docker, just do:
docker run -d -p 80:80 --name stroop vanessa/expfactory-stroop start
And then open to http://127.0.0.1. The experiment will proceed and what I'm debugging now (the things above to discuss) are the submission of the data, what I see in the console is:
and I'm trying to debug and need your help! It could either be that the data format is off, or the passing of the cookie isn't working. If we can talk about the above I can get a better sense of this - I'm super excited to get this underway!