LLMS_Quiz_Legacy::get_correct_answers_count( int $user_id, string $unique_id = '' )

Get number of correct answers


Description Description


Parameters Parameters

$user_id

(int) (Required) [ID of user]

$unique_id

(string) (Optional) [quiz wpnonce]

Default value: ''


Top ↑

Return Return

(int) [total number of correct answers]


Top ↑

Source Source

File: includes/class.llms.quiz.legacy.php

	public function get_correct_answers_count( $user_id, $unique_id = '' ) {
		$quiz = get_user_meta( $user_id, 'llms_quiz_data', true );
		$wpnonce = '';

		if ( $quiz ) {
			foreach ( $quiz as $key => $value ) {
				if ( $unique_id == $value['wpnonce'] ) {
					$count = 0;
					$wpnonce = $value['wpnonce'];
					foreach ( $value['questions'] as $k => $v ) {
						if ( $v['correct'] ) {
							$count++;
						}
					}
				} elseif ( $value['id'] == $this->id && '' == $wpnonce ) {
					$count = 0;
					foreach ( $value['questions'] as $k => $v ) {
						if ( $v['correct'] ) {
							$count++;
						}
					}
				}
			}
		}
		return $count;
	}

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.