Warning: Array to string conversion in /home/customer/www/docs.automatorplugin.com/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 825

Warning: foreach() argument must be of type array|object, string given in /home/customer/www/docs.automatorplugin.com/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 830
TUTORLMS_QUIZPASSED::passed( $attempt_id )

Validates Trigger.


Warning: Array to string conversion in /home/customer/www/docs.automatorplugin.com/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 825

Warning: foreach() argument must be of type array|object, string given in /home/customer/www/docs.automatorplugin.com/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 830

Parameters Parameters

$attempt_id

(Required) Post ID of the attempt


Source Source

File: src/integrations/tutorlms/triggers/tutorlms-quizpassed.php

	public function passed( $attempt_id ) {
		// get the quiz attempt.
		$attempt = tutor_utils()->get_attempt( $attempt_id );
		// Bail if this not the registered quiz post type
		if ( 'tutor_quiz' !== get_post_type( $attempt->quiz_id ) ) {
			return;
		}
		// bail if the attempt isn't finished yet.
		if ( 'attempt_ended' !== $attempt->attempt_status ) {
			return;
		}

		// bail if they haven't passed.
		if ( ! Automator()->helpers->recipe->tutorlms->options->was_quiz_attempt_successful( $attempt ) ) {
			return;
		}
		// current user.
		$user_id = get_current_user_id();
		// trigger entry args.
		$args = [
			'code'    => $this->trigger_code,
			'meta'    => $this->trigger_meta,
			'post_id' => $attempt->quiz_id,
			'user_id' => $user_id,
		];
		// run trigger.
		Automator()->maybe_add_trigger_entry( $args, true );
	}

Top ↑

Changelog Changelog

Changelog
VersionDescription
2.4.0Introduced.