-
Notifications
You must be signed in to change notification settings - Fork 135
/
results-attempt-questions-list.php
106 lines (89 loc) · 4.5 KB
/
results-attempt-questions-list.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
<?php
/**
* List of attempt questions/answers for a single attempt
*
* @since 3.16.0
* @since 3.17.8 Unknown.
* @since 5.3.0 Display removed questions too.
* @since 7.3.0 Script moved into the main llms.js.
* @version 7.3.0
*
* @param LLMS_Quiz_Attempt $attempt LLMS_Quiz_Attempt instance.
*/
defined( 'ABSPATH' ) || exit;
?>
<ol class="llms-quiz-attempt-results">
<?php
foreach ( $attempt->get_question_objects() as $attempt_question ) :
$quiz_question = $attempt_question->get_question();
if ( ! $quiz_question ) { // Question missing/deleted.
?>
<li class="llms-quiz-attempt-question type--removed status--<?php echo esc_attr( $attempt_question->get_status() ); ?> <?php echo $attempt_question->is_correct() ? 'correct' : 'incorrect'; ?>">
<header class="llms-quiz-attempt-question-header">
<span class="toggle-answer">
<h3 class="llms-question-title"><?php esc_html_e( 'This question has been deleted', 'lifterlms' ); ?></h3>
<span class="llms-points">
<?php echo esc_html( sprintf( __( '%1$d / %2$d points', 'lifterlms' ), $attempt_question->get( 'earned' ), $attempt_question->get( 'points' ) ) ); ?>
</span>
<?php echo wp_kses_post( $attempt_question->get_status_icon() ); ?>
</span>
</header>
</li>
<?php
continue;
}
?>
<li class="llms-quiz-attempt-question type--<?php echo esc_attr( $quiz_question->get( 'question_type' ) ); ?> status--<?php echo esc_attr( $attempt_question->get_status() ); ?> <?php echo $attempt_question->is_correct() ? 'correct' : 'incorrect'; ?>"
data-question-id="<?php echo esc_attr( $quiz_question->get( 'id' ) ); ?>"
data-grading-manual="<?php echo $attempt_question->can_be_manually_graded() ? 'yes' : 'no'; ?>"
data-points="<?php echo esc_attr( $attempt_question->get( 'points' ) ); ?>"
data-points-curr="<?php echo esc_attr( $attempt_question->get( 'earned' ) ); ?>">
<header class="llms-quiz-attempt-question-header">
<a class="toggle-answer" href="#">
<h3 class="llms-question-title"><?php echo wp_kses_post( $quiz_question->get_question( 'plain' ) ); ?></h3>
<?php if ( $quiz_question->get( 'points' ) ) : ?>
<span class="llms-points">
<?php echo esc_html( sprintf( __( '%1$d / %2$d points', 'lifterlms' ), $attempt_question->get( 'earned' ), $attempt_question->get( 'points' ) ) ); ?>
</span>
<?php endif; ?>
<?php echo wp_kses_post( $attempt_question->get_status_icon() ); ?>
</a>
</header>
<section class="llms-quiz-attempt-question-main">
<?php if ( apply_filters( 'llms_quiz_show_question_description', true, $attempt, $attempt_question, $quiz_question ) && $quiz_question->has_description() ) : ?>
<div class="llms-quiz-attempt-answer-section llms-question-description">
<?php echo wp_kses_post( $quiz_question->get_description() ); ?>
</div>
<?php endif; ?>
<?php if ( $attempt_question->get( 'answer' ) ) : ?>
<div class="llms-quiz-attempt-answer-section llms-student-answer">
<p class="llms-quiz-results-label student-answer"><?php esc_html_e( 'Selected answer: ', 'lifterlms' ); ?></p>
<?php echo wp_kses_post( $attempt_question->get_answer() ); ?>
</div>
<?php endif; ?>
<?php if ( ! $attempt_question->is_correct() ) : ?>
<?php if ( llms_parse_bool( $quiz_question->get_quiz()->get( 'show_correct_answer' ) ) ) : ?>
<?php if ( in_array( $quiz_question->get_auto_grade_type(), array( 'choices', 'conditional' ) ) ) : ?>
<div class="llms-quiz-attempt-answer-section llms-correct-answer">
<p class="llms-quiz-results-label correct-answer"><?php esc_html_e( 'Correct answer: ', 'lifterlms' ); ?></p>
<?php echo wp_kses_post( $attempt_question->get_correct_answer() ); ?>
</div>
<?php endif; ?>
<?php endif; ?>
<?php if ( llms_parse_bool( $quiz_question->get( 'clarifications_enabled' ) ) ) : ?>
<div class="llms-quiz-attempt-answer-section llms-clarifications">
<p class="llms-quiz-results-label clarification"><?php esc_html_e( 'Clarification: ', 'lifterlms' ); ?></p>
<?php echo wp_kses_post( $quiz_question->get( 'clarifications' ) ); ?>
</div>
<?php endif; ?>
<?php endif; ?>
<?php if ( $attempt_question->has_remarks() ) : ?>
<div class="llms-quiz-attempt-answer-section llms-remarks">
<p class="llms-quiz-results-label remarks"><?php esc_html_e( 'Instructor remarks: ', 'lifterlms' ); ?></p>
<div class="llms-remarks"><?php echo wp_kses_post( wpautop( $attempt_question->get( 'remarks' ) ) ); ?></div>
</div>
<?php endif; ?>
</section>
</li>
<?php endforeach; ?>
</ol>