contexts.php
4 years ago
qna-new.php
3 years ago
qna-single.php
3 years ago
qna-table.php
3 years ago
qna-table.php
198 lines
| 1 | <?php |
| 2 | extract( $data ); // $qna_list, $context, $qna_pagination, $view_as |
| 3 | |
| 4 | $page_key = 'qna-table'; |
| 5 | $table_columns = include __DIR__ . '/contexts.php'; |
| 6 | $view_as = isset( $view_as ) ? $view_as : ( is_admin() ? 'instructor' : 'student' ); |
| 7 | ?> |
| 8 | <?php if ( is_array( $qna_list ) && count( $qna_list ) ) : ?> |
| 9 | <div class="tutor-table-responsive"> |
| 10 | <table data-qna_context="<?php echo esc_attr( $context ); ?>" class="frontend-dashboard-qna-table-<?php echo esc_attr( $view_as ); ?> tutor-table tutor-table-middle qna-list-table"> |
| 11 | <thead> |
| 12 | <tr> |
| 13 | <?php foreach ( $table_columns as $key => $column ) : ?> |
| 14 | <th style="<?php echo $key == 'question' ? 'width: 40%;' : ''; ?>"> |
| 15 | <?php echo ( $key != 'action' ? $column : '' ); ?> |
| 16 | </th> |
| 17 | <?php endforeach; ?> |
| 18 | </tr> |
| 19 | </thead> |
| 20 | |
| 21 | <tbody> |
| 22 | <?php |
| 23 | $current_user_id = get_current_user_id(); |
| 24 | foreach ( $qna_list as $qna ) : |
| 25 | $id_string_delete = 'tutor_delete_qna_' . $qna->comment_ID; |
| 26 | $row_id = 'tutor_qna_row_' . $qna->comment_ID; |
| 27 | $menu_id = 'tutor_qna_menu_id_' . $qna->comment_ID; |
| 28 | $is_self = $current_user_id == $qna->user_id; |
| 29 | $key_slug = $context == 'frontend-dashboard-qna-table-student' ? '_' . $current_user_id : ''; |
| 30 | |
| 31 | $meta = $qna->meta; |
| 32 | $is_solved = (int) tutor_utils()->array_get( 'tutor_qna_solved' . $key_slug, $meta, 0 ); |
| 33 | $is_important = (int) tutor_utils()->array_get( 'tutor_qna_important' . $key_slug, $meta, 0 ); |
| 34 | $is_archived = (int) tutor_utils()->array_get( 'tutor_qna_archived' . $key_slug, $meta, 0 ); |
| 35 | $is_read = (int) tutor_utils()->array_get( 'tutor_qna_read' . $key_slug, $meta, 0 ); |
| 36 | ?> |
| 37 | <tr id="<?php echo esc_attr( $row_id ); ?>" data-question_id="<?php echo esc_attr( $qna->comment_ID ); ?>" class="<?php echo $is_read ? 'is-qna-read' : ''; ?>"> |
| 38 | <?php foreach ( $table_columns as $key => $column ) : ?> |
| 39 | <td> |
| 40 | <?php if ( $key == 'checkbox' ) : ?> |
| 41 | <div class="tutor-d-flex tutor-align-center"> |
| 42 | <input id="tutor-admin-list-<?php echo esc_attr( $qna->comment_ID ); ?>" type="checkbox" class="tutor-form-check-input tutor-bulk-checkbox" name="tutor-bulk-checkbox-all" value="<?php echo esc_attr( $qna->comment_ID ); ?>" /> |
| 43 | </div> |
| 44 | <?php elseif ( $key == 'student' ) : ?> |
| 45 | <div class="tutor-d-flex tutor-align-center tutor-gap-2"> |
| 46 | <div class="tooltip-wrap tooltip-icon-custom tutor-qna-badges-wrapper tutor-mt-4"> |
| 47 | <span |
| 48 | data-state-class-0="tutor-icon-important-line" |
| 49 | data-state-class-1="tutor-icon-important-bold" |
| 50 | data-action="important" |
| 51 | data-state-class-selector="i" |
| 52 | > |
| 53 | <i class="<?php echo $is_important ? 'tutor-icon-important-bold' : 'tutor-icon-important-line'; ?> tutor-cursor-pointer" area-hidden="true"></i> |
| 54 | </span> |
| 55 | |
| 56 | <span class="tooltip-txt tooltip-bottom"> |
| 57 | <?php $is_important ? esc_html_e( 'This conversation is important', 'tutor' ) : esc_html_e( 'Mark this conversation as important', 'tutor' ); ?> |
| 58 | </span> |
| 59 | </div> |
| 60 | |
| 61 | <?php echo tutor_utils()->get_tutor_avatar( $qna->user_id ); ?> |
| 62 | |
| 63 | <div> |
| 64 | <div> |
| 65 | <?php echo esc_html( $qna->display_name ); ?> |
| 66 | </div> |
| 67 | <div class="tutor-fs-7 tutor-color-muted tutor-mt-4"> |
| 68 | <?php echo esc_html( human_time_diff( strtotime( $qna->comment_date ) ) ); ?> |
| 69 | </div> |
| 70 | </div> |
| 71 | </div> |
| 72 | <?php elseif ( $key == 'question' ) : ?> |
| 73 | <?php $content = ( stripslashes( $qna->comment_content ) ); ?> |
| 74 | <a href="<?php echo esc_url( add_query_arg( array( 'question_id' => $qna->comment_ID ), tutor()->current_url ) ); ?>"> |
| 75 | <div class="tutor-form-feedback tutor-qna-question-col <?php echo $is_read ? 'is-read' : ''; ?>"> |
| 76 | <i class="tutor-icon-bullet-point tutor-form-feedback-icon" area-hidden="true"></i> |
| 77 | <div class="tutor-qna-desc"> |
| 78 | <div class="tutor-qna-content tutor-fs-6 tutor-fw-bold tutor-color-black"> |
| 79 | <?php |
| 80 | $limit = 60; |
| 81 | $content = strlen( $content ) > $limit ? substr( $content, 0, $limit ) . '...' : $content; |
| 82 | |
| 83 | echo $content //phpcs:ignore |
| 84 | ?> |
| 85 | </div> |
| 86 | <div class="tutor-fs-7 tutor-color-secondary"> |
| 87 | <span class="tutor-fw-medium"><?php esc_html_e( 'Course' ); ?>:</span> |
| 88 | <span><?php echo esc_html( $qna->post_title ); ?></span> |
| 89 | </div> |
| 90 | </div> |
| 91 | </div> |
| 92 | </a> |
| 93 | <?php elseif ( $key == 'reply' ) : ?> |
| 94 | <?php echo esc_html( $qna->answer_count ); ?> |
| 95 | <?php elseif ( $key == 'waiting_since' ) : ?> |
| 96 | <?php echo esc_html( human_time_diff( strtotime( $qna->comment_date ) ) ); ?> |
| 97 | <?php elseif ( $key == 'status' ) : ?> |
| 98 | <div class="tooltip-wrap tooltip-icon-custom" > |
| 99 | <i class="tutor-fs-4 <?php echo $is_solved ? 'tutor-icon-circle-mark tutor-color-success' : 'tutor-icon-circle-mark-line tutor-color-muted'; ?>"></i> |
| 100 | <span class="tooltip-txt tooltip-bottom"> |
| 101 | <?php $is_solved ? esc_html_e( 'Solved', 'tutor' ) : esc_html_e( 'Unresolved Yet', 'tutor' ); ?> |
| 102 | </span> |
| 103 | </div> |
| 104 | <?php elseif ( $key == 'action' ) : ?> |
| 105 | <div class="tutor-d-flex tutor-align-center tutor-justify-end tutor-gap-1"> |
| 106 | <a href="<?php echo esc_url( add_query_arg( array( 'question_id' => $qna->comment_ID ), tutor()->current_url ) ); ?>" class="tutor-btn tutor-btn-outline-primary tutor-btn-sm"> |
| 107 | <?php esc_html_e( 'Reply', 'tutor-pro' ); ?> |
| 108 | </a> |
| 109 | |
| 110 | <div class="tutor-dropdown-parent"> |
| 111 | <button type="button" class="tutor-iconic-btn" action-tutor-dropdown="toggle"> |
| 112 | <span class="tutor-icon-kebab-menu" area-hidden="true"></span> |
| 113 | </button> |
| 114 | <ul class="tutor-dropdown tutor-dropdown-dark tutor-text-left"> |
| 115 | <?php if ( $context != 'frontend-dashboard-qna-table-student' ) : ?> |
| 116 | <li class="tutor-qna-badges tutor-qna-badges-wrapper"> |
| 117 | <a class="tutor-dropdown-item" href="#" data-action="archived" data-state-text-selector="[data-state-text]" data-state-class-selector="[data-state-class]" data-state-text-0="<?php esc_attr_e( 'Archive', 'tutor' ); ?>" data-state-text-1="<?php esc_attr_e( 'Un-archive', 'tutor' ); ?>"> |
| 118 | <span class="tutor-icon-archive tutor-mr-8" data-state-class></span> |
| 119 | <span data-state-text> |
| 120 | <?php $is_archived ? esc_html_e( 'Un-archive', 'tutor' ) : esc_html_e( 'Archive', 'tutor' ); ?> |
| 121 | </span> |
| 122 | </a> |
| 123 | </li> |
| 124 | <?php endif; ?> |
| 125 | <li class="tutor-qna-badges tutor-qna-badges-wrapper"> |
| 126 | <a class="tutor-dropdown-item" href="#" data-action="read" data-state-text-selector="[data-state-text]" data-state-class-selector="[data-state-class]" data-state-text-0="<?php esc_attr_e( 'Mark as Read', 'tutor' ); ?>" data-state-text-1="<?php esc_attr_e( 'Mark as Unread', 'tutor' ); ?>"> |
| 127 | <span class="tutor-icon-envelope tutor-mr-8" data-state-class></span> |
| 128 | <span data-state-text> |
| 129 | <?php $is_read ? esc_html_e( 'Mark as Unread', 'tutor' ) : esc_html_e( 'Mark as read', 'tutor' ); ?> |
| 130 | </span> |
| 131 | </a> |
| 132 | </li> |
| 133 | <li> |
| 134 | <a class="tutor-dropdown-item" href="#" data-tutor-modal-target="<?php echo esc_attr( $id_string_delete ); ?>"> |
| 135 | <span class="tutor-icon-trash-can-bold tutor-mr-8"></span> |
| 136 | <span><?php esc_html_e( 'Delete', 'tutor' ); ?></span> |
| 137 | </a> |
| 138 | </li> |
| 139 | </ul> |
| 140 | </div> |
| 141 | |
| 142 | <!-- Delete confirmation modal --> |
| 143 | <div id="<?php echo esc_attr( $id_string_delete ); ?>" class="tutor-modal"> |
| 144 | <div class="tutor-modal-overlay"></div> |
| 145 | <div class="tutor-modal-window"> |
| 146 | <div class="tutor-modal-content tutor-modal-content-white"> |
| 147 | <button class="tutor-iconic-btn tutor-modal-close-o" data-tutor-modal-close> |
| 148 | <span class="tutor-icon-times" area-hidden="true"></span> |
| 149 | </button> |
| 150 | |
| 151 | <div class="tutor-modal-body tutor-text-center"> |
| 152 | <div class="tutor-mt-48"> |
| 153 | <img class="tutor-d-inline-block" src="<?php echo esc_url( trailingslashit( tutor()->url ) . 'assets/images/icon-trash.svg' ); ?>" /> |
| 154 | </div> |
| 155 | |
| 156 | <div class="tutor-fs-3 tutor-fw-medium tutor-color-black tutor-mb-12"><?php esc_html_e( 'Delete This Question?', 'tutor' ); ?></div> |
| 157 | <div class="tutor-fs-6 tutor-color-muted"><?php esc_html_e( 'All the replies also will be deleted.', 'tutor' ); ?></div> |
| 158 | |
| 159 | <div class="tutor-d-flex tutor-justify-center tutor-my-48"> |
| 160 | <button data-tutor-modal-close class="tutor-btn tutor-btn-outline-primary"> |
| 161 | <?php esc_html_e( 'Cancel', 'tutor' ); ?> |
| 162 | </button> |
| 163 | <button class="tutor-btn tutor-btn-primary tutor-list-ajax-action tutor-ml-20" data-request_data='{"question_id":<?php echo $qna->comment_ID; ?>,"action":"tutor_delete_dashboard_question"}' data-delete_element_id="<?php echo esc_attr( $row_id ); ?>"> |
| 164 | <?php esc_html_e( 'Yes, Delete This', 'tutor' ); ?> |
| 165 | </button> |
| 166 | </div> |
| 167 | </div> |
| 168 | </div> |
| 169 | </div> |
| 170 | </div> |
| 171 | </div> |
| 172 | <?php endif; ?> |
| 173 | </td> |
| 174 | <?php endforeach; ?> |
| 175 | </tr> |
| 176 | <?php endforeach; ?> |
| 177 | </tbody> |
| 178 | </table> |
| 179 | </div> |
| 180 | <?php else : ?> |
| 181 | <?php tutor_utils()->tutor_empty_state( tutor_utils()->not_found_text() ); ?> |
| 182 | <?php endif; ?> |
| 183 | |
| 184 | <?php if ( $qna_pagination['total_items'] > $qna_pagination['per_page'] ) : ?> |
| 185 | <div class="tutor-mt-32"> |
| 186 | <?php |
| 187 | $pagination_data = array( |
| 188 | 'base' => ! empty( $qna_pagination['base'] ) ? $qna_pagination['base'] : null, |
| 189 | 'total_items' => $qna_pagination['total_items'], |
| 190 | 'per_page' => $qna_pagination['per_page'], |
| 191 | 'paged' => $qna_pagination['paged'], |
| 192 | ); |
| 193 | $pagination_template = tutor()->path . 'views/elements/pagination.php'; |
| 194 | tutor_load_template_from_custom_path( $pagination_template, $pagination_data ); |
| 195 | ?> |
| 196 | </div> |
| 197 | <?php endif; ?> |
| 198 |