Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 26 |
|
0.00% |
0 / 4 |
CRAP | |
0.00% |
0 / 1 |
| SetupExtendedTextInteractionConfigurationRegistry | |
0.00% |
0 / 26 |
|
0.00% |
0 / 4 |
42 | |
0.00% |
0 / 1 |
| provideOptions | |
0.00% |
0 / 7 |
|
0.00% |
0 / 1 |
2 | |||
| provideDescription | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| run | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
6 | |||
| createReport | |
0.00% |
0 / 12 |
|
0.00% |
0 / 1 |
6 | |||
| 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 | * @author Sergei Mikhailov <sergei.mikhailov@taotesting.com> |
| 21 | */ |
| 22 | |
| 23 | declare(strict_types=1); |
| 24 | |
| 25 | namespace oat\taoQtiItem\install\scripts; |
| 26 | |
| 27 | use oat\oatbox\extension\script\ScriptAction; |
| 28 | use oat\oatbox\reporting\Report; |
| 29 | use oat\taoQtiItem\model\QtiCreator\ExtendedTextInteractionConfigurationRegistry; |
| 30 | |
| 31 | /** |
| 32 | * Run the following to enable Math Entry format option |
| 33 | * php index.php 'oat\taoQtiItem\install\scripts\SetupExtendedTextInteractionConfigurationRegistry' -m 1 |
| 34 | * |
| 35 | * Run the following to disable Math Entry format option |
| 36 | * php index.php 'oat\taoQtiItem\install\scripts\SetupExtendedTextInteractionConfigurationRegistry' -m 0 |
| 37 | * |
| 38 | * @deprecated This configuration will only be handled by featureFlag by default is always false |
| 39 | */ |
| 40 | class SetupExtendedTextInteractionConfigurationRegistry extends ScriptAction |
| 41 | { |
| 42 | public const HAS_MATH = 'math'; |
| 43 | |
| 44 | /** @var ExtendedTextInteractionConfigurationRegistry */ |
| 45 | private $registry; |
| 46 | |
| 47 | protected function provideOptions(): array |
| 48 | { |
| 49 | return [ |
| 50 | self::HAS_MATH => [ |
| 51 | 'prefix' => 'm', |
| 52 | 'longPrefix' => self::HAS_MATH, |
| 53 | 'description' => 'Enables / disables Math entry on extended text interactions', |
| 54 | ], |
| 55 | ]; |
| 56 | } |
| 57 | |
| 58 | protected function provideDescription(): string |
| 59 | { |
| 60 | return sprintf('Sets `%s` values.', ExtendedTextInteractionConfigurationRegistry::class); |
| 61 | } |
| 62 | |
| 63 | protected function run(): Report |
| 64 | { |
| 65 | $this->registry = $this->propagate(new ExtendedTextInteractionConfigurationRegistry()); |
| 66 | |
| 67 | if ($this->hasOption(self::HAS_MATH)) { |
| 68 | $this->registry->setHasMath( |
| 69 | (bool)$this->getOption(self::HAS_MATH) |
| 70 | ); |
| 71 | } |
| 72 | |
| 73 | return $this->createReport(); |
| 74 | } |
| 75 | |
| 76 | private function createReport(): Report |
| 77 | { |
| 78 | $setValues = $this->registry->get(ExtendedTextInteractionConfigurationRegistry::ID); |
| 79 | |
| 80 | return $setValues |
| 81 | ? Report::createSuccess( |
| 82 | sprintf( |
| 83 | "Applied the following configuration to `%s`\n%s", |
| 84 | ExtendedTextInteractionConfigurationRegistry::class, |
| 85 | json_encode($setValues) |
| 86 | ) |
| 87 | ) |
| 88 | : Report::createError( |
| 89 | sprintf('No values set to `%s`', ExtendedTextInteractionConfigurationRegistry::class) |
| 90 | ); |
| 91 | } |
| 92 | } |