Welcome, Guest
Username: Password: Remember me

TOPIC: Randomize questions, even across groups

Randomize questions, even across groups 3 years 10 months ago #67458

  • josecanuc
  • josecanuc's Avatar
  • Offline
  • Fresh Lemon
  • Posts: 4
  • Karma: 0
I have a survey that uses question groups to assess a score for each group. But, I want the entire survey on one page with all questions completely randomized in order.

However, they still show up ordered by group. Within the group, the order is random. But I want to ignore groups as far as presenting the questions go.

The docs at:
docs.limesurvey.org/Workarounds%3A+Surve..._random_survey_order
Give some instruction on this. But it doesn't seem to have an effect.

I edited index.php, found the buildsurveysession() function and added the following just before the "return" call:
if ($surveyid==91556)
{
  shuffle($_SESSION['fieldarray']);
}

However, it doesn't change anything.

I also have put every question in a single "randomization group" called "glob", but that still only randomized within groups.

Any help?
The administrator has disabled public write access.

Randomize questions, even across groups 3 years 10 months ago #67468

  • Mazi
  • Mazi's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 5725
  • Thank you received: 333
  • Karma: 255
How about using just one group and using the randomize group?

Best regards/Beste Grüße,
Dr. Marcel Minke
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)limesurvey.org'"
The administrator has disabled public write access.

Randomize questions, even across groups 3 years 10 months ago #67477

  • josecanuc
  • josecanuc's Avatar
  • Offline
  • Fresh Lemon
  • Posts: 4
  • Karma: 0
That would be fine, except I use the assessment tools to provide a score for each of the 12 groups, individually. In what way can I still make 12 different scores (each of 12 groups has 8 questions, scored zero to three.)?
The administrator has disabled public write access.

Randomize questions, even across groups 3 years 10 months ago #67491

  • Mazi
  • Mazi's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 5725
  • Thank you received: 333
  • Karma: 255
Well, you could use different min/max values at assessments e.g. group 1 has a max of 8*3=24, group2 uses 8*30=240, group3: 8*300=2400 and so on. You then just have to adjust the borders to differentiate the groups.

Best regards/Beste Grüße,
Dr. Marcel Minke
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)limesurvey.org'"
The administrator has disabled public write access.

Randomize questions, even across groups 3 years 10 months ago #67505

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 5081
  • Thank you received: 1046
  • Karma: 438
The following workaround will randomize the questions in "All in one" mode, even if they are place in groups.

Notes:
- the workaround is tested in the default template - may need slight tweaks for others
- I have NOT tested with conditions


1) Set up your survey to use JavaScript.

2) Add the following script to the source of one of the questions.
<script type="text/javascript" charset="utf-8">
 
	$(document).ready(function() {
 
		shuffleQuestions();
 
		function shuffleQuestions() {
 
			// Hide the group wrappers
			$('div[id^="group-"]').hide();
 
			// Create and insert a new question wrapper
			var qWrapper = '<div id="qWrapper">\
						<table class="group"> \
							<tbody> \
								<tr> \
									<td> \
									</td> \
								</tr> \
							</tbody> \
						</table>\
					</div>';
 
			$('div[id^="group-"]:last').after(qWrapper);
			$( 'div#qWrapper td' ).css({'padding-top':'10px'});	
 
			// Create an array to hold question IDs
			var qArray = new Array();
 
			// Load the IDs of all questions on the page into the array 
			$('div[id^="question"]').each(function(i) {
				qArray.push($(this).attr('id'));
			});
 
			// Shuffle the questions array
			function shuffle(o){
				for(var j, x, i = o.length; i; j = parseInt(Math.random() * i), x = o[--i], o[i] = o[j], o[j] = x);
				return o;
			}			
			shuffle(qArray);
 
			// Insert the questions into the new question wrapper in the shuffled order
			$.each(qArray, function(i, val){
				$('div#' + val + '').appendTo($('#qWrapper td:first'));
			});
 
		}
	});
</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.
The following user(s) said Thank You: DenisChenu

Randomize questions, even across groups 3 years 10 months ago #67512

  • josecanuc
  • josecanuc's Avatar
  • Offline
  • Fresh Lemon
  • Posts: 4
  • Karma: 0
tpartner wrote:
Looks great, except that I don't have the source code editor in my new-question screen. Is that another setting?
The administrator has disabled public write access.

Randomize questions, even across groups 3 years 10 months ago #67515

  • josecanuc
  • josecanuc's Avatar
  • Offline
  • Fresh Lemon
  • Posts: 4
  • Karma: 0
Replying to self -- I just pasted the code into the question anyway and it worked. Not sure why I don't have the HTML editor bar, though.
The administrator has disabled public write access.

Randomize questions, even across groups 3 years 10 months ago #67519

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 5081
  • Thank you received: 1046
  • Karma: 438
Maybe you don't have any editor enabled. There is a global setting for it:

This message has an attachment image.
Please log in or register to see it.

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.
Moderators: ITEd
Time to create page: 0.150 seconds