Completed
Push — master ( 35046b...d215ab )
by Mikołaj
03:13
created

QuestionDelete::postDeleteAction()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 18
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 18
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 12
nc 2
nop 2
1
<?php
2
3
namespace Egzaminer\Question;
4
5
use Egzaminer\Admin\Dashboard as Controller;
6
7
class QuestionDelete extends Controller
8
{
9
    public function deleteAction($testId, $id)
10
    {
11
        $question = (new Questions($this->get('dbh')))->getByQuestionId($id);
12
13
        $this->render('admin-delete', [
14
            'title'   => 'Usuwanie pytania',
15
            'content' => 'Czy na pewno chcesz usunąć pytanie <i>'.$question['content'].'</i>?',
16
        ]);
17
    }
18
19
    public function postDeleteAction($examID, $questionID)
20
    {
21
        $delModel = new QuestionDeleteModel($this->get('dbh'));
22
23
        if ($delModel->delete($questionID)) {
24
            $this->redirectWithMessage(
25
                '/admin/test/edit/'.$examID,
26
                'success',
27
                'Usunięto pomyślnie!'
28
            );
29
        } else {
30
            $this->redirectWithMessage(
31
                '/admin/test/edit/'.$examID.'/question/del/'.$questionID,
32
                'warning',
33
                'Coś się zepsuło!'
34
            );
35
        }
36
    }
37
}
38