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

TOPIC: Can "INSERTANS" generate sub-question code instead of the sub question name ?

Can "INSERTANS" generate sub-question code instead of the sub question name ? 4 years 11 months ago #64777

  • rasheed
  • rasheed's Avatar
  • Offline
  • Senior Lime
  • Posts: 52
  • Thank you received: 3
  • Karma: 1
Thanks in advance for your feedback !
The administrator has disabled public write access.

Can "INSERTANS" generate sub-question code instead of the sub question name ? 4 years 11 months ago #64781

  • TMSWhite
  • TMSWhite's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 758
  • Thank you received: 83
  • Karma: 37
For 1.91+, you'd probably have to use JavaScript.

For 1.92, you'll be able to use Expression Manager, which does let you insert the sub-question code.
The administrator has disabled public write access.
The following user(s) said Thank You: rasheed

Can "INSERTANS" generate sub-question code instead of the sub question name ? 4 years 11 months ago #64786

  • rasheed
  • rasheed's Avatar
  • Offline
  • Senior Lime
  • Posts: 52
  • Thank you received: 3
  • Karma: 1
Thanks for your inputs.

I am using 1.91+, would please give me more details on how to use Javascript for that.

If it's complicated, could you please tell me how to move from 1;91 to 1.92 ?

Thank you
The administrator has disabled public write access.

Can "INSERTANS" generate sub-question code instead of the sub question name ? 4 years 11 months ago #64793

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 6111
  • Thank you received: 1356
  • Karma: 532
The details of the JavaScript would depend on how you are using {INSERTANS}.

Are you using it in question text?

What template are you using.
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.
The following user(s) said Thank You: rasheed

Can "INSERTANS" generate sub-question code instead of the sub question name ? 4 years 11 months ago #64796

  • rasheed
  • rasheed's Avatar
  • Offline
  • Senior Lime
  • Posts: 52
  • Thank you received: 3
  • Karma: 1
Hi Tpartner,

Thanks for your help.

I am using {INSERTANS} to pass answers to another script at the end of the questionnaire.

In my questionnaire i am using Multi choice questions and drop down menus and i would like to pass the code of the sub-questions (for multi choice) and the options (for dorp down menus) not their content.

Template i am using is Redandgrey1.

Thank you in advance.
The administrator has disabled public write access.

Can "INSERTANS" generate sub-question code instead of the sub question name ? 4 years 11 months ago #64808

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 6111
  • Thank you received: 1356
  • Karma: 532
Then you can simply map the answer text to the appropriate answer codes:
 
	var prevAns = '{INSERTANS11111X22X33';
 
	switch(prevAns) {
		case 'Answer text 1' :
			prevAns = 'answerCode1';
			break;	
		case 'Answer text 2' :
			prevAns = 'answerCode2';
			break;	
		case 'Answer text 3' :
			prevAns = 'answerCode3';
			break;	
	}
 
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.
The following user(s) said Thank You: rasheed

Can "INSERTANS" generate sub-question code instead of the sub question name ? 4 years 11 months ago #64811

  • rasheed
  • rasheed's Avatar
  • Offline
  • Senior Lime
  • Posts: 52
  • Thank you received: 3
  • Karma: 1
Thank you, i start seeing the light at the end of the tunnel :)

However, i a, to pass more than 5 variables (from multichoice and dorp down menu questions) and as i am not a javascript expert, i don't really see what will be the code (should i add new variable ? prevAns2,...?) and where to insert it (template code ?).

Thank you so much.
Last Edit: 4 years 11 months ago by rasheed.
The administrator has disabled public write access.

Can "INSERTANS" generate sub-question code instead of the sub question name ? 4 years 11 months ago #64814

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 6111
  • Thank you received: 1356
  • Karma: 532
should i add new variable ?
Yes, something like:
	var prevAns1 = '{INSERTANS11111X22X33'; 
	var prevAns2 = '{INSERTANS11111X22X44'; 
	var prevAns3 = '{INSERTANS11111X22X55';
 
	switch(prevAns1) {
		case 'Q1 answer 1 text' :
			prevAns1 = 'q1Answer1Code';
			break;	
		case 'Q1 answer 2 text' :
			prevAns1 = 'q1Answer2Code';
			break;	
		case 'Q1 answer 3 text' :
			prevAns1 = 'q1Answer3Code';
			break;	
	}
 
	switch(prevAns2) {
		case 'Q2 answer 1 text' :
			prevAns2 = 'q2Answer1Code';
			break;	
		case 'Q2 answer 2 text' :
			prevAns2 = 'q2Answer2Code';
			break;	
		case 'Q2 answer 3 text' :
			prevAns2 = 'q2Answer3Code';
			break;	
	}
 
	switch(prevAns3) {
		case 'Q3 answer 1 text' :
			prevAns3 = 'q3Answer1Code';
			break;	
		case 'Q3 answer 2 text' :
			prevAns3 = 'q3Answer2Code';
			break;	
		case 'Q3 answer 3 text' :
			prevAns3 = 'q3Answer3Code';
			break;	
	}
 
and where to insert it
Wherever you have the script using INSERTANS now,
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.

Can "INSERTANS" generate sub-question code instead of the sub question name ? 4 years 11 months ago #64819

  • rasheed
  • rasheed's Avatar
  • Offline
  • Senior Lime
  • Posts: 52
  • Thank you received: 3
  • Karma: 1
I am using at the END URL in fact :huh:
thankyou.php?prenom={INSERTANS:57582X46X2708}
The administrator has disabled public write access.

Can "INSERTANS" generate sub-question code instead of the sub question name ? 4 years 11 months ago #64837

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 6111
  • Thank you received: 1356
  • Karma: 532
In that case, I think you will need to load a hidden question with the answer code(s) and then use INSERTANS for the hidden question in the end URL.
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.

Can "INSERTANS" generate sub-question code instead of the sub question name ? 4 years 11 months ago #64855

  • rasheed
  • rasheed's Avatar
  • Offline
  • Senior Lime
  • Posts: 52
  • Thank you received: 3
  • Karma: 1
Hmmm, clever solution, but how to load the hidden question with the answer code ?

If if it's with the javascript you mentioned above, where should i put it ?
Last Edit: 4 years 11 months ago by rasheed.
The administrator has disabled public write access.

Can "INSERTANS" generate sub-question code instead of the sub question name ? 4 years 11 months ago #64869

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 6111
  • Thank you received: 1356
  • Karma: 532
I can't give a snippet now but searching the forums and workarounds should give lots of hints on how to hide and populate a question.

If there are several questions involved, you will need to place the script in the source of a group description or question following all involved questions (maybe in the last group?).
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.
The following user(s) said Thank You: rasheed
Moderators: ITEd
Time to create page: 0.261 seconds
Imprint                   Data Protection Statement                  Revocation information and revocation form