Action tin-canny-learndash-reporting

uo_tincanny_reporting_questions_no_quiz_selected

Fires when no quiz is selected for Tincanny reporting, allowing custom actions before the user sees the error message.

add_action( 'uo_tincanny_reporting_questions_no_quiz_selected', $callback, 10, 1 );

Description

Fired when the Question Analysis Report page loads but no quiz has been selected. Developers can use this hook to display custom messages, enqueue scripts, or conditionally alter the report's appearance before the "Please select a quiz first" message is shown.


Usage

add_action( 'uo_tincanny_reporting_questions_no_quiz_selected', 'your_function_name', 10, 1 );

Examples

/**
 * Example of handling the uo_tincanny_reporting_questions_no_quiz_selected action hook.
 * This function adds a custom message or performs an action when no quiz is selected
 * for the Uncanny Tincanny reporting.
 */
add_action( 'uo_tincanny_reporting_questions_no_quiz_selected', function() {
	// You could log this event for debugging purposes.
	error_log( 'Uncanny Tincanny Reporting: No quiz selected. User needs to select a quiz to view reports.' );

	// You might want to add a custom class to the body for styling purposes
	// or conditionally enqueue a script that provides more guidance.
	// For this example, we'll just add a small visual cue.
	?>
	<div class="uo-tincanny-no-quiz-notice" style="background-color: #ffffe0; border: 1px solid #e6db55; padding: 10px; margin-bottom: 15px;">
		<p style="margin: 0;"><strong>Note:</strong> To see question analysis, please choose a specific quiz from the dropdown above.</p>
	</div>
	<?php
}, 10, 0 ); // 10 is the default priority, 0 means no arguments are passed to the callback function

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:876

if ( ! ultc_filter_has_var( 'quiz-id' ) ) {
					$display = 0;
				}
				// Placeholder code in case the table needs to be hidden for a logic
				if ( 1 !== $display ) {
					if ( ! ultc_filter_has_var( 'quiz-id' ) ) {

						do_action( 'uo_tincanny_reporting_questions_no_quiz_selected' );

						esc_html_e( 'Please select a quiz first.', 'uncanny-learndash-reporting' );
						echo '</div>';

						return ob_get_clean();
					}
					if ( empty( self::$questions ) ) {


Scroll to Top