Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

Create custom question template

  • cmitatakis
  • cmitatakis's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
6 years 2 months ago #163017 by cmitatakis
Create custom question template was created by cmitatakis
Hi,

I've recently downloaded the latest stable version of LimeSurvey. This is my version.php file:

$config = '3.0.5'; //The current version of this branch, LS3
$config = 345;
$config = '180118';
$config = true;
$config = '30008';

I am trying to implement a cutom question type, following the instructions that are described in github.com/LimeSurvey/LimeSurvey/blob/ma...s/question/README.md .

I use the structure exactly as described in the guidelines and I copied an existing type of question (multiple choice question type). Unfortunately, I am not able to see my new question type in LimeSurvey question type menu.
Is there anything else I should do in order to "register" the new custom type into my LimeSurvey installation?

I'm attaching the config file of the custom type of question as well as a picture of the structure of my upload folder.

Thanks in advance
The topic has been locked.
  • LouisGac
  • LouisGac's Avatar
  • Visitor
  • Visitor
6 years 2 months ago #163033 by LouisGac
Replied by LouisGac on topic Create custom question template
For now, question themes are only shown as theme for questions in the display accrodion, not as question type in question type list.

Take the example of Image Select:
create a new question, choose its type as List Radio, save, now in the Diplay accordion, you will see a selection "Question Theme" offering "image select".

In a close future, it will be possible to show those question theme as question type, and to select which question type/theme should be shown or hide (at global level and survey group level).

Also: Feel free to ask as many help as you need to create question themes, and to create bug reports if needed.
The topic has been locked.
More
5 years 11 months ago #167938 by aellison9
Replied by aellison9 on topic Create custom question template
Hello, we are currently working with version 3.7 and I have a couple of questions.

Config info:
$config = '3.7.1';
$config = 348;
$config = '180424';
$config = true;
$config = '30029';

I created a new question theme by copying the image-select question theme deployed with the release. The directory tree is attached. I removed the multiple choice version since I was simply testing to see if I could get my option to show up in the display accordion.

Question 1 - my maxdiff question theme is not showing up in the display accordion when I select a list radio question type. I do see the image-select option but cannot get my option to show up.

Question 2 - I have searched the documentation but cannot determine how you actually associate a new question theme with a question type. Any hints?

Thanks in advance for your assistance.
The topic has been locked.
  • LouisGac
  • LouisGac's Avatar
  • Visitor
  • Visitor
5 years 11 months ago #167951 by LouisGac
Replied by LouisGac on topic Create custom question template
aellison9:

php is not accepted for question themes, only twig.
So if the core question has not been converted from php to twig already, you must do it by yourself (not that hard).

Ex:
5 point choice has been converted to twig:
github.com/LimeSurvey/LimeSurvey/tree/ma.../answer/5pointchoice

But gender question has not:
github.com/LimeSurvey/LimeSurvey/tree/ma.../answer/gender/radio

We're hiring a new developper, and his first goal will be to convert all the question views to twig.
Meanwhile, you can still convert a php question view to twig by yourself, it's not that hard to do.
The topic has been locked.
More
5 years 11 months ago #167968 by aellison9
Replied by aellison9 on topic Create custom question template
Thank you LouisGac. Let me check out the examples you provided and see where that gets me. My ultimate goal is to create a question theme for maxdiff. I can get maxdiff working using the work around for 2.5 but I assume the best way in LS3 is a question theme. If I am thinking about it wrong, please let me know.

Thanks again for the examples.
The topic has been locked.
More
5 years 11 months ago #167973 by aellison9
Replied by aellison9 on topic Create custom question template
I must be doing something incorrectly or simply do not understand question themes. Relating back to your previous suggestion where PHP needs to be converted to TWIG, I could use more guidance.

Since the 5pointchoice question has already been converted to twig, I decided to test with that version. Here are the steps lI took:

1) copied the 5pointchoice files from /application/views/survey/questions/answer to my question template directory under /upload. Treeview attached.

2) created a config.xml file for the 5pointchoice question theme. config.xml attached

3) modified answer.twig to point to the local ./rows/item_row.twig

4) placed some "to be used" assets in the assets folder

At this point, when I add a 5pointchoice question to a question group, I would expect to be able to see and select my question theme within the display accordion....but the only option is "default"

Any advice as to what I am missing or do not understand would be appreciated. Thanks again.
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 years 11 months ago #168000 by tpartner
Replied by tpartner on topic Create custom question template
Here are a couple more custom questions that you can review/modify - github.com/tpartner?tab=repositories

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: Marc_Haupt, aellison9
The topic has been locked.
More
5 years 11 months ago #168001 by aellison9
Replied by aellison9 on topic Create custom question template
I cannot thank you enough Tony. Your examples pointed out a possible error in the documentation surrounding question themes and the location of files.

The LS3 documentation shows a dir tree with the question themes in the following path:
/pathToLimeSurvey/upload/question_templates/my_awesome_template

Your examples provided a different path:
/pathToLimeSurvey/upload/themes/question/my_awesome_template

Once I changed the location of the templates to the destination in your examples, my themes started showing up in the available choices.

On to the next step. Thanks again.
The following user(s) said Thank You: Marc_Haupt
The topic has been locked.
More
4 years 8 months ago #186348 by Marc_Haupt
Replied by Marc_Haupt on topic Create custom question template
This also helped me out a lot.

Thanks!
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose