Addons.php
4 years ago
Admin.php
4 years ago
Ajax.php
4 years ago
Announcements.php
4 years ago
Assets.php
3 years ago
Backend_Page_Trait.php
4 years ago
Course.php
3 years ago
Course_Filter.php
4 years ago
Course_List.php
3 years ago
Course_Settings_Tabs.php
4 years ago
Course_Widget.php
4 years ago
Custom_Validation.php
4 years ago
Dashboard.php
3 years ago
FormHandler.php
4 years ago
Frontend.php
3 years ago
Gutenberg.php
4 years ago
Input.php
3 years ago
Instructor.php
4 years ago
Instructors_List.php
3 years ago
Lesson.php
4 years ago
Options_V2.php
3 years ago
Post_types.php
4 years ago
Private_Course_Access.php
4 years ago
Q_and_A.php
4 years ago
Question_Answers_List.php
4 years ago
Quiz.php
4 years ago
Quiz_Attempts_List.php
4 years ago
RestAPI.php
4 years ago
Reviews.php
4 years ago
Rewrite_Rules.php
4 years ago
Shortcode.php
4 years ago
Student.php
4 years ago
Students_List.php
4 years ago
Taxonomies.php
4 years ago
Template.php
3 years ago
Theme_Compatibility.php
5 years ago
Tools.php
3 years ago
Tools_V2.php
4 years ago
Tutor.php
3 years ago
TutorEDD.php
4 years ago
Tutor_Base.php
5 years ago
Tutor_List_Table.php
4 years ago
Tutor_Setup.php
4 years ago
Upgrader.php
4 years ago
User.php
4 years ago
Utils.php
3 years ago
Video_Stream.php
4 years ago
Withdraw.php
3 years ago
Withdraw_Requests_List.php
4 years ago
WooCommerce.php
3 years ago
Question_Answers_List.php
78 lines
| 1 | <?php |
| 2 | namespace TUTOR; |
| 3 | |
| 4 | if ( ! defined( 'ABSPATH' ) ) { |
| 5 | exit; |
| 6 | } |
| 7 | |
| 8 | class Question_Answers_List { |
| 9 | |
| 10 | use Backend_Page_Trait; |
| 11 | |
| 12 | const Question_Answer_PAGE = 'question_answer'; |
| 13 | |
| 14 | function __construct($register_hook=true) { |
| 15 | if(!$register_hook) { |
| 16 | return; |
| 17 | } |
| 18 | |
| 19 | } |
| 20 | |
| 21 | |
| 22 | function get_items($args=array()) { |
| 23 | $per_page = tutor_utils()->get_option( 'pagination_per_page' ); |
| 24 | |
| 25 | $search_term = ''; |
| 26 | if (isset($args['search'])){ |
| 27 | $search_term = sanitize_text_field($args['search']); |
| 28 | } |
| 29 | |
| 30 | $current_page = isset( $_REQUEST['paged'] ) ? absint( $_REQUEST['paged'] ) : 1; |
| 31 | |
| 32 | $question_status= !empty($args['tab']) ? $args['tab'] : null; |
| 33 | $items = tutor_utils()->get_qa_questions(($current_page-1)*$per_page, $per_page, $search_term, null, null, null, $question_status, false, $args); |
| 34 | $total_items = tutor_utils()->get_qa_questions(($current_page-1)*$per_page, $per_page, $search_term, null, null, null, $question_status, true, $args); |
| 35 | |
| 36 | return array( |
| 37 | 'items' => $items, |
| 38 | 'pagination' => array( |
| 39 | 'total_items' => $total_items, |
| 40 | 'per_page' => $per_page, |
| 41 | 'paged' => $current_page |
| 42 | ) |
| 43 | ); |
| 44 | } |
| 45 | |
| 46 | public function get_bulk_actions() { |
| 47 | return array( |
| 48 | $this->bulk_action_default(), |
| 49 | $this->bulk_action_delete() |
| 50 | ); |
| 51 | } |
| 52 | |
| 53 | /** |
| 54 | * Get answer list by question id & type |
| 55 | * |
| 56 | * @since v2.0.2 |
| 57 | * |
| 58 | * @param integer $question_id |
| 59 | * @param string $question_type |
| 60 | * |
| 61 | * @return array list of answer |
| 62 | */ |
| 63 | public static function answer_list_by_question( int $question_id, string $question_type ): array { |
| 64 | global $wpdb; |
| 65 | $answers = $wpdb->get_results( |
| 66 | $wpdb->prepare( |
| 67 | "SELECT * FROM {$wpdb->prefix}tutor_quiz_question_answers |
| 68 | where belongs_question_id = %d |
| 69 | AND belongs_question_type = %s |
| 70 | order by answer_order asc ;", |
| 71 | $question_id, |
| 72 | $question_type |
| 73 | ) |
| 74 | ); |
| 75 | return is_array( $answers ) && count( $answers ) ? $answers : array(); |
| 76 | } |
| 77 | } |
| 78 |