| Reference | Downloads | Github

Problem with selecting random rows from a condition file

URL of experiment: Maximilian Nentwich / education_movie_01_control · GitLab

Description of the problem: I am designing a task where participants watch a short movie and then answer multiple choice questions. The questions and choices should be presented in random order.

Maybe this is not the most elegant way to set this up but I created a set of excel sheets with randomized order of questions and choices. Then, there is an outer loop that selects one of the files randomly.

This loop is set up in the builder like this:
Screenshot from 2021-08-30 12-26-03
I initially set ‘Selected rows’ to 1, but this will always select the second row. So, I found I can use ‘$random(1)*1000’

However, this will result in this error in the javascript:
Screenshot from 2021-08-30 11-56-37
It seemed to me that it is an error with the datatype in the javascript since 1 in ‘Selected rows’ was there as a string (‘1’). So, I tried making an edit in the javascript: html/education_movie.js · master · Maximilian Nentwich / education_movie_01_control · GitLab

This doesn’t seem to fix the issue:
Screenshot from 2021-08-30 12-21-40

Does anyone have any suggestions. I would appreciate the help.

In fact, changing the datatype works! random(1)*100 has to be Math.round(Math.random(1) * 100).toString() in javascript. By default it is Math.random(1) * 100), which gives the unknown selection type error.

The second error was due the range of the random index. I only had 100 files to choose from, but my index went to 1000.