Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 29 |
|
0.00% |
0 / 4 |
CRAP | |
0.00% |
0 / 1 |
| GetDeliveryExecutionsItems | |
0.00% |
0 / 29 |
|
0.00% |
0 / 4 |
42 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
2 | |||
| getItemsRefs | |
0.00% |
0 / 15 |
|
0.00% |
0 / 1 |
12 | |||
| setDirectoryStorage | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
2 | |||
| getTestFile | |
0.00% |
0 / 6 |
|
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) 2018 (original work) Open Assessment Technologies SA ; |
| 19 | */ |
| 20 | |
| 21 | namespace oat\taoQtiTest\models\cat; |
| 22 | |
| 23 | use core_kernel_classes_Resource; |
| 24 | use oat\taoDelivery\model\execution\DeliveryExecutionInterface; |
| 25 | use oat\taoDelivery\model\RuntimeService; |
| 26 | use qtism\data\ExtendedAssessmentItemRef; |
| 27 | use qtism\data\ExtendedAssessmentSection; |
| 28 | use qtism\runtime\tests\AssessmentTestSession; |
| 29 | use tao_models_classes_service_FileStorage; |
| 30 | use tao_models_classes_service_ServiceCallHelper; |
| 31 | |
| 32 | class GetDeliveryExecutionsItems |
| 33 | { |
| 34 | /** @var RuntimeService */ |
| 35 | private $runTimeService; |
| 36 | |
| 37 | /** @var CatService */ |
| 38 | private $catService; |
| 39 | |
| 40 | /** @var \tao_models_classes_service_StorageDirectory */ |
| 41 | private $directoryStorage; |
| 42 | |
| 43 | /** @var DeliveryExecutionInterface */ |
| 44 | private $deliveryExecution; |
| 45 | |
| 46 | /** @var AssessmentTestSession */ |
| 47 | private $assessmentTestSession; |
| 48 | |
| 49 | /** |
| 50 | * @param RuntimeService $runTimeService |
| 51 | * @param CatService $catService |
| 52 | * @param tao_models_classes_service_FileStorage $fileStorage |
| 53 | * @param DeliveryExecutionInterface $deliveryExecution |
| 54 | * @param AssessmentTestSession $assessmentTestSession |
| 55 | * @throws \Exception |
| 56 | */ |
| 57 | public function __construct( |
| 58 | RuntimeService $runTimeService, |
| 59 | CatService $catService, |
| 60 | tao_models_classes_service_FileStorage $fileStorage, |
| 61 | DeliveryExecutionInterface $deliveryExecution, |
| 62 | AssessmentTestSession $assessmentTestSession |
| 63 | ) { |
| 64 | $this->runTimeService = $runTimeService; |
| 65 | $this->catService = $catService; |
| 66 | $this->setDirectoryStorage($deliveryExecution->getDelivery()); |
| 67 | $this->deliveryExecution = $deliveryExecution; |
| 68 | $this->assessmentTestSession = $assessmentTestSession; |
| 69 | } |
| 70 | |
| 71 | |
| 72 | /** |
| 73 | * @return array |
| 74 | * @throws \Exception |
| 75 | */ |
| 76 | public function getItemsRefs() |
| 77 | { |
| 78 | $itemIds = []; |
| 79 | |
| 80 | $route = $this->assessmentTestSession->getRoute(); |
| 81 | $routeCount = $route->count(); |
| 82 | |
| 83 | for ($i = 0; $i < $routeCount; $i++) { |
| 84 | $routeItem = $route->getRouteItemAt($i); |
| 85 | $mainItemRef = $routeItem->getAssessmentItemRef(); |
| 86 | |
| 87 | if ($this->catService->isAdaptivePlaceholder($mainItemRef)) { |
| 88 | $seenCatItems = $this->catService->getPreviouslySeenCatItemIds( |
| 89 | $this->assessmentTestSession, |
| 90 | $this->directoryStorage, |
| 91 | $routeItem |
| 92 | ); |
| 93 | $itemIds = array_merge($itemIds, $seenCatItems); |
| 94 | } else { |
| 95 | $itemIds[] = $mainItemRef->getIdentifier(); |
| 96 | } |
| 97 | } |
| 98 | |
| 99 | return $itemIds; |
| 100 | } |
| 101 | |
| 102 | /** |
| 103 | * @param core_kernel_classes_Resource $delivery |
| 104 | * @return void |
| 105 | * @throws \common_exception_Error |
| 106 | */ |
| 107 | protected function setDirectoryStorage($delivery) |
| 108 | { |
| 109 | $fileStorage = \tao_models_classes_service_FileStorage::singleton(); |
| 110 | $directoryIds = explode('|', $this->getTestFile($delivery)); |
| 111 | $this->directoryStorage = $fileStorage->getDirectoryById($directoryIds[0]); |
| 112 | } |
| 113 | |
| 114 | /** |
| 115 | * @param \core_kernel_classes_Resource $delivery |
| 116 | * @return string |
| 117 | * @throws \common_exception_Error |
| 118 | */ |
| 119 | protected function getTestFile(\core_kernel_classes_Resource $delivery) |
| 120 | { |
| 121 | $parameters = tao_models_classes_service_ServiceCallHelper::getInputValues( |
| 122 | $this->runTimeService->getRuntime($delivery->getUri()), |
| 123 | [] |
| 124 | ); |
| 125 | list($private, $public) = explode('|', $parameters['QtiTestCompilation']); |
| 126 | return $private; |
| 127 | } |
| 128 | } |