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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 / dashboard / discussions / qna-single.php
tutor / templates / dashboard / discussions Last commit date
comment-card.php 5 days ago comment-form.php 5 days ago comment-list.php 5 days ago comment-replies.php 5 days ago comment-single.php 5 days ago qna-card.php 5 days ago qna-form.php 5 days ago qna-list.php 5 days ago qna-replies.php 5 days ago qna-single.php 5 days ago
qna-single.php
234 lines
1 <?php
2 /**
3 * Q&A replies template.
4 *
5 * @package Tutor\Templates
6 * @subpackage Dashboard
7 * @author Themeum <support@themeum.com>
8 * @link https://themeum.com
9 * @since 4.0.0
10 */
11
12 defined( 'ABSPATH' ) || exit;
13
14 use Tutor\Components\Avatar;
15 use Tutor\Components\Button;
16 use Tutor\Components\ConfirmationModal;
17 use Tutor\Components\Constants\Size;
18 use Tutor\Components\PreviewTrigger;
19 use TUTOR\Icon;
20 use Tutor\Components\SvgIcon;
21 use Tutor\Components\Constants\Color;
22 use Tutor\Components\Constants\Variant;
23 use TUTOR\Input;
24 use TUTOR\User;
25
26 $question = tutor_utils()->get_qa_question( (int) $discussion_id );
27 if ( ! $question ) {
28 wp_safe_redirect( $discussion_url );
29 return;
30 }
31
32 $user_id = get_current_user_id();
33 $is_user_asker = $user_id === (int) $question->user_id;
34 $qna_delete_modal_id = 'tutor-qna-delete-modal';
35
36 $replies_order = Input::get( 'order', '' );
37 $replies = tutor_utils()->get_qa_answer_by_question( $discussion_id, $replies_order, 'frontend' );
38
39 $is_solved = (int) tutor_utils()->array_get( 'tutor_qna_solved', $question->meta, 0 );
40 $is_important = (int) tutor_utils()->array_get( 'tutor_qna_important', $question->meta, 0 );
41 $is_archived = (int) tutor_utils()->array_get( 'tutor_qna_archived', $question->meta, 0 );
42
43 ?>
44 <div class="tutor-discussion-single" x-init="isSolved = <?php echo $is_solved ? 'true' : 'false'; ?>; isImportant = <?php echo $is_important ? 'true' : 'false'; ?>; isArchived = <?php echo $is_archived ? 'true' : 'false'; ?>;">
45 <div class="tutor-flex tutor-justify-between tutor-px-6 tutor-py-5 tutor-border-b">
46 <a href="<?php echo esc_url( $discussion_url ); ?>" class="tutor-btn tutor-btn-secondary tutor-btn-small tutor-gap-2">
47 <?php SvgIcon::make()->name( Icon::ARROW_LEFT_2 )->flip_rtl()->render(); ?>
48 <?php esc_html_e( 'Back', 'tutor' ); ?>
49 </a>
50 <?php if ( User::is_instructor_view() ) : ?>
51 <div class="tutor-flex tutor-gap-2">
52 <button
53 class="tutor-btn tutor-btn-link tutor-btn-x-small tutor-gap-2 tutor-text-subdued"
54 @click="handleQnASingleAction(<?php echo esc_html( $question->comment_ID ); ?>, 'solved')"
55 :disabled="qnaSingleActionMutation?.isPending"
56 >
57 <template x-if="qnaSingleActionMutation?.isPending && currentAction === 'solved'">
58 <?php SvgIcon::make()->name( Icon::SPINNER )->size( 14 )->attr( 'class', 'tutor-animate-spin' )->render(); ?>
59 </template>
60 <template x-if="!(qnaSingleActionMutation?.isPending && currentAction === 'solved')">
61 <span class="tutor-flex">
62 <template x-if="isSolved">
63 <?php SvgIcon::make()->name( Icon::COMPLETED_FILL )->size( 16 )->color( Color::SUCCESS_PRIMARY )->render(); ?>
64 </template>
65 <template x-if="!isSolved">
66 <?php SvgIcon::make()->name( Icon::COMPLETED_CIRCLE )->render(); ?>
67 </template>
68 </span>
69 </template>
70 <?php esc_html_e( 'Solved', 'tutor' ); ?>
71 </button>
72
73 <button
74 class="tutor-btn tutor-btn-link tutor-btn-x-small tutor-gap-2 tutor-text-subdued"
75 @click="handleQnASingleAction(<?php echo esc_html( $question->comment_ID ); ?>, 'important')"
76 :disabled="qnaSingleActionMutation?.isPending"
77 >
78 <template x-if="qnaSingleActionMutation?.isPending && currentAction === 'important'">
79 <?php SvgIcon::make()->name( Icon::SPINNER )->size( 14 )->attr( 'class', 'tutor-animate-spin' )->render(); ?>
80 </template>
81 <template x-if="!(qnaSingleActionMutation?.isPending && currentAction === 'important')">
82 <span class="tutor-flex">
83 <template x-if="isImportant">
84 <?php SvgIcon::make()->name( Icon::BOOKMARK_FILL )->size( 16 )->color( Color::EXCEPTION4 )->render(); ?>
85 </template>
86 <template x-if="!isImportant">
87 <?php SvgIcon::make()->name( Icon::BOOKMARK )->render(); ?>
88 </template>
89 </span>
90 </template>
91 <?php esc_html_e( 'Important', 'tutor' ); ?>
92 </button>
93 </div>
94 <?php endif; ?>
95 </div>
96 <div class="tutor-discussion-single-body tutor-p-6 tutor-border-b">
97 <div class="tutor-flex tutor-gap-5 tutor-mb-5">
98 <?php Avatar::make()->user( $question->user_id )->size( Size::SIZE_40 )->render(); ?>
99 <div class="tutor-min-w-0 tutor-flex-1">
100 <div class="tutor-flex tutor-items-center tutor-gap-5 tutor-small">
101 <span class="tutor-discussion-card-author tutor-flex-shrink-0"><?php echo esc_html( $question->comment_author ); ?></span>
102 <span class="tutor-text-secondary tutor-flex-shrink-0">
103 <?php
104 /* translators: %s human-readable time difference. */
105 echo esc_html( sprintf( __( '%s ago', 'tutor' ), human_time_diff( strtotime( $question->comment_date_gmt ) ) ) );
106 ?>
107 </span>
108 </div>
109 <div class="tutor-tiny tutor-flex tutor-items-center tutor-gap-1 tutor-overflow-hidden">
110 <span class="tutor-text-subdued tutor-flex-shrink-0">asked in</span>
111 <div class="tutor-min-w-0 tutor-flex-1">
112 <?php PreviewTrigger::make()->id( $question->course_id )->render(); ?>
113 </div>
114 </div>
115 </div>
116 <div class="tutor-ml-auto">
117 <div x-data="tutorPopover({ placement: 'bottom-end', offset: 4 })" class="tutor-quiz-item-result-more">
118 <?php
119 Button::make()
120 ->label( __( 'More options', 'tutor' ) )
121 ->variant( Variant::GHOST )
122 ->size( Size::X_SMALL )
123 ->icon( Icon::ELLIPSES, 'left', Size::SIZE_16, Color::SECONDARY )
124 ->icon_only()
125 ->attr( 'x-ref', 'trigger' )
126 ->attr( '@click', 'toggle()' )
127 ->render();
128 ?>
129
130 <div
131 x-ref="content"
132 x-show="open"
133 x-cloak
134 @click.outside="handleClickOutside()"
135 class="tutor-popover"
136 >
137 <div class="tutor-popover-menu" style="min-width: 130px;">
138 <?php if ( User::is_instructor_view() ) : ?>
139 <button
140 class="tutor-popover-menu-item tutor-gap-5"
141 @click="handleQnASingleAction(<?php echo esc_html( $question->comment_ID ); ?>, 'archived')"
142 :disabled="qnaSingleActionMutation?.isPending"
143 >
144 <template x-if="qnaSingleActionMutation?.isPending && currentAction === 'archived'">
145 <?php SvgIcon::make()->name( Icon::SPINNER )->size( 20 )->color( Color::SECONDARY )->attr( 'class', 'tutor-animate-spin' )->render(); ?>
146 </template>
147 <template x-if="!(qnaSingleActionMutation?.isPending && currentAction === 'archived')">
148 <?php SvgIcon::make()->name( Icon::ARCHIVE_2 )->size( 20 )->render(); ?>
149 </template>
150 <span x-text="isArchived ? '<?php echo esc_js( __( 'Un-Archive', 'tutor' ) ); ?>' : '<?php echo esc_js( __( 'Archive', 'tutor' ) ); ?>'"></span>
151 </button>
152 <?php endif; ?>
153 <?php if ( $is_user_asker ) : ?>
154 <button class="tutor-popover-menu-item tutor-gap-5" @click="setEditing(<?php echo (int) $question->comment_ID; ?>, 'qna'); hide()">
155 <?php SvgIcon::make()->name( Icon::EDIT_2 )->size( 20 )->render(); ?>
156 <?php esc_html_e( 'Edit', 'tutor' ); ?>
157 </button>
158 <?php endif; ?>
159 <button
160 class="tutor-popover-menu-item tutor-gap-5"
161 @click="TutorCore.modal.showModal('<?php echo esc_js( $qna_delete_modal_id ); ?>', { question_id: <?php echo esc_html( $question->comment_ID ); ?> }); hide();"
162 >
163 <?php SvgIcon::make()->name( Icon::DELETE_2 )->size( 20 )->render(); ?> <?php esc_html_e( 'Delete', 'tutor' ); ?>
164 </button>
165 </div>
166 </div>
167 </div>
168 </div>
169 </div>
170
171 <div x-show="editingId !== <?php echo (int) $question->comment_ID; ?>" id="tutor-qna-text-<?php echo esc_attr( $question->comment_ID ); ?>" class="tutor-p1 tutor-font-medium tutor-text-secondary">
172 <?php echo wp_kses_post( $question->comment_content ); ?>
173 </div>
174
175 <?php if ( $is_user_asker ) : ?>
176 <div x-show="editingId === <?php echo (int) $question->comment_ID; ?>" x-cloak class="tutor-w-full">
177 <?php
178 tutor_load_template(
179 'dashboard.discussions.qna-form',
180 array(
181 'form_id' => 'qna-edit-' . (int) $question->comment_ID,
182 'default_value' => $question->comment_content,
183 'submit_handler' => '(data) => updateQnAMutation?.mutate({ ...data, question_id: ' . (int) $question->comment_ID . ' })',
184 'cancel_handler' => 'setEditing(null)',
185 'is_pending' => 'updateQnAMutation?.isPending',
186 'keep_footer_visible' => true,
187 )
188 );
189 ?>
190 </div>
191 <?php endif; ?>
192 </div>
193
194 <?php
195 tutor_load_template(
196 'dashboard.discussions.qna-form',
197 array(
198 'form_id' => 'qna-reply-form-' . $question->comment_ID,
199 'submit_handler' => '(data) => replyQnAMutation?.mutate({ ...data, question_id: ' . (int) $question->comment_ID . ', course_id: ' . (int) $question->course_id . ', reply_context: "single" })',
200 'cancel_handler' => 'reset(); focused = false',
201 'is_pending' => 'replyQnAMutation?.isPending',
202 'placeholder' => __( 'Just drop your response here!', 'tutor' ),
203 'label' => __( 'Reply', 'tutor' ),
204 'submit_label' => __( 'Save', 'tutor' ),
205 'form_class' => 'tutor-discussion-single-reply-form tutor-p-6',
206 )
207 );
208 ?>
209
210 <div id="tutor-discussion-replies-list">
211 <?php
212 tutor_load_template(
213 'dashboard.discussions.qna-replies',
214 array(
215 'replies' => $replies,
216 'replies_order' => $replies_order,
217 'user_id' => $user_id,
218 )
219 );
220 ?>
221 </div>
222
223 <?php
224 ConfirmationModal::make()
225 ->id( $qna_delete_modal_id )
226 ->title( __( 'Delete This Question?', 'tutor' ) )
227 ->message( __( 'Are you sure you want to delete this question permanently? Please confirm your choice.', 'tutor' ) )
228 ->confirm_text( __( 'Yes, Delete This', 'tutor' ) )
229 ->confirm_handler( 'deleteQnAMutation?.mutate(payload)' )
230 ->mutation_state( 'deleteQnAMutation' )
231 ->render();
232 ?>
233 </div>
234