Create custom question template

More
10 months 2 weeks ago #163017 by cmitatakis
cmitatakis created the topic: Create custom question template
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
Attachments:

Please Log in or Create an account to join the conversation.

More
10 months 2 weeks ago #163033 by LouisGac
LouisGac replied the 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.

Please Log in or Create an account to join the conversation.

More
7 months 2 weeks ago #167938 by aellison9
aellison9 replied the 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.
Attachments:

Please Log in or Create an account to join the conversation.

More
7 months 2 weeks ago #167951 by LouisGac
LouisGac replied the 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.

Please Log in or Create an account to join the conversation.

More
7 months 2 weeks ago #167968 by aellison9
aellison9 replied the 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.

Please Log in or Create an account to join the conversation.

More
7 months 2 weeks ago #167973 by aellison9
aellison9 replied the 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.
Attachments:

Please Log in or Create an account to join the conversation.

More
7 months 2 weeks ago #168000 by tpartner
tpartner replied the 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: aellison9

Please Log in or Create an account to join the conversation.

More
7 months 2 weeks ago #168001 by aellison9
aellison9 replied the 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.

Please Log in or Create an account to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now
Join our Newsletter!