Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
| ReplaceCopiedQtiXmlIdentifierListener | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 1 |
| catchItemCreatedFromSource | |
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) 2020 (original work) Open Assessment Technologies SA; |
| 19 | */ |
| 20 | |
| 21 | declare(strict_types=1); |
| 22 | |
| 23 | namespace oat\taoQtiItem\model\Listener; |
| 24 | |
| 25 | use common_Exception; |
| 26 | use core_kernel_persistence_Exception; |
| 27 | use oat\oatbox\service\ServiceManager; |
| 28 | use oat\taoItems\model\event\ItemContentClonedEvent; |
| 29 | use oat\taoQtiItem\model\qti\copyist\QtiXmlDataManager; |
| 30 | use tao_models_classes_FileNotFoundException; |
| 31 | |
| 32 | /** |
| 33 | * After the clone or copy operation it is possible that items identifier in the qti.xml is different from current |
| 34 | * Class InheritedQtiXmlIdentifierListener |
| 35 | * @package oat\taoQtiItem\model\Listener |
| 36 | */ |
| 37 | class ReplaceCopiedQtiXmlIdentifierListener |
| 38 | { |
| 39 | /** |
| 40 | * @param ItemContentClonedEvent $itemContentClonedEvent |
| 41 | * @throws common_Exception |
| 42 | * @throws core_kernel_persistence_Exception |
| 43 | * @throws tao_models_classes_FileNotFoundException |
| 44 | */ |
| 45 | public static function catchItemCreatedFromSource(ItemContentClonedEvent $itemContentClonedEvent): void |
| 46 | { |
| 47 | ServiceManager::getServiceManager() |
| 48 | ->get(QtiXmlDataManager::class) |
| 49 | ->replaceItemIdentifier( |
| 50 | $itemContentClonedEvent->getSourceItemUri(), |
| 51 | $itemContentClonedEvent->getDestinationItemUri() |
| 52 | ); |
| 53 | } |
| 54 | } |