Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 20 |
|
0.00% |
0 / 5 |
CRAP | |
0.00% |
0 / 1 |
| ProctorService | |
0.00% |
0 / 20 |
|
0.00% |
0 / 5 |
72 | |
0.00% |
0 / 1 |
| getProctorableDeliveries | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
2 | |||
| getProctorableDeliveryExecutions | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
2 | |||
| countProctorableDeliveryExecutions | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
2 | |||
| getCriteria | |
0.00% |
0 / 8 |
|
0.00% |
0 / 1 |
20 | |||
| isSuitable | |
0.00% |
0 / 1 |
|
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 | |
| 23 | namespace oat\taoProctoring\model; |
| 24 | |
| 25 | use oat\generis\model\OntologyAwareTrait; |
| 26 | use oat\oatbox\user\User; |
| 27 | use oat\oatbox\service\ConfigurableService; |
| 28 | use oat\taoDeliveryRdf\model\DeliveryAssemblyService; |
| 29 | use oat\taoProctoring\model\monitorCache\DeliveryMonitoringService; |
| 30 | |
| 31 | /** |
| 32 | * Sample Delivery Service for proctoring |
| 33 | * |
| 34 | * @author Joel Bout <joel@taotesting.com> |
| 35 | */ |
| 36 | class ProctorService extends ConfigurableService implements ProctorServiceHandler |
| 37 | { |
| 38 | use OntologyAwareTrait; |
| 39 | |
| 40 | /** |
| 41 | * @deprecated constant moved to the \oat\taoProctoring\model\authorization\TestTakerAuthorizationService |
| 42 | */ |
| 43 | public const PROCTORED_BY_DEFAULT = 'proctored_by_default'; |
| 44 | |
| 45 | public const ROLE_PROCTOR = 'http://www.tao.lu/Ontologies/TAOProctor.rdf#ProctorRole'; |
| 46 | |
| 47 | public const ROLE_PROCTOR_ADMINISTRATOR = 'http://www.tao.lu/Ontologies/TAOProctor.rdf#ProctorAdministratorRole'; |
| 48 | |
| 49 | public const ACCESSIBLE_PROCTOR = 'http://www.tao.lu/Ontologies/TAODelivery.rdf#ProctorAccessible'; |
| 50 | |
| 51 | public const ACCESSIBLE_PROCTOR_ENABLED = 'http://www.tao.lu/Ontologies/TAODelivery.rdf#ComplyEnabled'; |
| 52 | |
| 53 | public const ACCESSIBLE_PROCTOR_DISABLED = 'http://www.tao.lu/Ontologies/TAODelivery.rdf#ComplyDisabled'; |
| 54 | |
| 55 | /** |
| 56 | * Gets all deliveries available for a proctor |
| 57 | * @param User $proctor |
| 58 | * @return array |
| 59 | */ |
| 60 | public function getProctorableDeliveries(User $proctor, $context = null) |
| 61 | { |
| 62 | return DeliveryAssemblyService::singleton()->getRootClass()->searchInstances( |
| 63 | array(self::ACCESSIBLE_PROCTOR => self::ACCESSIBLE_PROCTOR_ENABLED), |
| 64 | array('recursive' => true) |
| 65 | ); |
| 66 | } |
| 67 | |
| 68 | public function getProctorableDeliveryExecutions(User $proctor, $delivery = null, $context = null, $options = []) |
| 69 | { |
| 70 | $monitoringService = $this->getServiceManager()->get(DeliveryMonitoringService::SERVICE_ID); |
| 71 | $criteria = $this->getCriteria($delivery, $context, $options); |
| 72 | $options['asArray'] = true; |
| 73 | return $monitoringService->find($criteria, $options, true); |
| 74 | } |
| 75 | |
| 76 | public function countProctorableDeliveryExecutions(User $proctor, $delivery = null, $context = null, $options = []) |
| 77 | { |
| 78 | $monitoringService = $this->getServiceManager()->get(DeliveryMonitoringService::SERVICE_ID); |
| 79 | $criteria = $this->getCriteria($delivery, $context, $options); |
| 80 | return $monitoringService->count($criteria, $options); |
| 81 | } |
| 82 | |
| 83 | |
| 84 | /** |
| 85 | * @param null $delivery |
| 86 | * @param null $context |
| 87 | * @param array $options |
| 88 | * @return array |
| 89 | */ |
| 90 | protected function getCriteria($delivery = null, $context = null, $options = []) |
| 91 | { |
| 92 | $criteria = []; |
| 93 | if ($delivery !== null) { |
| 94 | $criteria = [ |
| 95 | [DeliveryMonitoringService::DELIVERY_ID => $delivery->getUri()] |
| 96 | ]; |
| 97 | } |
| 98 | |
| 99 | if (!empty($options['filters']) && is_array($options['filters'])) { |
| 100 | $criteria = array_merge($options['filters'], $criteria); |
| 101 | } |
| 102 | |
| 103 | return $criteria; |
| 104 | } |
| 105 | |
| 106 | /** |
| 107 | * (non-PHPdoc) |
| 108 | * @see \oat\taoProctoring\model\ProctorServiceHandler::isSuitable() |
| 109 | */ |
| 110 | public function isSuitable(User $user, $deliveryId = null) |
| 111 | { |
| 112 | return true; |
| 113 | } |
| 114 | } |