PluginProbe
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses / 4.4.10
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses v4.4.10
4.4.10 4.4.9.1 4.4.9 4.4.8 4.4.7 4.4.6 4.4.5 4.4.4 4.4.3 4.4.2 4.4.1 4.4.0 4.3.9.1 4.3.9 4.3.8 4.3.7 4.1.6.9 4.1.6.9.1 4.1.6.9.2 4.1.6.9.3 4.1.6.9.4 4.1.7 4.1.7.1 4.1.7.2 4.1.7.3 All 142 releases
← All changes | inc/TemplateHooks/CourseBuilder/Quiz/BuilderListQuizzesTemplate.php +69 -32 4.4.0 → 4.4.10 View file →
@@ -15,8 +15,9 @@
15 15 use LearnPress\Models\QuizPostModel;
16 16 use LearnPress\Models\UserModel;
17 17 use LearnPress\TemplateHooks\CourseBuilder\Course\BuilderCourseTemplate;
18 18 use LearnPress\TemplateHooks\CourseBuilder\CourseBuilderTemplate;
19 +use LearnPress\TemplateHooks\Table\TableListTemplate;
19 20 use LP_WP_Filesystem;
20 21 use Throwable;
21 22 use WP_Query;
22 23
@@ -71,9 +72,9 @@
71 72
72 73 $search = [
73 74 'wrapper' => sprintf( '<form class="cb-search-form" method="get" action="%s">', $link_tab ),
74 75 'search_quiz' => '<button class="lp-button cb-search-btn" type="submit"> <i class="lp-icon-search"> </i></button>',
75 - 'input' => sprintf( '<input class="cb-input-search-quiz" type="search" placeholder="%s" name="c_search" value="%s">', __( 'Search', 'learnpress' ), $args['c_search'] ?? '' ),
76 + 'input' => sprintf( '<input class="cb-input-search-quiz" type="search" placeholder="%s" name="c_search" value="%s">', __( 'Search', 'learnpress' ), esc_attr( $args['c_search'] ?? '' ) ),
76 77 'wrapper_end' => '</form>',
77 78 ];
78 79
79 80 return Template::combine_components( $search );
@@ -127,17 +128,9 @@
127 128 }
128 129 }
129 130 wp_reset_postdata();
130 131
131 - if ( ! empty( $quizzes ) ) {
132 - $html_quizzes = $this->list_quizzes( $quizzes );
133 - } else {
134 - $html_quizzes = Template::print_message(
135 - sprintf( __( 'No quizzes found', 'learnpress' ) ),
136 - 'info',
137 - false
138 - );
139 - }
132 + $html_quizzes = $this->list_quizzes( $quizzes );
140 133
141 134 $total_pages = \LP_Database::get_total_pages( $query_args['posts_per_page'], $total_quizzes );
142 135 $link_tab = CourseBuilder::get_tab_link( 'quizzes' );
143 136 $data_pagination = [
@@ -180,30 +173,59 @@
180 173 $content = '';
181 174
182 175 try {
183 176 $html_list_quiz = '';
177 +
178 + if ( empty( $quizzes ) ) {
179 + return Template::print_message(
180 + __( 'No quizzes found', 'learnpress' ),
181 + 'info',
182 + false
183 + );
184 + }
185 +
184 186 foreach ( $quizzes as $quiz_model ) {
185 187 $html_list_quiz .= self::render_quiz( $quiz_model );
186 188 }
187 189
188 - $header = '<div class="cb-list-table-header">';
189 - $header .= sprintf( '<span>%s</span>', __( 'Quiz Title', 'learnpress' ) );
190 - $header .= sprintf( '<span>%s</span>', __( 'Courses', 'learnpress' ) );
191 - $header .= sprintf( '<span>%s</span>', __( 'Questions', 'learnpress' ) );
192 - $header .= sprintf( '<span>%s</span>', __( 'Duration', 'learnpress' ) );
193 - $header .= sprintf( '<span>%s</span>', __( 'Create Date', 'learnpress' ) );
194 - $header .= sprintf( '<span>%s</span>', __( 'Status', 'learnpress' ) );
195 - $header .= sprintf( '<span>%s</span>', __( 'Actions', 'learnpress' ) );
196 - $header .= '</div>';
197 -
198 - $sections = [
199 - 'header' => $header,
200 - 'wrapper' => '<ul class="cb-list-quiz">',
201 - 'list_quiz' => $html_list_quiz,
202 - 'wrapper_end' => '</ul>',
190 + $table_args = [
191 + 'class_table' => 'cb-list-table cb-list-quiz',
192 + 'header' => [
193 + 'title' => [
194 + 'class' => 'cb-col-title',
195 + 'title' => __( 'Quiz Title', 'learnpress' ),
196 + ],
197 + 'courses' => [
198 + 'class' => 'cb-col-assigned',
199 + 'title' => __( 'Courses', 'learnpress' ),
200 + ],
201 + 'total_questions' => [
202 + 'class' => 'cb-col-questions',
203 + 'title' => __( 'Questions', 'learnpress' ),
204 + ],
205 + 'duration' => [
206 + 'class' => 'cb-col-duration',
207 + 'title' => __( 'Duration', 'learnpress' ),
208 + ],
209 + 'date' => [
210 + 'class' => 'cb-col-date',
211 + 'title' => __( 'Create Date', 'learnpress' ),
212 + ],
213 + 'status' => [
214 + 'class' => 'cb-col-status',
215 + 'title' => __( 'Status', 'learnpress' ),
216 + ],
217 + 'actions' => [
218 + 'class' => 'cb-col-actions',
219 + 'title' => __( 'Actions', 'learnpress' ),
220 + ],
221 + ],
222 + 'body' => [
223 + 'rows_html' => $html_list_quiz,
224 + ],
203 225 ];
204 226
205 - $content = Template::combine_components( $sections );
227 + $content = TableListTemplate::instance()->html_table( $table_args );
206 228 } catch ( Throwable $e ) {
207 229 error_log( __METHOD__ . ': ' . $e->getMessage() );
208 230 }
209 231
@@ -326,17 +348,32 @@
326 348 $quiz,
327 349 $settings
328 350 );
329 351
352 + $cell_classes = [
353 + 'courses' => 'assigned',
354 + 'total_questions' => 'questions',
355 + 'quiz_status' => 'status',
356 + ];
357 + $html_cells = [];
358 + foreach ( $html_content as $key => $html ) {
359 + $cell_class = $cell_classes[ $key ] ?? $key;
360 + $html_cells[ $key ] = sprintf(
361 + '<td class="cb-col-%s">%s</td>',
362 + esc_attr( sanitize_html_class( $cell_class ) ),
363 + $html
364 + );
365 + }
366 +
330 367 $section = apply_filters(
331 368 'learn-press/course-builder/list-quizzes/item-li',
332 369 [
333 - 'wrapper_li' => '<li class="quiz">',
334 - 'wrapper_div' => sprintf( '<div class="quiz-item" data-quiz-id="%s" data-status="%s">', $quiz['id'], $status ),
335 - 'quiz_info' => Template::combine_components( $html_content ),
336 - 'quiz_action' => Template::combine_components( $html_action ),
337 - 'wrapper_div_end' => '</div>',
338 - 'wrapper_li_end' => '</li>',
370 + 'wrapper_li' => sprintf( '<tr class="quiz quiz-item" data-quiz-id="%s" data-status="%s">', $quiz['id'], $status ),
371 + 'wrapper_div' => '',
372 + 'quiz_info' => Template::combine_components( $html_cells ),
373 + 'quiz_action' => sprintf( '<td class="cb-col-actions">%s</td>', Template::combine_components( $html_action ) ),
374 + 'wrapper_div_end' => '',
375 + 'wrapper_li_end' => '</tr>',
339 376 ],
340 377 $quiz,
341 378 $settings
342 379 );