Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
71.43% |
5 / 7 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
| TestTakerImportEventDispatcher | |
71.43% |
5 / 7 |
|
0.00% |
0 / 1 |
3.21 | |
0.00% |
0 / 1 |
| dispatch | |
71.43% |
5 / 7 |
|
0.00% |
0 / 1 |
3.21 | |||
| 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) 2016-2020 (original work) Open Assessment Technologies SA; |
| 19 | * |
| 20 | * @author Ivan klimchuk <klimchuk@1pt.com> |
| 21 | */ |
| 22 | |
| 23 | declare(strict_types=1); |
| 24 | |
| 25 | namespace oat\taoTestTaker\models\events\dispatcher; |
| 26 | |
| 27 | use common_Logger; |
| 28 | use common_report_Report; |
| 29 | use oat\oatbox\event\EventManagerAwareTrait; |
| 30 | use oat\oatbox\service\ConfigurableService; |
| 31 | use oat\taoTestTaker\models\events\TestTakerImportedEvent; |
| 32 | use Throwable; |
| 33 | |
| 34 | class TestTakerImportEventDispatcher extends ConfigurableService |
| 35 | { |
| 36 | use EventManagerAwareTrait; |
| 37 | |
| 38 | public function dispatch(common_report_Report $report, callable $processResource): void |
| 39 | { |
| 40 | /** @var common_report_Report $success */ |
| 41 | foreach ($report->getSuccesses() as $success) { |
| 42 | $resource = $success->getData(); |
| 43 | |
| 44 | try { |
| 45 | $this->getEventManager()->trigger( |
| 46 | new TestTakerImportedEvent($resource->getUri(), $processResource($resource)) |
| 47 | ); |
| 48 | } catch (Throwable $e) { |
| 49 | common_Logger::e($e->getMessage()); |
| 50 | } |
| 51 | } |
| 52 | } |
| 53 | } |