PluginProbe
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses / 4.4.8
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses v4.4.8
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
← All changes | inc/Models/Question/QuestionPostFIBModel.php +50 -50 4.3.9.14.4.8 View file →
@@ -1,50 +1,50 @@
1 -<?php
2 -
3 -namespace LearnPress\Models\Question;
4 -
5 -/**
6 - * Class QuestionPostFIBModel
7 - * Question type Fill in the Blank
8 - *
9 - * @package LearnPress/Classes
10 - * @version 1.0.0
11 - * @since 4.2.9
12 - */
13 -class QuestionPostFIBModel extends QuestionPostModel {
14 - public $question_type = 'fill_in_blanks';
15 -
16 - /**
17 - * Create default answers for question
18 - *
19 - * @return array[]
20 - */
21 - public function get_default_answers(): array {
22 - return array(
23 - array(
24 - 'value' => $this->random_value(),
25 - 'title' => '',
26 - ),
27 - );
28 - }
29 -
30 - /**
31 - * Convert content to format [fib fill="" id="" ]
32 - *
33 - * @param string $content
34 - *
35 - * @return string
36 - */
37 - public function convert_content_from_editor_to_db( string $content ): string {
38 - $pattern = '#<span class="lp-question-fib-input" data-id="([^"]+)">([^<]+)<\/span>#';
39 -
40 - return preg_replace_callback(
41 - $pattern,
42 - function ( $matches ) {
43 - $id = $matches[1];
44 - $fill = $matches[2];
45 - return '[fib fill="' . $fill . '" id="' . $id . '" ]';
46 - },
47 - $content
48 - );
49 - }
50 -}
1 +<?php
2 +
3 +namespace LearnPress\Models\Question;
4 +
5 +/**
6 + * Class QuestionPostFIBModel
7 + * Question type Fill in the Blank
8 + *
9 + * @package LearnPress/Classes
10 + * @version 1.0.0
11 + * @since 4.2.9
12 + */
13 +class QuestionPostFIBModel extends QuestionPostModel {
14 + public $question_type = 'fill_in_blanks';
15 +
16 + /**
17 + * Create default answers for question
18 + *
19 + * @return array[]
20 + */
21 + public function get_default_answers(): array {
22 + return array(
23 + array(
24 + 'value' => $this->random_value(),
25 + 'title' => '',
26 + ),
27 + );
28 + }
29 +
30 + /**
31 + * Convert content to format [fib fill="" id="" ]
32 + *
33 + * @param string $content
34 + *
35 + * @return string
36 + */
37 + public function convert_content_from_editor_to_db( string $content ): string {
38 + $pattern = '#<span class="lp-question-fib-input" data-id="([^"]+)">([^<]+)<\/span>#';
39 +
40 + return preg_replace_callback(
41 + $pattern,
42 + function ( $matches ) {
43 + $id = $matches[1];
44 + $fill = $matches[2];
45 + return '[fib fill="' . $fill . '" id="' . $id . '" ]';
46 + },
47 + $content
48 + );
49 + }
50 +}