link to external websites #1279
-
Hi, I'm new to jspsych and I'm setting up an experiment to run on Pavlovia. I just wanted to ask whether it is possible to include links to gorilla.sc experiments within the Pavlovia experiment? Ideally this would be near the beginning and also at the end. Any advice would be really appreciated Thanks so much, |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 3 replies
-
Hi Becca, Are you trying to include experiments from Gorilla inside the Pavlovia experiment, or just include a link so that participants leave Pavlovia to go to Gorilla? |
Beta Was this translation helpful? Give feedback.
-
I'm not sure about the details of either Pavlovia or Gorilla as hosting environments for an experiment, so I don't know if there are other problems that you will run into besides delivering a link to your participants. But, showing participants a link to click on is certainly possible with the var link_trial = {
type: 'html-keyboard-response',
stimulus: '<p>To complete the next part of the experiment, please follow <a href="url-to-experiment-here">this link to our consent form.</a></p>',
choices: jsPsych.NO_KEYS
} If you want to pass along the subject as a variable you can add that info into the URL. You may need to generate the Note that clicking on the link will exit the jsPsych experiment. You could force it to open in a new tab instead like this: var link_trial = {
type: 'html-keyboard-response',
stimulus: '<p>To complete the next part of the experiment, please follow <a target="_blank" href="url-to-experiment-here">this link to our consent form.</a></p>',
choices: jsPsych.NO_KEYS
} |
Beta Was this translation helpful? Give feedback.
-
In addition to Josh's answer about showing the link on the page, I thought I'd mention another option, which is to redirect to a specific link at the end of the experiment. To do this, it's useful to have a way of saving your data that includes a callback function, because you'll want to wait until the results have been saved to the server before redirecting to a different site. If we assume that you have a function called var id = "s123"; // this is the participant's ID, which you actually get during the task
var next_task_url = "www.example.com";
// add the participant ID onto the next task link using URL query parameters
// in this case the result will be: "www.example.com?id=s123"
var redirect_url = next_task_url + "?id=" + id;
// function to call after the results have been successfully sent back to the server
// this redirects from the current page to the new task link with the ID on the end
var redirect_fn = function() {
return window.location.replace(redirect_url);
};
jsPsych.init({
timeline: timeline,
on_finish: function() {
var results = jsPsych.data.get().json();
// save the data, then redirect to the next task
saveData(results, redirect_fn);
}
}); |
Beta Was this translation helpful? Give feedback.
I'm not sure about the details of either Pavlovia or Gorilla as hosting environments for an experiment, so I don't know if there are other problems that you will run into besides delivering a link to your participants. But, showing participants a link to click on is certainly possible with the
html-keyboard-response
plugin.If you want to pass along the subject as a variable you can add that info into the URL. You may need to generate the
stimulus
parameter using a…