Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
55.56% |
5 / 9 |
|
66.67% |
2 / 3 |
CRAP | |
0.00% |
0 / 1 |
| CvsToQtiTemplateDecorator | |
55.56% |
5 / 9 |
|
66.67% |
2 / 3 |
9.16 | |
0.00% |
0 / 1 |
| __construct | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| getCsvColumns | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getQtiTemplatePath | |
33.33% |
2 / 6 |
|
0.00% |
0 / 1 |
8.74 | |||
| 1 | <?php |
| 2 | |
| 3 | /* |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or |
| 6 | * modify it under the terms of the GNU General Public License |
| 7 | * as published by the Free Software Foundation; under version 2 |
| 8 | * of the License (non-upgradable). |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program; if not, write to the Free Software |
| 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 18 | * |
| 19 | * Copyright (c) 2021 (original work) Open Assessment Technologies SA; |
| 20 | */ |
| 21 | |
| 22 | declare(strict_types=1); |
| 23 | |
| 24 | namespace oat\taoQtiItem\model\import\Decorator; |
| 25 | |
| 26 | use oat\taoQtiItem\model\import\ItemInterface; |
| 27 | use oat\taoQtiItem\model\import\TemplateInterface; |
| 28 | |
| 29 | class CvsToQtiTemplateDecorator |
| 30 | { |
| 31 | /** |
| 32 | * @var array |
| 33 | */ |
| 34 | private $csvColumns; |
| 35 | |
| 36 | /** |
| 37 | * @var string |
| 38 | */ |
| 39 | private $qtiTemplatePath; |
| 40 | |
| 41 | public function __construct(TemplateInterface $template) |
| 42 | { |
| 43 | $this->qtiTemplatePath = $template->getDefinition()['target']['templatePath'] ?? []; |
| 44 | $this->csvColumns = $template->getDefinition()['columns'] ?? []; |
| 45 | } |
| 46 | |
| 47 | public function getCsvColumns(): array |
| 48 | { |
| 49 | return $this->csvColumns; |
| 50 | } |
| 51 | |
| 52 | public function getQtiTemplatePath(ItemInterface $item): string |
| 53 | { |
| 54 | if ($item->isNoneResponse()) { |
| 55 | return $this->qtiTemplatePath['noResponse']; |
| 56 | } |
| 57 | |
| 58 | if ($item->isMapResponse()) { |
| 59 | return $this->qtiTemplatePath['mapResponse']; |
| 60 | } |
| 61 | |
| 62 | if ($item->isMatchCorrectResponse()) { |
| 63 | return $this->qtiTemplatePath['matchCorrectResponse']; |
| 64 | } |
| 65 | } |
| 66 | } |