Skip to content

Commit

Permalink
BF: Before Experiment was not being written for JS (fixes #3115)
Browse files Browse the repository at this point in the history
  • Loading branch information
Todd authored and peircej committed Sep 4, 2020
1 parent 0650307 commit bbfd310
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions psychopy/experiment/_experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,8 @@ def writeScript(self, expPath=None, target="PsychoPy", modular=True):
self_copy._currentRoutine = entry
if hasattr(entry, 'writeInitCodeJS'):
entry.writeInitCodeJS(script)
if hasattr(entry, 'writePreCodeJS'):
entry.writePreCode(script)

This comment has been minimized.

Copy link
@peircej

peircej Sep 6, 2020

Member

Surely this should be writePreCodeJS?

This comment has been minimized.

Copy link
@kjj11033

kjj11033 Sep 12, 2020

I tested whether inserting code in the Before Experiment tab is applied to the JS code
(using 2020.2.4 version, which includes this corrected code)
However, code in the Before experiment did not appeared in the JS code, I could not find out why.
(I also checked whether above writherPreCodeJS correction is included in the _experiment.py)

Thanks!


# create globalClock etc
code = ("// Create some handy timers\n"
Expand Down
5 changes: 5 additions & 0 deletions psychopy/experiment/components/code/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,11 @@ def writePreCode(self, buff):
alerttools.checkPythonSyntax(self, 'Before Experiment')
buff.writeIndentedLines(str(self.params['Before Experiment']) + '\n')

def writePreCodeJS(self, buff):
if len(str(self.params['Before JS Experiment'])):
alerttools.checkPythonSyntax(self, 'Before Experiment')
buff.writeIndentedLines(str(self.params['Before JS Experiment']) + '\n')

def writeInitCode(self, buff):
if len(str(self.params['Begin Experiment'])):
alerttools.checkPythonSyntax(self, 'Begin Experiment')
Expand Down

0 comments on commit bbfd310

Please sign in to comment.