Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 8 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
TestPreviewerAssessmentTestGenerator | |
0.00% |
0 / 8 |
|
0.00% |
0 / 3 |
12 | |
0.00% |
0 / 1 |
generate | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
2 | |||
getQtiTestService | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getItemResolver | |
0.00% |
0 / 2 |
|
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) 2020 (original work) Open Assessment Technologies SA ; |
19 | */ |
20 | |
21 | declare(strict_types=1); |
22 | |
23 | namespace oat\taoQtiTestPreviewer\models\test\service; |
24 | |
25 | use oat\generis\model\OntologyAwareTrait; |
26 | use oat\oatbox\service\ConfigurableService; |
27 | use oat\taoQtiItem\model\qti\Service; |
28 | use oat\taoQtiTestPreviewer\models\test\TestPreviewRequest; |
29 | use qtism\data\AssessmentTest; |
30 | use qtism\data\storage\xml\XmlCompactDocument; |
31 | use taoQtiTest_helpers_ItemResolver; |
32 | use taoQtiTest_models_classes_QtiTestService; |
33 | |
34 | class TestPreviewerAssessmentTestGenerator extends ConfigurableService implements |
35 | TestPreviewerAssessmentTestGeneratorInterface |
36 | { |
37 | use OntologyAwareTrait; |
38 | |
39 | /** |
40 | * @inheritDoc |
41 | */ |
42 | public function generate(TestPreviewRequest $testPreviewRequest): AssessmentTest |
43 | { |
44 | $test = $this->getResource($testPreviewRequest->getTestUri()); |
45 | $resolver = $this->getItemResolver(); |
46 | $originalDoc = $this->getQtiTestService()->getDoc($test); |
47 | |
48 | $compiledDoc = XmlCompactDocument::createFromXmlAssessmentTestDocument($originalDoc, $resolver, $resolver); |
49 | |
50 | return $compiledDoc->getDocumentComponent(); |
51 | } |
52 | |
53 | private function getQtiTestService(): taoQtiTest_models_classes_QtiTestService |
54 | { |
55 | return $this->getServiceLocator()->get(taoQtiTest_models_classes_QtiTestService::class); |
56 | } |
57 | |
58 | private function getItemResolver(): taoQtiTest_helpers_ItemResolver |
59 | { |
60 | $service = $this->getServiceLocator()->get(Service::class); |
61 | |
62 | return new taoQtiTest_helpers_ItemResolver($service); |
63 | } |
64 | } |