Willkommen, Gast
Benutzername: Passwort: Angemeldet bleiben:

THEMA: Help me: Partial randomized answers in LimeSurvey 2.05+ - How can I do this?

Help me: Partial randomized answers in LimeSurvey 2.05+ - How can I do this? 1 Jahr 1 Woche her #106340

  • helviobrito
  • helviobritos Avatar
  • OFFLINE
  • Fresh Lemon
  • Beiträge: 18
  • Dank erhalten: 1
  • Karma: 0
:huh: Hi fellows.

Well, I`m here again. Hope someone can help me with this issue. And sorry my bad English. I am in Brazil.

I use LimeSurvey 2.05+ Build 140302.

I have a list radio question with 3 answers: 1 - aaaa, 2 - bbbb and 3 - NoAnswer. Just options 1 and 2 must be randomized. Option 3 should be fixed at the end. But I don't want NoAnswer in all my questions, so I set to "No" the specific option in General Settings.

Searching LimeSurvey Manual, I found two Workarounds with suggested scripts to do exactly what I need. I followed all the instructions, modifying the variables filterxsshtml to FALSE and shownoanswer to 0 in config.php, as stated, set the correct IDs in JavaScript, saved it in the source of the question, but nothing worked. All the answers were randomized.

What should I do? Can anyone help me? Keep in mind, fellows, that I'm not an IT professional. I'm a research specialist, very curious and darting in the mazes of coding.

Here are the Workarounds:

Partially Randomized Answers - Multiple Options & List (radio) questions - ENHANCED </br>
Partially Randomized Answers - Multiple Options & List (radio) questions

The scripts, with my sID, gID and qID. None worked, tested with Chrome, IE 9 and Firefox 20:





Thanks.

Helvio Brito.
Letzte Änderung: 1 Jahr 1 Woche her von helviobrito.
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Help me: Partial randomized answers in LimeSurvey 2.05+ - How can I do this? 1 Jahr 1 Woche her #106355

  • tpartner
  • tpartners Avatar
  • ONLINE
  • LimeSurvey Team
  • Beiträge: 4629
  • Dank erhalten: 922
  • Karma: 408
I think we can clean up that workaround a bit.

Assuming your answers codes are sequential numbers and you have set the answers to be randomized, adding this script to the question source will always place the last answer item at the end of the list. (you do not need to worry about the question ID - it will be automatically detected)

<script type="text/javascript" charset="utf-8">	
 
	$(document).ready(function() {
 
		// Identify this question
		var qID = {QID}; 
 
		// Find the number of answers
		var ansCount = $('#question'+qID+' li.answer-item').length;
 
		// Place the last answer created at the end of the list
		var answer = $( 'input[id$="X'+qID+ansCount+'"]');
		var answerItem = $(answer).closest('li');
		var answersList = $(answer).closest('ul');
		$(answersList).append(answerItem);
 
	});
</script>

Here's a working survey:

Dateianhang:

Dateiname: limesurvey_survey_187153.lss
Dateigröße: 19 KB
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.
Folgende Benutzer bedankten sich: helviobrito

Help me: Partial randomized answers in LimeSurvey 2.05+ - How can I do this? 1 Jahr 1 Woche her #106369

  • helviobrito
  • helviobritos Avatar
  • OFFLINE
  • Fresh Lemon
  • Beiträge: 18
  • Dank erhalten: 1
  • Karma: 0
Thanks a lot, tpartner.

It works perfectly.
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Help me: Partial randomized answers in LimeSurvey 2.05+ - How can I do this? 1 Jahr 1 Woche her #106372

  • helviobrito
  • helviobritos Avatar
  • OFFLINE
  • Fresh Lemon
  • Beiträge: 18
  • Dank erhalten: 1
  • Karma: 0
Can I ask for more help?

If I want to set more than 1 answer to be fixed at the end of the list, what shoul I do?

e.g.:

1 - aaaa; 2 - bbbb; 3 - cccc; 4 - NoAnswer - 5 - OtherAnswer, randomizing itens 1, 2 and 3.

Thanks, again.
Letzte Änderung: 1 Jahr 1 Woche her von helviobrito.
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Help me: Partial randomized answers in LimeSurvey 2.05+ - How can I do this? 1 Jahr 1 Woche her #106383

  • tpartner
  • tpartners Avatar
  • ONLINE
  • LimeSurvey Team
  • Beiträge: 4629
  • Dank erhalten: 922
  • Karma: 408
Use this script and, if necessary, modify the "fixedAnswers" variable.

<script type="text/javascript" charset="utf-8">	
 
	$(document).ready(function() {
 
		// The number of answers to be fixed at the end of the list
		var fixedAnswers = 2;
 
		// Identify this question
		var qID = {QID}; 
 
		// Find the number of answers
		var ansCount = $('#question'+qID+' li.answer-item').length;
 
		// Place the last n answers created at the end of the list
		var fixedIndex = fixedAnswers - 1;
		for (var i=0; i<fixedAnswers; i++) {
			var answer = $( 'input[id$="X'+qID+(ansCount-fixedIndex)+'"]');
			var answerItem = $(answer).closest('li');
			var answersList = $(answer).closest('ul');
			$(answersList).append(answerItem);
			fixedIndex--;
		}		
	});
</script>

Here's a working survey:

Dateianhang:

Dateiname: Partially_Randomized_Answers_Enhanced.lss
Dateigröße: 20 KB
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 1 Woche her von tpartner.
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Help me: Partial randomized answers in LimeSurvey 2.05+ - How can I do this? 1 Jahr 1 Woche her #106384

  • tpartner
  • tpartners Avatar
  • ONLINE
  • LimeSurvey Team
  • Beiträge: 4629
  • Dank erhalten: 922
  • Karma: 408
I've updated the two workarounds:

Partially Randomized Answers - Multiple Options & List (radio) questions - manual.limesurvey.org/Workarounds:_Manip...28radio.29_questions

Partially Randomized Answers - Multiple Options & List (radio) questions (Enhanced) - manual.limesurvey.org/Workarounds:_Manip...tions_.28Enhanced.29


.
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.

Help me: Partial randomized answers in LimeSurvey 2.05+ - How can I do this? 1 Jahr 1 Woche her #106385

  • helviobrito
  • helviobritos Avatar
  • OFFLINE
  • Fresh Lemon
  • Beiträge: 18
  • Dank erhalten: 1
  • Karma: 0
Thanks again and again. It's perfect.
Der Administrator hat öffentliche Schreibrechte deaktiviert.
Moderatoren: ITEd
Ladezeit der Seite: 0.156 Sekunden
Donation Image