Ld_Tokens::possible_tokens_quiz_score_percent( array $tokens = array(), array $args = array() )


Parameters Parameters

$tokens

(Optional)

Default value: array()

$args

(Optional)

Default value: array()


Top ↑

Return Return

(array)


Source Source

File: src/integrations/learndash/tokens/ld-tokens.php

	public function possible_tokens_quiz_score_percent( $tokens = array(), $args = array() ) {
		if ( ! isset( $args['value'] ) || ! isset( $args['meta'] ) ) {
			return $tokens;
		}

		if ( empty( $args['value'] ) || empty( $args['meta'] ) ) {
			return $tokens;
		}
		if ( ! isset( $args['triggers_meta'] ) ) {
			return $tokens;
		}

		$trigger_meta = $args['meta'];
		$trigger_code = $args['triggers_meta']['code'];

		if ( 'LD_QUIZPERCENT' === $trigger_code ) {
			$new_tokens[] = array(
				'tokenId'         => $trigger_meta . '_achieved_percent',
				'tokenName'       => __( "User's quiz percentage", 'uncanny-automator' ),
				'tokenType'       => 'float',
				'tokenIdentifier' => $trigger_meta,
			);
			$tokens       = array_merge( $tokens, $new_tokens );
		}

		if ( 'LD_QUIZSCORE' === $trigger_code ) {
			$new_tokens[] = array(
				'tokenId'         => $trigger_meta . '_achieved_score',
				'tokenName'       => __( "User's quiz score", 'uncanny-automator' ),
				'tokenType'       => 'int',
				'tokenIdentifier' => $trigger_meta,
			);
			$tokens       = array_merge( $tokens, $new_tokens );
		}

		if ( 'LD_QUIZPOINT' === $trigger_code ) {
			$new_tokens[] = array(
				'tokenId'         => $trigger_meta . '_achieved_points',
				'tokenName'       => __( "User's quiz points", 'uncanny-automator' ),
				'tokenType'       => 'int',
				'tokenIdentifier' => $trigger_meta,
			);
			$tokens       = array_merge( $tokens, $new_tokens );
		}

		return $tokens;
	}