Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 35 |
|
0.00% |
0 / 4 |
CRAP | |
0.00% |
0 / 1 |
DeliverySelection | |
0.00% |
0 / 35 |
|
0.00% |
0 / 4 |
56 | |
0.00% |
0 / 1 |
getDeliveries | |
0.00% |
0 / 18 |
|
0.00% |
0 / 1 |
20 | |||
getViewData | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
2 | |||
index | |
0.00% |
0 / 9 |
|
0.00% |
0 / 1 |
2 | |||
deliveries | |
0.00% |
0 / 4 |
|
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) 2015 (original work) Open Assessment Technologies SA ; |
19 | * |
20 | */ |
21 | |
22 | namespace oat\taoProctoring\controller; |
23 | |
24 | use oat\tao\model\mvc\DefaultUrlService; |
25 | use oat\taoProctoring\helpers\DeliveryHelper; |
26 | use oat\taoProctoring\model\ProctorService; |
27 | |
28 | /** |
29 | * Proctoring Delivery controllers |
30 | * |
31 | * @author Open Assessment Technologies SA |
32 | * @package taoProctoring |
33 | * @license GPL-2.0 |
34 | * |
35 | */ |
36 | class DeliverySelection extends SimplePageModule |
37 | { |
38 | /** |
39 | * Lists all available deliveries |
40 | * @return array |
41 | */ |
42 | protected function getDeliveries() |
43 | { |
44 | $service = $this->getServiceManager()->get(ProctorService::SERVICE_ID); |
45 | $proctor = \common_session_SessionManager::getSession()->getUser(); |
46 | $context = $this->hasRequestParameter('context') ? $this->getRequestParameter('context') : null; |
47 | $deliveries = $service->getProctorableDeliveries($proctor, $context); |
48 | $data = array(); |
49 | foreach ($deliveries as $delivery) { |
50 | $executions = $service->getProctorableDeliveryExecutions($proctor, $delivery, $context); |
51 | $deliveryData = DeliveryHelper::buildDeliveryData($delivery, $executions); |
52 | $deliveryData['url'] = _url( |
53 | 'index', |
54 | 'Monitor', |
55 | null, |
56 | is_null($context) |
57 | ? ['delivery' => $delivery->getUri()] |
58 | : ['delivery' => $delivery->getUri(), 'context' => $context] |
59 | ); |
60 | $data[] = $deliveryData; |
61 | } |
62 | |
63 | return $data; |
64 | } |
65 | |
66 | /** |
67 | * Gets the view parameters and data to display |
68 | * @return array |
69 | */ |
70 | protected function getViewData() |
71 | { |
72 | return [ |
73 | 'list' => $this->getDeliveries(), |
74 | 'categories' => DeliveryHelper::getAllReasonsCategories(), |
75 | ]; |
76 | } |
77 | |
78 | /** |
79 | * Lists all available deliveries |
80 | */ |
81 | public function index() |
82 | { |
83 | $this->setData( |
84 | 'homeUrl', |
85 | $this->getServiceManager()->get(DefaultUrlService::SERVICE_ID)->getUrl('ProctoringHome') |
86 | ); |
87 | $this->setData( |
88 | 'logout', |
89 | $this->getServiceManager()->get(DefaultUrlService::SERVICE_ID)->getUrl('ProctoringLogout') |
90 | ); |
91 | $this->composeView('delivery-index', null, 'pages/index.tpl', 'tao'); |
92 | } |
93 | |
94 | /** |
95 | * Lists all available deliveries |
96 | */ |
97 | public function deliveries() |
98 | { |
99 | $this->returnJson([ |
100 | 'success' => true, |
101 | 'data' => $this->getViewData(), |
102 | ]); |
103 | } |
104 | } |