Obtaining the question code of the preceding question when randomization occurs

More
2 weeks 10 hours ago #206786 by midnightking
Hello, I was wondering if there was any way to obtain the code of a question (in a randomization group).

I have 2 types in my group. One of them (1) presents a financial offer that the participants must decline or accept the other (2) asks the participants how satisfied they are.

I put 1 in a randomization group named offers and it is always followed directly by 2.I would like to have a way to make sure I know which offer preceded the offer satisfaction question.

File Attachment:

File Name: limesurvey..._329.lsg
File Size:58 KB
Attachments:

Please Log in to join the conversation.

More
2 weeks 8 hours ago #206788 by Joffm
This way it won't work.
You try to have a randomization group on the first picture and another one on the second picture with the offer and the satisfaction without.

Either you redesign everything-
without all of your randomization groups.
You may use two hidden questions (QH1 and QH2) of type short text, where you create two random strings.
<script type="text/javascript" charset="utf-8">
 
function shuffle(array) {
  var currentIndex = array.length, temporaryValue, randomIndex;
 
  // While there remain elements to shuffle...
  while (0 !== currentIndex) {
 
    // Pick a remaining element...
    randomIndex = Math.floor(Math.random() * currentIndex);
    currentIndex -= 1;
 
    // And swap it with the current element.
    temporaryValue = array[currentIndex];
    array[currentIndex] = array[randomIndex];
    array[randomIndex] = temporaryValue;
  }
 
  return array;
}
 
 
	$(document).on('ready pjax:scriptcomplete',function(){
// Fill the array, here 20 letters
      var arr = ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T"];
      arr = shuffle(arr);
// Slice: take the first 10      
      anumbers = arr.slice(0,10).join('');
      $('#question{QID} input[type="text"]').val(anumbers);
      $('#question{QID}').hide();
   });
</script>

Now you have two strings like
GAHKDC...
LFACENP...

in your first proposer questions you may display the image that corresponds to the first letter of the string
in your second proposer questions you may display the image that corresponds to the second letter of the string
in your third proposer questions you may display the image that corresponds to the third letter of the string
...
the same in your offer questions
here you use the second string.

Best to rename the images to "proposeA.jpg", "proposeB.jpg",...
and "offerA.jpg", "offerB.jpg"

You display the first image by <img alt="" src="/limesurvey/upload/surveys/123456/images/offer{substr(QH1,0,1)}.JPG" />
You display the second image by <img alt="" src="/limesurvey/upload/surveys/123456/images/offer{substr(QH1,1,1)}.JPG" />
Remember: the first index of "substr" is 0.

And as you have your strings saved you know exactly which combination was displayed first, second, and so on.


Or - in my opinion - better, shorter - you use the solution you have in your prototype questions.
But I do not know why you changed the javascript in "prototype3" to "prototype5"

Joffm


Volunteers are not paid.
Not because they are worthless, but because they are priceless

Please Log in to join the conversation.

More
1 week 6 days ago #206793 by midnightking
Yes, I was intending to use the template in my prototype4 question going forward. Prototype 5 was just me trying to randomly generate a picture from my database into my question.

Anyway, so if I understand correctly by changing my image names to ''proposer A'' , ''proposer B'' and so on, I should obtain their order of display in the hidden QH1 question.

I should also use <img alt="" src="/limesurvey/upload/surveys/123456/images/offer{substr(QH1,0,1)}.JPG" /> rather than img alt="" src="/limesurvey/upload/surveys/123456/images/AF14NES.jpg to display images in my questions using the solution in the prototypes.

Are my understanding correctly ?

Thank you for your help

Please Log in to join the conversation.

More
1 week 6 days ago #206806 by DenisChenu
This plugin : gitlab.com/SondagesPro/getQuestionOrder

Was done to keep track of randomization order in a short text question.

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development . I don't answer to private message.

Please Log in to join the conversation.

More
1 week 6 days ago #206810 by holch
If you use question by question layout (or group by group if the satisfaction question can be on the same page as the financial offer to accept or decline) you could just put the satisfaction question in the same question group with the offer and then randomize the question groups rather the questions. Then you always know which satisfaction was for which offer, because they are always displayed together.

I did not look at your LSG though, because I am too lazy to create a survey to import your LSG file into.

I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.

Please Log in to join the conversation.

More
1 week 6 days ago #206813 by Joffm
Here a small example.


You see that in the first question image "xxx_D" is displayed for 5 seconds, then image "yyy_C" and the question text is displayed.

In the second question "xxx_A" and "yyy_B", in the third "xxx_B" and "yyy_D" and so on.





File Attachment:

File Name: limesurvey...7195.lss
File Size:23 KB


In my opinion this is easy and straightforward. Just extend to the number of questions in your test.

Joffm

And never again send lsq or lsg exports, only lss.


Volunteers are not paid.
Not because they are worthless, but because they are priceless
Attachments:

Please Log in to join the conversation.

More
1 week 3 days ago #207012 by midnightking
@Joffm


I have imported your script and I can't seem to see the pictures when I try to preview the questions and the survey
I have uploaded pictures and renamed them accordingly as well, i.e proposer_A and offer_B.

File Attachment:

File Name: limesurvey... (2).lss
File Size:27 KB
Attachments:

Please Log in to join the conversation.

More
1 week 3 days ago #207025 by Joffm
<div id="d1" style="text-align: center;"><img alt="" src="/lime3/upload/surveys/922959/images/proposer_{substr(QH1,0,1)}.jpg" /></div>
 
<div id="d2" style="text-align: center;"><img alt="" src="/lime3/upload/surveys/922959/images/OFFER_{substr(QH2,1,1)}.jpg" /></div>

Of course the link showed my configuration.
"lime3" is my installation folder of the LimeSurvey 3.x. installation.
You have to use the correct link to your images.
Best you insert an image with the "image" button and the wizard; then have a look at the source code to be sure about your link to the image.

And for the second image in the first question you should use {substr(QH2,0,1)}

renamed them accordingly as well, i.e proposer_A and offer_B.

Really?
In your code the second image is named "OFFER_x".

Joffm


Volunteers are not paid.
Not because they are worthless, but because they are priceless

Please Log in to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now