Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 11 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| QtiCompatibleXmlRule | |
0.00% |
0 / 11 |
|
0.00% |
0 / 2 |
12 | |
0.00% |
0 / 1 |
| validate | |
0.00% |
0 / 10 |
|
0.00% |
0 / 1 |
6 | |||
| isQtiCompliant | |
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) 2021 (original work) Open Assessment Technologies SA; |
| 19 | */ |
| 20 | |
| 21 | namespace oat\taoQtiItem\model\import\Validator\Rule; |
| 22 | |
| 23 | use oat\oatbox\service\ConfigurableService; |
| 24 | use oat\taoQtiItem\model\import\Validator\WarningValidationException; |
| 25 | |
| 26 | class QtiCompatibleXmlRule extends ConfigurableService implements ValidationRuleInterface |
| 27 | { |
| 28 | /** |
| 29 | * @inheritDoc |
| 30 | */ |
| 31 | public function validate(string $column, $value, $rules = null, array $context = []): void |
| 32 | { |
| 33 | if (!$this->isQtiCompliant($value)) { |
| 34 | $exception = new WarningValidationException( |
| 35 | '`%s` is invalid', |
| 36 | [ |
| 37 | $column, |
| 38 | ] |
| 39 | ); |
| 40 | |
| 41 | $exception->setColumn($column); |
| 42 | |
| 43 | throw $exception; |
| 44 | } |
| 45 | } |
| 46 | |
| 47 | private function isQtiCompliant(string $value): bool |
| 48 | { |
| 49 | //@TODO Do proper QTI Validation or remove it if not necessary |
| 50 | return true; |
| 51 | } |
| 52 | } |