Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jsPsych on Pavlovia #3491

Open
giuliunimib opened this issue Jan 20, 2025 · 3 comments
Open

jsPsych on Pavlovia #3491

giuliunimib opened this issue Jan 20, 2025 · 3 comments

Comments

@giuliunimib
Copy link

Hi!

I have set up my jsPsych experiment to run on Pavlovia, and it works perfectly fine locally. However, when I follow the instructions to modify the timeline (see here) and try to pilot the experiment on Pavlovia, I only see a blank page. I’ve read that some variables (e.g., jsPsych.init) no longer work with the latest version, but even after updating the script, it still doesn't run.

Here’s the link to the experiment: https://gitlab.pavlovia.org/giulialoca18/jspsych_bwsnorms/-/blob/master/index.html .

I've tried several potential solutions, and occasionally, I encounter errors related to the plugins I added (although no error is shown in this latest version of the code). I suspect the issue may be linked to the plugins or to the connection with the server.

Could anyone help me identify the problem or suggest which part of the script I should check or modify? Could this issue be related to conflicting versions of jsPsych and Pavlovia?

Thank you in advance for your help!
Giulia

@shaheedazaad
Copy link

Hi Giulia,

Are there any errors in your browser console?

I ran into a similar issue, and it was because the documentation was outdated.

Try replacing the init and finish code with this:

    var pavlovia_init = {
        type: jsPsychPavlovia,
        command: "init",
        show_progress_bar: true
    };
		var pavlovia_finish = {
			type: jsPsychPavlovia,
			command: "finish",
			participantId: "JSPSYCH-DEMO"
		};

@giuliunimib
Copy link
Author

Hi! Thank you so much for your response.
I've tried replacing the init and finish code as you suggested, but it still doesn't work unfortunately. There is no error shown if i inspect the page, so I really do not know what the problem could be. Maybe something related to the plugins and/or the versions of jsPsych and Pavlovia? But they should be compatible, so I still have no clue.
But thank you so much again for your suggestions!

@shaheedazaad
Copy link

shaheedazaad commented Jan 28, 2025

Hi! Thank you so much for your response. I've tried replacing the init and finish code as you suggested, but it still doesn't work unfortunately. There is no error shown if i inspect the page, so I really do not know what the problem could be. Maybe something related to the plugins and/or the versions of jsPsych and Pavlovia? But they should be compatible, so I still have no clue. But thank you so much again for your suggestions!

Ah, I see the problem now - your timeline is missing the jsPsych.run(timeline) function call at the end.

You also have a redundant jsPsych init call at the end. So your code should look like:

        // finish connection with pavlovia.org //
		var pavlovia_finish = {
			type: jsPsychPavlovia,
			command: "finish",
			participantId: "JSPSYCH-DEMO"
		};
		timeline.push(pavlovia_finish);
        jsPsych.run(timeline);
    }

You'll also need to change the type parameters on all your trials from strings to objects. For example:

    var thank_you = {
            type: "html-button-response",
            stimulus: "<p>You have now completed the experiment. Thank you for participating!</p>" + 
            '<p>Press any key to close the experiment.</p>',
            choices: ["Close"]
        };

should be:

    var thank_you = {
            type: jsPsychHtmlKeyboardResponse,
            stimulus: "<p>You have now completed the experiment. Thank you for participating!</p>" + 
            '<p>Press any key to close the experiment.</p>', // removed the choices argument since all keys should be enabled
        };

You can find the correct value to enter for trial types in the plugin documentation: (e.g., https://www.jspsych.org/v7/plugins/html-keyboard-response/)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants