Passed
Pull Request — master (#6549)
by
unknown
08:39
created

PageBreakQuestion   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 30
dl 0
loc 52
rs 10
c 1
b 0
f 0
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A createForm() 0 28 1
A __construct() 0 5 1
A processAnswersCreation() 0 1 1
A processCreation() 0 6 1
A createAnswersForm() 0 1 1
1
<?php
2
/* For licensing terms, see /license.txt */
3
4
class PageBreakQuestion extends Question
5
{
6
    public $typePicture = 'page_break.png';
7
    public $explanationLangVar = 'PageBreak';
8
9
    public function __construct()
10
    {
11
        parent::__construct();
12
        $this->type      = PAGE_BREAK;
13
        $this->isContent = 1;
14
    }
15
16
    public function createForm(&$form, $exercise)
17
    {
18
        $form->addText(
19
            'questionName',
20
            get_lang('Page Title'),
21
            false,
22
            ['maxlength' => 255]
23
        );
24
        $editorConfig = [
25
            'ToolbarSet' => 'TestQuestionDescription',
26
            'Height'     => '100'
27
        ];
28
        $form->addHtmlEditor(
29
            'questionDescription',
30
            get_lang('Page Introduction'),
31
            false,
32
            false,
33
            $editorConfig
34
        );
35
36
        global $text;
37
        $form->addButtonSave($text, 'submitQuestion');
38
39
        $defaults = [
40
            'questionName'        => $this->question,
41
            'questionDescription' => $this->description
42
        ];
43
        $form->setDefaults($defaults);
44
    }
45
46
    public function createAnswersForm($form) {}
47
48
    public function processAnswersCreation($form, $exercise) {}
49
50
    public function processCreation(FormValidator $form, Exercise $exercise)
51
    {
52
        $this->updateTitle($form->getSubmitValue('questionName'));
53
        $this->updateDescription($form->getSubmitValue('questionDescription'));
54
        $this->save($exercise);
55
        $exercise->addToList($this->id);
56
    }
57
}
58