10/12/2020
Print Article
Intro to Template Variables Documentation for 7.0 version of plugins is available at QSM 7.0 Documentation (https://quizandsurveymaster.com/docs/v7/)
What are 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 (#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 (#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 field. 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: 1/4