OS (e.g. Win10): Win10
PsychoPy version (e.g. 1.84.x): 2020.2.10
I currently use the following piece of code to make sure participants first give an answer on a slider and press spacebar before they can continue. I want to add a time element to that as well.
I tried the following but it does not seem to work online.
#in python begin routine:
timer = core.CountdownTimer(3)
#in javascript begin routine:
timer =new.code.CountdownTimer(3);
and
# in python each frame:
keys = event.getKeys()
if slider_predicts1f.getRating() is not None and 'space' in keys and timer.getTime()<0:
continueRoutine=False
# in javascript each frame:
var _pj;
function _pj_snippets(container) {
function in_es6(left, right) {
if (((right instanceof Array) || ((typeof right) === "string"))) {
return (right.indexOf(left) > (- 1));
} else {
if (((right instanceof Map) || (right instanceof Set) || (right instanceof WeakMap) || (right instanceof WeakSet))) {
return right.has(left);
} else {
return (left in right);
}
}
}
container["in_es6"] = in_es6;
return container;
}
_pj = {};
_pj_snippets(_pj);
keys = event.getKeys();
if ((((slider_predicts1f.getRating() !== undefined) && _pj.in_es6("space", keys)) && (timer.getTime() > 0))) {
continueRoutine = false;
}
It gives me the error:
- TypeError: core.CountdownTimer is not a constructor
I would greatly appreciate any help with adding the 3 second ‘wait’ period before participants can continue (in addition to the spacebar and slider).