Code Coverage  | 
      ||||||||||
Lines  | 
       Functions and Methods  | 
       Classes and Traits  | 
      ||||||||
| Total |         | 
       0.00%  | 
       0 / 22  | 
               | 
       0.00%  | 
       0 / 8  | 
       CRAP |         | 
       0.00%  | 
       0 / 1  | 
      
| GapImg |         | 
       0.00%  | 
       0 / 22  | 
               | 
       0.00%  | 
       0 / 8  | 
       90 |         | 
       0.00%  | 
       0 / 1  | 
      
| __construct |         | 
       0.00%  | 
       0 / 3  | 
               | 
       0.00%  | 
       0 / 1  | 
       2 | |||
| getUsedAttributes |         | 
       0.00%  | 
       0 / 6  | 
               | 
       0.00%  | 
       0 / 1  | 
       2 | |||
| setContent |         | 
       0.00%  | 
       0 / 3  | 
               | 
       0.00%  | 
       0 / 1  | 
       6 | |||
| getContent |         | 
       0.00%  | 
       0 / 1  | 
               | 
       0.00%  | 
       0 / 1  | 
       2 | |||
| setObject |         | 
       0.00%  | 
       0 / 1  | 
               | 
       0.00%  | 
       0 / 1  | 
       2 | |||
| getObject |         | 
       0.00%  | 
       0 / 1  | 
               | 
       0.00%  | 
       0 / 1  | 
       2 | |||
| getTemplateQtiVariables |         | 
       0.00%  | 
       0 / 3  | 
               | 
       0.00%  | 
       0 / 1  | 
       2 | |||
| toArray |         | 
       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) 2013 (original work) Open Assessment Technologies SA (under the project TAO-PRODUCT); | 
| 19 | * | 
| 20 | * | 
| 21 | */ | 
| 22 | |
| 23 | namespace oat\taoQtiItem\model\qti\choice; | 
| 24 | |
| 25 | use oat\taoQtiItem\model\qti\choice\GapImg; | 
| 26 | use oat\taoQtiItem\model\qti\choice\Choice; | 
| 27 | use oat\taoQtiItem\model\qti\Item; | 
| 28 | use oat\taoQtiItem\model\qti\QtiObject; | 
| 29 | |
| 30 | /** | 
| 31 | * A choice is a kind of interaction's proposition. | 
| 32 | * | 
| 33 | * @access public | 
| 34 | * @author Sam, <sam@taotesting.com> | 
| 35 | * @package taoQTI | 
| 36 | |
| 37 | */ | 
| 38 | class GapImg extends Choice | 
| 39 | { | 
| 40 | /** | 
| 41 | * the QTI tag name as defined in QTI standard | 
| 42 | * | 
| 43 | * @access protected | 
| 44 | * @var string | 
| 45 | */ | 
| 46 | protected static $qtiTagName = 'gapImg'; | 
| 47 | |
| 48 | /** | 
| 49 | * The image object of a gapImg must have a image MIME type | 
| 50 | * | 
| 51 | * @var oat\taoQtiItem\model\qti\QtiObject | 
| 52 | */ | 
| 53 | protected $object = null; | 
| 54 | |
| 55 | public function __construct($attributes = [], Item $relatedItem = null, $serial = '') | 
| 56 | { | 
| 57 | parent::__construct($attributes, $relatedItem, $serial); | 
| 58 | $this->object = new QtiObject(); | 
| 59 | } | 
| 60 | |
| 61 | protected function getUsedAttributes() | 
| 62 | { | 
| 63 | return array_merge( | 
| 64 | parent::getUsedAttributes(), | 
| 65 | [ | 
| 66 | 'oat\\taoQtiItem\\model\\qti\\attribute\\ObjectLabel' | 
| 67 | ] | 
| 68 | ); | 
| 69 | } | 
| 70 | |
| 71 | public function setContent($content) | 
| 72 | { | 
| 73 | if ($content instanceof QtiObject) { | 
| 74 | $this->setObject($content); | 
| 75 | } else { | 
| 76 | throw new InvalidArgumentException('a GapImg can contain taoQTI_models_classes_QTI_Object only'); | 
| 77 | } | 
| 78 | } | 
| 79 | |
| 80 | public function getContent() | 
| 81 | { | 
| 82 | return $this->getObject(); | 
| 83 | } | 
| 84 | |
| 85 | public function setObject(QtiObject $imgObject) | 
| 86 | { | 
| 87 | //@todo: check MIME type | 
| 88 | $this->object = $imgObject; | 
| 89 | } | 
| 90 | |
| 91 | public function getObject() | 
| 92 | { | 
| 93 | return $this->object; | 
| 94 | } | 
| 95 | |
| 96 | protected function getTemplateQtiVariables() | 
| 97 | { | 
| 98 | //use the default qti.element.tpl.php | 
| 99 | $variables = parent::getTemplateQtiVariables(); | 
| 100 | $variables['body'] = $this->object->toQTI(); | 
| 101 | return $variables; | 
| 102 | } | 
| 103 | |
| 104 | public function toArray($filterVariableContent = false, &$filtered = []) | 
| 105 | { | 
| 106 | $returnValue = parent::toArray($filterVariableContent, $filtered); | 
| 107 | $returnValue['object'] = $this->object->toArray($filterVariableContent, $filtered); | 
| 108 | return $returnValue; | 
| 109 | } | 
| 110 | } |