LimeSurvey version: 3.24.3
==================
Hi everyone,
I'm a PhD student taking her first steps with LimeSurvey, and am trying to do something that I thought would be very straightforward but after days of looking into it with no answer I am starting to have doubts. I am sorry if some similar question has already been asked on the forum, but I really could not find any satisfying explanation or solution.
My survey consists in successively submitting pairs of images to the user, for them to choose one. The pattern of randomization is complicated to explain (in brief: some images should not end up in the same pair), and is not the point of my question, but after careful consideration, it seems that defining an array at the beginning of the survey storing all possible pairs of pictures and shuffling it would solve the issue. This array would be 2-dimensional and look like this:
Code:
arr = [[img1, img2], [img1, img3], ... , [img1, imgn], ..., [img(n-1), imgn]]
This array would allow me to retrieve valid pairs of images in the subsequent questions where images are submitted to the user.
I had anticipated to do this in the following way:
Code:
<img alt="" src="/upload/surveys/248689/images/{arr[1][1]}.jpg" />
Unfortunately, it does not work: my main hypothesis is that arr was not properly defined.
Here are the steps I followed to define it:
1. I created a question of type Equation. I set it to "Mandatory" and set the option "Always hide this question" to ON. The code of the question is
arr, and its source code is:
Code:
<script type="text/javascript" charset="utf-8">
let arr = [[11, 12], [11, 13]];
</script>
(I willingly defined a very basic array)
This JS code is pretty simple compared to many examples I saw on this forum which use jquery, but I don't think that in my case I need to do more.
2. In some following questions, I tried to import some image using
arr. Here is again some example of source code:
Code:
<img alt="" src="/upload/surveys/248689/images/{arr[1][1]}.jpg" />
Unfortunately no image is displayed.
Could you please help me? I am willing to investigate and understand what could be the issue but I'm lacking knowledge and experience I suppose. And I found nothing in the documentation that could help me solve this issue. Any help would be very much appreciated! And if you need any supplementary information please ask.
Thank you very much for reading and have a nice day/evening,
Best regards
Léa