Filter tin-canny-learndash-reporting

uo_tincan_validate_rustici_scorm_first

Filters whether to check for Rustici SCORM packages before other formats. Filters whether to check Rustici SCORM packages first, prioritizing them during file processing.

add_filter( 'uo_tincan_validate_rustici_scorm_first', $callback, 10, 2 );

Description

Filters whether to prioritize Rustici SCORM package detection over other formats when identifying file types. Developers can use this hook to override the default behavior, which is not to check Rustici SCORM first. This is useful if you have specific requirements for how Rustici SCORM content is processed.


Usage

add_filter( 'uo_tincan_validate_rustici_scorm_first', 'your_function_name', 10, 2 );

Parameters

$check_rustici_scorm (bool)
Whether to prioritize Rustici SCORM detection. Default false.
$this (NewFile)
Current NewFile instance for context.

Return Value

bool True to check Rustici SCORM first, false otherwise.


Examples

add_filter( 'uo_tincan_validate_rustici_scorm_first', 'my_plugin_prioritize_rustici_scorm', 10, 2 );

/**
 * Custom filter to prioritize Rustici SCORM detection for a specific file.
 *
 * This function checks if the current NewFile instance represents a Rustici SCORM
 * package and returns true to prioritize its detection, if certain conditions are met.
 *
 * @param bool    $check_rustici_scorm The default value from the filter (false).
 * @param NewFile $this                The current NewFile instance.
 * @return bool True if Rustici SCORM should be checked first for this file, false otherwise.
 */
function my_plugin_prioritize_rustici_scorm( $check_rustici_scorm, $new_file_instance ) {
	// Let's say we want to prioritize Rustici SCORM if the file is located in a specific directory
	// or has a specific naming convention that indicates it's from Rustici.
	// For this example, we'll simulate a check based on a hypothetical method
	// `is_project_source_directory` and if the file is larger than 1MB (indicating a complex SCORM).

	// Replace this with your actual logic.
	// For example, you might check $new_file_instance->get_path() or similar properties.
	$is_special_project = false;
	if ( method_exists( $new_file_instance, 'get_path' ) ) {
		$file_path = $new_file_instance->get_path();
		if ( strpos( $file_path, '/special-rustici-projects/' ) !== false ) {
			$is_special_project = true;
		}
	}

	// Check if the file size is greater than 1MB (example condition)
	$is_large_file = false;
	if ( method_exists( $new_file_instance, 'get_size' ) ) {
		if ( $new_file_instance->get_size() > 1024 * 1024 ) {
			$is_large_file = true;
		}
	}

	// If both conditions are met, return true to prioritize Rustici SCORM detection.
	if ( $is_special_project && $is_large_file ) {
		return true;
	}

	// Otherwise, return the default value.
	return $check_rustici_scorm;
}

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/NewFile.php:225

private function get_file_type() {

		/**
		 * Filters whether to check for Rustici SCORM packages before other formats.
		 *
		 * @param bool     $check_rustici_scorm Whether to prioritize Rustici SCORM detection. Default false.
		 * @param NewFile  $this                Current NewFile instance for context.
		 * @return bool True to check Rustici SCORM first, false otherwise.
		 */
		$check_rustici_scorm = apply_filters( 'uo_tincan_validate_rustici_scorm_first', false, $this );
		
		/* Check if it is Rustici SCORM */
		if ( true === $check_rustici_scorm && $this->is_rustici_scorm() ) {
			return 'Scorm';
		}
		/* END Rustici SCORM */

		if ( $this->is_storyline() ) {
			return 'Storyline';
		}

		if ( $this->is_captivate() ) {
			return 'Captivate';
		}

		if ( $this->is_ispring() ) {
			return 'iSpring';
		}

		if ( $this->is_articulate_rise() ) {
			return 'ArticulateRise';
		}

		if ( $this->is_ispring_web() ) {
			return 'iSpring';
		}

		if ( $this->is_captivate2017() ) {
			return 'Captivate2017';
		}

		if ( $this->is_articulate_rise_2017() ) {
			return 'AR2017';
		}

		if ( $this->is_articulate_rise_360() ) {
			return 'AR360';
		}

		/* add Presenter360 tin can format */
		if ( $this->is_presenter_360() ) {
			return 'Presenter360';
		}
		/* END Presenter360 */

		/* add Lectora tin can format */
		if ( $this->is_lectora() ) {
			return 'Lectora';
		}
		/* END Lectora */

		/* add SCORM tin can format */
		if ( $this->is_scorm() ) {
			return 'Scorm';
		}
		/* END SCORM */

		/* add XAPI tin can format */
		if ( $this->is_xapi() ) {
			return 'Tincan';
		}

		/* END XAPI */

		return false;
	}

Scroll to Top