- Posts: 19
- Thank you received: 1
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Modify the HMTL generated for a question
- yannickberger
- Topic Author
- Offline
- New Member
I have been working around a few days in Lime Survey and I want to know if it's possible to modify the generated HTML of a question : for instance if I choose the 5 radio format question.
I created personal theme a copy of the original vanilla, I copied the orignial vanilla files in the copied theme in the upload folder, then I modified the config.xml to match my needs.
I've been looking around the template_choice-5-pt-radio.twig (located in the upload theme at \upload\themes\survey\vanilla_heg\views\subviews\printanswers\question_types)
In this case i want to add a <h1> field, but when I load my survey the change i made in my twig doesn't show up (see attachement).
I've been reading the manual but it's not very clear if it's possible or not, so my question is can we do this or not ?
And if yes wich is the file to modify to edit the answers of a survey ? and how to proceed ?
Thanks for any help
- tpartner
- Offline
- LimeSurvey Community Team
- Posts: 10104
- Thank you received: 3593
To get a sense of what is required for a custom question, install this - github.com/tpartner/LimeSurvey-5-Point-Smileys . You can then copy that and create your own using a similar file structure and config.xml file.
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
- LouisGac
- Visitor
github.com/LimeSurvey/LimeSurvey/tree/ma...vey/questions/answer
- LouisGac
- Visitor
github.com/LimeSurvey/LimeSurvey/tree/master/themes/question
- yannickberger
- Topic Author
- Offline
- New Member
- Posts: 19
- Thank you received: 1
So i've been doing some work and managed to get my theme display in Lime Survey (wich is nice) but when i try to apply my theme it doesn't save, so I guess there are some errors lefts, unfornately I've been checking the console and couldn't find a error message.
So i respected the folder organisation and took the code given in the "5pt-smiley" answer and edited to fit my needs.
What I am trying to do is have a radio list with the answers options
Here are the files in my folder and the code, can you find what's wrong or give me a hint ?
Plus I have another question, is there somehere where i can find all the attributes you can get from LimeSurvey ?
Looking forward to your answer
Answer.twig + folder display
item-row.twig
Config.xml
CSS
- LouisGac
- Visitor
could you rather attach a zip file with your question theme, it will be easier to find what's going on.
- yannickberger
- Topic Author
- Offline
- New Member
- Posts: 19
- Thank you received: 1
- LouisGac
- Visitor
1. "name" should not contains spaces or special characters, now we use "title" for that:
github.com/LimeSurvey/LimeSurvey/blob/ma...io/config.xml#L9-L10
2. You still cant hide core attributes: but it will be possible very soon, and probably the way you tried to do it
- tpartner
- Offline
- LimeSurvey Community Team
- Posts: 10104
- Thank you received: 3593
Yes, but in the meantime you can disable them and set defaults if required. If you don't want a default value, simply remove that tag.LouisGac wrote: You still cant hide core attributes: but it will be possible very soon, and probably the way you tried to do it
<attribute> <name>slider_layout</name> <category>Disabled options</category> <sortorder>12</sortorder> <inputtype></inputtype> <default>1</default> <help>This setting is not available in this question theme.</help> <caption>Use slider layout (defaulted to "On")</caption> <readonly_when_active>false</readonly_when_active> </attribute>
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
- tpartner
- Offline
- LimeSurvey Community Team
- Posts: 10104
- Thank you received: 3593
There are two arrays of variables available in question themes - aData and surveyInfo.
yannickberger wrote: Plus I have another question, is there somehere where i can find all the attributes you can get from LimeSurvey ?
To see what's available, add something like this to the end of answer.twig:
<h3>Dump of aData</h3> {{ dump(aData) }} <h3>Dump of surveyInfo</h3> {{ dump(surveyInfo) }}
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
- yannickberger
- Topic Author
- Offline
- New Member
- Posts: 19
- Thank you received: 1
I managed to implement my personal question.
My goal was to make the radio-list question accessible for person with disabilities because it was not fully the case. Accessibility guidelines required the radio-input element to be sourrounded by a <fieldset> with an accurate aria-label wich is now done with my question theme.
I put my question theme in copy in case you want to have a look of what's have been done.
I will continue to try to correct some accessible errors i've seen on different question type.
Again thank you both for your precious help, it has been really appreciated
Cheers,
Yannick
- LouisGac
- Visitor
yannickberger wrote: Thank both of you for your answers it sure did help me.
I managed to implement my personal question.
My goal was to make the radio-list question accessible for person with disabilities because it was not fully the case. Accessibility guidelines required the radio-input element to be sourrounded by a <fieldset> with an accurate aria-label wich is now done with my question theme.
I put my question theme in copy in case you want to have a look of what's have been done.
I will continue to try to correct some accessible errors i've seen on different question type.
Again thank you both for your precious help, it has been really appreciated
Cheers,
Yannick
well, if you agree, we could even make it a core question theme.