Creating Your Own Template Variables

There will be times when you will want to create your own template variables. The template variables use a pair of filters to manipulate the text. For text before the quiz has been submitted, we use the “mlw_qmn_template_variable_quiz_page” filter. Examples for this filter include the message before quiz, the message before comments, and the message at the end of the quiz. For text after the quiz has been submitted, we use the “mlw_qmn_template_variable_results_page” filter. Examples for this filter include the user emails, the results pages, and the admin emails.

Both filters pass two parameters: $content and $qmn_quiz_array. $content is the text being filtered and $qmn_quiz_array is an array of almost every value for the quiz at that point. So, lets take a look at what will be in the array for the “mlw_qmn_template_variable_quiz_page” filter:

So, to create a template variable using that filter may look something like below. This adds the %QUIZ_NAME% variable which is replaced with the name of the quiz.

Now, lets take a look at the array for the “mlw_qmn_template_variable_results_page” filter:

So, to create a template variable using that filter may look something like below. This adds the %CORRECT_SCORE% variable which is replaced with the score that the user earned.

Lastly, you may want to add your variable to the list of variables. You can do so using the “qmn_template_variable_list” hook. So, for example:

        %CURRENT_DATE% – 

<?php }