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/Question/BuilderListQuestionsTemplate.php +63 -30 4.4.9 → 4.4.10 View file →
@@ -15,8 +15,9 @@
15 15 use LearnPress\Models\Question\QuestionPostModel;
16 16 use LearnPress\Models\UserModel;
17 17 use LearnPress\TemplateHooks\CourseBuilder\CourseBuilderTemplate;
18 18 use LearnPress\TemplateHooks\CourseBuilder\Quiz\BuilderQuizTemplate;
19 +use LearnPress\TemplateHooks\Table\TableListTemplate;
19 20 use LP_Question;
20 21 use LP_Question_CURD;
21 22 use LP_WP_Filesystem;
22 23 use Throwable;
@@ -130,17 +131,9 @@
130 131 }
131 132 }
132 133 wp_reset_postdata();
133 134
134 - if ( ! empty( $questions ) ) {
135 - $html_questions = $this->list_questions( $questions );
136 - } else {
137 - $html_questions = Template::print_message(
138 - sprintf( __( 'No questions found', 'learnpress' ) ),
139 - 'info',
140 - false
141 - );
142 - }
135 + $html_questions = $this->list_questions( $questions );
143 136
144 137 $total_pages = \LP_Database::get_total_pages( $query_args['posts_per_page'], $total_questions );
145 138 $link_tab = CourseBuilder::get_tab_link( 'questions' );
146 139 $data_pagination = [
@@ -183,29 +176,55 @@
183 176 $content = '';
184 177
185 178 try {
186 179 $html_list_question = '';
180 +
181 + if ( empty( $questions ) ) {
182 + return Template::print_message(
183 + __( 'No questions found', 'learnpress' ),
184 + 'info',
185 + false
186 + );
187 + }
188 +
187 189 foreach ( $questions as $question_model ) {
188 190 $html_list_question .= self::render_question( $question_model );
189 191 }
190 192
191 - $header = '<div class="cb-list-table-header">';
192 - $header .= sprintf( '<span>%s</span>', __( 'Question Title', 'learnpress' ) );
193 - $header .= sprintf( '<span>%s</span>', __( 'Quiz', 'learnpress' ) );
194 - $header .= sprintf( '<span>%s</span>', __( 'Create Date', 'learnpress' ) );
195 - $header .= sprintf( '<span>%s</span>', __( 'Status', 'learnpress' ) );
196 - $header .= sprintf( '<span>%s</span>', __( 'Preview', 'learnpress' ) );
197 - $header .= sprintf( '<span>%s</span>', __( 'Actions', 'learnpress' ) );
198 - $header .= '</div>';
199 -
200 - $sections = [
201 - 'header' => $header,
202 - 'wrapper' => '<ul class="cb-list-question">',
203 - 'list_question' => $html_list_question,
204 - 'wrapper_end' => '</ul>',
193 + $table_args = [
194 + 'class_table' => 'cb-list-table cb-list-question',
195 + 'header' => [
196 + 'title' => [
197 + 'class' => 'cb-col-title',
198 + 'title' => __( 'Question Title', 'learnpress' ),
199 + ],
200 + 'quizzes' => [
201 + 'class' => 'cb-col-assigned',
202 + 'title' => __( 'Quiz', 'learnpress' ),
203 + ],
204 + 'date' => [
205 + 'class' => 'cb-col-date',
206 + 'title' => __( 'Create Date', 'learnpress' ),
207 + ],
208 + 'status' => [
209 + 'class' => 'cb-col-status',
210 + 'title' => __( 'Status', 'learnpress' ),
211 + ],
212 + 'type' => [
213 + 'class' => 'cb-col-type',
214 + 'title' => __( 'Preview', 'learnpress' ),
215 + ],
216 + 'actions' => [
217 + 'class' => 'cb-col-actions',
218 + 'title' => __( 'Actions', 'learnpress' ),
219 + ],
220 + ],
221 + 'body' => [
222 + 'rows_html' => $html_list_question,
223 + ],
205 224 ];
206 225
207 - $content = Template::combine_components( $sections );
226 + $content = TableListTemplate::instance()->html_table( $table_args );
208 227 } catch ( Throwable $e ) {
209 228 error_log( __METHOD__ . ': ' . $e->getMessage() );
210 229 }
211 230
@@ -330,17 +349,31 @@
330 349 $question,
331 350 $settings
332 351 );
333 352
353 + $cell_classes = [
354 + 'quizzes' => 'assigned',
355 + 'question_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 +
334 367 $section = apply_filters(
335 368 'learn-press/course-builder/list-questions/item-li',
336 369 [
337 - 'wrapper_li' => '<li class="question">',
338 - 'wrapper_div' => sprintf( '<div class="question-item" data-question-id="%s" data-status="%s">', $question['id'], $status ),
339 - 'question_info' => Template::combine_components( $html_content ),
340 - 'question_action' => Template::combine_components( $html_action ),
341 - 'wrapper_div_end' => '</div>',
342 - 'wrapper_li_end' => '</li>',
370 + 'wrapper_li' => sprintf( '<tr class="question question-item" data-question-id="%s" data-status="%s">', $question['id'], $status ),
371 + 'wrapper_div' => '',
372 + 'question_info' => Template::combine_components( $html_cells ),
373 + 'question_action' => sprintf( '<td class="cb-col-actions">%s</td>', Template::combine_components( $html_action ) ),
374 + 'wrapper_div_end' => '',
375 + 'wrapper_li_end' => '</tr>',
343 376 ],
344 377 $question,
345 378 $settings
346 379 );