Willkommen, Gast
Benutzername: Passwort: Angemeldet bleiben:

THEMA: Please Help, hidden question with answers

Re: Please Help, hidden question with answers 1 Jahr 7 Monate her #91054

  • tpartner
  • tpartners Avatar
  • OFFLINE
  • LimeSurvey Team
  • Beiträge: 4139
  • Dank erhalten: 767
  • Karma: 348
Okay, can you give me examples of the token attribute(s) used for the departments?
Cheers,
Tony Partner

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

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Re: Please Help, hidden question with answers 1 Jahr 7 Monate her #91086

  • Serafim
  • Serafims Avatar
  • OFFLINE
  • Expert Lime
  • Beiträge: 114
  • Dank erhalten: 2
  • Karma: 2
ok, so it would be something like this:
Token 1:
attribute_1attribute_2attribute_3attribute_4
Dep1Dep3
Token 2:
attribute_1attribute_2attribute_3attribute_4
Dep2Dep4

Token 1 would have attribue_1 and attibute_3 for example, and token 2 the other 2 attributes.

When token 1 would answer the survey we would rate from 0 to 10 only Dep1 and Dep3.

One other thing I remembered, but don't no if it is possible, is this:

Token 1:
attribute_Dep1attribute_Dep2attribute_Dep3attribute_Dep4
YNYN
Token 2:
attribute_Dep1attribute_Dep2attribute_Dep3attribute_Dep4
NYNY
Don't no witch way is better. this is making my head spin...
Letzte Änderung: 1 Jahr 7 Monate her von Serafim.
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Re: Please Help, hidden question with answers 1 Jahr 7 Monate her #91121

  • tpartner
  • tpartners Avatar
  • OFFLINE
  • LimeSurvey Team
  • Beiträge: 4139
  • Dank erhalten: 767
  • Karma: 348
I would use the second example of your tokens:
attribute_1attribute_2attribute_3attribute_4
Token 1YNYN
Token 2NYNY

Then, place the multiple choice question (departments) in a group BEFORE the array (ratings) question and add this to the question source of the multiple choice question. It will hide the question and toggle the checkboxes according to the attribute values.
<script type="text/javascript" charset="utf-8">
	$(document).ready(function() {
 
		// Get the question ID and the token values
		var qID = '{QID}';
		var dept1 = '{TOKEN:ATTRIBUTE_1}';
		var dept2 = '{TOKEN:ATTRIBUTE_2}';
		var dept3 = '{TOKEN:ATTRIBUTE_3}';
		var dept4 = '{TOKEN:ATTRIBUTE_4}';
 
		// Hide the question
		$('#question'+qID).css({
			'position':'absolute',
			'left':'-9999em'
		});
 
		// Check the appropriate boxes
		if(dept1 == 'Y') {
			$('#question'+qID+' input[type="checkbox"]:eq(0)').attr('checked', true);
		}
		if(dept2 == 'Y') {
			$('#question'+qID+' input[type="checkbox"]:eq(1)').attr('checked', true);
		}
		if(dept3 == 'Y') {
			$('#question'+qID+' input[type="checkbox"]:eq(2)').attr('checked', true);
		}
		if(dept4 == 'Y') {
			$('#question'+qID+' input[type="checkbox"]:eq(3)').attr('checked', true);
		}
	});
</script>
Cheers,
Tony Partner

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

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
Letzte Änderung: 1 Jahr 7 Monate her von tpartner.
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Re: Please Help, hidden question with answers 1 Jahr 7 Monate her #91133

  • Serafim
  • Serafims Avatar
  • OFFLINE
  • Expert Lime
  • Beiträge: 114
  • Dank erhalten: 2
  • Karma: 2
Oh, I see. I understand the code, that as to work. I'm just waiting for someone to give me admin privileges to try it. With the user I have can´t insert code in the questions.

Many thanks.
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Re: Please Help, hidden question with answers 1 Jahr 7 Monate her #91691

  • Serafim
  • Serafims Avatar
  • OFFLINE
  • Expert Lime
  • Beiträge: 114
  • Dank erhalten: 2
  • Karma: 2
