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