Diff: STRATO-apps/wordpress_03/app/wp-content/plugins/tutor/templates/single/lesson/lesson_sidebar.php

Keine Baseline-Datei – Diff nur gegen leer.
Zur Liste
1 -
1 + <?php
2 + /**
3 + * Display Topics and Lesson lists for learn
4 + *
5 + * @package Tutor\Templates
6 + * @subpackage Single\Lesson
7 + * @author Themeum <support@themeum.com>
8 + * @link https://themeum.com
9 + * @since 1.0.0
10 + */
11 +
12 + use TUTOR\Input;
13 + use Tutor\Models\QuizModel;
14 + use TUTOR\Quiz;
15 +
16 + if ( ! defined( 'ABSPATH' ) ) {
17 + exit;
18 + }
19 +
20 + global $post;
21 +
22 + $current_post_id = get_the_ID();
23 + if ( ! empty( Input::post( 'lesson_id' ) ) ) {
24 + $current_post_id = Input::post( 'lesson_id' );
25 + }
26 +
27 + $current_post = $post;
28 + $_is_preview = get_post_meta( $current_post_id, '_is_preview', true );
29 + $course_id = tutor_utils()->get_course_id_by_subcontent( $post->ID );
30 +
31 + $user_id = get_current_user_id();
32 + $enable_qa_for_this_course = get_post_meta( $course_id, '_tutor_enable_qa', true ) == 'yes';
33 + $enable_q_and_a_on_course = tutor_utils()->get_option( 'enable_q_and_a_on_course' ) && $enable_qa_for_this_course;
34 + $is_enrolled = tutor_utils()->is_enrolled( $course_id );
35 + $is_instructor_of_this_course = tutor_utils()->has_user_course_content_access( $user_id, $course_id );
36 + $is_user_admin = current_user_can( 'administrator' );
37 + $is_public_course = \TUTOR\Course_List::is_public( $course_id );
38 + ?>
39 +
40 + <?php do_action( 'tutor_lesson/single/before/lesson_sidebar' ); ?>
41 + <div class="tutor-course-single-sidebar-title tutor-d-flex tutor-justify-between">
42 + <span class="tutor-fs-6 tutor-fw-medium tutor-color-secondary"><?php esc_html_e( 'Course Content', 'tutor' ); ?></span>
43 + <span class="tutor-d-block tutor-d-xl-none">
44 + <a href="#" class="tutor-iconic-btn" tutor-hide-course-single-sidebar>
45 + <span class="tutor-icon-times" area-hidden="true"></span>
46 + </a>
47 + </span>
48 + </div>
49 +
50 + <?php
51 + $topics = tutor_utils()->get_topics( $course_id );
52 + if ( $topics->have_posts() ) {
53 +
54 + // Loop through topics.
55 + while ( $topics->have_posts() ) {
56 + $topics->the_post();
57 + $topic_id = get_the_ID();
58 + $topic_summery = get_the_content();
59 + $total_contents = tutor_utils()->count_completed_contents_by_topic( $topic_id );
60 + $lessons = tutor_utils()->get_course_contents_by_topic( get_the_ID(), -1 );
61 + $is_topic_active = ! empty(
62 + array_filter(
63 + $lessons->posts,
64 + function ( $content ) use ( $current_post ) {
65 + return $content->ID == $current_post->ID;
66 + }
67 + )
68 + );
69 + ?>
70 + <div class="tutor-course-topic tutor-course-topic-<?php echo esc_attr( $topic_id ); ?>">
71 + <div class="tutor-accordion-item-header<?php echo $is_topic_active ? ' is-active' : ''; ?>" tutor-course-single-topic-toggler>
72 + <div class="tutor-row tutor-gx-1">
73 + <div class="tutor-col">
74 + <div class="tutor-course-topic-title">
75 + <?php the_title(); ?>
76 + <?php if ( true ) : ?>
77 + <?php if ( trim( $topic_summery ) ) : ?>
78 + <div class="tutor-course-topic-title-info tutor-ml-8">
79 + <div class="tooltip-wrap">
80 + <i class="tutor-course-topic-title-info-icon tutor-icon-circle-info-o"></i>
81 + <span class="tooltip-txt tooltip-bottom">
82 + <?php echo esc_textarea( $topic_summery ); ?>
83 + </span>
84 + </div>
85 + </div>
86 + <?php endif; ?>
87 + <?php endif; ?>
88 + </div>
89 + </div>
90 +
91 + <div class="tutor-col-auto tutor-align-self-center">
92 + <?php if ( isset( $total_contents['contents'] ) && $total_contents['contents'] > 0 ) : ?>
93 + <div class="tutor-course-topic-summary tutor-pl-8">
94 + <?php echo esc_html( isset( $total_contents['completed'] ) ? $total_contents['completed'] : 0 ); ?>/<?php echo esc_html( isset( $total_contents['contents'] ) ? $total_contents['contents'] : 0 ); ?>
95 + </div>
96 + <?php endif; ?>
97 + </div>
98 + </div>
99 + </div>
100 +
101 + <div class="tutor-accordion-item-body <?php echo $is_topic_active ? '' : 'tutor-display-none'; ?>">
102 + <?php
103 + do_action( 'tutor/lesson_list/before/topic', $topic_id );
104 +
105 + // Loop through lesson, quiz, assignment, zoom lesson.
106 + while ( $lessons->have_posts() ) {
107 + $lessons->the_post();
108 +
109 + $show_permalink = ! $_is_preview || $is_enrolled || get_post_meta( $post->ID, '_is_preview', true ) || $is_public_course || $is_instructor_of_this_course;
110 + $show_permalink = apply_filters( 'tutor_course/single/content/show_permalink', $show_permalink, get_the_ID() );
111 + $lock_icon = ! $show_permalink;
112 + $show_permalink = null === $show_permalink ? true : $show_permalink;
113 +
114 + if ( 'tutor_quiz' === $post->post_type ) {
115 + $quiz = $post;
116 + ?>
117 + <div class="tutor-course-topic-item tutor-course-topic-item-quiz<?php echo ( get_the_ID() == $current_post->ID ) ? ' is-active' : ''; ?>" data-quiz-id="<?php echo esc_attr( $quiz->ID ); ?>">
118 + <a href="<?php echo $show_permalink ? esc_url( get_permalink( $quiz->ID ) ) : '#'; ?>" data-quiz-id="<?php echo esc_attr( $quiz->ID ); ?>">
119 + <div class="tutor-d-flex tutor-mr-32">
120 + <span class="tutor-course-topic-item-icon tutor-icon-quiz-o tutor-mr-8 tutor-mt-2" area-hidden="true"></span>
121 + <span class="tutor-course-topic-item-title tutor-fs-7 tutor-fw-medium">
122 + <?php echo esc_html( $quiz->post_title ); ?>
123 + </span>
124 + </div>
125 + <div class="tutor-d-flex tutor-ml-auto tutor-flex-shrink-0">
126 + <?php
127 + $time_limit = (int) tutor_utils()->get_quiz_option( $quiz->ID, 'time_limit.time_value' );
128 + $last_attempt = ( new QuizModel() )->get_first_or_last_attempt( $quiz->ID );
129 +
130 + // $attempt_ended = is_object( $last_attempt ) && ( 'attempt_ended' === ( $last_attempt->attempt_status ) || $last_attempt->is_manually_reviewed ) ? true : false;
131 +
132 + $attempt_ended = is_object( $last_attempt ) && QuizModel::ATTEMPT_STARTED !== $last_attempt->attempt_status;
133 + $result_class = '';
134 +
135 + $quiz_result = QuizModel::get_quiz_result( $quiz->ID );
136 + if ( $attempt_ended && QuizModel::ATTEMPT_STARTED !== $last_attempt->attempt_status ) {
137 + if ( 'fail' === $quiz_result ) {
138 + $result_class = 'tutor-check-fail';
139 + }
140 + if ( 'pending' === $quiz_result ) {
141 + $result_class = 'tutor-check-pending';
142 + }
143 + }
144 +
145 + if ( $time_limit ) {
146 + $time_type = tutor_utils()->get_quiz_option( $quiz->ID, 'time_limit.time_type' );
147 +
148 + $time_multipliers = array(
149 + 'minutes' => MINUTE_IN_SECONDS,
150 + 'hours' => HOUR_IN_SECONDS,
151 + 'days' => DAY_IN_SECONDS,
152 + 'weeks' => WEEK_IN_SECONDS,
153 + );
154 +
155 + if ( isset( $time_multipliers[ $time_type ] ) ) {
156 + $time_limit *= $time_multipliers[ $time_type ];
157 + }
158 +
159 + $hours = floor( $time_limit / HOUR_IN_SECONDS );
160 + $minutes = floor( ( $time_limit % HOUR_IN_SECONDS ) / MINUTE_IN_SECONDS );
161 + $seconds = $time_limit % MINUTE_IN_SECONDS;
162 + $formatted_time = sprintf( '%02d:%02d:%02d', $hours, $minutes, $seconds );
163 +
164 + $markup = '<span class="tutor-course-topic-item-duration tutor-fs-7 tutor-fw-medium tutor-color-muted tutor-mr-8">' . $formatted_time . '</span>';
165 + echo wp_kses(
166 + $markup,
167 + array(
168 + 'span' => array( 'class' => true ),
169 + )
170 + );
171 + }
172 + ?>
173 +
174 + <?php if ( ! $lock_icon ) : ?>
175 + <input type="checkbox"
176 + class="tutor-form-check-input tutor-form-check-circle <?php echo esc_attr( $result_class ); ?>"
177 + disabled="disabled"
178 + readonly="readonly"
179 + <?php echo esc_attr( $attempt_ended ? 'checked="checked"' : '' ); ?> />
180 + <?php else : ?>
181 + <i class="tutor-icon-lock-line tutor-fs-7 tutor-color-muted tutor-mr-4" area-hidden="true"></i>
182 + <?php endif; ?>
183 + </div>
184 + </a>
185 + </div>
186 + <?php } elseif ( 'tutor_assignments' === $post->post_type ) { ?>
187 + <div class="tutor-course-topic-item tutor-course-topic-item-assignment<?php echo esc_attr( get_the_ID() == $current_post->ID ? ' is-active' : '' ); ?>">
188 + <a href="<?php echo $show_permalink ? esc_url( get_permalink( $post->ID ) ) : '#'; ?>" data-assignment-id="<?php echo esc_attr( $post->ID ); ?>">
189 + <div class="tutor-d-flex tutor-mr-32">
190 + <span class="tutor-course-topic-item-icon tutor-icon-assignment tutor-mr-8" area-hidden="true"></span>
191 + <span class="tutor-course-topic-item-title tutor-fs-7 tutor-fw-medium">
192 + <?php echo esc_html( $post->post_title ); ?>
193 + </span>
194 + </div>
195 + <div class="tutor-d-flex tutor-ml-auto tutor-flex-shrink-0">
196 + <?php if ( $show_permalink ) : ?>
197 + <?php do_action( 'tutor/assignment/right_icon_area', $post, $lock_icon ); ?>
198 + <?php else : ?>
199 + <i class="tutor-icon-lock-line tutor-fs-7 tutor-color-muted tutor-mr-4" area-hidden="true"></i>
200 + <?php endif; ?>
201 + </div>
202 + </a>
203 + </div>
204 + <?php } elseif ( 'tutor_zoom_meeting' === $post->post_type ) { ?>
205 + <div class="tutor-course-topic-item tutor-course-topic-item-zoom<?php echo esc_attr( ( get_the_ID() == $current_post->ID ) ? ' is-active' : '' ); ?>">
206 + <a href="<?php echo $show_permalink ? esc_url( get_permalink( $post->ID ) ) : '#'; ?>">
207 + <div class="tutor-d-flex tutor-mr-32">
208 + <span class="tutor-course-topic-item-icon tutor-icon-brand-zoom-o tutor-mr-8 tutor-mt-2" area-hidden="true"></span>
209 + <span class="tutor-course-topic-item-title tutor-fs-7 tutor-fw-medium">
210 + <?php echo esc_html( $post->post_title ); ?>
211 + </span>
212 + </div>
213 + <div class="tutor-d-flex tutor-ml-auto tutor-flex-shrink-0">
214 + <?php if ( $show_permalink ) : ?>
215 + <?php do_action( 'tutor/zoom/right_icon_area', $post->ID, $lock_icon ); ?>
216 + <?php else : ?>
217 + <i class="tutor-icon-lock-line tutor-fs-7 tutor-color-muted tutor-mr-4" area-hidden="true"></i>
218 + <?php endif; ?>
219 + </div>
220 + </a>
221 + </div>
222 + <?php } elseif ( 'tutor-google-meet' === $post->post_type ) { ?>
223 + <div class="tutor-course-topic-item tutor-course-topic-item-zoom<?php echo esc_attr( get_the_ID() == $current_post->ID ? ' is-active' : '' ); ?>">
224 + <a href="<?php echo $show_permalink ? esc_url( get_permalink( $post->ID ) ) : '#'; ?>">
225 + <div class="tutor-d-flex tutor-mr-32">
226 + <span class="tutor-course-topic-item-icon tutor-icon-brand-google-meet tutor-mr-8 tutor-mt-2" area-hidden="true"></span>
227 + <span class="tutor-course-topic-item-title tutor-fs-7 tutor-fw-medium">
228 + <?php echo esc_html( $post->post_title ); ?>
229 + </span>
230 + </div>
231 + <div class="tutor-d-flex tutor-ml-auto tutor-flex-shrink-0">
232 + <?php if ( $show_permalink ) : ?>
233 + <?php do_action( 'tutor/google_meet/right_icon_area', $post->ID, false ); ?>
234 + <?php else : ?>
235 + <i class="tutor-icon-lock-line tutor-fs-7 tutor-color-muted tutor-mr-4" area-hidden="true"></i>
236 + <?php endif; ?>
237 + </div>
238 + </a>
239 + </div>
240 + <?php } else { ?>
241 + <?php
242 + $video = tutor_utils()->get_video_info();
243 + $play_time = false;
244 + if ( $video ) {
245 + $play_time = $video->playtime;
246 + }
247 + $is_completed_lesson = tutor_utils()->is_completed_lesson();
248 + ?>
249 + <div class="tutor-course-topic-item tutor-course-topic-item-lesson<?php echo esc_attr( get_the_ID() == $current_post->ID ? ' is-active' : '' ); ?>">
250 + <a href="<?php echo $show_permalink ? esc_url( get_the_permalink() ) : '#'; ?>" data-lesson-id="<?php the_ID(); ?>">
251 + <div class="tutor-d-flex tutor-mr-32">
252 + <?php
253 + $tutor_lesson_type_icon = $play_time ? 'brand-youtube-bold' : 'document-text';
254 + $markup = '<span class="tutor-course-topic-item-icon tutor-icon-' . $tutor_lesson_type_icon . ' tutor-mr-8 tutor-mt-2" area-hidden="true"></span>';
255 + echo wp_kses(
256 + $markup,
257 + array(
258 + 'span' => array(
259 + 'class' => true,
260 + 'area-hidden' => true,
261 + ),
262 + )
263 + );
264 + ?>
265 + <span class="tutor-course-topic-item-title tutor-fs-7 tutor-fw-medium">
266 + <?php the_title(); ?>
267 + </span>
268 + </div>
269 +
270 + <div class="tutor-d-flex tutor-ml-auto tutor-flex-shrink-0">
271 + <?php
272 + if ( $play_time ) {
273 + $markup = "<span class='tutor-course-topic-item-duration tutor-fs-7 tutor-fw-medium tutor-color-muted tutor-mr-8'>" . tutor_utils()->get_optimized_duration( $play_time ) . '</span>';
274 + echo wp_kses(
275 + $markup,
276 + array(
277 + 'span' => array( 'class' => true ),
278 + )
279 + );
280 + }
281 +
282 + $lesson_complete_icon = $is_completed_lesson ? 'checked' : '';
283 +
284 + if ( ! $lock_icon ) {
285 + $markup = "<input $lesson_complete_icon type='checkbox' class='tutor-form-check-input tutor-form-check-circle' disabled readonly />";
286 + echo wp_kses(
287 + $markup,
288 + array(
289 + 'input' => array(
290 + 'checked' => true,
291 + 'class' => true,
292 + 'type' => true,
293 + 'disabled' => true,
294 + 'readonly' => true,
295 + ),
296 + )
297 + );
298 + } else {
299 + $markup = '<i class="tutor-icon-lock-line tutor-fs-7 tutor-color-muted tutor-mr-4" area-hidden="true"></i>';
300 + echo wp_kses(
301 + $markup,
302 + array(
303 + 'i' => array(
304 + 'class' => true,
305 + 'area-hidden' => true,
306 + ),
307 + )
308 + );
309 + }
310 + ?>
311 + </div>
312 + </a>
313 + </div>
314 + <?php
315 + }
316 + }
317 + $lessons->reset_postdata();
318 + do_action( 'tutor/lesson_list/after/topic', $topic_id );
319 + ?>
320 + </div>
321 + </div>
322 + <?php
323 + }
324 + $topics->reset_postdata();
325 + wp_reset_postdata();
326 + }
327 + ?>
328 + <?php do_action( 'tutor_lesson/single/after/lesson_sidebar' ); ?>
329 +