1. Home
  2. Docs
  3. Overview
  4. Intro to Template Variables

Intro to Template Variables

What are Template Variables?

The Quiz and Survey Master plug-in helps you by taking a lot of work out of your hands by creating key parts of your quiz or survey, but quizzes and surveys are always better if you can customize them as much as possible to your specific audience and purpose. For example, in a quiz, you will probably want to customize the way the results of your quiz are displayed, including adding things like the name of the quiz, the number of questions they got right, and the correct answers.

But – these will be different for each quiz, each user, and each time that the user takes the quiz. How do you add this information to your quiz without knowing what they are beforehand? This is the value of template variables: they allow you to put a variable in the content already set for your quiz or survey (your template) and that variable be replaced with the corresponding value when the user takes the quiz.

For example, when we write the results page template, we won’t be able to put the points the user has earned because the user hasn’t taken the quiz yet. So, we can put the variable %POINT_SCORE% into the results page. Then, when the user takes the quiz, the plugin will put the total points in place of the variable for you.

USING TEMPLATE VARIABLES

There are lots of variables you can use in your templates. Almost all of the template variables follow the same format, with percent signs at the beginning and end and the variable name in the middle, ex. %QUIZ_SCORE%  (Note that there are no spaces between the % and the name – that’s important!)

Each template includes a list of variables that work in that template. For example, the Message Displayed Before Quiz template can only have the variables %QUIZ_NAME% and %CURRENT_DATE%. So be sure to check which variables are allowed before you write that masterpiece in the template.

List of Template Variables

%CONTACT_X% – This is used to show the value user entered into the contact field. Where X is the number of contact fields. For example, the first contact field would be %CONTACT_1%. Check the below example:

Great Job %CONTACT_1% Stay connected for more!

%CONTACT_ALL% – this is used to list the user values for all the contact fields entered by the user. For example:

Great Job!These are the details you entered %CONTACT_ALL%

%POINT_SCORE% – this is used to show the number of points a user earned during the quiz. For example:

Great job! You earned %POINT_SCORE% points!

%MAXIMUM_POINTS% – This is used to display the maximum possible points one can score in the given test/quiz. For Example:

Welcome! This test is of %MAXIMUM_POINTS% points. Good Luck!

%QUESTIONS_ANSWERS_EMAIL% – it is used to show the question, the answer provided by the user, and the correct answer while sending emails to the user and the quiz admin.

You answered %QUESTIONS_ANSWERS_EMAIL%

%AVERAGE_POINT% – this is the average amount of points the user earned per question. For example:

Great Job! You averaged %AVERAGE_POINT% points per question!

%AMOUNT_CORRECT% – the number of questions the user answered correctly. For example:

You answered %AMOUNT_CORRECT% questions correctly!

%AMOUNT_INCORRECT% – the number of questions the user answered incorrectly. For example:

You answered %AMOUNT_INCORRECT% questions incorrectly!

%AMOUNT_ATTEMPTED% – The total number of questions attempted by the user. For Example:

You attempted %AMOUNT_ATTEMPTED% questions in this test.

%TOTAL_QUESTIONS% – the total amount of questions that were displayed for the user. For example:

The quiz you just took had %TOTAL_QUESTIONS% questions!

%CORRECT_SCORE% – the percentage score the user earned during the quiz. For example:

Great job! You scored %CORRECT_SCORE% % on this quiz!

%USER_NAME% – the name the user entered into the Name text box. For example:

Thank you %USER_NAME% for taking this quiz!

%FULL_NAME% – This will display the full name i.e the First and Last Name of the registered Quiz taker if you’ve enabled the “Require User Login” in the Options tab. If the “Require User Login” option is disabled then the output will be blank.

Thanks %FULL_NAME% you have successfully taken the online test.

%USER_BUSINESS% – the company the user entered into the Business text box. For example:

%USER_NAME% from the company of %USER_BUSINESS% just took this quiz!

%USER_PHONE% – the phone number the user entered into the Phone text box. For example:

%USER_NAME% just took the quiz. This user can be reached at %USER_PHONE%.

%USER_EMAIL% – the email the user entered into the Email text box. For example:

%USER_NAME% just took the quiz and can be emailed at %USER_EMAIL%

%QUIZ_NAME% – the name of the quiz. For example:

Great Job %USER_NAME%! You have just taken the %QUIZ_NAME%.

%QUIZ_LINK% – this will display the link of the current quiz. For Example:

You are free to share this link with your friends %QUIZ_LINK%

%QUESTIONS_ANSWERS% – shows the questions, answers, and comments. This variable can be edited on the Text tab. An example of usage would be:

Great Job %USER_NAME%! You earned %POINT_SCORE% points. Review your answers below to see which questions you answered correctly and which ones you did not.
%QUESTIONS_ANSWERS%

