LLMS_Table_Quiz_Attempts::get_data( string $key, LLMS_Quiz_Attempt $attempt )
Retrieve data for a cell.
Parameters Parameters
- $key
-
(string) (Required) The column id / key.
- $attempt
-
(LLMS_Quiz_Attempt) (Required) LLMS_Quiz_Attempt obj.
Return Return
(mixed)
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%';
$additional = $attempt->l10n( 'status' );
if ( $attempt->can_be_resumed() && $attempt->is_last_attempt() ) {
$additional .= ' - ' . esc_html__( 'Can be resumed', 'lifterlms' );
}
$value .= ' (' . $additional . ')';
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;
}
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
| Version | Description |
|---|---|
| 7.8.0 | Added information about whether the attempt can be resumed. |
| 3.26.3 | Unknown. |
| 3.16.0 | Introduced. |