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

Get total time spent on quiz Subtract start time from end time


Description Description


Parameters Parameters

$user_id

(int) (Required) [ID of user]

$unique_id

(string) (Optional) [wpnonce of quiz submit]

Default value: ''


Top ↑

Return Return

(string) [formatted string representing total minutes]


Top ↑

Source Source

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

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

		$total_time = 0;
		if ( $quiz ) {
			foreach ( $quiz as $key => $value ) {
				if ( $unique_id == $value['wpnonce'] ) {
					//best attempt
					if ( $value['end_date'] ) {
						$total_time = $this->get_date_diff( $value['start_date'], $this->get_end_date( $user_id, $unique_id ) );
					}
					break;
				} elseif ( $value['id'] == $this->id ) {
					if ( $value['end_date'] ) {
						$total_time = $this->get_date_diff( $value['start_date'], $this->get_end_date( $user_id ) );
					}
				}
			}
		}
		return $total_time;
	}


Top ↑

User Contributed Notes User Contributed Notes

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