Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 16 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
| MonitorProctorAdministrator | |
0.00% |
0 / 16 |
|
0.00% |
0 / 1 |
20 | |
0.00% |
0 / 1 |
| reactivateExecutions | |
0.00% |
0 / 16 |
|
0.00% |
0 / 1 |
20 | |||
| 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) 2017 (original work) Open Assessment Technologies SA ; |
| 19 | * |
| 20 | */ |
| 21 | |
| 22 | namespace oat\taoProctoring\controller; |
| 23 | |
| 24 | use oat\taoProctoring\helpers\DeliveryHelper; |
| 25 | use Zend\ServiceManager\Exception\ServiceNotFoundException; |
| 26 | |
| 27 | /** |
| 28 | * Monitoring Proctor Administrator controller |
| 29 | * |
| 30 | * @author Open Assessment Technologies SA |
| 31 | * @package taoProctoring |
| 32 | * @license GPL-2.0 |
| 33 | * |
| 34 | */ |
| 35 | class MonitorProctorAdministrator extends Monitor |
| 36 | { |
| 37 | public const ERROR_REACTIVATE_EXECUTIONS = 6; |
| 38 | |
| 39 | /** |
| 40 | * @throws \common_Exception |
| 41 | */ |
| 42 | public function reactivateExecutions() |
| 43 | { |
| 44 | $deliveryExecution = $this->getRequestParameter('execution'); |
| 45 | $reason = $this->getRequestParameter('reason'); |
| 46 | |
| 47 | if (!is_array($deliveryExecution)) { |
| 48 | $deliveryExecution = array($deliveryExecution); |
| 49 | } |
| 50 | |
| 51 | try { |
| 52 | $data = DeliveryHelper::reactivateExecution($deliveryExecution, $reason); |
| 53 | |
| 54 | $response = [ |
| 55 | 'success' => !count($data['unprocessed']), |
| 56 | 'data' => $data |
| 57 | ]; |
| 58 | |
| 59 | if (!$response['success']) { |
| 60 | $response['errorCode'] = self::ERROR_REACTIVATE_EXECUTIONS; |
| 61 | $response['errorMsg'] = __('Some delivery executions have not been reactivated'); |
| 62 | } |
| 63 | |
| 64 | $this->returnJson($response); |
| 65 | } catch (ServiceNotFoundException $e) { |
| 66 | \common_Logger::w('No delivery service defined for proctoring'); |
| 67 | $this->returnError('Proctoring interface not available'); |
| 68 | } |
| 69 | } |
| 70 | } |