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 / question / class-lp-question-single-choice.php

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

68 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * LP_Question_Single_Choice
4 *
5 * @author ThimPress
6 * @package LearnPress/Templates
7 * @version 3.0.0
8 * @extends LP_Question
9 */
10
11 /**
12 * Prevent loading this file directly
13 */
14 defined( 'ABSPATH' ) || exit();
15
16 if ( ! class_exists( 'LP_Question_Single_Choice' ) ) {
17
18 /**
19 * Class LP_Question_Single_Choice
20 */
21 class LP_Question_Single_Choice extends LP_Question {
22
23 /**
24 * Type of this question.
25 *
26 * @var string
27 */
28 protected $_question_type = 'single_choice';
29
30 /**
31 * LP_Question_Single_Choice constructor.
32 *
33 * @param null $the_question
34 * @param null $args
35 *
36 * @throws Exception
37 */
38 public function __construct( $the_question = null, $args = null ) {
39 parent::__construct( $the_question, $args );
40
41 }
42
43 /**
44 * Check user answer.
45 *
46 * @param null $user_answer
47 *
48 * @return array
49 */
50 public function check( $user_answer = null ) {
51 $return = parent::check();
52 $answers = $this->get_answers();
53
54 if ( $answers ) {
55 foreach ( $answers as $key => $option ) {
56 if ( ( $option['is_true'] == 'yes' ) && ( $this->is_selected_option( $option, $user_answer ) ) ) {
57 $return['correct'] = true;
58 $return['mark'] = floatval( $this->get_mark() );
59 break;
60 }
61 }
62 }
63
64 return $return;
65 }
66 }
67 }
68