Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 22 |
|
0.00% |
0 / 5 |
CRAP | |
0.00% |
0 / 1 |
| UnionAssignmentService | |
0.00% |
0 / 22 |
|
0.00% |
0 / 5 |
156 | |
0.00% |
0 / 1 |
| getInternalServices | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
6 | |||
| getAssignments | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
6 | |||
| getAssignedUsers | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
6 | |||
| isDeliveryExecutionAllowed | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
12 | |||
| getRuntime | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
12 | |||
| 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 (original work) Open Assessment Technologies SA; |
| 19 | * |
| 20 | * @author Alexander Zagovorichev <zagovorichev@1pt.com> |
| 21 | */ |
| 22 | |
| 23 | namespace oat\taoDelivery\model\AssignmentAggregator; |
| 24 | |
| 25 | use oat\oatbox\service\ConfigurableService; |
| 26 | use oat\oatbox\user\User; |
| 27 | use oat\taoDelivery\model\Assignment; |
| 28 | |
| 29 | class UnionAssignmentService extends ConfigurableService implements UnionAssignmentInterface |
| 30 | { |
| 31 | public function getInternalServices() |
| 32 | { |
| 33 | $services = $this->getOption('services'); |
| 34 | foreach ($services as $service) { |
| 35 | $this->propagate($service); |
| 36 | } |
| 37 | return $services; |
| 38 | } |
| 39 | |
| 40 | /** |
| 41 | * Returns the deliveries available to a user |
| 42 | * |
| 43 | * @param User $user |
| 44 | * @return Assignment[] list of deliveries |
| 45 | */ |
| 46 | public function getAssignments(User $user) |
| 47 | { |
| 48 | $assignments = []; |
| 49 | foreach ($this->getInternalServices() as $service) { |
| 50 | $assignments = array_merge($assignments, $service->getAssignments($user)); |
| 51 | } |
| 52 | |
| 53 | return $assignments; |
| 54 | } |
| 55 | |
| 56 | /** |
| 57 | * Returns the ids of users assigned to a delivery |
| 58 | * |
| 59 | * @param string|\core_kernel_classes_Resource $deliveryId form|delivery instance or form id |
| 60 | * @return string[] ids of users |
| 61 | */ |
| 62 | public function getAssignedUsers($deliveryId) |
| 63 | { |
| 64 | $users = []; |
| 65 | foreach ($this->getInternalServices() as $service) { |
| 66 | $users = array_merge($users, $service->getAssignedUsers($deliveryId)); |
| 67 | } |
| 68 | |
| 69 | return $users; |
| 70 | } |
| 71 | |
| 72 | public function isDeliveryExecutionAllowed($deliveryIdentifier, User $user) |
| 73 | { |
| 74 | $result = false; |
| 75 | foreach ($this->getInternalServices() as $service) { |
| 76 | if ($service->isDeliveryExecutionAllowed($deliveryIdentifier, $user)) { |
| 77 | return true; |
| 78 | } |
| 79 | } |
| 80 | |
| 81 | return $result; |
| 82 | } |
| 83 | |
| 84 | public function getRuntime($deliveryId) |
| 85 | { |
| 86 | foreach ($this->getInternalServices() as $service) { |
| 87 | $runtime = $service->getRuntime($deliveryId); |
| 88 | if ($runtime) { |
| 89 | return $runtime; |
| 90 | } |
| 91 | } |
| 92 | |
| 93 | return false; |
| 94 | } |
| 95 | } |