Tag Archives: update

WatuPRO Hooks Reference & Developers API

As WatuPRO is growing we see the need of many customers to enhance and customize it. We do provide some customization services but can’t handle all of the requests. Besides, we wanted to allow third party developers and companies to extend WatuPRO and add more functionality to it. So here is the first version of the developers API. Please consider this page work in progress, as is the API itself. We are starting with just a few basic function calls. More will be added and documented with the time. For simplicity the API itself will use the same version number as the plugin.

WatuPRO API Version 3.6

Main Concept

WatuPRO API uses WordPress do_action calls to create custom actions. This means that in order to add custom functionality you need to use add_action() to call your custom functions. Any custom parameters passed to do_action will be shown below.

Barebone Custom Plugin

We have created a “barebone” custom plugin that will help you with the initial setup for your custom work. Download the plugin here: watupro-custom

Available actions

do_action(‘watupro_completed_exam’, $taking_id) – called when test is completed. Passes the current completed exam record ID.

do_action(‘watupro_completed_exam_edited’, $taking_id) – called when admin/teacher edits user’s details. This option is enabled by the “Manual grading” feature in the Intelligence module. Passes the ID of the taken exam record.

do_action(‘watupro_my_certificates’) – this call is at the bottom of the “My certificates” page. The action passes no parameters but you can get the current user ID as a global. This action is already used by the Play Plugin.

do_action(‘watupro_select_show_exam’, $exam) – called when displaying the exam on the screen, and prior to any permission checks. Passes the exam object and allows you to do something with it.

do_action(‘watupro_admin_menu’) – lets you hook a custom page under watupro admin menu. Use ‘watupro_exams’ as parent.

do_action(‘watupro_user_menu’) – lets you hook a custom page under watupro user dashboard menu. Use ‘my_watupro_exams’ as parent.

do_action(‘watupro_show_exam_js’, $exam) – lets you plug your custom javascript in the quiz itself. Passes the $exam object.

Available Filters

We have started adding some filters too:

apply_filters( ‘watupro_filter_view_show_exam’, $show_exam_view, $exam); – called right before showing the quiz. You can use it to load your custom show_exam view. We recommend to still include our view (views/show_exam.php) and use it only to do something before or after it.

apply_filters( ‘watu_filter_current_question_text’, $current_text, $qct, $question_content, $correct ) – called after a question has been processed so you can modify the way it’s displayed on the final screen and live result.

The following filters allow you to modify the content of the emails sent to admin or quiz taker when a quiz is completed:

$output = apply_filters(‘watupro-email-results-taker’, $output, $taking_id);

$output = apply_filters(‘watupro-email-results-admin’, $output, $taking_id);

The following filter allows you to modify the content of user uploaded files:

$contents = apply_filters(‘watupro-user-file-uploaded’, $contents, $question_id, $detail_id, $taking_id);

$achieved = apply_filters(‘watupro-achieved-points’, $achieved, $taking_id); – allows third party plugins to modify number of points

The following filter is applied on calculating quiz grade:

watupro_calculate_grade -it’s more complicated so it’s documented separately here.

Expect a lot more actions to be added in the next versions of Watu PRO.

WatuPRO: Quick Getting Started Guide

Here is how to start really quick with WatuPRO:

  1. Go to Create new quiz page:create-exam
  2. You can skip filling almost everything – just entering quiz name is enough. However you may want to check at least the “Final page / Quiz output” tab. It gives you full control over what the user sees when they submit the quiz. Maybe there is something you want to add or remove there:
    final-screen
  3. Once the test is saved you’ll be taken to a page to create questions. Please add some, a test makes no sense without any questions.
  4. If you want to create grades, you can do this after the quiz is saved and questions created by clicking on the “Grades” link for the new quiz:show-hide-grade
  5. Go back to edit the quiz. Check the checkbox shown below to have the quiz automatically published when you save it:
    auto-publishAlternatively you can copy the quiz shortcode from the “Quizzes” page and publish it yourself in a post, page, custom post type, etc.
  6. You can view who submitted your new quiz by clicking on the hyperlinked number under the “View Results” column. You will see all the details, and you can filter through them, import, export them, etc.taken
  7. That’s it! Feel free to create quiz categories and question categories, certificates, and user groups.