Quiz::table_quiz_attempts_column( $cell_data,  $column,  $row_data )

Filter default column data for Quiz Attempts Table


Parameters

$cell_data

(Required)

$column

(Required)

$row_data

(Required)


Return

(string)


Source

File: classes/Quiz.php

	public function table_quiz_attempts_column( $cell_data, $column, $row_data ) {

		$attempt_id = dozent_array_get( 'id', $row_data );
		$quiz_id    = dozent_array_get( 'quiz_id', $row_data );
		$course_id  = dozent_array_get( 'course_id', $row_data );

		if ( $column === 'info' ) {

			$output = "";

			$quiz_title   = "<a href=' " . get_the_permalink( $quiz_id ) . " '> " . get_the_title( $quiz_id ) . " </a>";
			$course_title = "<a href=' " . get_the_permalink( $course_id ) . " '> " . get_the_title( $course_id )
			                . " </a>";

			$output .= "<p> <strong> <i class='dicon-quiz'></i> " . __( 'Quiz', 'dozent' ) . " : </strong> "
			           . $quiz_title . " </p>";
			$output .= "<p> <strong> <i class='dicon-graduation-cap'></i> " . __( 'Quiz', 'dozent' ) . " : </strong> "
			           . $course_title . " </p>";


			return $output;
		}

		if ( $column === 'time' ) {
			$output = "";

			$created_at = dozent_array_get( 'created_at', $row_data );
			$ended_at   = dozent_array_get( 'ended_at', $row_data );

			$output .= "<p> " . __( 'Started at', 'dozent' ) . " : <span class='dozent-text-muted'> "
			           . dozent_datetime_format( strtotime( $created_at ) ) . " </span> </p>";
			$output .= "<p> " . __( 'Started at', 'dozent' ) . " : <span class='dozent-text-muted'> "
			           . dozent_datetime_format( strtotime( $ended_at ) ) . " </span> </p>";

			return $output;
		}

		if ( $column === 'stats' ) {

			$output = "";

			$total_scores    = dozent_array_get( 'total_scores', $row_data );
			$earned_scores   = dozent_array_get( 'earned_scores', $row_data );
			$attempt_status  = dozent_array_get( 'status', $row_data );
			$passing_percent = dozent_array_get( 'passing_percent', $row_data );

			$earned_percentage = $earned_scores > 0 ? ( number_format( ( $earned_scores * 100 ) / $total_scores ) ) : 0;

			$result = '';
			if ( $attempt_status === 'in_review' ) {
				$result = '<span class="dozent-pill">' . __( 'Under Review', 'dozent' ) . '</span>';
			} else {
				if ( $earned_percentage >= $passing_percent ) {
					$result = '<span class="dozent-pill dozent-pill-result-pass">' . __( 'Pass', 'dozent' ) . '</span>';
				} else {
					$result = '<span class="dozent-pill dozent-pill-result-fail">' . __( 'Fail', 'dozent' ) . '</span>';
				}
			}

			$output .= "<p> " . __( 'Total Scores', 'dozent' ) . " : <span class='dozent-text-muted'> " . $total_scores
			           . " </span> </p>";
			$output .= "<p> " . __( 'Earned Scores', 'dozent' ) . " : <span class='dozent-text-muted'> "
			           . $earned_scores . " ({$earned_percentage}%)" . " </span> </p>";

			$output .= "<p> " . __( 'Result', 'dozent' ) . " : {$result} </p>";

			return $output;
		}

		if ( $column === 'status' ) {
			$status = dozent_array_get( $cell_data, dozent_attempt_statuses() );
			$output = "<span class='dozent-pill dozent-pill-status-{$cell_data}'> {$status} </span>";

			return $output;
		}

		if ( $column === 'actions' ) {
			$attempt_id = dozent_array_get( 'id', $row_data );
			$url        = add_query_arg( [ 'view_attempt_id' => $attempt_id ] );

			$output = "<a href='{$url}'> " . __( 'View', 'dozent' ) . " </a>";

			return $output;
		}

		return $cell_data;
	}


Changelog

Changelog
Version Description
DozentLMS 1.0.0 Introduced.