mirror of
https://github.com/jspsych/jsPsych.git
synced 2025-05-10 11:10:54 +00:00
Demo flanker working ++ updates to keyboard-response simulate methods ++ added remove_post_trial_gap to simluate_opts
This commit is contained in:
parent
8dc1959d13
commit
3dbcd94ef0
@ -111,6 +111,13 @@
|
||||
timeline: timeline,
|
||||
on_finish: function() {
|
||||
jsPsych.data.displayData();
|
||||
},
|
||||
simulate: true,
|
||||
// will need to handle what happens when only partially defined
|
||||
simulate_opts: {
|
||||
'trial_duration': 25,
|
||||
'response_ends_trial': true,
|
||||
'remove_post_trial_gap': true
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
@ -104,7 +104,8 @@ window.jsPsych = (function() {
|
||||
'simulate': false,
|
||||
'simulate_opts': {
|
||||
'trial_duration': 500,
|
||||
'response_ends_trial': true
|
||||
'response_ends_trial': true,
|
||||
'remove_post_trial_gap': true
|
||||
}
|
||||
};
|
||||
|
||||
@ -1031,6 +1032,9 @@ window.jsPsych = (function() {
|
||||
if (trial.response_ends_trial !== true) {
|
||||
trial.response_ends_trial = true
|
||||
}
|
||||
if (curr_trial_opts.remove_post_trial_gap === true) {
|
||||
trial.post_trial_gap = 0
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -147,7 +147,13 @@ jsPsych.plugins["html-keyboard-response"] = (function() {
|
||||
|
||||
plugin.simulate = function(trial, simulate_opts) {
|
||||
if(trial.choices !== jsPsych.NO_KEYS) {
|
||||
var key_response = jsPsych.randomization.sampleWithoutReplacement(trial.choices, 1)[0];
|
||||
let valid_keys
|
||||
if (trial.choices === jsPsych.ALL_KEYS) {
|
||||
valid_keys = ['enter', 'space', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
|
||||
} else {
|
||||
valid_keys = trial.choices
|
||||
}
|
||||
var key_response = jsPsych.randomization.sampleWithoutReplacement(valid_keys, 1)[0];
|
||||
setTimeout(function(){
|
||||
document.querySelector('.jspsych-display-element').dispatchEvent(new KeyboardEvent('keydown', {key: key_response}));
|
||||
document.querySelector('.jspsych-display-element').dispatchEvent(new KeyboardEvent('keyup', {key: key_response}));
|
||||
|
@ -260,9 +260,14 @@ jsPsych.plugins["image-keyboard-response"] = (function() {
|
||||
};
|
||||
|
||||
plugin.simulate = function(trial, simulate_opts) {
|
||||
console.log('vleze')
|
||||
if(trial.choices !== jsPsych.NO_KEYS) {
|
||||
var key_response = jsPsych.randomization.sampleWithoutReplacement(trial.choices, 1)[0];
|
||||
let valid_keys
|
||||
if (trial.choices === jsPsych.ALL_KEYS) {
|
||||
valid_keys = ['enter', 'space', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
|
||||
} else {
|
||||
valid_keys = trial.choices
|
||||
}
|
||||
var key_response = jsPsych.randomization.sampleWithoutReplacement(valid_keys, 1)[0];
|
||||
setTimeout(function(){
|
||||
document.querySelector('.jspsych-display-element').dispatchEvent(new KeyboardEvent('keydown', {key: key_response}));
|
||||
document.querySelector('.jspsych-display-element').dispatchEvent(new KeyboardEvent('keyup', {key: key_response}));
|
||||
|
Loading…
Reference in New Issue
Block a user