%COMMENT_SECTION%  – the text the user entered into the quiz comment section (if enabled). An example of usage would be:

%USER_NAME% took the quiz and left these comments:
%COMMENT_SECTION%

%TIMER_MINUTES% – This variable is used to show the amount of time taken by the user on the quiz in minutes. Note this variable will only show the time in “minutes” excluding any decimal values of seconds. i.e. If the total time is 3 minutes 38 seconds. This will output 3.

Hi %USER_NAME%, you took %TIMER_MINUTES% minutes to complete the quiz.

%TIMER_SECONDS% – This variable is used to show the leftover seconds’ user spent on the quiz. i.e. If the total time is 3 minutes 38 seconds. This will output 38.

Hi %USER_NAME%, you took %TIMER_MINUTES% minutes and %TIMER_SECONDS% seconds to complete the quiz.

%TIMER% – This variable is used to show the total time the user took to complete the quiz in seconds. For example:

The user took %TIMER% seconds to complete this test.

%CATEGORY_POINTS_X%–  this is used to display the number of points a user earned in a specific category. An example of the usage would be:

You earned %CATEGORY_POINTS_History% points in the History category.

%CATEGORY_SCORE_X% – this is used to display the percentage score of questions the user answered correctly in a specific category. For example:

You earned %CATEGORY_SCORE_Math% in the Math category of this quiz.

%CATEGORY_AVERAGE_POINTS% – this is used to display the average amount of points the user earned between all categories.For Example:

On average, you earned %CATEGORY_AVERAGE_POINTS% points in every category for this quiz.

%CATEGORY_AVERAGE_SCORE% – this is used to display the average percentage score of questions the user answered in all categories. For example:

On average, you earned %CATEGORY_AVERAGE_SCORE% % per category for this quiz.

%CURRENT_DATE% – Displays the current data

User attempted this quiz on %CURRENT_DATE%

%QUESTION_MAX_POINTS% – This will display the Maximum points allotted to the question. This variable will work in loop, you can use this variable in the Text tab. For Example:

You have earned %QUESTION_MAX_POINTS% points for the asked question.

%FACEBOOK_SHARE% – displays the button to share on Facebook. Note the Facebook share button currently only supports sharing on personal profiles and not the Facebook page.

Be sure to share your results on Facebook by using the button below!
%FACEBOOK_SHARE%

%TWITTER_SHARE% – displays the button to share on Twitter

Be sure to share your results on Twitter by using the button below.
%TWITTER_SHARE%

%RESULT_LINK% – This will display the link of the results page. For Example:

Thanks for taking this exam, here is the results link: %RESULT_LINK%

%AVERAGE_CATEGORY_POINTS_X% – Here “X” is the Category name. This will display the average amount of points a specific category earned. For Example:

Awesome! Your Average Category Score was %AVERAGE_CATEGORY_POINTS_X%.

%POLL_RESULTS_X% – this is used to display the poll results bearing a particular question ID. Note: It’s only supported for multiple choice answers. For Example:

Here are the Poll results %POLL_RESULTS_1%

%RESULT_ID% – this is used to show the result id. That is the result number. For Example:  5

The result number for this quiz is: %RESULT_ID%

%QUESTION_ANSWER_X% – The output of this variable depends on where you are using it.

If you are using the %QUESTION_ANSWER_X% variable in the Emails Template then the output format will be according to the format of your %QUESTIONS_ANSWERS_EMAIL% Text message of the Text Tab.

And, if you are using the %QUESTION_ANSWER_X% variable in the Results Page then its output will be according to the Results Page %QUESTIONS_ANSWERS% Text message format of the Text Tab.

It can be used to display the result of a particular question. Where ‘X‘ is the Question ID. Question ID can be found in the Edit Question Window in the Questions Tab. For Example:

Your response for Question 10 was %QUESTION_ANSWER_10%

%ANSWER_X% -It can be used to display the answer to a particular question id. Where ‘X‘ is the Question ID. Question ID can be found in the Edit Question Window in the Questions Tab. The variable was introduced in QSM v8.0.3 and you won’t find it in lower versions. For Example:

The answer to Question 5 is %ANSWER_5%

%TIME_FINISHED% – It can be used to display the current time (exact time in HH:MM XM) to the user after they complete the quiz. Note that this is the website’s time on which the quiz is being attempted and not the user’s system or local time.

Your response has been recorded. You atttempted the quiz on %TIME_FINISHED%.

%QUESTION_POINT_SCORE% – This variable shows the number of points allotted to each question in the Quiz/Survey and displays it at the end of the quiz. One of the ways to use this variable with %QUESTIONS_ANSWERS% in the Text Tab of the Quizzes/Surveys Plugin.

How can we help?