Filter tin-canny-learndash-reporting

uotc_quiz_report_quiz_modal_not_attempted_label

Filters the label displayed for quizzes not attempted by a user in the quiz report modal.

add_filter( 'uotc_quiz_report_quiz_modal_not_attempted_label', $callback, 10, 1 );

Description

Filters the label displayed for quizzes that a user has not attempted within the Uncanny Toolkit's group quiz reports. Developers can modify this text to customize the user experience. This filter is applied before displaying the "Not Attempted" status in the quiz modal.


Usage

add_filter( 'uotc_quiz_report_quiz_modal_not_attempted_label', 'your_function_name', 10, 1 );

Parameters

$user_data (mixed)
This parameter contains the default text for labeling quizzes that have not been attempted by a user.

Return Value

The filtered value.


Examples

<?php
/**
 * Example function to modify the 'Not Attempted' label displayed in the quiz modal.
 *
 * This function allows administrators or theme developers to customize the text
 * shown when a user has not yet attempted a specific quiz within the group report.
 *
 * @param string   $label     The current label for 'Not Attempted'.
 * @param WP_User $user_data The user object for whom the report is being generated.
 * @return string The modified 'Not Attempted' label.
 */
function my_custom_not_attempted_label_in_quiz_modal( $label, $user_data ) {
	// You can add conditional logic here if you want to change the label
	// based on specific user roles, quiz IDs, or other criteria.

	// For example, to prepend the user's ID to the label:
	// $modified_label = sprintf( '[User ID: %d] %s', $user_data->ID, $label );
	// return $modified_label;

	// Or, to simply change the text to something else:
	// return __( 'No Quiz Taken', 'my-text-domain' );

	// In this example, we'll just append a suffix to the original label
	// to demonstrate a modification.
	$modified_label = $label . ' (Yet)';

	return $modified_label;
}
add_filter( 'uotc_quiz_report_quiz_modal_not_attempted_label', 'my_custom_not_attempted_label_in_quiz_modal', 10, 2 );

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/reporting/learndash/frontend-reports/group-quiz-report.php:501

$results[] = array(
					'ID'         => $user_data->ID,
					'user_name'  => $user_data->user_login,
					'user_email' => $user_data->user_email,
					'first_name' => $user_data->first_name,
					'last_name'  => $user_data->last_name,
					'quiz_score' => apply_filters( 'uotc_quiz_report_quiz_score_not_attempted_label', __( 'Not Attempted', 'uncanny-learndash-reporting' ), $user_data ),
					'quiz_modal' => apply_filters( 'uotc_quiz_report_quiz_modal_not_attempted_label', __( 'Not Attempted', 'uncanny-learndash-reporting' ), $user_data ),
					'quiz_date'  => apply_filters( 'uotc_quiz_report_quiz_date_not_attempted_label', __( 'Not Attempted', 'uncanny-learndash-reporting' ), $user_data ),
				);
			}
		}

		$results = apply_filters(
			'uotc_rest_api_get_quiz_data',


Scroll to Top