Filter tin-canny-learndash-reporting

uo_tincanny_question_analysis_report_cols

Filters the columns displayed in the Uncanny Toolkit question analysis report.

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

Description

Filters the columns displayed in the Question Analysis Report. Developers can add, remove, or modify column definitions to customize the report's output. The `$cols` parameter is an associative array where keys are internal column identifiers and values are their display titles.


Usage

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

Return Value

The filtered value.


Examples

// Example: Add a custom column to the Uncanny Toolkit Question Analysis Report
// This will add a new column called "All Answers" which displays a comma-separated
// list of all possible answers for each question.
add_filter(
	'uo_tincanny_question_analysis_report_cols',
	function( $columns, $class_name ) {
		// Ensure we're working with an array
		if ( ! is_array( $columns ) ) {
			return $columns;
		}

		// Add a new column key and its translated title
		$columns['all-answers'] = __( 'All Answers', 'uncanny-learndash-reporting' );

		// You could also reorder columns here if needed. For example, to place
		// 'all-answers' after 'correct-answer':
		// $new_columns = array();
		// foreach ( $columns as $key => $value ) {
		// 	$new_columns[ $key ] = $value;
		// 	if ( $key === 'correct-answer' ) {
		// 		$new_columns['all-answers'] = __( 'All Answers', 'uncanny-learndash-reporting' );
		// 	}
		// }
		// return $new_columns;

		return $columns;
	},
	10, // Priority
	2   // Accepted args: $columns, $class_name
);

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

public static function setup_columns() {
		self::$columns = apply_filters(
			'uo_tincanny_question_analysis_report_cols',
			array(
				'question-title'  => __( 'Question title', 'uncanny-learndash-reporting' ),
				'question'        => __( 'Question', 'uncanny-learndash-reporting' ),
				'correct-answer'  => __( 'Correct answer', 'uncanny-learndash-reporting' ),
				'correct-percent' => __( '%', 'uncanny-learndash-reporting' ),
				'times-asked'     => __( 'Times asked', 'uncanny-learndash-reporting' ),
				'avg-time'        => __( 'Average time (s)', 'uncanny-learndash-reporting' ),
			),
			__CLASS__
		);
	}

Scroll to Top