LLMS_Table_Quiz_Attempts::get_data( string $key, obj $attempt )

Retrieve data for a cell


Parameters Parameters

$key

(string) (Required) the column id / key

$attempt

(obj) (Required) LLMS_Quiz_Attempt obj


Top ↑

Return Return

(mixed)


Top ↑

Source Source

File: includes/admin/reporting/tables/llms.table.quiz.attempts.php

	protected function get_data( $key, $attempt ) {

		switch ( $key ) {

			case 'student':
				$value   = '–';
				$student = $attempt->get_student();
				if ( $student ) {
					$value = $student->get_name();
				}
				break;

			case 'attempt':
				$value = '#' . $attempt->get( $key );
				break;

			case 'grade':
				$value  = $attempt->get( $key ) ? $attempt->get( $key ) . '%' : '0%';
				$value .= ' (' . $attempt->l10n( 'status' ) . ')';
				break;

			case 'start_date':
			case 'end_date':
				$value = '–';
				$date  = $attempt->get( $key );
				if ( $date ) {
					$value = date_i18n( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ), strtotime( $date ) );
				}

				break;

			case 'id':
				$value = sprintf( '%2$d (%1$s)', $attempt->get_key(), $attempt->get( 'id' ) );

				$url = LLMS_Admin_Reporting::get_current_tab_url(
					array(
						'tab'        => 'quizzes',
						'stab'       => 'attempts',
						'quiz_id'    => $attempt->get( 'quiz_id' ),
						'attempt_id' => $attempt->get( 'id' ),
					)
				);

				$value = '<a href="' . esc_url( $url ) . '">' . $value . '</a>';

				break;

			default:
				$value = $key;

		}// End switch().

		return $value;
	}


Top ↑

Changelog Changelog

Changelog
Version Description
3.16.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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