uo_tincanny_quiz_report_module_first_entry
Filters the first entry data for the Tincanny quiz report module, allowing modification before display.
add_filter( 'uo_tincanny_quiz_report_module_first_entry', $callback, 10, 1 );
Description
This filter hook allows developers to modify the logic for determining the first entry in a Tincanny quiz report module. By default, it returns `false`, indicating the standard behavior. Developers can return a different value to control which entry is considered "first" or to bypass this logic entirely.
Usage
add_filter( 'uo_tincanny_quiz_report_module_first_entry', 'your_function_name', 10, 1 );
Return Value
The filtered value.
Examples
/**
* Modify the default behavior to keep only the first entry in the quiz report module.
*
* This filter allows developers to selectively keep only the first quiz attempt
* displayed in the report for a specific module. By default, it's set to false,
* meaning all entries are displayed. Setting it to true will limit the report
* to the very first attempt.
*
* @param bool $keep_first_entry Whether to keep only the first entry. Default is false.
* @return bool Whether to keep only the first entry.
*/
add_filter( 'uo_tincanny_quiz_report_module_first_entry', function( $keep_first_entry ) {
// For demonstration purposes, let's say we want to always keep only the first entry
// for a specific quiz ID, for example, if the quiz ID is 123.
// In a real-world scenario, you'd likely check for a specific user, course, or quiz.
// Example: Check if a specific quiz ID (replace 123 with your actual quiz ID)
// is being processed. This would typically involve checking a global variable
// or passing context through another filter if available.
// For simplicity in this example, we'll just always return true.
// If you wanted to conditionally enable this based on a global or option:
// if ( get_option( 'my_plugin_limit_quiz_reports' ) === 'yes' ) {
// return true;
// }
// In this simplified example, we'll always enable keeping the first entry.
return true;
}, 10, 1 ); // 10 is the priority, 1 is the number of accepted arguments.
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/quiz-module-reports.php:460
src/reporting/learndash/frontend-reports/quiz-module-reports.php:982
// Lets cache the results
$this->set_cache( $data_cache_key, $tc_quizzes );
}
$display_format = apply_filters( 'learndash_date_time_formats', get_option( 'date_format' ) . ' ' . get_option( 'time_format' ) );
$keep_report_first_entry = apply_filters( 'uo_tincanny_quiz_report_module_first_entry', false );
// Loop through H5P completed and answered modules
foreach ( $tc_quizzes as $_quiz ) {
// Sanity check that the result is valid
$score = 0 === absint( $_quiz->result ) ? '' : $_quiz->result . '%';