JsPsych, save a second file for metadata

URL of experiment: There’s no experiment for the moment

Description of the problem:
I would like to know if it would be possible to save a second file, in addition to my json with the participants results. A file in which I could append informations about each participant, age / right or left-handed / mean results / mean duration / etc. to get an of the experiment and the participants in one file in order to determine easily if I need more participants, if a need to pay more attention to a participant. I want to use prolific and we need to check participants results to say “okay he can be paid” / “no he can’t be paid because he didn’t respect the rules” so it would be very useful to get such a file.

EDIT : I forgot to precise I use JsPsych and my version of the plugin is n° 2020.4 (link to the plugin) which is a modified version propose by @thomas_pronk and that allow me to filter the data I save.

I don’t know jsPsych, but I do know that that in PSychoPy I can pipe the summary results to Qualtrics (or any other tool which can accept URL variables).

I’ve set my my VESPR Study Portal to allow the researcher to monitor the number of participants in different groups, but that’s only really intended to look at one categorical variable, not a full summary of the responses.

Here is a sketch of an approach that might work, but note I haven’t tested it. The dataFilter function of the pavlovia plugin allows you to store any data you’d like by having that function return that data. Save the trial data the first time (by having dataFilter return the data that is passed to it via it’s first argument) and save the metadata the second time (by having dataFilter return the metadata).

You could use completedCallback to determine whether you just saved the data the first time (thus moving on the metadata for the second time) or saved the data the second time (thus completing the task).

Hope this helps, and if you pursue this approach, then I’d love to know whether it worked out!

Hi @wakecarter yes I wanted something more complete, I will try the answer of Thomas.

@thomas_pronk before your answer I tried to modify the promise in _uploadData like this :


                const data = {

                    key: mainKey,

                    value: mainValue

                };

                const additionalData = {

                    key: additionalKey,

                    value: additionalValue

                };

                $.post(url, data, null, 'json').done((serverData, textStatus) => {

                        $.post(url, additionalData, null, 'json').done((serverData, textStatus) => {

                                resolve(Object.assign(response, {

                                    serverData

                                }));

                            })

                            .fail((jqXHR, textStatus, errorThrown) => {

                                console.error('error:', textStatus);

                                reject(Object.assign(response, {

                                    error: textStatus

                                }));

                            });

                    })

                    .fail((jqXHR, textStatus, errorThrown) => {

                        console.error('error:', textStatus);

                        reject(Object.assign(response, {

                            error: textStatus

                        }));

                    });

            });

where the additional data come from a new field in the trial object, basically I copied the filterData function to send this metadata.

I don’t know why it works 5/6 times and after this it stopped to work… Maybe the server is not okay to receive 2 consecutive request or maybe I did it wrong, I am not that friendly with promises…

So, to conclude I will try your solution with your correct version of the plugin (because I’m sure that it works well) and I will give you a feedback. I just didn’t understand what you mean. I need to return not only the data but an array with [data, metadata] , that’s it ?

Thank you for your help !

Hey again!

Not sure why your version wouldn’t work, but if you’d like, you could take a peek at your browser’s network panel to see what it reports. See this tutorial

About the plugin solution: it’s important that whatever is returned by dataFilter is valid text, like a CSV string in the default version (see this line). So you could return data the first time, the second time perhaps some kind of serialized metadata, like JSON.stringify([a, list, of, variables])