Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Qualtrics.SurveyEngine.addOnload(function() {
- var questions = $('Questions');
- var qs = questions.select('div.QuestionOuter');
- var qarr1 = [];
- var qarr2 = [];
- for(var i=0; i<qs.length; i++) {
- qarr1.push(qs[i].id);
- qarr2[qs[i].id] = qs[i+1].id;
- i++;
- }
- shuffle(qarr1);
- var separators = questions.select('div.Separator');
- var j=0;
- for(i=0; i<qarr1.length; i++) {
- questions.insert({bottom: $(qarr1[i])});
- questions.insert({bottom: separators[j]});
- j++;
- questions.insert({bottom: $(qarr2[qarr1[i]])});
- if(j < (separators.length - 1)) {
- questions.insert({bottom: separators[j]});
- j++;
- }
- }
- function shuffle(array) {
- var currentIndex = array.length, temporaryValue, randomIndex ;
- while (0 !== currentIndex) {
- randomIndex = Math.floor(Math.random() * currentIndex);
- currentIndex -= 1;
- temporaryValue = array[currentIndex];
- array[currentIndex] = array[randomIndex];
- array[randomIndex] = temporaryValue;
- }
- return array;
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement