I have a survey that randomizes the order of two photos within a question using javascript. The photo sources for each question are pulled from a single row in a loop and merge that is randomized. Participants then answer a single multiple choice question about the two photos. Currently, the csv output only gives the participant response to the each question. I would also like it to give the order in which the photos were presented. Any thoughts how to go about this? I've been messing with embedded data with no success. Also looking into SQL
Here is my randomization in JS: (My two photos are after
- in html)
function htmlShuffle(elem) {
function shuffle(arr) {
var len = arr.length;
var d = len;
var array = ];
var k, i;
for (i = 0; i < d; i++) {
k = Math.floor(Math.random() * len);
array.push(arrek]);
arr.splice(k, 1);
len = arr.length;
}
for (i = 0; i < d; i++) {
arri] = arrayi];
}
return arr;
}
var el = document.querySelectorAll(elem + " *");
document.querySelector(elem).innerHTML = "";
let pos = "];
for (let i = 0; i < el.length; i++) {
pos.push(i);
}
pos = shuffle(pos);
for (let i = 0; i < pos.length; i++) {
document.querySelector(elem).appendChild(eloposli]]);
}
}
htmlShuffle("ul");