# Trouble moving experiment to Pavlovia

**URL:** <https://discourse.psychopy.org/t/trouble-moving-experiment-to-pavlovia/14177>\
**Category:** Online experiments\
**Tags:** randomization, pavlovia\
**Created:** [June 11, 2020, 3:35pm UTC](https://discourse.psychopy.org/t/trouble-moving-experiment-to-pavlovia/14177 "2020-06-11T15:35:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![bbrashea](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/bbrashea/32/8977_2.png) [@bbrashea](https://discourse.psychopy.org/u/bbrashea)\
**Post date:** [June 11, 2020, 3:35pm UTC](https://discourse.psychopy.org/t/trouble-moving-experiment-to-pavlovia/14177/1 "2020-06-11T15:35:32Z")

</div>

URL of experiment: [Pavlovia](https://pavlovia.org/bbrashea/feature-verbalizablity)

Description of the problem: This is my first time trying to export a PsychoPy experiment to Pavlovia. The experiment works fine from the PsychoPy console, but when I try to run it online, it is stuck on the initialization screen.

I know randomization is an issue when generating the JS files, so I wrote an admittedly clunky randomizer for the JS version:

> ThisStim = Math.floor(Math.random() \* 2);  
> if ((ThisStim === 0)) {  
> StimSet = “train/train\_stimfile\_VB\_1.xlsx”;  
> } else if ((ThisStim === 1)) {  
> StimSet = “train/train\_stimfile\_NV\_1.xlsx”;  
> } else if ((ThisStim === 2)) {  
> StimSet = “train/train\_stimfile\_VB\_2.xlsx”;  
> } else if ((ThisStim === 3)) {  
> StimSet = “train/train\_stimfile\_NV\_2.xlsx”;  
> } else if ((ThisStim === 4)) {  
> StimSet = “train/train\_stimfile\_VB\_3.xlsx”;  
> } else if ((ThisStim === 5)) {  
> StimSet = “train/train\_stimfile\_NV\_3.xlsx”;  
> } else if ((ThisStim === 6)) {  
> StimSet = “train/train\_stimfile\_VB\_4.xlsx”;  
> } else if ((ThisStim === 7)) {  
> StimSet = “train/train\_stimfile\_NV\_4.xlsx”;  
> } else if ((ThisStim === 8)) {  
> StimSet = “train/train\_stimfile\_VB\_5.xlsx”;  
> } else if ((ThisStim === 9)) {  
> StimSet = “train/train\_stimfile\_NV\_5.xlsx”;  
> }  
> }  
> StimSet = infile;  
> psychoJS.experiment.addData(“StimSet”, StimSet);

However, either this fix didn’t work or there is another issue with the JS file that’s preventing the experiment from running. I don’t have much experience working with JS, so I’m not really sure what other issues could be causing this.

---

<div class="post-metadata">

**Author:** ![aisa2](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/aisa2/32/8666_2.png) [@aisa2](https://discourse.psychopy.org/u/aisa2)\
**Post date:** [June 11, 2020, 3:47pm UTC](https://discourse.psychopy.org/t/trouble-moving-experiment-to-pavlovia/14177/2 "2020-06-11T15:47:13Z")

</div>

The crib sheet might be a good place to start:

> **[PsychoPy Python to Javascript crib sheet](https://docs.google.com/document/d/13jp0QAqQeFlYSjeZS0fDInvgaDzBXjGQNe4VNKbbNHQ/edit#)**
>
> PsychoPy version 2020.1.3Python to JavaScript Crib Sheet Compiled by Wakefield Morys-Carter, Oxford Brookes UniversityPlease retweet Psych\_Stats. PsychoPy 2020 has an automatic Python to Javascript translation tool. This document contains...

You can also see any errors produced by using debugger tools in the console (google “web developer tools” for your browser). That might give you better information about the errors + tracebacks to what line of code is producing them.

---

<div class="post-metadata">

**Author:** ![wakecarter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/wakecarter/32/5753_2.png) [@wakecarter](https://discourse.psychopy.org/u/wakecarter)\
**Post date:** [June 11, 2020, 4:03pm UTC](https://discourse.psychopy.org/t/trouble-moving-experiment-to-pavlovia/14177/3 "2020-06-11T16:03:08Z")

</div>

The first line of int\_code in your int routine is an import which will cause a crash. Please look at my crib sheet for how to deal with randomisation.
