Monthly Archives: December 2020

Performance on Multiple Quizzes and Conditional Content in WatuPRO

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.

UI Customization Snippets for WatuPRO

This post will contain some free JavaScript code snippets that you can use to customize the default behavior of the quiz plugin WatuPRO.  The snippets can be placed in your theme functions, in the footer of your theme, or (easiest) using a plugin like Insert Headers and Footers.

Each snippet is coded to work on its own. Two or more snippets used at the same time may or may not work together.

Available snippets:

Right-click on an answer to strike-through

Selecting a radio button disables the others

Show only user first name in WatuPRO Play leaderboards

Right-click on an answer to strike-through

This helps the user to visually strike-through an answer to mark it wrong for their own note. The state is non-persistent and will be lost of the page is refreshed. Left click on an answer removes the strike-though and makes it selected just like the normal behavior is.

<script>
jQuery( "label.answer span" ).contextmenu(function(ev) {
  console.log(jQuery(this));
  jQuery(this).css({"text-decoration": "line-through", "font-style": "italic"});
  return false;
});

jQuery( "label.answer span" ).on('click', function() {
   jQuery(this).css({"text-decoration": "none", "font-style": "normal"});
});
</script>

Selecting a radio button disables the others

This snippets make clicking on a radio button in a “Single choice” question exclusive to all other answers – the user can no longer change their answer once they have clicked. The state is non-persistent and will be cleared after page refresh.

<script>
jQuery("input[type=radio].answer").click(function() {
   var classList = jQuery(this).attr('class').split(/\s+/);
   var thisID = jQuery(this).attr('id');
   jQuery.each(classList, function(index, item) {     
    if (item.indexOf('answerof-') != -1) {
        jQuery('.'+item).not('#'+thisID).attr("disabled", true);
    }
  });
});
</script>

Show only user first name in WatuPRO Play leaderboards

This can be used in case you don’t want user’s full “display name” shown in the leaderboard.

<script>
jQuery('.watupro-leaderboard tr:not(.current_user) td.display_name').each(function(i, elt){
 var parts = elt.innerHTML.split(' ');
  elt.innerHTML = parts[0] + ' ' + parts[1];
});
</script>

[WatuPRO Intelligence Module] Restart Quiz Attempts When Payment Is Made

From version 6.4.8 of WatuPRO (with the Intelligence module installed) there is a new feature for paid quizzes:

It gives you a new level of flexibility allowing you to sell a fixed number of attempts on a quiz for a fee. Here are a few examples how it works:

  • If you allow only one attempt on the quiz, a payment will allow a new attempt.
  • If you allow for example 5 attempts, after the 5th attempt the quiz taker will again be shown the payment option and let them have another 5 attempts.
  • If you allow 2 attempts per 24 hours and the quiz taker uses them, they can purchase another 2 attempts for the next 24 hours.
  • If you have selected that the quiz can be re-taken only after at least 12 hours from the previous attempt, user who does not want to wait can pay and void the limitation.

This new flexible option will give you even more opportunities to monetize your quizzes.