Check out the LimeSurvey source code on GitHub!

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

More
5 years 6 months ago #64777 by rasheed
Thanks in advance for your feedback !

Please Log in to join the conversation.

More
5 years 6 months ago #64781 by TMSWhite
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 following user(s) said Thank You: rasheed

Please Log in to join the conversation.

More
5 years 6 months ago #64786 by rasheed
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

Please Log in to join the conversation.

More
5 years 6 months ago #64793 by tpartner
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 following user(s) said Thank You: rasheed

Please Log in to join the conversation.

More
5 years 6 months ago #64796 by rasheed
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.

Please Log in to join the conversation.

More
5 years 6 months ago #64808 by tpartner
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 following user(s) said Thank You: rasheed

Please Log in to join the conversation.

More
5 years 6 months ago - 5 years 6 months ago #64811 by rasheed
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: 5 years 6 months ago by rasheed.

Please Log in to join the conversation.

More
5 years 6 months ago #64814 by tpartner

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.

Please Log in to join the conversation.

More
5 years 6 months ago #64819 by rasheed
I am using at the END URL in fact :huh:
thankyou.php?prenom={INSERTANS:57582X46X2708}

Please Log in to join the conversation.

More
5 years 6 months ago #64837 by tpartner
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.

Please Log in to join the conversation.

More
5 years 6 months ago - 5 years 6 months ago #64855 by rasheed
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: 5 years 6 months ago by rasheed.

Please Log in to join the conversation.

More
5 years 6 months ago #64869 by tpartner
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 following user(s) said Thank You: rasheed

Please Log in to join the conversation.

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