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.2 3.5.0 3.6.0 3.6.1 3.6.2 3.6.3 3.6.4 3.7.0 3.7.1 3.7.2 3.7.3 3.7.4 3.8.0 3.8.1 3.8.2 3.8.3 3.9.0 3.9.1 3.9.10 3.9.2 3.9.3 3.9.4 3.9.5 3.9.6 3.9.7 3.9.8 3.9.9
tutor / templates / learning-area / subpages / qna.php
tutor / templates / learning-area / subpages Last commit date
qna 5 days ago reviews 5 days ago announcements.php 5 days ago course-info.php 5 days ago qna.php 5 days ago reviews.php 5 days ago
qna.php
160 lines
1 <?php
2 /**
3 * Tutor learning area Q&A.
4 *
5 * @package Tutor\Templates
6 * @author Themeum <support@themeum.com>
7 * @link https://themeum.com
8 * @since 4.0.0
9 */
10
11 defined( 'ABSPATH' ) || exit;
12
13 use TUTOR\Icon;
14 use Tutor\Components\SvgIcon;
15 use TUTOR\Input;
16 use Tutor\Components\ConfirmationModal;
17 use Tutor\Components\Constants\Size;
18 use Tutor\Components\EmptyState;
19 use Tutor\Components\Pagination;
20 use Tutor\Components\SearchFilter;
21 use Tutor\Components\Sorting;
22 use Tutor\Helpers\UrlHelper;
23
24 $question_id = Input::get( 'question_id', 0, Input::TYPE_INT );
25
26 if ( $question_id ) {
27 tutor_load_template( 'learning-area.subpages.qna.single' );
28 return;
29 }
30
31 // Get course ID from global variable set in learning-area/index.php .
32 global $tutor_course_id;
33
34 // Pagination setup.
35 $question_per_page = tutor_utils()->get_option( 'pagination_per_page', 10 );
36 $current_page = max( 1, Input::get( 'current_page', 1, Input::TYPE_INT ) );
37 $offset = ( $current_page - 1 ) * $question_per_page;
38 $search_query = Input::get( 'search', '' );
39 $order_by = Input::get( 'order', 'DESC' );
40
41 // Get questions for this course.
42 $total_items = (int) tutor_utils()->get_qa_questions(
43 $offset,
44 $question_per_page,
45 $search_query,
46 null,
47 null,
48 null,
49 null,
50 true,
51 array(
52 'course_id' => $tutor_course_id,
53 'order' => $order_by,
54 )
55 );
56 $questions = tutor_utils()->get_qa_questions(
57 $offset,
58 $question_per_page,
59 $search_query,
60 null,
61 null,
62 null,
63 null,
64 false,
65 array(
66 'course_id' => $tutor_course_id,
67 'order' => $order_by,
68 )
69 );
70
71 ?>
72 <div class="tutor-py-8">
73 <h4 class="tutor-h4 tutor-mb-5 tutor-flex tutor-items-center tutor-gap-4">
74 <?php SvgIcon::make()->name( Icon::QA )->size( 24 )->render(); ?>
75 <?php esc_html_e( 'Q&A', 'tutor' ); ?>
76 </h4>
77 <div class="tutor-learning-area-qna" x-data="tutorQnA()">
78 <div class="tutor-discussion-search tutor-p-6 tutor-border-b">
79 <?php
80 SearchFilter::make()
81 ->form_id( 'tutor-qna-search-form' )
82 ->placeholder( 'Search questions, topics...' )
83 ->action( UrlHelper::current() )
84 ->hidden_inputs( array( 'subpage' => 'qna' ) )
85 ->size( Size::LARGE )
86 ->render();
87 ?>
88 </div>
89
90 <div class="tutor-p-6">
91 <label for="answer" class="tutor-block tutor-medium tutor-font-semibold tutor-mb-4">
92 <?php esc_html_e( 'Question & Answer', 'tutor' ); ?>
93 </label>
94 <?php
95 tutor_load_template(
96 'learning-area.subpages.qna.form',
97 array(
98 'form_id' => 'learning-area-qna-form',
99 'submit_handler' => '(data) => createQnAMutation?.mutate({ ...data, course_id: ' . (int) $tutor_course_id . ' })',
100 'cancel_handler' => 'reset(); focused = false',
101 'is_pending' => 'createQnAMutation?.isPending',
102 'placeholder' => __( 'Asked questions...', 'tutor' ),
103 'submit_label' => __( 'Save', 'tutor' ),
104 )
105 );
106 ?>
107 </div>
108
109 <div class="tutor-flex tutor-items-center tutor-justify-between tutor-px-6 tutor-py-5 tutor-border-b tutor-border-t">
110 <div class="tutor-small tutor-text-secondary">
111 <?php esc_html_e( 'Questions', 'tutor' ); ?>
112 <span class="tutor-text-primary tutor-font-medium">(<?php echo esc_html( $total_items ); ?>)</span>
113 </div>
114 <?php Sorting::make()->order( $order_by )->render(); ?>
115 </div>
116
117 <?php if ( empty( $questions ) ) : ?>
118 <?php
119 EmptyState::make()
120 ->title( 'No Questions Found!' )
121 ->icon( tutor_utils()->get_themed_svg( 'images/illustrations/qna-empty.svg' ) )
122 ->render();
123 ?>
124 <?php else : ?>
125 <div class="tutor-discussion-card-wrapper tutor-flex tutor-flex-column tutor-gap-4 tutor-sm-gap-none tutor-p-6 tutor-sm-p-none">
126 <?php
127 foreach ( $questions as $question ) :
128 tutor_load_template(
129 'learning-area.subpages.qna.card',
130 array(
131 'question' => $question,
132 )
133 );
134 endforeach;
135 ?>
136 </div>
137 <?php endif; ?>
138
139 <?php
140 Pagination::make()
141 ->current( $current_page )
142 ->total( $total_items )
143 ->limit( $question_per_page )
144 ->attr( 'class', 'tutor-px-6 tutor-pb-6 tutor-sm-p-5 tutor-sm-border-t' )
145 ->render();
146 ?>
147
148 <?php
149 ConfirmationModal::make()
150 ->id( 'tutor-qna-delete-modal' )
151 ->title( __( 'Delete This Question?', 'tutor' ) )
152 ->message( __( 'Are you sure you want to delete this question permanently? Please confirm your choice.', 'tutor' ) )
153 ->confirm_text( __( 'Yes, Delete This', 'tutor' ) )
154 ->confirm_handler( 'deleteQnAMutation?.mutate(payload)' )
155 ->mutation_state( 'deleteQnAMutation' )
156 ->render();
157 ?>
158 </div>
159 </div>
160