mirror of
https://github.com/jspsych/jsPsych.git
synced 2025-05-10 19:20:55 +00:00
fixes double call of function as parameter (#158)
fixed by changing the evaluate parameters function to modify the trial object directly, so the function is replaced by its value.
This commit is contained in:
parent
ed4b2ba99c
commit
dba6c4befc
18
jspsych.js
18
jspsych.js
@ -145,11 +145,8 @@
|
|||||||
// handle callback at whole-experiment level
|
// handle callback at whole-experiment level
|
||||||
opts.on_trial_finish();
|
opts.on_trial_finish();
|
||||||
|
|
||||||
// if timing_post_trial is a function, evaluate it
|
if(current_trial.timing_post_trial > 0){
|
||||||
var time_gap = (typeof current_trial.timing_post_trial == 'function') ? current_trial.timing_post_trial() : current_trial.timing_post_trial;
|
setTimeout(next_trial, current_trial.timing_post_trial);
|
||||||
|
|
||||||
if(time_gap > 0){
|
|
||||||
setTimeout(next_trial, time_gap);
|
|
||||||
} else {
|
} else {
|
||||||
next_trial();
|
next_trial();
|
||||||
}
|
}
|
||||||
@ -616,7 +613,7 @@
|
|||||||
var progress = jsPsych.progress();
|
var progress = jsPsych.progress();
|
||||||
var trial = jsPsych.currentTrial();
|
var trial = jsPsych.currentTrial();
|
||||||
|
|
||||||
var trial_opt_data = typeof trial.data == 'function' ? trial.data() : trial.data;
|
//var trial_opt_data = typeof trial.data == 'function' ? trial.data() : trial.data;
|
||||||
|
|
||||||
var default_data = {
|
var default_data = {
|
||||||
'trial_type': trial.type,
|
'trial_type': trial.type,
|
||||||
@ -626,7 +623,7 @@
|
|||||||
'internal_chunk_id': jsPsych.currentChunkID()
|
'internal_chunk_id': jsPsych.currentChunkID()
|
||||||
};
|
};
|
||||||
|
|
||||||
var ext_data_object = $.extend({}, data_object, trial_opt_data, default_data, dataProperties);
|
var ext_data_object = $.extend({}, data_object, trial.data, default_data, dataProperties);
|
||||||
|
|
||||||
allData.push(ext_data_object);
|
allData.push(ext_data_object);
|
||||||
|
|
||||||
@ -1366,7 +1363,6 @@
|
|||||||
|
|
||||||
var keys = getKeys(trial);
|
var keys = getKeys(trial);
|
||||||
|
|
||||||
var tmp = {};
|
|
||||||
for (var i = 0; i < keys.length; i++) {
|
for (var i = 0; i < keys.length; i++) {
|
||||||
|
|
||||||
var process = true;
|
var process = true;
|
||||||
@ -1378,14 +1374,12 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (typeof trial[keys[i]] == "function" && process) {
|
if (typeof trial[keys[i]] == "function" && process) {
|
||||||
tmp[keys[i]] = trial[keys[i]].call();
|
trial[keys[i]] = trial[keys[i]].call();
|
||||||
} else {
|
|
||||||
tmp[keys[i]] = trial[keys[i]];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return tmp;
|
return trial;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
choices: [89,78], // Y or N
|
choices: [89,78], // Y or N
|
||||||
prompt: '<p class="center-content">Have you seen this face before? Y or N.</p>',
|
prompt: '<p class="center-content">Have you seen this face before? Y or N.</p>',
|
||||||
data: {trial_data: true},
|
data: {trial_data: true},
|
||||||
timing_post_trial: function() { return Math.floor(Math.random()*10000 + 250) }
|
timing_post_trial: function() { return Math.floor(Math.random()*1000 + 250) }
|
||||||
}
|
}
|
||||||
|
|
||||||
function start(){
|
function start(){
|
||||||
|
Loading…
Reference in New Issue
Block a user