uo_tin_can_filter_activity_label
Filters the label for the Quiz Tin Can activity when generating reports, allowing customization of the displayed name.
add_filter( 'uo_tin_can_filter_activity_label', $callback, 10, 1 );
Description
Filters the label displayed for quiz activities in Tin Can reporting. Developers can modify this label to customize how quiz activities are identified, for example, to better match internal terminology or localization. The default label is 'Quiz'.
Usage
add_filter( 'uo_tin_can_filter_activity_label', 'your_function_name', 10, 1 );
Return Value
The filtered value.
Examples
/**
* Example function to modify the Tin Can filter activity label.
*
* This function demonstrates how to use the 'uo_tin_can_filter_activity_label'
* filter to change the default label for quiz activities in the Tin Can reporting.
*
* @param string $label The original activity label.
* @param mixed $param2 The second parameter passed to the filter (currently unused).
*
* @return string The modified activity label.
*/
function my_custom_tin_can_quiz_label( $label, $param2 ) {
// Let's assume we want to append a suffix to the label if a specific condition is met.
// For this example, let's say we want to append "(Custom)" if the current user has a specific role.
if ( current_user_can( 'editor' ) ) {
return $label . ' (Custom)';
}
// If the condition is not met, return the original label.
return $label;
}
add_filter( 'uo_tin_can_filter_activity_label', 'my_custom_tin_can_quiz_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/xapi-quiz/templates/xapi-quiz-filter.php:194
src/reporting/tin-can/templates/tc-tincan-filter.php:198
</div>
</div>
<div class="reporting-tincan-filters-col reporting-tincan-filters-col--3">
<div class="reporting-tincan-section__title">
<?php echo ucfirst( apply_filters( 'uo_tin_can_filter_activity_label', esc_html_x( 'Quiz', 'Tin Can Filter Activity name', 'uncanny-learndash-reporting' ), false ) ); ?>
</div>
<div class="reporting-tincan-section__content">
<div class="reporting-tincan-section__field">
<label for="tc_filter_quiz"><?php esc_html_e( 'Question', 'uncanny-learndash-reporting' ); ?></label>
<select class="uo-admin-select" name="tc_filter_quiz" id="tc_filter_quiz">
<?php if ( ! empty( $tc_quiz_filter ) ) { ?>
<option value="<?php echo esc_attr( $tc_quiz_filter ); ?>" selected="selected">