Check out the LimeSurvey source code on GitHub!

Changing code in qanda.php

More
5 years 6 months ago #64366 by UKEpsychosomatik
Dear Limers,
I Have a question regarding a design issue. I want to show a question like in my updated picute and want not to show buttons for answering but instead of the buttons numbers like 1 2 3 4.

What do I have to change in my qanda.php?
I must give the labels the values of their input. I know. But how?
My programming is not that good. So I would by glad for some help.
Thank you soooooo much!
Attachments:

Please Log in to join the conversation.

More
5 years 6 months ago #64372 by tpartner
I would not mess around with quanda.php. That will leave you exposed to over-writing when updating.

I would do it with JavaScript. (this example is for the "Array" question type)

1) Set up your survey to use JavaScript .

2) Add the following script to the source of the array. Replace "QQ" with the array question ID .

The script replaces the radio buttons with their values. When an answer cell is clicked, it is given a class "selectedRadio" so you can style it.
<script type="text/javascript" charset="utf-8">
 
	$(document).ready(function() {
 
		// Call the function with the question ID
		labelReplace(QQ);
 
		// A function to replace radio inputs with their values
		function labelReplace(qID) {
 
			// Hide the radio buttons and insert the labels
			$('#question'+qID+' label[for^="answer"]').each(function(i){
				var val = $('input.radio', this).val();
				$(this).append(val);
				$('input.radio', this).hide();
			});
 
			// Add a class to the clicked radio cell
			$('#question'+qID+' table.question tbody td').click(function(){
				var row = $(this).parent();
				$('td', row).removeClass('selectedRadio');
				$(this).addClass('selectedRadio');
			});
		}
 
	});
 
</script>

3) Then add something like this to the end of template.css:
.selectedRadio {
	background-color: pink;
	font-weight: bold;
}

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 #64400 by UKEpsychosomatik
Hi Tony!

Thank you but there are some problems in realisation of your instruction.

1)I set up my JavaScript (I did it very often in the past so it works correctly.

For a try i build an array question with one subquestion and 4 answer options (look picture attached)


2) I added your script to the source of the question and replaced the "QQ" with the SGQA of the question. But nothimg happened.


I wondered if it could by due to the "$" in the code. I remember that I had those problems in the past. Might it be or do I have to add the script not to the source of the question but to the answer or the subquestion? I am very confused.....

I attached the question as well. Maybe I am tooooooo stupid??? :(


Thank you!
Attachments:

Please Log in to join the conversation.

More
5 years 6 months ago #64428 by tpartner

...and replaced the "QQ" with the SGQA of the question...

Not the SGQA, just the question ID:


Cheers,
Tony Partner

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

Please Log in to join the conversation.

More
5 years 6 months ago #64464 by UKEpsychosomatik
THANKSSSS! It works finde but I do not want to have the label code (which is limited due to 5 charackters but instead I want to replace wirh the answer options. (Because I want to write " not at all"...) Is there any possibility?

Please Log in to join the conversation.

More
5 years 6 months ago #64489 by tpartner
Change this line:
var val = $('input.radio', this).val();

To:
var val = $('input.radio', this).attr('title');

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: UKEpsychosomatik

Please Log in to join the conversation.

More
5 years 6 months ago #64616 by UKEpsychosomatik
Super, thank you sooooo much!
It works fine!

B) B) B)

Please Log in to join the conversation.

More
5 years 6 months ago #64751 by UKEpsychosomatik
Another short question and then I promise to donate:=)
Is there a possibility to make the anwer option (the text) bigger?

thank yoooooouuuuuu!

Please Log in to join the conversation.

More
5 years 6 months ago - 5 years 6 months ago #64757 by tpartner
Add the following to the end of template.css. Replace "QQ" with the question ID.
#questionQQ table.question tbody td {
	font-size: 150%;
}

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last Edit: 5 years 6 months ago by tpartner.

Please Log in to join the conversation.

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