uo_tincanny_reporting_questions_no_multiple_choice
Fires after the quiz reporting section displays questions that are not multiple-choice.
add_action( 'uo_tincanny_reporting_questions_no_multiple_choice', $callback, 10, 1 );
Description
Fires when no multiple-choice questions are found within a selected quiz. Developers can use this action to display custom messages or add alternative content when this specific scenario occurs in the Uncanny Toolkit's reporting features.
Usage
add_action( 'uo_tincanny_reporting_questions_no_multiple_choice', 'your_function_name', 10, 1 );
Examples
/**
* Add a custom message or perform an action when there are no multiple-choice questions in a quiz report.
*
* This example demonstrates how to hook into the 'uo_tincanny_reporting_questions_no_multiple_choice'
* action to log a notification or display an additional message to the administrator.
*/
add_action( 'uo_tincanny_reporting_questions_no_multiple_choice', function () {
// In a real-world scenario, you might want to:
// 1. Log this event for debugging or auditing purposes.
// 2. Display a more prominent alert to the user.
// 3. Potentially trigger an email notification to an administrator.
// For this example, we'll simply add a hidden notification to the admin area.
// This is just a placeholder and would need to be implemented more robustly.
if ( is_admin() ) {
// This is a simplified example. In a production environment,
// you'd likely use a more structured way to add admin notices.
// For instance, using the 'admin_notices' hook and checking a flag set by this action.
?>
<script type="text/javascript">
console.warn('Tincanny Report: No multiple-choice questions found for the selected quiz.');
</script>
<?php
}
// If you wanted to add a message to the front-end report itself
// and the hook was designed to accept arguments, you would do something like:
// global $post; // Assuming $post is available and relevant in the context
// if ( isset( $post->ID ) ) {
// $quiz_id = get_post_meta( $post->ID, 'related_quiz_id', true ); // Example: get quiz ID
// if ( ! empty( $quiz_id ) ) {
// error_log( sprintf( 'User %d: No multiple-choice questions found for quiz ID %d in Tincanny report.', get_current_user_id(), $quiz_id ) );
// }
// }
}, 10, 0 ); // 10 is the default priority, 0 is the number of accepted arguments.
Placement
This code should be placed in the functions.php file of your active theme, a custom plugin, or using a code snippets plugin.
Source Code
src/uncanny-question-analysis-report/question-analysis-report.php:884
esc_html_e( 'Please select a quiz first.', 'uncanny-learndash-reporting' );
echo '</div>';
return ob_get_clean();
}
if ( empty( self::$questions ) ) {
do_action( 'uo_tincanny_reporting_questions_no_multiple_choice' );
esc_html_e( 'There are no multiple choice questions in this quiz.', 'uncanny-learndash-reporting' );
echo '</div>';
return ob_get_clean();
}
}