comment-card.php
4 days ago
comment-form.php
4 days ago
comment-list.php
4 days ago
comment-replies.php
4 days ago
comment-single.php
4 days ago
qna-card.php
4 days ago
qna-form.php
4 days ago
qna-list.php
4 days ago
qna-replies.php
4 days ago
qna-single.php
4 days ago
qna-list.php
122 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Q&A list 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 | * These variables are inherited from the parent template file. |
| 12 | * template: /tutor/templates/dashboard/discussions.php |
| 13 | * |
| 14 | * @var string $discussion_url |
| 15 | * @var int $item_per_page |
| 16 | * @var int $offset |
| 17 | * @var string $order_filter |
| 18 | * @var int $current_page |
| 19 | */ |
| 20 | |
| 21 | defined( 'ABSPATH' ) || exit; |
| 22 | |
| 23 | use Tutor\Components\ConfirmationModal; |
| 24 | use Tutor\Components\DropdownFilter; |
| 25 | use Tutor\Components\EmptyState; |
| 26 | use Tutor\Components\Pagination; |
| 27 | use Tutor\Components\Sorting; |
| 28 | use TUTOR\Input; |
| 29 | use TUTOR\User; |
| 30 | |
| 31 | $user_id = get_current_user_id(); |
| 32 | $is_instructor = tutor_utils()->is_instructor( $user_id, true ); |
| 33 | $q_status = Input::get( 'data' ); |
| 34 | $view_as = User::get_current_view_mode(); |
| 35 | $asker_id = User::is_instructor_view() ? null : $user_id; |
| 36 | |
| 37 | $total_items = (int) tutor_utils()->get_qa_questions( $offset, $item_per_page, '', null, null, $asker_id, $q_status, true ); |
| 38 | $questions = tutor_utils()->get_qa_questions( $offset, $item_per_page, '', null, null, $asker_id, $q_status, false, array( 'order' => $order_filter ) ); |
| 39 | |
| 40 | $nav_items = array( |
| 41 | array( |
| 42 | 'label' => __( 'All', 'tutor' ), |
| 43 | 'value' => '', |
| 44 | 'count' => $total_items, |
| 45 | ), |
| 46 | array( |
| 47 | 'label' => __( 'Read', 'tutor' ), |
| 48 | 'value' => 'read', |
| 49 | 'count' => tutor_utils()->get_qa_questions( $offset, $item_per_page, '', null, null, $asker_id, 'read', true ), |
| 50 | ), |
| 51 | array( |
| 52 | 'label' => __( 'Unread', 'tutor' ), |
| 53 | 'value' => 'unread', |
| 54 | 'count' => tutor_utils()->get_qa_questions( $offset, $item_per_page, '', null, null, $asker_id, 'unread', true ), |
| 55 | ), |
| 56 | ...( User::is_instructor_view() ? array( |
| 57 | array( |
| 58 | 'label' => __( 'Important', 'tutor' ), |
| 59 | 'value' => 'important', |
| 60 | 'count' => tutor_utils()->get_qa_questions( $offset, $item_per_page, '', null, null, $asker_id, 'important', true ), |
| 61 | ), |
| 62 | array( |
| 63 | 'label' => __( 'Archived', 'tutor' ), |
| 64 | 'value' => 'archived', |
| 65 | 'count' => tutor_utils()->get_qa_questions( $offset, $item_per_page, '', null, null, $asker_id, 'archived', true ), |
| 66 | ), |
| 67 | ) : array() ), |
| 68 | ); |
| 69 | ?> |
| 70 | <div class="tutor-flex tutor-items-center tutor-justify-between tutor-px-6 tutor-py-5 tutor-sm-p-5 tutor-border-b"> |
| 71 | <?php DropdownFilter::make()->options( $nav_items )->query_param( 'data' )->render(); ?> |
| 72 | <div class="tutor-discussion-filter-right"> |
| 73 | <?php Sorting::make()->order( $order_filter )->render(); ?> |
| 74 | </div> |
| 75 | </div> |
| 76 | |
| 77 | <?php if ( empty( $questions ) ) : ?> |
| 78 | <?php |
| 79 | EmptyState::make() |
| 80 | ->title( 'No Questions Found!' ) |
| 81 | ->icon( tutor_utils()->get_themed_svg( 'images/illustrations/qna-empty.svg' ) ) |
| 82 | ->render(); |
| 83 | ?> |
| 84 | <?php else : ?> |
| 85 | <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"> |
| 86 | <?php |
| 87 | foreach ( $questions as $question ) : |
| 88 | tutor_load_template( |
| 89 | 'dashboard.discussions.qna-card', |
| 90 | array( |
| 91 | 'question' => $question, |
| 92 | 'view_as' => $view_as, |
| 93 | 'discussion_url' => $discussion_url, |
| 94 | ) |
| 95 | ); |
| 96 | endforeach; |
| 97 | ?> |
| 98 | </div> |
| 99 | <?php endif; ?> |
| 100 | |
| 101 | <?php |
| 102 | Pagination::make() |
| 103 | ->current( $current_page ) |
| 104 | ->total( $total_items ) |
| 105 | ->limit( $item_per_page ) |
| 106 | ->attr( 'class', 'tutor-px-6 tutor-pb-6 tutor-sm-p-5 tutor-sm-border-t' ) |
| 107 | ->render(); |
| 108 | ?> |
| 109 | |
| 110 | <?php |
| 111 | if ( ! empty( $questions ) ) { |
| 112 | ConfirmationModal::make() |
| 113 | ->id( 'tutor-qna-delete-modal' ) |
| 114 | ->title( __( 'Delete This Question?', 'tutor' ) ) |
| 115 | ->message( __( 'Are you sure you want to delete this question permanently? Please confirm your choice.', 'tutor' ) ) |
| 116 | ->confirm_text( __( 'Yes, Delete This', 'tutor' ) ) |
| 117 | ->confirm_handler( 'deleteQnAMutation?.mutate(payload)' ) |
| 118 | ->mutation_state( 'deleteQnAMutation' ) |
| 119 | ->render(); |
| 120 | } |
| 121 | ?> |
| 122 |