24-S1-2-C-Moral-Decisions / LandingSite

This is an archive of all the files used in the project.
0 stars 0 forks source link

Implement a redirect to a specific page using jsPsych #9

Open Eddyhzz opened 5 months ago

Eddyhzz commented 5 months ago

Describe the bug When attempting to implement a redirect to a specific page using jsPsych, the expected behavior is not observed.

To Reproduce Steps to reproduce the behavior:

  1. Initialize jsPsych and set up the experiment.
  2. Include code to redirect to a specific page using jsPsych.
  3. Execute the experiment.
  4. The redirect to the specified page does not occur as intended.

Expected behavior Upon reaching the designated point in the experiment, the participant should be redirected to the specified page seamlessly.

Additional context The experiment setup includes various trials and tasks using jsPsych. The redirect functionality is crucial for navigating participants to the next phase or providing supplementary information.

Eddyhzz commented 5 months ago

Solution: To display specific slides in jsPsych, you can use the jsPsych.init() function to initialize your experiment and define your slides in the timeline parameter. Then, you can use the jsPsych.startExperiment() function to start your experiment and specify the slides to be displayed according to your needs.

var myTimeline = [
  {
    type: 'display-slide', // here are the parameters for the slideshow
    // This is where the slideshow's parameters are set.
    // ...
  }, {
  {
    type: 'display-slide', // Here are the parameters for the slide // ... }, { type: 'display-slide', // Here are the parameters for the slide
    // Here are the parameters for the slideshow.
    // ...
  }, { type: 'display-slide', // Here are the slideshow parameters // ...
  // Add more slides...
];

// Initialize the experiment
jsPsych.init({
  timeline: myTimeline, // initialize the experiment...
  // Other initialization options...
});

// Specify the index of the slide to be shown here
var slideIndexToShow = 1; // For example, show the second slide

// Start the experiment and show the specified slide
jsPsych.startExperiment({
  timeline: myTimeline.slice(slideIndexToShow), // other options...
  // Other options...
});