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

PageBreakQuestion::createForm()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 28
Code Lines 20

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 20
nc 1
nop 2
dl 0
loc 28
rs 9.6
c 1
b 0
f 0
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