Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 14 |
|
0.00% |
0 / 6 |
CRAP | |
0.00% |
0 / 1 |
| TestSessionMemento | |
0.00% |
0 / 14 |
|
0.00% |
0 / 6 |
56 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| update | |
0.00% |
0 / 8 |
|
0.00% |
0 / 1 |
6 | |||
| getState | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getItem | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getSection | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getSession | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * This program is free software; you can redistribute it and/or |
| 5 | * modify it under the terms of the GNU General Public License |
| 6 | * as published by the Free Software Foundation; under version 2 |
| 7 | * of the License (non-upgradable). |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this program; if not, write to the Free Software |
| 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 17 | * |
| 18 | * Copyright (c) 2016 (original work) Open Assessment Technologies SA; |
| 19 | * |
| 20 | */ |
| 21 | |
| 22 | namespace oat\taoQtiTest\helpers; |
| 23 | |
| 24 | use qtism\runtime\tests\AssessmentTestSessionState; |
| 25 | use qtism\runtime\tests\AssessmentTestSession; |
| 26 | use qtism\data\AssessmentSection; |
| 27 | use qtism\data\AssessmentItemRef; |
| 28 | |
| 29 | /** |
| 30 | * Class represents test session state at a certain point in time. |
| 31 | * |
| 32 | * Class TestSessionMemento |
| 33 | * @package oat\taoQtiTest\helpers |
| 34 | */ |
| 35 | class TestSessionMemento |
| 36 | { |
| 37 | /** |
| 38 | * @var AssessmentTestSession |
| 39 | */ |
| 40 | private $session; |
| 41 | |
| 42 | /** |
| 43 | * @var AssessmentTestSessionState |
| 44 | */ |
| 45 | private $state; |
| 46 | |
| 47 | /** |
| 48 | * @var AssessmentItemRef |
| 49 | */ |
| 50 | private $item; |
| 51 | |
| 52 | /** |
| 53 | * @var AssessmentSection |
| 54 | */ |
| 55 | private $section; |
| 56 | |
| 57 | /** |
| 58 | * TestSessionMemento constructor. |
| 59 | * @param AssessmentTestSession $session |
| 60 | */ |
| 61 | public function __construct(AssessmentTestSession $session) |
| 62 | { |
| 63 | $this->session = $session; |
| 64 | $this->update(); |
| 65 | } |
| 66 | |
| 67 | /** |
| 68 | * Update memento |
| 69 | */ |
| 70 | public function update() |
| 71 | { |
| 72 | $session = $this->session; |
| 73 | $this->state = $session->getState(); |
| 74 | $route = $session->getRoute(); |
| 75 | if ($route->valid()) { |
| 76 | $this->item = $session->getCurrentAssessmentItemRef(); |
| 77 | $this->section = $session->getCurrentAssessmentSection(); |
| 78 | } else { |
| 79 | $this->item = false; |
| 80 | $this->section = false; |
| 81 | } |
| 82 | } |
| 83 | |
| 84 | /** |
| 85 | * @return int|AssessmentTestSessionState |
| 86 | */ |
| 87 | public function getState() |
| 88 | { |
| 89 | return $this->state; |
| 90 | } |
| 91 | |
| 92 | /** |
| 93 | * @return false|AssessmentItemRef |
| 94 | */ |
| 95 | public function getItem() |
| 96 | { |
| 97 | return $this->item; |
| 98 | } |
| 99 | |
| 100 | /** |
| 101 | * @return false|AssessmentSection |
| 102 | */ |
| 103 | public function getSection() |
| 104 | { |
| 105 | return $this->section; |
| 106 | } |
| 107 | |
| 108 | /** |
| 109 | * @return AssessmentTestSession |
| 110 | */ |
| 111 | public function getSession() |
| 112 | { |
| 113 | return $this->session; |
| 114 | } |
| 115 | } |