Here is a new super power of the WordPress quiz plugin WatuPRO, available from version 6.4.8.5: a shortcode to calculate the performance of a logged in user on multiple quizzes. It can display:
- The total points collected
- The average percent correct answers on all quizzes.
- The average percent achieved points from maximum points in every quiz.
- The total number of correct answers.
- The total number of wrong answers.
- The total number of unanswered questions.
- The total maximum points that could be collected.
The stats are based on all attempts of the logged in user of the quizzes whose IDs are passed in a shortcode attribute.
The new feature also allows you conditionally display any content based on the total points collected, average percent correct answers, or average percent from maximum points.
Let’s see how this all works.
The Shortcode and The Variables
Note: from version 6.6.7.3 you can pass the parameter use_only_latest_attempts=1 to base the calculations only on the latest attempt of the user instead of all attempts.
It is a content-enclosing shortcode and will not produce any output by its own. You need to enclose the content that you want to use along with variables that you want calculated. The shortcode has a required parameter quiz_ids which should contain the ID of the quizzes that will be used, separated by comma. Example:
[watupro-multiquiz quiz_ids="2,3,25"]
On the 3 quizzes you collected a total of %%MULTI_POINTS%% points and you gave average of %%MULTI_PERCENTAGE%%% correct answers.
[/watupro-multiquiz]
Here are all the available variables for this shortcode:
- %%MULTI_POINTS%% – the total points collected
- %%MULTI_PERCENTAGE%% – the average percent correct answers
- %%MULTI_PERCENTAGEOFMAX%% – the average percent points collected from maximum points possible (the stat is calculated for each quiz attempt and then dividied. It’s NOT an average of all collected points vs all possible points).
- %%MULTI_CORRECT%% – the total number of correct answers given
- %%MULTI_WRONG%% – the total number of wrong answers given
- %%MULTI_EMPTY%% – the total number of unanswered questions
- %%MULTI_MAX-POINTS%% – the total maximum points possible from all quizzes and all attempts
If the user is not logged in or if the quiz_ids attribute is not passed, the shortcode will not display anything.
The Conditional Parameters
This shortcode can be used also to conditionally display some content based on how the user has performed on the selected tests. You can use conditions for point range, percentage range and range for percent from maximum points. All conditions can be used at the same time.
The content enclosed between such shortcode will be shown only if all the conditions are met. This is a very useful way to display something only when the conditions are met. It’s almost like the standard quiz grading except that the grade will not be stored anywhere and cannot trigger certificates or other actions.
Here’s how to use it:
[watupro-multiquiz quiz_ids="2,3,25" condition_points="10-25" condition_percent_correct="50-100" condition_percent_max="50-100"]
Congratulations you did extremely well and earned a discount code: BIGDISCOUNT
On the 3 quizzes you collected a total of %%MULTI_POINTS%% points and you gave average of %%MULTI_PERCENTAGE%%% correct answers.
[/watupro-multiquiz]
You can skip any of the condition attributes to use only one or two of them.