@wakecarter the document that you provided is amazingly informative! Thank you so much.
I edited the code a little bit already by using it (i.e., I moved the continueRoutine = False code from Begin Routine to Each Frame).
With defining event in code_JS helped the experiment work online however, I have one following question.
I want to;
- skip next trial when the correct response is given.
- give an ‘X’ feedback when the incorrect response is given and skip next trial after 1 second.
- if there is no response at all. ‘Please respond’ message needs to be presented and participants need to press space in order to continue the experiment.
For now, I managed to do first continuing when the response is correct but 2nd and 3rd steps I couldn’t.
When I respond correctly it jumps to the next trial without a problem. However, when I respond incorrectly the trial (i.e., word) disappears but I dont get the feedback message ‘X’ and I need to press ‘space’ to continue (which I want to skip to the next trial after 1 second). Also, If I don’t respond after 2 second trial disappears without displaying ‘please respond message’ and requires space key press (which I want in this case).
I will share the PY and JS code. I would be really grateful if you can help me to realize where I did a mistake to I need to edit.
#There are two routines. First is called trial and the other one is feedback. This is the Py code (in Each Frame) in trial
keys = event.getKeys()
if keys:
if 't' in keys and keys == corrAns:
continueRoutine=False
elif 't' in keys and keys != corrAns:
msg='X'
elif 'v' in keys and keys == corrAns:
continueRoutine=False
elif 'v' in keys and keys != corrAns:
msg='X'
elif not keys:
msg='You need to give faster responses. Please press space to continue'
//JS code in Each Frame in trial
var _pj;
var msg;
var keys;
event=psychoJS.eventManager
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 (keys) {
if ((_pj.in_es6("t", keys) && (keys === corrAns))) {
continueRoutine = false;
} else {
if ((_pj.in_es6("t", keys) && (keys !== corrAns))) {
msg = "X";
} else {
if ((_pj.in_es6("v", keys) && (keys === corrAns))) {
continueRoutine = false;
} else {
if ((_pj.in_es6("v", keys) && (keys !== corrAns))) {
msg = "X";
}
}
}
}
} else {
if ((! keys)) {
msg = "You need to give faster responses. Please press space to continue";
}
}
#Py code (in Each Frame) in feedback routine
keys = event.getKeys()
if resp.corr:
continueRoutine = False
# if the response was wrong, then end if a key is
# pushed, or regardless at 3 s:
elif msg == 'X':
if t >= 1.0:
continueRoutine = False
else: # was no response, so wait indefinitely until a key is pushed
if keys and 'space' in keys:
continueRoutine = False
// JS code in Feedback routine
var _pj;
var msg;
var keys;
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 (resp.corr) {
continueRoutine = false;
} else {
if ((msg === "X")) {
if ((t >= 1.0)) {
continueRoutine = false;
}
} else {
if ((keys && _pj.in_es6("space", keys))) {
continueRoutine = false;
}
}
}
I know that the message has been quiet long, excuse me for this.
Thank you in advance!
Emre