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.


One thought on “WatuPRO Hooks Reference & Developers API

  1. Pingback: [WatuPRO] How To Display Different Content Depending on Last / Not Last Quiz Attempt | CalendarScripts Blog

Leave a Reply

Your email address will not be published. Required fields are marked *