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
  • yannickberger's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
5 years 10 months ago #169244 by yannickberger
Modify the HMTL generated for a question was created by yannickberger
Hello,

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
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 years 10 months ago #169246 by tpartner
Replied by tpartner on topic Modify the HMTL generated for a question
It looks to me like you are modifying the print file, not the question.

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.
The following user(s) said Thank You: yannickberger
The topic has been locked.
  • LouisGac
  • LouisGac's Avatar
  • Visitor
  • Visitor
5 years 10 months ago #169247 by LouisGac
Replied by LouisGac on topic Modify the HMTL generated for a question
yes it's possible, you should look how works the "bootstrap buttons" question themes:
github.com/LimeSurvey/LimeSurvey/tree/ma...vey/questions/answer
The topic has been locked.
  • LouisGac
  • LouisGac's Avatar
  • Visitor
  • Visitor
5 years 10 months ago #169248 by LouisGac
Replied by LouisGac on topic Modify the HMTL generated for a question
also, you'll find some documentation here:
github.com/LimeSurvey/LimeSurvey/tree/master/themes/question
The topic has been locked.
  • yannickberger
  • yannickberger's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
5 years 10 months ago #169304 by yannickberger
Replied by yannickberger on topic Modify the HMTL generated for a question
First thank you for your answers it sure helped me a bit.

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
The topic has been locked.
  • LouisGac
  • LouisGac's Avatar
  • Visitor
  • Visitor
5 years 10 months ago #169307 by LouisGac
Replied by LouisGac on topic Modify the HMTL generated for a question
well thank you for trying this new feature.
could you rather attach a zip file with your question theme, it will be easier to find what's going on.
The topic has been locked.
  • yannickberger
  • yannickberger's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
5 years 10 months ago #169310 by yannickberger
Replied by yannickberger on topic Modify the HMTL generated for a question
Thanks for responding so quick, Here's the zip you requested

File Attachment:

File Name: radio-accessible.zip
File Size:4 KB
The topic has been locked.
  • LouisGac
  • LouisGac's Avatar
  • Visitor
  • Visitor
5 years 10 months ago #169313 by LouisGac
Replied by LouisGac on topic Modify the HMTL generated for a question
So:

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 ;-)
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 years 10 months ago - 5 years 10 months ago #169315 by tpartner
Replied by tpartner on topic Modify the HMTL generated for a question

LouisGac wrote: You still cant hide core attributes: but it will be possible very soon, and probably the way you tried to do it ;-)

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.

Code:
        <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.
Last edit: 5 years 10 months ago by tpartner.
The following user(s) said Thank You: yannickberger
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 years 10 months ago #169316 by tpartner
Replied by tpartner on topic Modify the HMTL generated for a question


yannickberger wrote: Plus I have another question, is there somehere where i can find all the attributes you can get from LimeSurvey ?

There are two arrays of variables available in question themes - aData and surveyInfo.

To see what's available, add something like this to the end of answer.twig:

Code:
<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.
The following user(s) said Thank You: yannickberger
The topic has been locked.
  • yannickberger
  • yannickberger's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
5 years 10 months ago #169427 by yannickberger
Replied by yannickberger on topic Modify the HMTL generated for a question
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.

File Attachment:

File Name: radio_accessible.zip
File Size:15 KB


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
The following user(s) said Thank You: LouisGac
The topic has been locked.
  • LouisGac
  • LouisGac's Avatar
  • Visitor
  • Visitor
5 years 10 months ago #169435 by LouisGac
Replied by LouisGac on topic Modify the HMTL generated for a question

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.

File Attachment:

File Name: radio_accessible.zip
File Size:15 KB


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.
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose