Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 31 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| Delivery | |
0.00% |
0 / 31 |
|
0.00% |
0 / 2 |
6 | |
0.00% |
0 / 1 |
| buildFromAssembly | |
0.00% |
0 / 15 |
|
0.00% |
0 / 1 |
2 | |||
| buildFromDeliveryExecution | |
0.00% |
0 / 16 |
|
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\taoDelivery\helper; |
| 23 | |
| 24 | use oat\oatbox\user\User; |
| 25 | use oat\taoDelivery\model\execution\DeliveryExecution; |
| 26 | |
| 27 | /** |
| 28 | * Helper to render the delivery form on the group page |
| 29 | * |
| 30 | * @author joel bout, <joel@taotesting.com> |
| 31 | * @package taoDelivery |
| 32 | |
| 33 | */ |
| 34 | class Delivery |
| 35 | { |
| 36 | public const ID = 'id'; |
| 37 | |
| 38 | public const LABEL = 'label'; |
| 39 | |
| 40 | public const AUTHORIZED = 'TAO_DELIVERY_TAKABLE'; |
| 41 | |
| 42 | public const DESCRIPTION = 'description'; |
| 43 | |
| 44 | public const LAUNCH_URL = 'launchUrl'; |
| 45 | |
| 46 | public static function buildFromAssembly($assignment, User $user) |
| 47 | { |
| 48 | $data = [ |
| 49 | self::ID => $assignment->getDeliveryId(), |
| 50 | self::LABEL => $assignment->getLabel(), |
| 51 | self::LAUNCH_URL => _url( |
| 52 | 'initDeliveryExecution', |
| 53 | 'DeliveryServer', |
| 54 | null, |
| 55 | [ |
| 56 | 'uri' => $assignment->getDeliveryId(), |
| 57 | ] |
| 58 | ), |
| 59 | self::DESCRIPTION => $assignment->getDescriptionStrings(), |
| 60 | self::AUTHORIZED => $assignment->isStartable() |
| 61 | ]; |
| 62 | return $data; |
| 63 | } |
| 64 | |
| 65 | public static function buildFromDeliveryExecution(DeliveryExecution $deliveryExecution) |
| 66 | { |
| 67 | $data = []; |
| 68 | $data[self::ID] = $deliveryExecution->getIdentifier(); |
| 69 | $data[self::LABEL] = $deliveryExecution->getLabel(); |
| 70 | $data[self::LAUNCH_URL] = _url( |
| 71 | 'runDeliveryExecution', |
| 72 | 'DeliveryServer', |
| 73 | null, |
| 74 | [ |
| 75 | 'deliveryExecution' => $deliveryExecution->getIdentifier(), |
| 76 | ] |
| 77 | ); |
| 78 | $data[self::DESCRIPTION] = [ |
| 79 | __("Started at %s", \tao_helpers_Date::displayeDate($deliveryExecution->getStartTime())), |
| 80 | ]; |
| 81 | $data[self::AUTHORIZED] = true; |
| 82 | return $data; |
| 83 | } |
| 84 | } |