Add Colors in questions

More
2 months 5 days ago - 2 months 5 days ago #157647 by mistercitrus
mistercitrus created the topic: Add Colors in questions
I'm wondering what the easiest way to accomplish on the form what I've done in mspaint.exe here (see attachment)
Just need to add some colors to a number of questions, the entire survey would share the same color scheme and each question would always have 5 responses if that makes things simpler.







Open to other solutions such as graphic 'buttons' or just colored text to
The closest I've seen is this example -

LouisGac wrote: Hi,

It should be possible to adapt old survey template with the new system without too much difficulties.
We're working on it for the future.

Here basically the work that must be done (you can help with it) :

1. All the question types, less arrays, have now separated views :
github.com/LimeSurvey/LimeSurvey/tree/ma...ews/survey/questions

In a close future, this will give the possibility to any LimeSurvey user with some skill in PHP/JS/CSS to add new question rendering, with its own HTML, JS files, and CSS, and to share them as question modules.

Have a look to the YES/NO question or GENDER question and their new question attribute to see how it works. Basically, for gender question, you can see that we added new 'button' views :
github.com/LimeSurvey/LimeSurvey/tree/ma...vey/questions/gender



accessible via the 'display' question attribute.



2. So, we must finish to export the array question HTML to view

3. Then we must add the old question HTML of 2.0x as views accessible via a display option


For now, I will advise you just to build new template on the base of one of the new ones. They use Bootstrap (easy to use), and are fully responsive.

Attachments:
Last Edit: 2 months 5 days ago by mistercitrus.

Please Log in to join the conversation.

More
2 months 4 days ago - 2 months 4 days ago #157649 by Joffm
Joffm replied the topic: Add Colors in questions
Hi, mistercitrus,

here is a solution for array. Only example with three colored columns.
Insert into the sourcecode of the question:
<style type="text/css">
.answer_cell_001,
.answer_cell_1
{
	Background-color: red !important;
}
.answer_cell_003,
.answer_cell_3
{
	Background-color: yellow !important;
}
.answer_cell_006,
.answer_cell_6
{
	Background-color: #DDDDDD !important;
}
</style>
You see the cells are hard coded. So you have to adapt. You get e.g. the following (screenshot)
And the smileys? Well, that's something different.
Of course I used an existing question of one of our questionnaires.
Attachments:
Last Edit: 2 months 4 days ago by Joffm.

Please Log in to join the conversation.

More
2 months 4 days ago #157658 by tpartner
tpartner replied the topic: Add Colors in questions
From your mock-up, it appears that you also want to colour the header labels.

1) Assign a question class "coloured-array".


2) Add something like this to the end of template.js:
$(document).ready(function() {
	$('.coloured-array').each(function(i) {
		// Assign column-specific classes
		$('table.subquestion-list tr', this).each(function(i) {
			$('> *:gt(0)', this).each(function(i){
				$(this).addClass('column-'+(i+1));
			});
		});
	});
});

3) Add something like this to the end of template.css:
.coloured-array .column-1 {	background-color: #FF5B5B;}
 
.coloured-array .column-2 {	background-color: #FF9B57;}
 
.coloured-array .column-3 {	background-color: #F4F781;}
 
.coloured-array .column-4 {	background-color: #99FDA3;}
 
.coloured-array .column-5 {	background-color: #53C170;}





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
2 months 4 days ago #157674 by mistercitrus
mistercitrus replied the topic: Add Colors in questions
www.limesurvey.org/media/kunena/attachme...11021/capture-11.png example looks spot-on
Just having some trouble getting it to activate the css changes
I've created a new template (copy of default) and made those changes, adding
/*** Array Colors are defined here***/
 
.coloured-array .column-1 { background-color: #FF5B5B;}
 
.coloured-array .column-2 {	background-color: #FF9B57;}
 
.coloured-array .column-3 {	background-color: #F4F781;}
 
.coloured-array .column-4 {	background-color: #99FDA3;}
 
.coloured-array .column-5 {	background-color: #53C170;}

to the end of the new template's css/template.css and then
$('.coloured-array').each(function(i) {
		// Assign column-specific classes
		$('table.subquestion-list tr', this).each(function(i) {
			$('> *:gt(0)', this).each(function(i){
				$(this).addClass('column-'+(i+1));
			});
		});
	});

just before the error section of scripts/template.js (line 138)

my array questions all have "coloured-array" without quotes in the CSSClass(es) in the advanced settings. I have gone over it a couple of times and don't think I've missed anything but when I perform a preview of the survey or question group I can see no changes and the source for the page if I view it doesn't show the entries in the css.

Please Log in to join the conversation.

More
2 months 4 days ago #157675 by mistercitrus
mistercitrus replied the topic: Add Colors in questions
A better way of explaining the issue is if I preview then 'view source' in the browser the CSS points to "/tmp/assets/8ca1ef2c/css/template.css" and if i inspect that file none of the changes I've made to template.css are reflected, is this a caching issue?

Please Log in to join the conversation.

More
2 months 4 days ago #157676 by mistercitrus
mistercitrus replied the topic: Add Colors in questions
Nevermind! I fixed it, Just needed to make a new survey with the new template (applying to an existing survey doesn't work) but excellent solution, thank you!

Please Log in to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now