Editing the timeline during runtime? #3220
Unanswered
Rleonard02
asked this question in
Q&A
Replies: 1 comment 2 replies
-
You are going about things the wrong way. Instead of changing an entire node on the timeline, you can simply change what content the node is to display. You can use dynamic parameters for that. For example: let jspsych = initJsPsych();
let trial_1 = {
type: jsPsychHtmlKeyboardResponse,
stimulus: 'Hello world',
choices: ['f', 'j'],
};
let trial_2 = {
type: jsPsychHtmlKeyboardResponse,
// Dynamic parameter: a function that returns the parameter; evaluates when the trial is run instead of at the start
stimulus: function () {
let response = jspsych.data.getLastTrialData().values()[0].response;
return `Participant response was ${response}`;
},
}
jspsych.run([trial_1, trial_2]); You can modify what to display on the screen based on the data from the previous trial. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm a little new to JsPsych so apologies if this seems like an obvious question.
I'm currently trying to edit an experiment that displays a cue and response box for the user to type the target value. For each cue there are two target words associated with it. If the user types a response that matches target1 I want to display a new trial screen that simply shows the cue -- target2 pairing, and vice versa.
I'm struggling to figure out how to edit the timeline during runtime, since from my understanding, the timeline is loaded at runtime and I've found one function: addNodeToEndOfTimeline() which is close but not what I want.
I want to be able to add the node directly after the node that's currently appearing in the timeline. I've attached the js file I've been working in, the lines of interest are 174-280. Help with this is much appreciated.
experiment.txt
Beta Was this translation helpful? Give feedback.
All reactions