SQuiz 3 uses the TWIG template engine. Most outputs are generated by the template engine so that you are able to customize it by creating your own templates.

Quiz items will get the template parameter through settings in the quiz edit page.

Templates for emails send from Evaluation area can be selected in the options menu on the result detail page.

All templates are located in /SQuiz/templates, quiz item templates have own folders with multiple template files for each layout part. A full set for quizzes look like this:

2016-08-16 12_33_17-squiz3-standard-template

If you want to build your own you have not to create each template part. All parts you omit will be searched in /standard. Learn more about Template Overloading.

Basically contain templates simple html code. Every dynamic output generated by php is enclosed with double curly braces {{ my_var }}.

Every programatically stuff is enclosed in curly braces and percent signs. For example:

<div class="squiz_checkbox_container">
    <input type="checkbox" name="quizdata[question_{{ item.id }}_{{ question.id }}]"
               id="quizdata_question_{{ item.id }}_{{ answer.id }}"
               data-question="{{ question.id }}"
               class="squiz_checkbox squiz_hide" value="{{ answer.id }}" />
    <label for="quizdata_question_{{ item.id }}_{{ answer.id }}" class="squiz_label squiz_label_checkbox">
        {{ answer.text|raw }}

This is the answer_checkbox template. You can make a copy into a new folder and change everything in this template but you must include the dynamic outputs as seen in the example above. If there is something missing like data-question tag or name tag of the input field the quiz item won’t work.

As you can see in the label tag there is as content answer.question and divided by a pip a modifier ‘raw’. This causes the text is displayed as is – html code will be put out  as html and not as text.

Be careful: Do not customize basic templates delivered with this plugin.The next update will override your changes. Make a copy of an email template respectively copy a folder and make your additions or changes there.

More about Twig can be found here.

Leave a Reply

Your email address will not be published. Required fields are marked *