Description of the problem:
An experiment I’m building involves rating stimuli in a loop along two dimensions of emotion (valence and arousal) using two sliders appearing side by side. I want participants to press ‘enter’ after they input their responses along both sliders to complete a trial. The following condition statement works in Psychopy for a keyboard response component to become active:
Start condition: $valenceRatingScale.rating and arousalRatingScale.rating
However, the Pavlovia experiment page won’t load the experiment with this code. Is there an alternative way to do this? I’m not very familiar with Python or Javascript so I am pasting the routine’s code below.
This start condition for the keyboard component throws the following two error messages:
ERROR Line 399: Unexpected identifier in newExperiment.js
ERROR Line 392: Unexpected identifier in newExperiment-legacy-browsers.js
Many thanks in advance!
# -------Run Routine "test"-------
while continueRoutine:
# get current time
t = testClock.getTime()
tThisFlip = win.getFutureFlipTime(clock=testClock)
tThisFlipGlobal = win.getFutureFlipTime(clock=None)
frameN = frameN + 1 # number of completed frames (so 0 is the first frame)
# update/draw components on each frame
# *valenceRatingScale* updates
if valenceRatingScale.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance:
# keep track of start time/frame for later
valenceRatingScale.frameNStart = frameN # exact frame index
valenceRatingScale.tStart = t # local t and not account for scr refresh
valenceRatingScale.tStartRefresh = tThisFlipGlobal # on global time
win.timeOnFlip(valenceRatingScale, 'tStartRefresh') # time at next scr refresh
valenceRatingScale.setAutoDraw(True)
# *arousalRatingScale* updates
if arousalRatingScale.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance:
# keep track of start time/frame for later
arousalRatingScale.frameNStart = frameN # exact frame index
arousalRatingScale.tStart = t # local t and not account for scr refresh
arousalRatingScale.tStartRefresh = tThisFlipGlobal # on global time
win.timeOnFlip(arousalRatingScale, 'tStartRefresh') # time at next scr refresh
arousalRatingScale.setAutoDraw(True)
# *continuneText* updates
if continuneText.status == NOT_STARTED and valenceRatingScale.rating and arousalRatingScale.rating:
# keep track of start time/frame for later
continuneText.frameNStart = frameN # exact frame index
continuneText.tStart = t # local t and not account for scr refresh
continuneText.tStartRefresh = tThisFlipGlobal # on global time
win.timeOnFlip(continuneText, 'tStartRefresh') # time at next scr refresh
continuneText.setAutoDraw(True)
# *key_resp_10* updates
waitOnFlip = False
if key_resp_10.status == NOT_STARTED and valenceRatingScale.rating and arousalRatingScale.rating:
# keep track of start time/frame for later
key_resp_10.frameNStart = frameN # exact frame index
key_resp_10.tStart = t # local t and not account for scr refresh
key_resp_10.tStartRefresh = tThisFlipGlobal # on global time
win.timeOnFlip(key_resp_10, 'tStartRefresh') # time at next scr refresh
key_resp_10.status = STARTED
# keyboard checking is just starting
waitOnFlip = True
win.callOnFlip(key_resp_10.clock.reset) # t=0 on next screen flip
win.callOnFlip(key_resp_10.clearEvents, eventType='keyboard') # clear events on next screen flip
if key_resp_10.status == STARTED and not waitOnFlip:
theseKeys = key_resp_10.getKeys(keyList=['return'], waitRelease=False)
_key_resp_10_allKeys.extend(theseKeys)
if len(_key_resp_10_allKeys):
key_resp_10.keys = _key_resp_10_allKeys[-1].name # just the last key pressed
key_resp_10.rt = _key_resp_10_allKeys[-1].rt
# a response ends the routine
continueRoutine = False
# check for quit (typically the Esc key)
if endExpNow or defaultKeyboard.getKeys(keyList=["escape"]):
core.quit()
# check if all components have finished
if not continueRoutine: # a component has requested a forced-end of Routine
break
continueRoutine = False # will revert to True if at least one component still running
for thisComponent in testComponents:
if hasattr(thisComponent, "status") and thisComponent.status != FINISHED:
continueRoutine = True
break # at least one component has not yet finished
# refresh the screen
if continueRoutine: # don't flip if this routine is over or we'll get a blank screen
win.flip()
# -------Ending Routine "test"-------
for thisComponent in testComponents:
if hasattr(thisComponent, "setAutoDraw"):
thisComponent.setAutoDraw(False)
thisExp.addData('valenceRatingScale.response', valenceRatingScale.getRating())
thisExp.addData('valenceRatingScale.rt', valenceRatingScale.getRT())
thisExp.addData('valenceRatingScale.started', valenceRatingScale.tStartRefresh)
thisExp.addData('valenceRatingScale.stopped', valenceRatingScale.tStopRefresh)
thisExp.addData('arousalRatingScale.response', arousalRatingScale.getRating())
thisExp.addData('arousalRatingScale.rt', arousalRatingScale.getRT())
thisExp.addData('arousalRatingScale.started', arousalRatingScale.tStartRefresh)
thisExp.addData('arousalRatingScale.stopped', arousalRatingScale.tStopRefresh)
thisExp.addData('continuneText.started', continuneText.tStartRefresh)
thisExp.addData('continuneText.stopped', continuneText.tStopRefresh)
# check responses