random selection of desired option..

Mehr
3 Jahre 8 Monate her #104351 von first
first erstellte das Thema random selection of desired option..
Hi Everyone,

Q1 and Q2 is a Multiple choice questions with same answer list and 6 answer options. I want auto select those answers options at Q2 that were answered at Q1. This auto-selection should be based on following two logics.

Logics:
At most 3 should be auto selected at Q2
Random selection.

Answers list of Q1 and Q2:
a
b
c
d
e
f


Please help me out.

Survey Designer and Programmer

Bitte Anmelden um an der Konversation teilzunehmen.

Mehr
3 Jahre 8 Monate her #104361 von tpartner
tpartner antwortete auf das Thema: random selection of desired option..
trivender, I see from your signature that you are using group-by-group mode and the questions are in separate groups.

Do you allow respondents to go backwards in this survey? If so, what do you want to happen to Q2 on subsequent visits?


.

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

Bitte Anmelden um an der Konversation teilzunehmen.

Mehr
3 Jahre 8 Monate her #104363 von first
first antwortete auf das Thema: random selection of desired option..
Tony , First lets assume that I wont allow respondent to move back in survey.

I made Q1 randomized and then created a hidden multiple open text question on the same page. I come up with the following script.

<script>
$(document).ready(function(){
$("#movenextbtn").click(function(){
$("input:text").val("")
var inputBoxIndex = 1;
$( "input:checkbox:checked" ).each(function(){
$("input:text").eq(inputBoxIndex).val($(this).attr("id").substring(25));
inputBoxIndex++;
});
//return false;
});
});
</script>

Survey Designer and Programmer

Bitte Anmelden um an der Konversation teilzunehmen.

Mehr
3 Jahre 8 Monate her #104364 von tpartner
tpartner antwortete auf das Thema: random selection of desired option..
I'm thinking along the same lines - recording an array of the Q1 answers. My approach would be to put in a hidden element in Q2, since that's where we need to access it.

LS version?


.

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

Bitte Anmelden um an der Konversation teilzunehmen.

Mehr
3 Jahre 8 Monate her #104365 von tpartner
tpartner antwortete auf das Thema: random selection of desired option..
Assuming you are using 2.05...

1) Add a hidden <p> element to the source of Q2 and use Expression Manager to pipe the Q1 results into that element. There may be a better way to do it, but something like this:
<p class="q1-answers" style="display:none;">{if(Q1_a == "Y", ",a", '')}{if(Q1_b == "Y", ",b", '')}{if(Q1_c == "Y", ",c", '')}{if(Q1_d == "Y", ",d", '')}{if(Q1_e == "Y", ",e", '')}{if(Q1_f == "Y", ",f", '')}</p>


2) Add this script to that question source (I think the comments explain it):
<script type="text/javascript" charset="utf-8">	
 
	$(document).ready(function(){
 
		// Identify this question
		var thisQuestion = $('#question{QID}');
		var thisQuestionID = '{QID}';
 
		// Create an array of the Q1 answered codes
		var q1Answers = $('p.q1-answers', thisQuestion).text().replace(/,/, '');
		var q1AnswersArr = q1Answers.split(',');
 
		// Shuffle the 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(q1AnswersArr);
 
		// Check the first 3 options in the array
		$(q1AnswersArr).each(function(i) {
			if(i < 3) {
				var thisCode = $.trim(this);
				$('input[type="checkbox"][id$="X'+thisQuestionID+thisCode+'"]', thisQuestion).prop('checked', true);
			}
		});
	});
 
</script>


.

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

Bitte Anmelden um an der Konversation teilzunehmen.

Jetzt loslegen!

Melden Sie sich jetzt an, und erstellen Sie in wenigen Minuten Ihre erste Umfrage.

Account einrichten