Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 8 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| AbstractInteractionRegistry | |
0.00% |
0 / 8 |
|
0.00% |
0 / 2 |
20 | |
0.00% |
0 / 1 |
| getInteractionClass | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
| set | |
0.00% |
0 / 7 |
|
0.00% |
0 / 1 |
12 | |||
| getExtension | |
0.00% |
0 / 1 |
|
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) 2014 (original work) Open Assessment Technologies SA (under the project TAO-PRODUCT); |
| 19 | * |
| 20 | */ |
| 21 | |
| 22 | namespace oat\taoQtiItem\model; |
| 23 | |
| 24 | use oat\oatbox\AbstractRegistry; |
| 25 | use common_exception_Error; |
| 26 | use common_ext_ExtensionsManager; |
| 27 | |
| 28 | /** |
| 29 | * |
| 30 | * @author Lionel Lecaque <lionel@taotesting.com> |
| 31 | */ |
| 32 | abstract class AbstractInteractionRegistry extends AbstractRegistry |
| 33 | { |
| 34 | /** |
| 35 | * |
| 36 | * @author Lionel Lecaque, lionel@taotesting.com |
| 37 | */ |
| 38 | abstract protected function getInteractionClass(); |
| 39 | |
| 40 | |
| 41 | /** |
| 42 | * Register a new custom interaction |
| 43 | * |
| 44 | * @param string $qtiClass |
| 45 | * @param string $phpClass |
| 46 | * @throws common_exception_Error |
| 47 | */ |
| 48 | public function set($qtiClass, $phpClass) |
| 49 | { |
| 50 | if (! class_exists($phpClass)) { |
| 51 | throw new common_exception_Error('Custom interaction class ' . $phpClass . ' not found'); |
| 52 | } |
| 53 | if (! is_subclass_of($phpClass, $this->getInteractionClass())) { |
| 54 | throw new common_exception_Error( |
| 55 | 'Class ' . $phpClass . ' not a subclass of ' . $this->getInteractionClass() |
| 56 | ); |
| 57 | } |
| 58 | parent::set($qtiClass, $phpClass); |
| 59 | } |
| 60 | |
| 61 | |
| 62 | /** |
| 63 | * |
| 64 | * @author Lionel Lecaque, lionel@taotesting.com |
| 65 | * @return \common_ext_Extension |
| 66 | */ |
| 67 | protected function getExtension() |
| 68 | { |
| 69 | return common_ext_ExtensionsManager::singleton()->getExtensionById('taoQtiItem'); |
| 70 | } |
| 71 | } |