Replies: 1 comment
-
Hmm, it sounds like you should be able to access your var test_stimuli = [
{
"stimulus": "<p id = 'stroop_stim' style = 'color: red; font-size: 60pt;'>red<\/p>",
"data": {
"word": "red",
"color": "red",
"stim_type": 1
}
},
// ...
]; and your HTML file looks something like this: <!DOCTYPE html>
<html>
<head>
<!-- load jsPsych JavaScript and CSS files -->
<script src="stimulus_sequence.js" type = "text/javascript"></script>
</head>
<body></body>
<script>
var test = {
type: "html-keyboard-response",
response_ends_trial: false,
stimulus: jsPsych.timelineVariable('stimulus'),
data: jsPsych.timelineVariable('data'),
on_finish: function(data){
var correct = false;
if(data.stim_type == 0 && data.key_press == 'a'){
correct = true;
} else if(data.stim_type == 1 && data.key_press != 'a'){
correct = true;
}
data.correct = correct;
},
choices: ['a', '1', '2', '3', '4'],
trial_duration: 900,
post_trial_gap: 600
};
var trial_procedure = {
timeline: [test],
timeline_variables: test_stimuli
};
</script>
</html> Do you see any errors in the browser's JavaScript console? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, I know a similar question has been asked but I couldn't get this to work. I have a javascript file that contains an array with all my stimuli (stimulus_sequence.js). It's a long script so I want to keep it separate from my main script. I'm not sure how to access the stimulus_sequence.js stimuli in the way I would if they were in my main script (which I'm currently doing using jsPsych.timelineVariable('stimulus')). Below is what my main script looks like at the moment. Currently I just have a subset of the stimuli as I am still building the experiment. stimulus_sequence.js contains a variable 'test_stimuli' that looks the same as 'test_stimuli' in my main script, just longer. I have tried loading stimulus_sequence.js at the start of my main script (using <script src="stimulus_sequence.js" type = "text/javascript"></script>) but it seems like I can't access the variable 'test_stimuli' in it. Any help with this would be appreciated. Thanks!
Beta Was this translation helpful? Give feedback.
All reactions