Filter tin-canny-learndash-reporting

uotc_quiz_report_quiz_date_not_attempted_label

Filters the label displayed for quizzes a user has not attempted in reports.

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

Description

Filters the label displayed for quizzes not attempted by a user in Uncanny LearnDash Reporting. Developers can change this default "Not Attempted" label to customize how this status is presented in quiz reports. This hook fires when a user's quiz status is being processed for display.


Usage

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

Parameters

$user_data (mixed)
This parameter is the default string displayed for quizzes that have not been attempted by a user, and it can be translated using WordPress's internationalization functions.

Return Value

The filtered value.


Examples

<?php
/**
 * Modify the "Not Attempted" label for quiz dates in the group quiz report.
 *
 * This example shows how to change the default "Not Attempted" text to something
 * more specific, like "No Quiz Date Yet", if the user has not yet attempted the quiz.
 *
 * @param string  $label     The current label for "Not Attempted".
 * @param WP_User $user_data The WP_User object for the current user.
 * @return string The modified label.
 */
add_filter( 'uotc_quiz_report_quiz_date_not_attempted_label', function( $label, $user_data ) {
	// In a real scenario, you might check for specific conditions related to the quiz
	// or user to determine if a different label is appropriate.
	// For this example, we'll assume that if the user hasn't attempted the quiz,
	// we want a slightly different message for the quiz date.

	// You would typically have logic here to determine if the user has actually
	// attempted the quiz. For demonstration purposes, we'll just change the label.

	// Check if the $user_data object is valid and has an ID.
	if ( is_a( $user_data, 'WP_User' ) && $user_data->ID ) {
		// Here you would ideally check if the user has actually attempted the quiz.
		// For example, by querying LearnDash data.
		// If the user has NOT attempted the quiz:
		return __( 'No Quiz Date Yet', 'uncanny-learndash-reporting' );
	}

	// If for some reason the user data is not as expected, return the original label.
	return $label;
}, 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:502

'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',
			$results,


Scroll to Top