Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 19 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
| LomIdentifierGuardian | |
0.00% |
0 / 19 |
|
0.00% |
0 / 1 |
20 | |
0.00% |
0 / 1 |
| guard | |
0.00% |
0 / 19 |
|
0.00% |
0 / 1 |
20 | |||
| 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) 2015-2021 (original work) Open Assessment Technologies SA (under the project TAO-PRODUCT); |
| 19 | */ |
| 20 | |
| 21 | namespace oat\taoQtiItem\model\qti\metadata\guardians; |
| 22 | |
| 23 | use oat\tao\model\TaoOntology; |
| 24 | use oat\taoQtiItem\model\qti\metadata\MetadataGuardian; |
| 25 | |
| 26 | /** |
| 27 | * LOMIdentifierGuardian is an implementation of MetadataGuardian. |
| 28 | * |
| 29 | * @author Jérôme Bogaerts <jerome@taotesting.com> |
| 30 | * |
| 31 | * @deprecated Use oat\taoQtiItem\model\qti\metadata\guardians\ItemMetadataGuardian with default config instead |
| 32 | */ |
| 33 | class LomIdentifierGuardian implements MetadataGuardian |
| 34 | { |
| 35 | public function guard(array $metadataValues) |
| 36 | { |
| 37 | $guard = false; |
| 38 | |
| 39 | // Search for a metadataValue with path: |
| 40 | // http://www.imsglobal.org/xsd/imsmd_v1p2#lom |
| 41 | // http://www.imsglobal.org/xsd/imsmd_v1p2#general |
| 42 | // http://www.imsglobal.org/xsd/imsmd_v1p2#identifier |
| 43 | |
| 44 | foreach ($metadataValues as $metadataValue) { |
| 45 | $path = $metadataValue->getPath(); |
| 46 | $expectedPath = [ |
| 47 | 'http://www.imsglobal.org/xsd/imsmd_v1p2#lom', |
| 48 | 'http://www.imsglobal.org/xsd/imsmd_v1p2#general', |
| 49 | 'http://www.imsglobal.org/xsd/imsmd_v1p2#identifier' |
| 50 | ]; |
| 51 | |
| 52 | if ($path === $expectedPath) { |
| 53 | // Check for such a value in database... |
| 54 | $prop = new \core_kernel_classes_Property('http://www.imsglobal.org/xsd/imsmd_v1p2#identifier'); |
| 55 | $class = new \core_kernel_classes_Class(TaoOntology::ITEM_CLASS_URI); |
| 56 | $instances = $class->searchInstances( |
| 57 | [$prop->getUri() => $metadataValue->getValue()], |
| 58 | ['like' => false, 'recursive' => true] |
| 59 | ); |
| 60 | |
| 61 | if (count($instances) > 0) { |
| 62 | //var_dump($instances); |
| 63 | $guard = reset($instances); |
| 64 | break; |
| 65 | } |
| 66 | } |
| 67 | } |
| 68 | |
| 69 | return $guard; |
| 70 | } |
| 71 | } |