listing.php
5 KB
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
<?php
/**
* LearnDash LD30 Displays a quiz listing
*
* Available Variables:
*
* $course_id : (int) ID of Course
* $lesson_id : (int) ID of Lesson
* $user_id : (int) ID of User
* $quizzes : (array) Quizzes
* $context : (string) Context of the usage. Either 'lesson' or 'topic'.
*
* @since 3.0.0
*
* @package LearnDash\Templates\LD30
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
// Extra sanity check that this lesson has quizzes.
if ( ! empty( $quizzes ) ) :
/**
* Fires before the quiz list.
*
* The dynamic portion of the hook name, `$context`, refers to the context for which the hook is fired,
* such as `course`, `lesson`, `topic`, `quiz`, etc.
*
* @since 3.0.0
*
* @param int|false $post_id Post ID.
* @param int $course_id Course ID.
* @param int $user_id User ID.
*/
do_action( 'learndash-' . $context . '-quiz-list-before', get_the_ID(), $course_id, $user_id );
$is_sample = false;
if ( ( isset( $lesson_id ) ) && ( ! empty( $lesson_id ) ) ) {
$is_sample = learndash_get_setting( $lesson_id, 'sample_lesson' );
}
$table_class = 'ld-table-list ld-topic-list ld-quiz-list'
. ( isset( $is_sample ) && 'on' === $is_sample ? ' is_sample' : '' )
?>
<div class="<?php echo esc_attr( $table_class ); ?>">
<div class="ld-table-list-header ld-primary-background">
<?php
/**
* Fires before the quiz listing header.
*
* The dynamic portion of the hook name, `$context`, refers to the context for which the hook is fired,
* such as `course`, `lesson`, `topic`, `quiz`, etc.
*
* @since 3.0.0
*
* @param int|false $post_id Post ID.
* @param int $course_id Course ID.
* @param int $user_id User ID.
*/
do_action( 'learndash-' . $context . '-quiz-list-heading-before', get_the_ID(), $course_id, $user_id );
?>
<?php // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Method escapes output?>
<div class="ld-table-list-title"><?php echo LearnDash_Custom_Label::get_label( 'quizzes' ); ?></div>
<?php
/**
* Fires before the lesson progress stats.
*
* The dynamic portion of the hook name, `$context`, refers to the context for which the hook is fired,
* such as `course`, `lesson`, `topic`, `quiz`, etc.
*
* @since 3.0.0
*
* @param int|false $post_id Post ID.
* @param int $course_id Course ID.
* @param int $user_id User ID.
*/
do_action( 'learndash-' . $context . '-quiz-list-progress-before', get_the_ID(), $course_id, $user_id );
?>
<?php
/**
* TODO @37designs - need to create a function to count quizes complete / incomplete
*
<span><?php sprintf( '%s% Complete', $lesson_progress['percentage'] ); ?></span>
<span><?php sprintf( '%s/%s Steps', $lesson_progress['complete'], $lesson_progress['total'] ); ?></span>
*/
?>
<div class="ld-table-list-lesson-details"></div>
<?php
/**
* Fires after the lesson progress stats.
*
* The dynamic portion of the hook name, `$context`, refers to the context for which the hook is fired,
* such as `course`, `lesson`, `topic`, `quiz`, etc.
*
* @param int|false $post_id Post ID.
* @param int $course_id Course ID.
* @param int $user_id User ID.
*
* @since 3.0.0
*/
do_action( 'learndash-' . $context . '-quiz-list-progress-after', get_the_ID(), $course_id, $user_id );
?>
<?php
/**
* Fires after the topic listing header.
*
* The dynamic portion of the hook name, `$context`, refers to the context for which the hook is fired,
* such as `course`, `lesson`, `topic`, `quiz`, etc.
*
* @param int|false $post_id Post ID.
* @param int $course_id Course ID.
* @param int $user_id User ID.
*
* @since 3.0.0
*/
do_action( 'learndash-' . $context . '-quiz-list-heading-after', get_the_ID(), $course_id, $user_id );
?>
</div> <!--/.ld-table-list-header-->
<div class="ld-table-list-items">
<?php
// TODO @37designs Need to check pagination to see if we should show these - think there is a setting here too to disable quizzes in listing?
foreach ( $quizzes as $quiz ) :
learndash_get_template_part(
'quiz/partials/row.php',
array(
'quiz' => $quiz,
'course_id' => $course_id,
'user_id' => $user_id,
'context' => $context,
),
true
);
endforeach;
?>
</div> <!--/.ld-table-list-items-->
<div class="ld-table-list-footer"></div>
</div>
<?php
/**
* Fires after the quiz list.
*
* The dynamic portion of the hook name, `$context`, refers to the context for which the hook is fired,
* such as `course`, `lesson`, `topic`, `quiz`, etc.
*
* @param int|false $post_id Post ID.
* @param int $course_id Course ID.
* @param int $user_id User ID.
*
* @since 3.0.0
*/
do_action( 'learndash-' . $context . '-quiz-list-after', get_the_ID(), $course_id, $user_id );
?>
<?php
endif;