Hi there,

finally I've tried the code, and it works just fine, just have one question.

The code only works if I have question by question or group by group, if I have the survey to show all the questions in the same screen it doesn't work, but that's no problem, I just to change my survey to question by question.

What I can't change is that when the code hides the question, in my survey will have an empty screen, did I do something wrong or is there any solution?

Once again thanks.
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Re: Please Help, hidden question with answers 1 Jahr 7 Monate her #91709

  • tpartner
  • tpartners Avatar
  • OFFLINE
  • LimeSurvey Team
  • Beiträge: 4139
  • Dank erhalten: 767
  • Karma: 348
This should work in "all-in-one" mode. Do you get any JavaScript errors?
Cheers,
Tony Partner

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

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Re: Please Help, hidden question with answers 1 Jahr 7 Monate her #91726

  • Serafim
  • Serafims Avatar
  • OFFLINE
  • Expert Lime
  • Beiträge: 114
  • Dank erhalten: 2
  • Karma: 2
Maybe I'm doing something wrong, but I don't have any JavaScript errors. I took the code to hide the question to see it work, it chooses the right answers, but in the second question it doesn't shows anything.
Anhang:
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Re: Please Help, hidden question with answers 1 Jahr 7 Monate her #91760

  • tpartner
  • tpartners Avatar
  • OFFLINE
  • LimeSurvey Team
  • Beiträge: 4139
  • Dank erhalten: 767
  • Karma: 348
Ah, to have it all on one page, you will need to fire the checkconditions() function after checking the boxes:
<script type="text/javascript" charset="utf-8">
	$(document).ready(function() {
 
		// Get the question ID and the token values
		var qID = '{QID}';
		var dept1 = '{TOKEN:ATTRIBUTE_1}';
		var dept2 = '{TOKEN:ATTRIBUTE_2}';
		var dept3 = '{TOKEN:ATTRIBUTE_3}';
		var dept4 = '{TOKEN:ATTRIBUTE_4}';
 
		// Hide the question
		$('#question'+qID).css({
			'position':'absolute',
			'left':'-9999em'
		});
 
		// Check the appropriate boxes
		if(dept1 == 'Y') {
			checkTheBox($('#question'+qID+' input[type="checkbox"]:eq(0)'));
		}
		if(dept2 == 'Y') {
			checkTheBox($('#question'+qID+' input[type="checkbox"]:eq(1)'));
		}
		if(dept3 == 'Y') {
			checkTheBox($('#question'+qID+' input[type="checkbox"]:eq(2)'));
		}
		if(dept4 == 'Y') {
			checkTheBox($('#question'+qID+' input[type="checkbox"]:eq(3)'));
		}
 
		function checkTheBox(el) {
			$(el).attr('checked', true);
			checkconditions($(el).attr('value'), $(el).attr('name'), $(el).attr('type'));
		}
	});
</script>
Cheers,
Tony Partner

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

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Re: Please Help, hidden question with answers 1 Jahr 7 Monate her #91763

  • Serafim
  • Serafims Avatar
  • OFFLINE
  • Expert Lime
  • Beiträge: 114
  • Dank erhalten: 2
  • Karma: 2
Ahh, nice, just perfect.

Only one thing, maybe in css I can solve it, as the first question is hidden, how can I take the space that it takes visually? What I mean is, question by question, I have to submit the first question or a empty screen to go to the second question, if it is every questions in a page, there is an empty space (+-3 lines) before the second question. I'm sure that in the css I can do this, and just show the second question right?

Any way, just the case of this code working is perfect for me, it was my big problem, to use attributes as answers. Thanks.
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Re: Please Help, hidden question with answers 1 Jahr 7 Monate her #91916

  • Serafim
  • Serafims Avatar
  • OFFLINE
  • Expert Lime
  • Beiträge: 114
  • Dank erhalten: 2
  • Karma: 2
Hi there, any suggestions?
Der Administrator hat öffentliche Schreibrechte deaktiviert.
Moderatoren: ITEd
Ladezeit der Seite: 0.183 Sekunden
Donation Image