uo_tincanny_reporting_scorm_launch_url
Filters the SCORM launch URL before it's generated, allowing modifications to the launch file.
add_filter( 'uo_tincanny_reporting_scorm_launch_url', $callback, 10, 2 );
Description
Filters the SCORM launch URL before it's used for reporting. Developers can modify this URL to point to an alternative launch file or external SCORM player. The hook provides the current launch URL and the intended launch file name.
Usage
add_filter( 'uo_tincanny_reporting_scorm_launch_url', 'your_function_name', 10, 2 );
Parameters
-
$launch_url(mixed) - This parameter contains the launch URL for the SCORM content, which is typically the full path to the SCORM package's entry point.
-
$launch_file(mixed) - This parameter contains the full URL that will be used to launch the SCORM module.
Return Value
The filtered value.
Examples
<?php
/**
* Example of modifying the SCORM launch URL.
*
* This filter can be used to modify the launch URL of a SCORM module
* before it's used for reporting purposes. For instance, you might want
* to append a specific parameter for tracking or redirect to a different
* version of the SCORM package.
*
* @param string $launch_url The original SCORM launch URL.
* @param string $launch_file The SCORM launch file name (e.g., index.html).
* @return string The modified or original SCORM launch URL.
*/
add_filter( 'uo_tincanny_reporting_scorm_launch_url', function( $launch_url, $launch_file ) {
// Example: Append a UTM parameter for campaign tracking if not already present.
if ( strpos( $launch_url, 'utm_source' ) === false ) {
$launch_url = add_query_arg( 'utm_source', 'uncanny_toolkit', $launch_url );
$launch_url = add_query_arg( 'utm_medium', 'scorm_module', $launch_url );
}
// Example: If the launch file is a specific name, redirect to a staging URL.
// This is a hypothetical scenario.
if ( $launch_file === 'staging_launch.html' ) {
$launch_url = str_replace( '/wp-content/uploads/', '/staging/wp-content/uploads/', $launch_url );
}
return $launch_url;
}, 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/uncanny-articulate-and-captivate/classes/FileSystem/Module/Scorm.php:102
if ( $key_ref >= 0 ) {
$launch_file = $page[ $key_ref ];
$launch_title = $title[ $key_ref ];
$file_name = explode( '?', $launch_file );
$launch_path = dirname( $imsmanifest_file ) . DIRECTORY_SEPARATOR . $file_name[0];
$launch_url = $this->get_target_url() . '/' . $launch_file;
$launch_url = apply_filters( 'uo_tincanny_reporting_scorm_launch_url', $launch_url, $launch_file );
}
if ( ! empty( $launch_path ) && file_exists( $launch_path ) ) {
break;
}
}
}
if( empty( trim( $launch_title ) ) ) {