Welcome, Guest
Username: Password: Remember me

TOPIC: Storing randomization order in the database

Storing randomization order in the database 1 year 5 months ago #87427

Is it possible to either:
  • Store the randomization order in the database (so if a questions' answers, or a randomization group is used, there is a record of which options/questions appeared 1st, 2nd, 3rd, etc...)?
  • Have a question take its "randomization" order FROM an external file or script? For example, it would reference a script that told the survey which order to show the options or questions (if in a randomization group)?

Just trying to see how best to implement a survey where we need to randomly "show" respondents 3 images, but must keep a tally so that of our desired 300 completed surveys, 100 respondents see Image A first... 100 respondents see Image B first... and 100 respondents see Image C first.

Any input appreciated!
I'm a call centre and market research technology consultant, lead/sample provider, and panel broker.

I'm also the co-founder and former IT Director of Winning Research Ltd. - LimeSurvey helped the company become a multi-million dollar company within just a few years!
The administrator has disabled public write access.

Re: Storing randomization order in the database 1 year 5 months ago #87462

  • tpartner
  • tpartner's Avatar
  • NOW ONLINE
  • LimeSurvey Team
  • Posts: 3813
  • Thank you received: 683
  • Karma: 328
If you're using the built-in randomization feature and displaying the survey in "group by group" mode you could use JavaScript/jQuery to create a list if the images or answer codes as displayed and load that into a hidden question.
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
The administrator has disabled public write access.

Re: Storing randomization order in the database 1 year 5 months ago #87463

Thank you. Any idea how I could use that to control the total number of people seeing each one first, though?

The only thing that's coming to mind... if it would work... would be to somehow use the JS/jQuery to store which question was shown first in a database, but then how do we control the order of showing once some limit has been reached (like 100 have already seen Image 2)?

Alternately, if it were possible to sequentially cycle through each image every time the survey is loaded that might work too (so 1st respondent sees Image 1, 2nd respondent sees Image 2, 3rd respondent sees Image 3, 4th respondent sees Image 1... etc...).

Any thoughts?
I'm a call centre and market research technology consultant, lead/sample provider, and panel broker.

I'm also the co-founder and former IT Director of Winning Research Ltd. - LimeSurvey helped the company become a multi-million dollar company within just a few years!
The administrator has disabled public write access.

Re: Storing randomization order in the database 1 year 5 months ago #87473

  • tpartner
  • tpartner's Avatar
  • NOW ONLINE
  • LimeSurvey Team
  • Posts: 3813
  • Thank you received: 683
  • Karma: 328
Alternately, if it were possible to sequentially cycle through each image every time the survey is loaded...
You can access the Response ID with the {SAVEDID} placeholder after the first question page is submitted. The response ID is a sequential so you can use JavaScript to do a little math (using the modulus operator) to generate sequential "start" numbers for the images and then display them accordingly.

The details of the script would depend on the question type(s).
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
Last Edit: 1 year 5 months ago by tpartner.
The administrator has disabled public write access.

Re: Storing randomization order in the database 1 year 5 months ago #87475

tpartner wrote:
If you're using the built-in randomization feature and displaying the survey in "group by group" mode you could use JavaScript/jQuery to create a list if the images or answer codes as displayed and load that into a hidden question.

Let's say I went this route and created a a hidden question to record the randomization order that was achieved in Q1 (multiple choice). How would I then use the data saved in that hidden question to preserve the randomization order of Q1 into Q2 (multiple choice) or Q3 (Array of numbers)?
I'm a call centre and market research technology consultant, lead/sample provider, and panel broker.

I'm also the co-founder and former IT Director of Winning Research Ltd. - LimeSurvey helped the company become a multi-million dollar company within just a few years!
The administrator has disabled public write access.

Re: Storing randomization order in the database 1 year 5 months ago #87477

  • tpartner
  • tpartner's Avatar
  • NOW ONLINE
  • LimeSurvey Team
  • Posts: 3813
  • Thank you received: 683
  • Karma: 328
Some assumptions:
- All questions use the same answer codes
- There is only one multiple-options question on the page with Q2
- There is only one array-numbers question on the page with Q3
- Q2 and Q3 are on page(s) following the Q1 page

Q1:
- Add a short-text to the page, lets give it a code "QHidden".
- Set Q1 to have randomized answers.
- Add the following code to one of the questions. It will hide the short text and populate it with the Q1 answer codes in the order displayed.
<script type="text/javascript" charset="utf-8">
	$(document).ready(function() {
 
		// Hide the short-text
		$('.text-short').hide(); 
 
		// The multi-opt id
		var multiOptID = $('.multiple-opt').attr('id').split('question')[1];
 
		// Populate the short-text
		var ansCodesList = new Array();
		$('.multiple-opt li[id^="javatbd"]').each(function(i){
			var ansCode = $(this).attr('id').split('X'+multiOptID)[1];
			ansCodesList.push(ansCode);
		});
		$('.text-short input.text').val(ansCodesList);
	});	
</script>

Q2:
- Add the following code to the source of Q2. It will find the order of the answer codes in Q1 and use the same order here.
<script type="text/javascript" charset="utf-8">
	$(document).ready(function() {
 
		// Get the previous answer order
		var ansCodesList = '{QHidden.value}'.split(',');
 
		// The multi-opt id
		var multiOptID = $('.multiple-opt').attr('id').split('question')[1];
 
		var answersParent = $('.multiple-opt li[id^="javatbd"]:eq(0)').parent();
 
		// Change the order of the multi-opt answers
		$(ansCodesList).each(function(i){
			$(answersParent).append($('.multiple-opt li[id$="'+multiOptID+this+'"]'))
		});
	});
</script>

Q3:
- Add the following code to the source of Q3. It will find the order of the answer codes in Q1 and use the same order here. Then it will set the correct alternating background colours for the array rows.
<script type="text/javascript" charset="utf-8">
	$(document).ready(function() {
 
		// Get the previous answer order
		var ansCodesList = '{QHidden.value}'.split(',');
 
		// The array id
		var multiOptID = $('.array-multi-flexi').attr('id').split('question')[1];
 
		var answersParent2 = $('.array-multi-flexi tbody[id^="javatbd"]:eq(0)').parent();
 
		// Change the order of the array rows
		$(ansCodesList).each(function(i){
			$(answersParent2).append($('.array-multi-flexi tbody[id$="'+multiOptID+this+'"]'))
		});
 
		// Fix up the array row background colours
		var rowIndex = 0;
		$('.array-multi-flexi table.question tbody tr').each(function(i, el){
			rowIndex ++;
			$(el).removeClass('array1, array2');			
			if(rowIndex % 2 == 0) {
				$(el).addClass('array1');
			}
			else {
				$(el).addClass('array2');
			}
		});
	});
</script>
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
The administrator has disabled public write access.

Re: Storing randomization order in the database 1 year 5 months ago #87479

Thank you for the detailed reply, tpartner.

I also just discovered this option: "Get order from previous question"

Would that be an easier way to solve the problem in this case, or am I misunderstanding the function of this option?
I'm a call centre and market research technology consultant, lead/sample provider, and panel broker.

I'm also the co-founder and former IT Director of Winning Research Ltd. - LimeSurvey helped the company become a multi-million dollar company within just a few years!
The administrator has disabled public write access.

Re: Storing randomization order in the database 1 year 5 months ago #87484

  • tpartner
  • tpartner's Avatar
  • NOW ONLINE
  • LimeSurvey Team
  • Posts: 3813
  • Thank you received: 683
  • Karma: 328
I wasn't aware that setting existed.
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
The administrator has disabled public write access.

Re: Storing randomization order in the database 1 year 5 months ago #87485

Yes, it seems quite useful, if only I could get it to work :)

www.limesurvey.org/en/forum/design-issue...-functionality#87480
I'm a call centre and market research technology consultant, lead/sample provider, and panel broker.

I'm also the co-founder and former IT Director of Winning Research Ltd. - LimeSurvey helped the company become a multi-million dollar company within just a few years!
The administrator has disabled public write access.
Moderators: ITEd
Time to create page: 0.128 seconds
Donation Image