Check out the LimeSurvey source code on GitHub!
Welcome, Guest
Username: Password:

TOPIC: Compute value in question

Compute value in question 4 years 8 months ago #68215

  • rafael_ur
  • rafael_ur's Avatar
  • Offline
  • Senior Lime
  • Posts: 74
  • Karma: 0
Hi everybody
I have a question with multiple choice, P1, in the next question P2, I exclude the answers given in P1 y the rest options show randomly. How could I know if an item is selected in the P2 (I need to load the answer in another question, P3, which is a question of quota)

For instance,

P1 (spontaneous)
1. BMW
2. FIAT
3. RENAULT
4. MERCEDES
5. TOYOTA
It choices 1,3

P2 (random)
1. RENAULT
2. TOYOTA
3. FIAT
It selects 2

P3 (hidden)
YES-NO
Choice FIAT? -> NO

I need to compute FIAT

Thank,
Rafael
The administrator has disabled public write access.

Compute value in question 4 years 8 months ago #68219

  • Mazi
  • Mazi's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 5974
  • Thank you received: 366
  • Karma: 260
Can't you use conditions for this and maybe have several follow up question displayed depending on the conditions?

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.

Compute value in question 4 years 8 months ago #68226

  • rafael_ur
  • rafael_ur's Avatar
  • Offline
  • Senior Lime
  • Posts: 74
  • Karma: 0
Thank Mazi,

Probably but I have all done I only need to finish this. Is it possible.

Many thank,
Rafael
The administrator has disabled public write access.

Compute value in question 4 years 8 months ago #68230

  • Mazi
  • Mazi's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 5974
  • Thank you received: 366
  • Karma: 260
I this case I think some custom Javascript to read out the answer and eventually check the yes/no answer option is the only choice.

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.

Compute value in question 4 years 8 months ago #68233

  • rafael_ur
  • rafael_ur's Avatar
  • Offline
  • Senior Lime
  • Posts: 74
  • Karma: 0
Yes, I think so but I don't know to do Javascript to read out the answer in the multiple optionc with random.

Rafael.
The administrator has disabled public write access.

Compute value in question 4 years 8 months ago #68237

  • Mazi
  • Mazi's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 5974
  • Thank you received: 366
  • Karma: 260
Maybe our Javascript expert "tpartner" comes around to have a look...

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.

Compute value in question 4 years 8 months ago #68261

  • tpartner
  • tpartner's Avatar
  • Online
  • LimeSurvey Team
  • Posts: 6140
  • Thank you received: 1363
  • Karma: 535
Rafael, are all question on the same page? Can you attach a sample survey?
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The administrator has disabled public write access.

Compute value in question 4 years 8 months ago #68266

  • rafael_ur
  • rafael_ur's Avatar
  • Offline
  • Senior Lime
  • Posts: 74
  • Karma: 0
Hi Tony,
It is question mp2 where I put script.

Many thank,
Rafael
Attachments:
The administrator has disabled public write access.

Compute value in question 4 years 8 months ago #68305

  • tpartner
  • tpartner's Avatar
  • Online
  • LimeSurvey Team
  • Posts: 6140
  • Thank you received: 1363
  • Karma: 535
I'm not clear on what you are trying to do.

Is this correct?

- If "Fiat" is selected in p1 or p2, then mp2 = "Sí"

- Else mp2 = "No"

If so, I think you will need move mp2 to a third group because p2 may be hidden by conditions.
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The administrator has disabled public write access.

Compute value in question 4 years 8 months ago #68318

  • rafael_ur
  • rafael_ur's Avatar
  • Offline
  • Senior Lime
  • Posts: 74
  • Karma: 0
Hi Toni, many thank for you help.

It is correct.
I need everyone to know the brand if not end the interview, so my fee is mp2 and is on the same page, mp2 is quota.
I know when you click on FIAT in P2.
I do not know if I explained.

Thank,
Rafael
The administrator has disabled public write access.

Compute value in question 4 years 8 months ago #68320

  • tpartner
  • tpartner's Avatar
  • Online
  • LimeSurvey Team
  • Posts: 6140
  • Thank you received: 1363
  • Karma: 535
Okay, but I still think you should move mp2 (the quota question) to another group because p2 may not be shown (depending on conditions) and that would leave an empty page shown.
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The administrator has disabled public write access.

Compute value in question 4 years 8 months ago #68326

  • rafael_ur
  • rafael_ur's Avatar
  • Offline
  • Senior Lime
  • Posts: 74
  • Karma: 0
OK Toni,
've changed the thing to the next page shows the blank page buts How I can do to jump to the next page (now empty)?
Sending the file.


Thank,
Rafael
Attachments:
The administrator has disabled public write access.

Compute value in question 4 years 8 months ago #68327

  • tpartner
  • tpartner's Avatar
  • Online
  • LimeSurvey Team
  • Posts: 6140
  • Thank you received: 1363
  • Karma: 535
That makes it easier - we can use {INSERTANS} to get the answers for p1 and p2.

So, in mp2, we add a script that does the following:
- hides the <body> element
- finds if "FIAT" was selected in p1 or p2
- clicks the appropriate radio in mp2
- automatically submits the group
Note that the SGQA values in this script will be different from yours when you import the attached sample survey.
<script type="text/javascript" charset="utf-8"> 
 
	$(document).ready(function(){  	
		// Get p1 and p2 answers
		var p1Ans = "{INSERTANS:35779X963X122822}";  	
		var p2Ans = "{INSERTANS:35779X964X122842}";
 
		// Hide the <body> element so user sees less flash
		$('body').hide();
 
		// Set the radio question
		if (p1Ans == 'FIAT' || p2Ans == 'FIAT') {
			$('.yes-no:eq(0) input.radio:eq(0)').attr('checked', true);	
		}
		else  {
			$('.yes-no:eq(0) input.radio:eq(1)').attr('checked', true);	
		}
 
		// Advance in the survey
		document.limesurvey.move.value = 'movenext';
		document.limesurvey.submit();        
 
	});
</script>

Then in p3, we need to add a small script to allow skipping of the previous hidden group so respondents can go back in the survey:
<script type="text/javascript" charset="utf-8"> 
 
	$(document).ready(function(){ 
 
		// Skip previous group
		$('#moveprevbtn').mousedown(function () { 
			$('#thisstep').val($('#thisstep').val() - 1);
		});
 
	});
</script>

Here is the sample survey with the new code in mp2 and p3:

File Attachment:

File Name: p1p2_v2_TONY.lss
File Size:37 KB
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The administrator has disabled public write access.

Compute value in question 4 years 8 months ago #68328

  • rafael_ur
  • rafael_ur's Avatar
  • Offline
  • Senior Lime
  • Posts: 74
  • Karma: 0
Hi Tony,

Many thanks for your help, good job (I'm going to contribute to support).

Rafael
The administrator has disabled public write access.
Moderators: ITEd
Time to create page: 0.277 seconds
Imprint                   Data Protection Statement                  Revocation information and revocation form