PluginProbe
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses / trunk
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses vtrunk
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 4.2.1 4.2.1.1 All 137 releases
learnpress / inc / Models / Question / QuestionPostFIBModel.php

QuestionPostFIBModel.php in LearnPress – WordPress LMS Plugin for Create and Sell Online Courses trunk, at inc/Models/Question/QuestionPostFIBModel.php

51 lines 999 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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 }
51