Filter tin-canny-learndash-reporting

uotc_quiz_report_quiz_score_not_attempted_label

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

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

Description

This filter allows developers to customize the label displayed for quizzes not attempted by users in the Uncanny Toolkit Group Quiz Report. It fires when the report is being generated and the user's quiz status is determined as not attempted. Developers can change this default "Not Attempted" text to anything they need.


Usage

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

Parameters

$user_data (mixed)
This parameter holds the translated string that will be displayed when a quiz has not been attempted by a user.

Return Value

The filtered value.


Examples

<?php
/**
 * Example of how to use the uotc_quiz_report_quiz_score_not_attempted_label filter.
 * This example changes the "Not Attempted" label to "No Score Yet" for users
 * who have not attempted a specific quiz within a group report.
 *
 * @param string  $label     The default "Not Attempted" label.
 * @param WP_User $user_data The WordPress User object for the current user.
 * @return string The modified label.
 */
add_filter(
	'uotc_quiz_report_quiz_score_not_attempted_label',
	function ( $label, $user_data ) {
		// You might want to add more specific logic here,
		// e.g., check if the user has any activity at all,
		// or if this is a specific quiz that's not yet attempted.
		// For this example, we'll just change the label directly.

		// Assuming $user_data is a WP_User object or an object with user properties.
		// You could potentially check $user_data->ID or other properties
		// to determine if a more specific label is needed for this user.

		return __( 'No Score Yet', 'your-text-domain' );
	},
	10, // Priority
	2   // Accepted arguments: $label, $user_data
);

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

$user_data = $all_user_data[ $user_id ];
				$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(


Scroll to Top