Replies: 2 comments
-
I have done something similar to this (though the main difference is that I also get participants to respond twice). In my experiment, I ended up using two timeline variables (one for the first response and one for the second response). So I guess that in your experiment, you coudl do something similar (have more than one timeline variable) where you set a time limit on the first timeline object and if the second is needed you can display it and add the two RTs together to get a total RT. I'm not sure if there is an easier way to do this unless you write your own plugin. Hope this helps, Cai |
Beta Was this translation helpful? Give feedback.
-
Hi @rMinion, the reason it doesn't work to put the line that changes the trial display inside of a script tag is because that code will run as soon as the page (experiment) first loads, whereas you need it to run during the appropriate trial. In addition to @cslongman's great suggestion for setting this up as multiple trials to achieve the dipslay change, I thought I'd mention a few other options. One option is to add some code to the trial's // set up a function to get a random integer within a range of values
function randomNumberInRange(min, max) {
return Math.round(Math.random() * (max - min) + min);
}
var trial = {
// ... trial parameters ...
on_load: function() {
// get a random duration, in milliseconds, between 6 and 120 seconds
var rand_duration = randomNumberInRange(6000, 120000);
// set up a timer to change the display after this duration
jsPsych.pluginAPI.setTimeout(function() {
document.getElementById("myID").innerHTML = '';
}, rand_duration);
},
on_finish: function(data) {
jsPsych.pluginAPI.clearAllTimeouts();
}
}; Another option is to modify the plugin, by adding the same lines of code as in the I hope this helps. Let us know if any of these solutions work for you, and if you need further guidance. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi Guys,
I have a conceptual problem. I want to update the stimulus without finishing the current trial. I have a set of trials that can be ended only by participant response (html-keyboard-response plugin).
Periodically, in the random time interval (6-120s.) I want to change some particular element displayed on the screen without finishing the current trial.
How can I achieve this?
I tried
document.getElementById("myID").innerHTML =
`` within script tag but i get NULL. I think that it is connected to webpage elements loading order.I don't want to use
on_start
oron_finish
within the trial mainly because it will not trigger the change of HTML when participants do not respond, and this is something that I want to avoid.Beta Was this translation helpful? Give feedback.
All reactions