Check out the LimeSurvey source code on GitHub!

Partially Randomized Answers For Array Typed Questions

4 years 3 weeks ago - 4 years 3 weeks ago #92002 by david2013
There is Javascript workaround for Multiple Options & List (radio) questions if you want to partially randomized answers. I'm wondering can we do something similar to Array Type questions? See below, can we randomize first 5 attributes but keep other at the end? Also, can we add "other" option to the grid too so that respondent can enter some text?

1 2 3 4 5
Attribute 1
Attribute 2
Attribute 3
Attribute 4
Attribute 5
Last Edit: 4 years 3 weeks ago by david2013. Reason: Grid doesn't appear properly

Please Log in to join the conversation.

4 years 3 weeks ago #92069 by tpartner
1) Follow the instructions regarding answer/subquestion codes here -

2) Set your array to "Random answer order"

3) Add this script to the source of the array (this code is for the plain "Array" question and may need to be modified for other question types):
<script type="text/javascript" charset="utf-8">
	$(document).ready(function() {
		// Identify some elements
		var q1ID = '{QID}';
		var q1 = $('#question'+q1ID+'');
		var tbody = $('tr[id^="javatbd"]:eq(0)', q1).parent();
		// Find the number of answers
		var ansCount = $('tr[id^="javatbd"]', q1).length;
		// Place the last answer created at the end of the list
		$('tr[id$="X'+q1ID+ansCount+'"]', q1).appendTo($(tbody));

Regarding the "Other" option, you can add a following short-text question that is shown conditionally when an option in that array row is clicked.

Tony Partner

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

Please Log in to join the conversation.

4 years 1 week ago #92647 by david2013
Thank you very much

Please Log in to join the conversation.

Imprint                   Privacy policy         General Terms & Conditions         Revocation information and revocation form