uo_tincanny_data_consider_scaled_score
Filters whether the scaled score should be considered, firing before data processing for the Tincanny integration.
add_filter( 'uo_tincanny_data_consider_scaled_score', $callback, 10, 1 );
Description
Fires before Tincanny data is processed to determine if scaled scores should be considered. Developers can use this filter to force the consideration of scaled scores by returning `true`, or to prevent it by returning `false`. The default value is `false`, meaning scaled scores are not considered by default.
Usage
add_filter( 'uo_tincanny_data_consider_scaled_score', 'your_function_name', 10, 1 );
Return Value
The filtered value.
Examples
// Ensure that we only consider scaled scores if a specific post type is present.
add_filter( 'uo_tincanny_data_consider_scaled_score', function( $consider_scaled_score ) {
// This is a placeholder. In a real scenario, you'd likely check some global settings,
// custom fields on the post, or other conditions to dynamically decide whether
// to consider scaled scores.
// For demonstration, let's say we only want to consider scaled scores for 'sfwd-quiz' post types.
// This example assumes this filter is being used within a context where $lesson->post_type is available.
// However, as the hook is defined outside the loop, this direct check might not be feasible here.
// A more practical approach might involve passing context to the filter if the hook allowed it,
// or relying on external conditions evaluated within the filter.
// Since the hook doesn't pass context, we'll simulate a scenario where a site-wide option
// determines this behavior.
$option_name = 'uncanny_tincan_use_scaled_scores';
$use_scaled_scores_option = get_option( $option_name, false );
if ( $use_scaled_scores_option ) {
return true;
}
return $consider_scaled_score;
}, 10, 1 );
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-tincan/classes/Database/Admin.php:477
'sfwd-topic',
'sfwd-quiz',
'sfwd-certificates',
'sfwd-assignment',
'groups',
);
$consider_scaled_score = (bool) apply_filters( 'uo_tincanny_data_consider_scaled_score', false );
foreach ( $data as $row ) {
$site_url = site_url();
$lesson = get_post( $row->lesson_id );
if ( ! empty( $lesson ) && in_array( $lesson->post_type, $tincan_post_types, true ) ) {