-
Notifications
You must be signed in to change notification settings - Fork 135
/
results.php
82 lines (71 loc) · 2.09 KB
/
results.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<?php
/**
* Quiz Results Template
*
* @package LifterLMS/Templates
*
* @since 1.0.0
* @since 3.35.0 Access `$_GET` data via `llms_filter_input()`.
* @since 4.17.0 Return early if accessed without a logged in user.
* @since 5.9.0 Stop using deprecated `FILTER_SANITIZE_STRING`.
* @version 5.9.0
*
* @property LLMS_Quiz_Attempt $attempt Attempt object.
*/
defined( 'ABSPATH' ) || exit;
global $post;
$quiz = llms_get_post( $post );
if ( ! $quiz ) {
return;
}
$student = llms_get_student();
if ( ! $student ) {
return;
}
$attempts = $student->quizzes()->get_attempts_by_quiz(
$quiz->get( 'id' ),
array(
'per_page' => 25,
'sort' => array(
'attempt' => 'DESC',
),
)
);
$key = llms_filter_input_sanitize_string( INPUT_GET, 'attempt_key' );
$attempt = $key ? $student->quizzes()->get_attempt_by_key( $key ) : false;
if ( ! $attempt && ! $attempts ) {
return;
}
?>
<div class="clear"></div>
<div class="llms-quiz-results">
<?php
/**
* llms_single_quiz_attempt_results
*
* @hooked lifterlms_template_quiz_attempt_results - 10
*/
/**
* Action fired prior to the output of LifterLMS Quiz Results HTML
*
* @since Unknown
*
* @param LLMS_Quiz_Attempt $attempt Attempt object.
*/
do_action( 'llms_single_quiz_attempt_results', $attempt );
?>
<?php if ( $attempts ) : ?>
<section class="llms-quiz-results-history">
<h2 class="llms-quiz-results-title"><?php esc_html_e( 'View Previous Attempts', 'lifterlms' ); ?></h2>
<select id="llms-quiz-attempt-select">
<option value="">-- <?php esc_html_e( 'Select an Attempt', 'lifterlms' ); ?> --</option>
<?php foreach ( $attempts as $attempt ) : ?>
<option value="<?php echo esc_url( $attempt->get_permalink() ); ?>">
<?php // Translators: %1$d = Attempt number; %2$s = Grade percentage; %3$s = Pass/fail text. ?>
<?php echo esc_html( sprintf( __( 'Attempt #%1$d - %2$s (%3$s)', 'lifterlms' ), $attempt->get( 'attempt' ), round( $attempt->get( 'grade' ), 2 ) . '%', $attempt->l10n( 'status' ) ) ); ?>
</option>
<?php endforeach; ?>
</select>
</section>
<?php endif; ?>
</div>