I've just started implementing a rating task using jspsych, and I'm really happy with this library. However, I'm a bit stuck at the moment (sorry, I'm not really an experienced programer, and I haven't really worked with javascript before).
My experiment consists of videos that participants rate on a likert scale. One video is presented per page, randomly chosen from a set of videos (all of which have to be shown during the experiement. This is what I did:
var random_video = jsPsych.randomization.sample(sign_pool, sign_pool.length, false);
for(var i = 0; i < random_video.length; i++) {
var selected_video = random_video[i]
var rating_trial = {
type: 'survey-likert',
preamble: ['<video width="480" controls autoplay loop src="videos/'+selected_video+'.mov"></video>'],
questions: [[""]],
labels: [[scale_valence]],
intervals: [[7]],
data: [{video: selected_video}]
}
experiment.push(rating_trial);
};
This works great so far. However, there are 400 videos to be rated, so I would like to build in a break after every 50 rating trials. So the structure of the experiment would be 50 rating trials, break, another 50 trials, break... until all the videos have been shown. I suppose I need to use chunks to create is and while loops, but I'm not sure how to go about it.
And an unrelated query: I would like to add a little form at the beginning to add participant information (which would then be saved with their answer). Could I do this with the single stim plugin (create a form and use the entered information)? Or would it be more complicated than that?
Thank you in advance.
Best,
Anna
Just to say that I solved the problem of adding in breaks between rating trials. I created a linear chunk of a rating trial and a "pause" trial and added an if/else statement which calls the chunk with the break at every n-th trial.
Here is the code:
var random_video = jsPsych.randomization.sample(video_pool, video_pool.length, false);
for(var i = 0; i < random_video.length; i++) { // looping through the randomized list of videos
var selected_video = random_video[i]
var rating_trial = { // a simple rating trial: video + rating scale
type: 'survey-likert',
preamble: ['<video width="960" controls autoplay loop src="videos/'+selected_video+'"></video>'],
questions: [[""]],
labels: [[scale_valence]],
intervals: [[7]],
data: [{video: selected_video}]
}
var rating_pause = { // Break: displays an image. Pressing any key will continue the experiment.
type: 'single-stim',
stimuli: ['img/break.jpg']
}
var trial_pause_chunk = { // chunk consisting of a rating trial and a break trial, called when the n-th video is reached
chunk_type: 'linear',
timeline: [rating_trial, rating_pause]
}
// adding in the breaks
var N_videos = 50 // number of videos after which there is a pause
if (i % N_videos == 0 && i != 0 && i != random_video.length-1) {
experiment.push(trial_pause_chunk);
} else {
experiment.push(rating_trial);
}
};
The way the if statement works means that the first break comes after n+1 videos, and every n-th video thereafter (except the final one). This is fine for me.
Best,
Anna
--
You received this message because you are subscribed to the Google Groups "jsPsych" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jspsych+u...@googlegroups.com.
To post to this group, send email to jsp...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jspsych/ab5b899f-f290-4155-9c08-3782625992ac%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.