Randomize a list of questions in three rounds #1182
-
|
Hi, I need to design a three-round experiment: Thank you!! question.txt |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
Hi @xliu382, sorry for the delay. Your approach of sampling from the Here's one approach that might work: // array with all 60 questions
var all_questions = [
{data: { i: 1 }, q: 'Q1'},
{data: { i: 2 }, q: 'Q2'},
{data: { i: 3 }, q: 'Q3'},
{data: { i: 4 }, q: 'Q4'},
{data: { i: 5 }, q: 'Q5'},
{data: { i: 6 }, q: 'Q6'},
// ...
{data: { i: 60 }, q: 'Q60'},
];
// randomize the array
var all_questions_random = jsPsych.randomization.shuffle(all_questions);
// use the first 40 questions in the randomized array for rounds 1 and 3
// get the first 40 items using the .slice function: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice
var round_1_questions = all_questions_random.slice(0,39);
// use the last 20 questions in the randomized array for round 2
var round_2_questions = all_questions_random.slice(39);
var round1_trial = {
timeline_variables: round_1_questions
// other trial procedure parameters...
};
var round2_trial = {
timeline_variables: round_2_questions
// other trial procedure parameters...
};
var round3_trial = {
timeline_variables: round_1_questions
// other trial procedure parameters...
}; |
Beta Was this translation helpful? Give feedback.
Hi @xliu382, sorry for the delay. Your approach of sampling from the
timeline_variablesarray using thesampleparameter makes sense for situations when you only need to do the sampling once, without re-using the same items. But in your case I would instead do the random sampling outside of the trial procedure, using jsPsych's randomization functions, so that you can store the randomly-selected items and re-use them later.Here's one approach that might work: