Tag Archives: watupro

WatuPRO Developer’s API: Custom Grade Calculation

From version 6.0.4 WatuPro has a filter that allows plugging in your own custom grade calculation that replaces the built-in calculation. This can be useful in very specific quizzes where the grade is calculated in a non-standard way and cannot be handled by the existing functions.

This filter is a bit more complicated to explain hence we have created a separate post for it. If you are looking for the general developer’s API guide it’s here.

Using the filter:

You need to add the filter in the following way:

add_filter('watupro_calculate_grade', 'your_callback_function', 10, 8);

As you can see the filter needs 8 arguments. Here is how your callback function should be structured, with explanation of all arguments:

function your_callback_function($return_arr, $taking_id, $exam_id, $points, $percent, $cat_id, $user_grade_ids, $points_percent) {
   // expand $return_arr in the 4 constructing variables if you need:
   list($grade_text, $certificate_id, $redirect_url, $grade_object) = $return_arr;

   // your custom calculation here which may modify each of the 4 $return_arr elements
   // ...

   // return array of 4 elements
   return array($grade_text, $certificate_id, $redirect_url, $grade_object);
}

 

Attributes / Arguments

Here are the attributes in detail:

$return_arr is an array of 4 variables: $grade_text is the human-readable grade or personality type returned from the test (title and description); $certificate_id is ID of the assigned certificate, if any, otherwise 0; $redirect_url is optional URL where the user should be redirected to at the end of quiz, or false if no redirect; $grade_object is the grade as DB object returned from the wp_watupro_grades table. You can construct it yourself with the minimum required properties: “title” and “description”.

$taking_id is the ID from the watupro_taken_exams table which corresponds to this quiz attempt. VERY IMPORTANT: at the time of grade calculation the $taking_id already exists however the full details are not yet populated in watupro_taken_exams table. That’s why we pass points, percent correct, etc. as additional variables. The purpose of passing $taking_id is that it allows you to access all the individual answers from wp_watupro_student_answers table in your custom grade calculator, should you need so. Example query:

$answers = $wpdb->get_results($wpdb->prepare("SELECT * FROM ".WATUPRO_STUDENT_ANSWERS." WHERE taking_id=%d ORDER BY ID", $taking_id));

$exam_id is the ID of the test / quiz.

$points is the number of points collected. If $cat_id is 0, then $points are the total points collected on the attempt. If $cat_id is not 0, then $points is the number of points collected for that specific category ID.

$percent is the % correct answers collected. If $cat_id is 0, then $percent is the % correct answers on the whole attempt. If $cat_id is no 0, then $percent is the % correct answers for that specific category ID.

$cat_id is the ID of the category for which the grade is calculated. When 0 this means we are calculating the grade / result for the test attempt. When not 0 we are calculating grade for that specific category and you should return grade for that specific category, or none.

$user_grade_ids is used only on personality tests. It contains array with IDs of the personality types in a specific format.

$points_percent contains the percent of maximum points on this quiz attempt. If $cat_id is not 0, then it’s the percent of maximum points for that category ID.

Your custom function should always return an array of 4 elements as explained in $return_arr above – changed or unchanged. Be very careful not to mess the order of variables as you won’t be getting the expected result.

WatuPRO 6.0

The premium WordPress quiz and exams plugin WatuPRO has been updated to version 6.0.

Here is the change log between version 5.9 and 6.0:

  • Added option to choose the view of downloaded files of single user quiz attempt: snapshot or table. Defaults to snapshot. You can also choose the file format which from now on will default to .html instead of the problematic .doc file. Don’t forget you can generate PDF files instead using our free PDF bridge.
  • Improved user data removal and hooked to WP personal data eraser (for better compatibility to data protection laws).
  • Added Text Settings page where some of the user-facing texts can be changed from the administration without the need of applying translation files.
  • New shortcode added: N/a to display average % correct answer or points for a group of users answered the same way a selected question. More information here.
  • Improved watupro-segment-stats shortcode: now it lets you display the % of users from the same segment who received the same grade or even category grade in a question category.
  • Fixed the non-working “delete my results” link when the My Tests page was used in a shortcode. The “export data” link will be available for users only when they access the dashboard version of the page.
  • A new option on the quiz General Settings tab lets you specify different design theme for each quiz.
  • Added attribute “return” to the watupro-users-completed shortcode. When return=”percent” it will calculate the % of quiz attempts vs. total instead of showing the number that satisfies the criteria defined by the other attributes. Added attribute “catgrade_id” to calculate number of attempts achieved a specific category grade. Note that category grade IDs were not recorded up to this version so using this parameter on tests which had data before the change may return inaccurate results.
  • The optional answer explanation box in the administration is now hidden by default  when adding new question and can be toggled by a link to save screen space.
  • When quiz accept file uploads for open-end questions a check for allowed file sizes and types will be performed also before submitting the quiz (javascript based, will work only in modern browsers).
  • Added design configurations for the timer of timed tests: it can now be configured to scroll together with the screen.
  • The timer position now be distanced from left or right, top or bottom by choice.
  • The segment-stats shortcode now allows calculating the % of users who got worse or better grade when the criteria is “grade” or “category_grade”.
  • After copying of quiz / questions the page will redirect back to all quizzes to avoid confusion.
  • Added option to mass-change “accept user feedback” on questions. (The mass-change options become available on the Manage Questions page at the bottom, only after you select at least one checkbox from the table with questions).
  • Question paginator position can now be top or bottom.
  • In the administration questions can now be reordered by draggind and dropping the row with the question.
  • Open-end questions that accept file uploads can also require the file to be uploaded to consider the question answered.
  • You can now override our main.js file the same way you can override view files.
  • The option to allow users to rate questions now can be enabled per individual question instead of all the questions in the test.
  • Added parameter “public” to the watupro-takings shortcode to allow public read only access to the page.
  • On View results page added information how the grades on this test are calculated. Helps if you receive some unexpected grades. Helps us to answer questions as well.
  • The two custom fields in “Ask user for contact details” section can now be drop-down fields with pre-defined values.
  • When the option “answer to each question can be seen immediately by pressing a button” is selected, you have a new option that allows you not to require the user to attempt answering the question first.
  • Added option to calculate & display total points earned from registered users on your main WP Users page.
  • A new variable %%GROUP-MANAGER% in the admin email field in User and Email Settings tab allows you to specify that the email with test results will be sent to managers from the same user groups of the respondent.
  • User group IDs are now visible in User Groups page.
  • [Namaste! PRO Integration] For class managers with access to view test results only the results of students in their classes will be shown.
  • [Intelligence module] “Fill the gaps” questions now can have per-question case sensitive mode.
  • [Intelligence module] Added new bundle type: number of unque tests – you don’t need to specify which paid tests exactly or test category. It’s good for selling packages of 5, 10, etc paid tests.
  • [Intelligence module] Added configuration for font size of “Fill the gaps” questions gaps & drop-down boxes (on WatuPRO Settings page).
  • [Intelligence module] Added option to hide the “My Quizzes” page for any of the user roles that are given rights to manage the tests.
  • [Reporting module] Added parameter “user_choice” to the watupror-poll shortcode to allow marking the user’s answer when the shortcode is used at the end of the test. See the WatuPRO -> Help page in your menu for full details.
  • Fixed issues with multiple quiz certificates.
  • [Fixed bug] When “Apply difficulty level restrictions per user account” is selected questions with no difficulty level were not allowed to users with some difficulty level in their profile.
  • [Fixed bug] When “Sum up subcategory performance” was selected the parent category was not included in the Advanced Settings tab for reordering. If %%CATGRADES%% was not used at the Final screen, you could not use the %%CATEGORY-xxx% variables on these parent categories.
  • [Fixed bug] When a timed quiz also asked for contact details at the beginning of a quiz with a required checkbox it was impossible to submit the quiz due to wrong “field required” message.
  • [Fixed bug] The column “% of points” was showing negative % in some cases. It should always show between 0% and 100%.
  • [Fixed bug] When quiz reused question from other quizzes it could not be reverted back to using its own questions.
  • [Fixed bug] The new way of reordering questions in admin did not work on some installations.

Using Certificates in WatuPRO

This pictorial will guide you step by step through the process of creating and assigning certificates in WatuPRO.

In this guide:

Creating Certificates

Go to WatuPRO -> Certificates and click on “Add new” link. You will be taken to a page with a simple form to create a certificate:

This is as simple as creating a post in your site. You can insert and format text and pictures just like everywhere in WordPress.

Attention: If you have a ready design for your certificate or prefer to design it yourself using HTML we strongly recommend not using the rich text editor at all and selecting this option at WatuPRO Certificates page:

In such case you will be presented a regular textarea where to create or paste your HTML code. This is because the WordPress rich text editor is known to “fix” the code to its own likes, which can often create problems with carefully designed pages.

Note that when this option is selected we will not automatically add new lines on the front-end! You are entering HTML code and you should use <br> or <p> tags where appropriate.

 

Under the box for creating certificate you will find several variables which you can use inside the certificate so they are replaced with dynamic content when the certificate is displayed.

The certificate can have expiration date or require admin approval.

Certificate Verification

From version 6.5.5.5 WatuPRO supports verification of the issued certificates. For each of them the plugin generates an unique URL which can be used to verify that this certificate is really issued by your site.

All you need to do is to use the variable %%VERIFICATION%% inside the certificate contents. It will output the URL for verification. It’s not a hyperlink so use the rich text editor or a HTML code to make it clickable.

If you have the plugin QRCode installed and active, instead of an URL the variable will print a QR code. In such case do not hyperlink it. The QR code will automatically take the user who scanned it to the URL for verification.

The verification URL is not the same as public certificate URL. It does not expose the certificate contents and does not require the certificate to be marked as public. All it does is to show a text saying whether the certificate is valid or not.

PDF Certificates

Normally certificates are just rendered in the browser when they are achieved. This is very convenient because it works on all devices and even lets you include video or audio in the certificate.

However many customers need certificates that are printable and easy to download. PDF is the industry standard for this. To create such certificate you need to download and install our free PDF bridge. This plugin is large so the functionality is intentionally not included in the WatuPRO core.

Once installed and activated you need to select and save the following option on the WatuPRO Certificates page:

After that your Add/Edit Certificate page in WatuPRO will get a new section called PDF settings:

Certificates will be created in PDF format accordingly to your selections in this area.

So far we have covered the most important points of creating certificates. But how do quiz takers actually get them? To do this we need first to talk about the difference between single-quiz and multiple quiz certificates.

Single Quiz or Multiple Quiz Certificates

By default certificates in WatuPRO can get assigned when user completes a quiz and if they achieve a desired result (grade). More on this in the next section.

However you can define certificates that get assigned upon completing several tests. To create such certificate select the multiple quiz option, then select the quizzes and the desired criteria:

Assign Certificates to Quizzes

So, how do certificates actually get assigned? There is a difference between single-quiz and multiple quiz certificates:

  • Single quiz certificates get assigned when user completes a quiz with a desired grade. How do you define this grade? By going to Grades link for the quiz you want to issue certificate and assigning the certificate to the successful grade(s) of that quiz:
    Save the grade and when the user completes the quiz and achieves this grade they will be assigned the certificate.
    If you have a quiz that defines no grades but still want to assign a certificate you must create one “catch-all” grade that will cover every possible outcome of the quiz (from 0% to 100% correct answers) and assign the certificate to it. You don’t have to show this grade in the end of the quiz if you don’t want to. However it must exist.
    You can also have more than one grade in the quiz assign the certificate or even have different grades assign different certificates.Don’t let the phrase “single quiz certificate” mislead you. Such certificates are not tied up to only one quiz. You can very well reuse them in any of your tests.
  • Multiple quiz certificates get assigned automatically when all requirements are met. This means all the required tests are completed by the user AND the average points and percentages required are achieved. If you allow multiple attempts on your quizzes and the respondent doesn’t achieve the required averages on their first attempt, but achieve them later, they will get the certificate when the conditions are achieved.

Multiple Certificates from a Single Test Attempt?

After version 6.0 of WatuPRO it’s possible to achieve multiple certificates in a single quiz attempt. The respondent can get one “single-quiz” certificate assigned to the achieved grade + any number of multiple-quiz certificates as long as completing the current test has triggered their assignment.

When multiple certificates are assigned, the %%CERTIFICATE%% variable will contain individual links to all of them. If you are using the PDF bridge and have selected to send certificates by email as attachments, each of the approved certificates will be attached to the email.

OK, now you know how certificates are assigned. But how do users actually get to see them:

How Users Can See Their Certificates

  • In the “Final screen” of the quiz. The easiest method to let the user know they achieved a single quiz certificate is to include the %%CERTIFICATE%% variable in the “Final page / Quiz output” box of the quiz. If a certificate is not earned the variable will be replaced with nothing. If the certificate is earned it will contain the text “You can now print your certificate” with a link to it.
  • In their dashboard. By default all registered users get “My Certificates” page in their dashboard, under the “My Quizzes” (or “My Tests”, “My Exams”, etc. depending on your choice of words) page. They can refer to these certificates any time.
  • By email. You can select to have an email sent to the user when they complete the test. From Edit Quiz page go to User and Email related settings tab and select:
    Then make sure that the %%CERTIFICATE%% variable is included in the quiz Final page or the email contents box so the user gets a link to the certificate in the email.
    If you have installed the PDF bridge and selected that certificates will be generated as PDF, you can skip the %%CERTIFICATE%% variable in the email contents and instead have the PDF attached to the message by selecting this option:

    Certificates that require admin approval will not be sent by email when the quiz is completed! Instead they can be sent when the approval is done and only if you have configured the following section:

Troubleshooting Not Assigned Certificates

A certificate is not assigned as expected? Please check the following most common problems:

  • It’s a single quiz certificate and the desired grade is not achieved. You can see the result of the particular user in your Quizzes -> View results page. Is the desired grade achieved? Probably not. If yes, please make sure you have actually assigned the certificate to the grade in Quizzes -> Grades page.
  • It’s a multiple quiz certificate and the criteria are not met. This is harder to check because you need to find all user’s attempt on the required tests and calculate the averages. However we can assure you that WatuPRO does these calculations correctly and this has been tested multiple times. So even if you are sure something is not OK please double and triple check your Math before emailing us.
  • It’s a certificate requiring admin approval. These certificates do not get issued until admin manually approves them.
  • It’s a certificate with expiration date and has expired.

If you have gone through the troubleshooting list and still don’t have a certificate assigned as expected you can contact us to have a look. In such case you MUST provide URL of your site, administrator’s login and clear explanation which certificate had to be assigned to which user but it did not happen.

Paid Certificates

If you have the Intelligence module installed you can also charge for getting a certificate. In such case the test taker must first complete the test(s) successfully so they earn the certificate. After that, when the access the link to see it they will be presented the selected payment methods. After payment the certificate becomes available for viewing and/or downloading.

Assuming you have set some payment methods in WatuPRO Settings page, enabling paid certificates requires just setting a price on the Add / Edit Certificate page:

Note that paid certificates cannot be sent as attachment to emails – you can however insert the link to the certificate so users can pay when they try to visit / download it.

Coupon codes and bundles cannot be used for paid certificates. Users with rights to manage WatuPRO will always be able to see paid certificates.

If you use our free WooCommerce bridge and have WatuPRO 6.3 or a newer version you will be able to also sell certificates as WooCommerce products.