uotc_quiz_report_quiz_options
Filters the quiz options displayed in the quiz report, triggered when generating the report for a specific quiz group, user, or role.
add_filter( 'uotc_quiz_report_quiz_options', $callback, 10, 4 );
Description
Allows modification of quiz options displayed in the Group Quiz Report. Developers can alter or add options based on group, user ID, or user role before report generation.
Usage
add_filter( 'uotc_quiz_report_quiz_options', 'your_function_name', 10, 4 );
Parameters
-
$options(mixed) - This parameter contains an array of options that are used to generate the quiz report.
-
$group_id(mixed) - This parameter contains the array of options for displaying quiz information in the report.
-
$user_id(mixed) - This parameter contains the ID of the group for which the quiz report is being generated.
-
$user_role(mixed) - The `$user_id` parameter contains the ID of the user for whom the quiz report is being generated.
Return Value
The filtered value.
Examples
<?php
/**
* Modify the quiz options in the group quiz report to exclude quizzes
* that are marked as "development" for administrators only.
*/
add_filter( 'uotc_quiz_report_quiz_options', function( $options, $group_id, $user_id, $user_role ) {
// Only apply this modification if the current user is an administrator.
if ( ! in_array( 'administrator', $user_role ) ) {
return $options;
}
// Assuming $options is an array of quiz data, and each quiz has a 'status' key.
// We'll filter out quizzes where the status is 'development'.
$filtered_options = array_filter( $options, function( $quiz_data ) {
// Ensure the quiz_data and its 'status' key exist before checking.
if ( isset( $quiz_data['status'] ) && 'development' === $quiz_data['status'] ) {
return false; // Exclude development quizzes
}
return true; // Keep other quizzes
} );
// Re-index the array to maintain consistent keys after filtering.
return array_values( $filtered_options );
}, 10, 4 );
?>
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:934
),
),
),
$options
);
}
return apply_filters( 'uotc_quiz_report_quiz_options', $options, $group_id, $user_id, $user_role );
}
/**
* Filter shared steps quizzes.
*
* @return bool
*/