# Randomization does not work online

**URL:** <https://discourse.psychopy.org/t/randomization-does-not-work-online/16883>\
**Category:** Online experiments\
**Created:** [September 29, 2020, 3:19pm UTC](https://discourse.psychopy.org/t/randomization-does-not-work-online/16883 "2020-09-29T15:19:39Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![JensBoelte](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/jensboelte/32/9060_2.png) [@JensBoelte](https://discourse.psychopy.org/u/JensBoelte)\
**Post date:** [September 29, 2020, 3:19pm UTC](https://discourse.psychopy.org/t/randomization-does-not-work-online/16883/1 "2020-09-29T15:19:39Z")

</div>

URL of experiment: [https://run.pavlovia.org/jens.boelte/ankerexp1/html](https://run.pavlovia.org/jens.boelte/ankerexp1/html)

Description of the problem: The old/new items are not randomized in the requested order. I am trying to program an anchoring-experiment. The old/new items should appear in a pseudo-randomized order. The pseudo-randomization works offline, but not online. Online always the same sequence is being used. I am using this code-element to shuffle the items in the order I want.

 ![grafik](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/5/7/5774c5e5ef8d5255cc273570c700bea76a52f116.png)

Suggestions are heartly welocme.

Cheers Jens

---

<div class="post-metadata">

**Author:** ![thomas\_pronk](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/thomas_pronk/32/9531_2.png) [@thomas\_pronk](https://discourse.psychopy.org/u/thomas_pronk)\
**Post date:** [October 5, 2020, 12:08pm UTC](https://discourse.psychopy.org/t/randomization-does-not-work-online/16883/2 "2020-10-05T12:08:14Z")

</div>

Hi Jens,

I’d like to a look. Could you share the project with me? My Pavlovia username is tpronk

Best, Thomas

---

<div class="post-metadata">

**Author:** ![sotiri](https://avatars.discourse-cdn.com/v4/letter/s/59ef9b/32.png) [@sotiri](https://discourse.psychopy.org/u/sotiri)\
**Post date:** [October 5, 2020, 12:13pm UTC](https://discourse.psychopy.org/t/randomization-does-not-work-online/16883/3 "2020-10-05T12:13:32Z")

</div>

@JensBoelte On it, thanks for flagging, @thomas_pronk don’t worry about it for now, thanks, x

---

<div class="post-metadata">

**Author:** ![JensBoelte](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/jensboelte/32/9060_2.png) [@JensBoelte](https://discourse.psychopy.org/u/JensBoelte)\
**Post date:** [October 5, 2020, 12:49pm UTC](https://discourse.psychopy.org/t/randomization-does-not-work-online/16883/4 "2020-10-05T12:49:50Z")

</div>

Hello,

sorry, I added the wrong url it is not the anchroing experiment but the [ChangeBlindness-Experiment](https://run.pavlovia.org/jens.boelte/changeblindnessexp3/html) and the [FalseFriend-Experiment](https://run.pavlovia.org/jens.boelte/falsememexp2/html). I am preparing too many experiments at the moment. 😉

Cheers Jens

---

<div class="post-metadata">

**Author:** ![JensBoelte](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/jensboelte/32/9060_2.png) [@JensBoelte](https://discourse.psychopy.org/u/JensBoelte)\
**Post date:** [October 5, 2020, 1:57pm UTC](https://discourse.psychopy.org/t/randomization-does-not-work-online/16883/5 "2020-10-05T13:57:16Z")

</div>

@sotiri and @thomas_pronk.

I think that we have identified the problem. If we change the line  
`trialList: TrialHandler.importConditions(psychoJS.serverManager, (AbrufListe + ".xlsx"), index),`  
to  
`trialList: TrialHandler.importConditions(psychoJS.serverManager, (AbrufListe + ".xlsx"), index.toString()),`  
the randomization works.  
At the moment, we do this by hand in the JavaScript code stored online. Suggestions are welcome on how to code this properly in the JavaScript part in Builder. Simply making the index to a string index did not work.

Cheers Jens

---

<div class="post-metadata">

**Author:** ![sotiri](https://avatars.discourse-cdn.com/v4/letter/s/59ef9b/32.png) [@sotiri](https://discourse.psychopy.org/u/sotiri)\
**Post date:** [October 5, 2020, 2:15pm UTC](https://discourse.psychopy.org/t/randomization-does-not-work-online/16883/6 "2020-10-05T14:15:10Z")

</div>

Dear @JensBoelte, alright thanks for the update. Without getting too technical, `TrialHandler.importConditions()` is open to having a selection argument independent of type. Whether you feed in the `index` array as is or converted to a string like you describe should make no difference. I believe there is more to the issue. Please consider my reponse on GitHub for details. Cheers, x

---

<div class="post-metadata">

**Author:** ![JensBoelte](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/jensboelte/32/9060_2.png) [@JensBoelte](https://discourse.psychopy.org/u/JensBoelte)\
**Post date:** [October 5, 2020, 2:26pm UTC](https://discourse.psychopy.org/t/randomization-does-not-work-online/16883/8 "2020-10-05T14:26:45Z")

</div>

Let’s keep the discussion on GitHub.
