jsPsych experiment, token randomly consumed, no data stored

Hey,

I am currently experiencing issues with my jsPsych experiment on Pavlovia. I am using nearly the same setup in another experiment which is working fine.
Either the data is not stored and a token is consumed and/or reserved, or only the header of the data file is stored and no token is consumed. I opted for storing the data as a csv and I am also saving incomplete trials. The data is neither available in the git repository, nor by downloading it via the dashboard.

Is this currently a known issue, or does anyone experience similar issues?

Best
DonShirley

I’m not sure if it’s a known issue, but it might be handy to take a peek at the network panel in your browser’s devtools to see if the data gets sent to the server (or not). Here are two learning materials about that:

Thanks a lot! I think I have identified the problem, but I don’t know how to deal with it.
The data file which is generated has a size of around 2MB, so it can easily take 15 seconds to upload the data to the server.
I am redirecting the participant to Prolific at the end of the experiment. Due to that the upload result POST seems to stay pending and in the end is not finished at all.
Removing window.location.replace() to Prolific isn’t a problem, but the data is also not stored when the participant closes the browser tab directly after the experiment.

The solution maybe would be something like sending an event at the end of the upload to tell the participant that he can now close the experiment.
Do you see any other solutions?

At least we’re a step closer to a solution! If I remember right, Pavlovia sends a receipt confirmation once all the data is in, so I guess you could fire a callback when this happens, even do your redirect at that point.

If you’ve got trouble figuring out how to achieve this, give a shout. I’ve got a couple of jsPsych-related tasks on my list, so I could add this one as well.

Hi @thomas_pronk , thank you very much for sending me to this post! I took a look at my three tasks and found that the one with data loss is the one that generates the largest data file (around 110 KB, still small compared to other’s data in MB). I did save the data successfully once when I did it without any redirecting afterward. Don’t know if redirecting plus large data size is the cause?

After reading all these posts, here’s my action plan:

  1. Try to get Pavlovia’s receipt confirmation before or during redirecting.
  2. Try to insert a delay before redirecting (if the first method does not work).

One question: is there any information on how we can get Pavlovia receipt confirmation? Thank you!

Best,
Lillian

Sounds like a plan! I’ll tackle a bunch of jsPsych topics at once the coming days, so I’ll tackle this one too.

2 Likes

Hi, @thomas_pronk I added you to my project, you should be able to see it now and hopefully get some idea where the problem is coming from, so I can prevent it in the future.

Best and thanks again for your fast replies, I really appreciate it :slight_smile:
Mila

1 Like

@DonShirley, I wonder where in your code the redirect to Pavlovia takes place. Could you share your jsPsych experiment with me? (tpronk). Hmmm, actually same question for @Lillian_XU

Also, I’m getting a bit confused which thread is about what :slight_smile:

@DonShirley and @Lillian_XU, I went ahead and added a little feature to our jsPsych Pavlovia plugin, updating it to version 2020.3. It now offers a completedCallback which is called once the data is in. The demo below contains the updated plugin and an illustration on how to use it.

This is how I tested it: the demo task only sends a tiny bit of data, but via the Network Panel in your browser’s Developer Tool, you can simulate an extremely slow internet connection. While simulating a low connection, this happened:

  • After completing the task I saw the text Please wait a moment while the data are uploaded to the pavlovia.org server... for a couple of seconds
  • Then the alert that says data successfully submitted! appeared. In the Network Panel I could see that this happened after all the network requests had resolved.

If you put your redirect in completedCallback, that should fix the data issues.

2 Likes

Thanks so much @thomas_pronk for the prompt fix! We’ll try out this completecallback plugin soon.

I’ve now added you to my go-nogo task on gitlab, let me know if you cannot see it.

And yes, we can continue our discussion using this current thread.

Got it and I took a peek at the code. I don’t see anything suspicious there. Well… as far as my jsPsych expertise can see.

1 Like

Thank you very much, it works like a charm! I added you to my repository as a guest so you can have a look if you still want to.

1 Like

Very happy to read this solves all of the poblems!

Hello @thomas_pronk. I think I am running into a similar issue. I tried following the steps that worked for the others, but I am not sure where to add the extra lines of code. Could I share my jsPsych experiment with you as well? Thanks in advance!

Hi @vwang. Sure!

@vwang, I took a look at your code. Here are some pointers to the example experiment to show what needs to be updated:

  • You’re using version 3.0.6 of the pavlovia plugin, use 2020.4 instead. See this line
  • For instructing pavlovia to store the data and have something happen when the data has been stored, see this line

@thomas_pronk, thank you so much for your fast response!

I updated the version of my pavlovia plugin to 2020.4. As for the pavlovia_finish, I have that in my UrnUpdate.js script here. Does this work? Where should I put the completedCallback function?

Thanks!

I see the indentation on gitlab is a bit confusing, so I copy-pasted it here. Note that the pavlovia_finish command has a bunch more options for checking whether the data is in. Redirect your participants to another website in completedCallback

		/* finish connection with pavlovia.org */
		var pavlovia_finish = {
			type: "pavlovia",
			command: "finish",
			participantId: "JSPSYCH-DEMO",
            // Thomas Pronk; your filter function here
            dataFilter: function(data) {
                // Printing the data received from jsPsych.data.get().csv(); a CSV data structure
                console.log(data);
                // You can also access the data directly, for instance getting it as JSON
                console.log(jsPsych.data.get().json());
                // Return whatever data you'd like to store
                return data;
            },
            // Thomas Pronk; call this function when we're done with the experiment and data reception has been confirmed by Pavlovia
            completedCallback: function() {
                alert('data successfully submitted!');
            }
		};