Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
56.25% |
9 / 16 |
|
50.00% |
1 / 2 |
CRAP | |
0.00% |
0 / 1 |
| DeliveryServerService | |
56.25% |
9 / 16 |
|
50.00% |
1 / 2 |
3.75 | |
0.00% |
0 / 1 |
| getResumableStates | |
0.00% |
0 / 7 |
|
0.00% |
0 / 1 |
2 | |||
| revoke | |
100.00% |
9 / 9 |
|
100.00% |
1 / 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) 2013 (original work) Open Assessment Technologies SA (under the project TAO-PRODUCT); |
| 19 | * |
| 20 | */ |
| 21 | |
| 22 | namespace oat\taoProctoring\model; |
| 23 | |
| 24 | use common_exception_NotFound; |
| 25 | use oat\oatbox\service\exception\InvalidServiceManagerException; |
| 26 | use oat\taoProctoring\model\execution\DeliveryExecution; |
| 27 | use oat\taoDelivery\model\execution\DeliveryExecution as DeliveryDeliveryExecution; |
| 28 | |
| 29 | /** |
| 30 | * Service to manage the execution of deliveries |
| 31 | * |
| 32 | * @access public |
| 33 | * @author Aleh Hutnikau Bout, <joel@taotesting.com> |
| 34 | * @package taoDelivery |
| 35 | */ |
| 36 | class DeliveryServerService extends \oat\taoDelivery\model\execution\DeliveryServerService |
| 37 | { |
| 38 | /** |
| 39 | * (non-PHPdoc) |
| 40 | * @see \oat\taoDelivery\model\execution\DeliveryServerService::getResumableStates() |
| 41 | */ |
| 42 | public function getResumableStates() |
| 43 | { |
| 44 | return array_merge( |
| 45 | parent::getResumableStates(), |
| 46 | [ |
| 47 | DeliveryExecution::STATE_AWAITING |
| 48 | ,DeliveryExecution::STATE_AUTHORIZED |
| 49 | ] |
| 50 | ); |
| 51 | } |
| 52 | |
| 53 | /** |
| 54 | * @param DeliveryDeliveryExecution $deliveryExecution |
| 55 | * @throws common_exception_NotFound |
| 56 | * @throws InvalidServiceManagerException |
| 57 | */ |
| 58 | public function revoke(DeliveryDeliveryExecution $deliveryExecution) |
| 59 | { |
| 60 | if ($deliveryExecution->getState()->getUri() !== DeliveryExecution::STATE_PAUSED) { |
| 61 | /** @var DeliveryExecutionStateService $deliveryExecutionStateService */ |
| 62 | $deliveryExecutionStateService = $this->getServiceLocator()->get(DeliveryExecutionStateService::SERVICE_ID); |
| 63 | //do not remove these comments, this is used to generate the translation in .po file |
| 64 | // __('Assessment has been paused due to attempt to switch to another window/tab.'); |
| 65 | $deliveryExecutionStateService->pauseExecution( |
| 66 | $deliveryExecution, |
| 67 | [ |
| 68 | 'reasons' => ['category' => 'focus-loss'], |
| 69 | 'comment' => 'Assessment has been paused due to attempt to switch to another window/tab.', |
| 70 | ] |
| 71 | ); |
| 72 | } |
| 73 | } |
| 74 | } |