PluginProbe
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses / 4.1.7.3
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses v4.1.7.3
4.4.8 4.4.7 4.4.6 4.4.5 4.4.4 4.4.3 4.4.2 4.4.1 4.4.0 4.3.9.1 4.3.9 4.3.8 4.3.7 4.1.6.9 4.1.6.9.1 4.1.6.9.2 4.1.6.9.3 4.1.6.9.4 4.1.7 4.1.7.1 4.1.7.2 4.1.7.3 4.1.7.3.1 4.1.7.3.2 4.2.0 All 139 releases
learnpress / inc / databases / class-lp-question-answers-db.php

class-lp-question-answers-db.php in LearnPress – WordPress LMS Plugin for Create and Sell Online Courses 4.1.7.3, at inc/databases/class-lp-question-answers-db.php

63 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 if ( ! defined( 'ABSPATH' ) ) {
4 exit; // Exit if accessed directly
5 }
6
7 /**
8 * Class LP_Quiz_Questions_DB
9 *
10 * @since 4.1.7
11 * @version 1.0.0
12 */
13 class LP_Question_Answers_DB extends LP_Database {
14 private static $_instance;
15
16 protected function __construct() {
17 parent::__construct();
18 }
19
20 public static function getInstance() {
21 if ( is_null( self::$_instance ) ) {
22 self::$_instance = new self();
23 }
24
25 return self::$_instance;
26 }
27
28 /**
29 * Get question answers
30 *
31 * @throws Exception
32 */
33 public function get_question_asnwers( LP_Question_Answers_Filter $filter, &$total_rows = 0 ) {
34 $default_fields = $this->get_cols_of_table( $this->tb_lp_question_answers );
35 $filter->fields = array_merge( $default_fields, $filter->fields );
36 $filter->exclude_fields[] = 'order';
37 $filter->fields[] = '`order`';
38
39 if ( empty( $filter->collection ) ) {
40 $filter->collection = $this->tb_lp_question_answers;
41 }
42
43 if ( empty( $filter->collection_alias ) ) {
44 $filter->collection_alias = 'qa';
45 }
46
47 // Question ids
48 if ( ! empty( $filter->question_ids ) ) {
49 $question_ids_format = LP_Helper::db_format_array( $filter->question_ids, '%d' );
50 $filter->where[] = $this->wpdb->prepare( "AND {$filter->collection_alias}.question_id IN (" . $question_ids_format . ')', $filter->question_ids );
51 }
52
53 // question_answer_ids
54 if ( ! empty( $filter->question_answer_ids ) ) {
55 $question_answer_ids_format = LP_Helper::db_format_array( $filter->question_answer_ids, '%d' );
56 $filter->where[] = $this->wpdb->prepare( "AND {$filter->collection_alias}.question_answer_id IN (" . $question_answer_ids_format . ')', $filter->question_answer_ids );
57 }
58
59 return $this->execute( $filter, $total_rows );
60 }
61 }
62
63