PluginProbe
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses / 4.4.2
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses v4.4.2
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-quiz-db.php

class-lp-quiz-db.php in LearnPress – WordPress LMS Plugin for Create and Sell Online Courses 4.4.2, at inc/Databases/class-lp-quiz-db.php

69 lines 1.2 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_Lesson_DB
9 *
10 * @since 3.2.7.4
11 * @author tungnx
12 * @version 1.0.0
13 */
14 class LP_Quiz_DB extends LP_Database {
15 private static $_instance;
16
17 protected function __construct() {
18 parent::__construct();
19 }
20
21 public static function getInstance() {
22 if ( is_null( self::$_instance ) ) {
23 self::$_instance = new self();
24 }
25
26 return self::$_instance;
27 }
28
29 /**
30 * Get quiz_id of question
31 *
32 * @param int $question_id
33 *
34 * @return int
35 */
36 public function get_quiz_id_by_question( int $question_id = 0 ) : int {
37 $query = $this->wpdb->prepare(
38 "
39 SELECT quiz_id
40 FROM $this->tb_lp_quiz_questions
41 WHERE question_id = %d",
42 $question_id
43 );
44
45 return (int) $this->wpdb->get_var( $query );
46 }
47
48 /**
49 * Get total questions assign for Quiz
50 *
51 * @param int $quiz_id
52 * @author tungnx
53 * @since 4.1.4.1
54 * @version 1.0.0
55 * @return int
56 */
57 public function get_total_question( int $quiz_id = 0 ) : int {
58 $query = $this->wpdb->prepare(
59 "SELECT COUNT(question_id) AS total
60 FROM $this->tb_lp_quiz_questions
61 WHERE quiz_id = %d",
62 $quiz_id
63 );
64
65 return (int) $this->wpdb->get_var( $query );
66 }
67 }
68
69