URL of experiment: Pavlovia
Description of the problem: Right now, the screen is stuck on “initalising the experiment…” and I’m unsure how to fix that.
There are also
/*Syntax Error: Fix Python code */
within “code”, “code_15”, and “code_16” when trying to convert from Python to JavaScript. I’m not very knowledgeable with coding. Any help is appreciated!
code_15
loop_o += 1
if not key_resp_11.keys: #if no entry
continueRoutine = True
msg3 =‘Be faster! \nScore = %.1f%%’ %(number_correct_2100/loop_o) #JS problem
msg3Color = ‘red’
thisExp.addData(“operation_correct”, 0)
repeat_if_wrong_prac.finished = False
else:
if (‘’.join(key_resp_11.keys) == str(Operation_answer)):
number_correct_2 = number_correct_2 + 1
msg3 =‘Correct! \nScore = %.1f%%’ %(number_correct_2 100/loop_o) #JS problem
msg3Color = ‘green’
thisExp.addData(“operation_correct”, 1)
repeat_if_wrong_prac.finished = True
else:
msg3 =‘Oops! That was wrong \nScore = %.1f%%’ %(number_correct_2*100/loop_o) #JS problem
msg3Color = ‘red’
thisExp.addData(“operation_correct”, 0)
repeat_if_wrong_prac.finished = False
code_16
loop_o_2 += 1
if not key_resp_7.keys: #if no entry
continueRoutine = True
msg4 =‘Be faster! \nScore = %.1f%%’ %(number_correct_3100/loop_o_2) #JS problem
msg4Color = ‘red’
thisExp.addData(“operation_correct”, 0)
repeat_if_wrong.finished = False
else:
if (‘’.join(key_resp_7.keys) == str(Operation_answer)):
number_correct_3 = number_correct_3 + 1
msg4 =‘Correct! \nScore = %.1f%%’ %(number_correct_3 100/loop_o_2) #JS problem
msg4Color = ‘green’
thisExp.addData(“operation_correct”, 1)
repeat_if_wrong.finished = True
else:
msg4 =‘Oops! That was wrong \nScore = %.1f%%’ %(number_correct_3*100/loop_o_2) #JS problem
msg4Color = ‘red’
thisExp.addData(“operation_correct”, 0)
repeat_if_wrong.finished = False
code
if trials.thisN == 0:
number_correct = 0
if ((''.join(key_resp.keys)) == str(Operation_answer)):
number_correct = number_correct + 1
curr_pct_corr = (number_correct*100) / (trials.thisN+1)
msg = 'Correct! \nScore = %.1f%%' % curr_pct_corr #doesn't translate to JS
msgColor = 'green'
else:
curr_pct_corr = (number_correct*100) / (trials.thisN+1)
msg = 'Oops! That was wrong \nScore = %.1f%%' % curr_pct_corr #doesn't translate to JS
msgColor = 'red'
Well
Python-code that does not translate to JavaScript properly will result in JavaScript-code that will not run. So you need to make your Python-code JavaScript compatible. Check the crib sheet by @wakecarter .
Many people come to this forum because their experiment works fine locally but doesn’t work online. The reason is that the Python code needs to be translated to Javascript and the auto translate that was added to PsychoPy in January 2020 primarily translates the grammar rather than the individual functions.
If you want to run PsychoPy online I highly recommend that you:
Write your experiment in Builder using version 2023.1.3 (or later).
Study my crib sheet to familiarise yourself with the…
Best wishes Jens
BTW. please surround code with triple `. This result in proper formating.