Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 20 |
|
0.00% |
0 / 4 |
CRAP | |
0.00% |
0 / 1 |
| QtiObject | |
0.00% |
0 / 20 |
|
0.00% |
0 / 4 |
110 | |
0.00% |
0 / 1 |
| getUsedAttributes | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
2 | |||
| setAlt | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
12 | |||
| getTemplateQtiVariables | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
12 | |||
| toArray | |
0.00% |
0 / 6 |
|
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) 2013 (original work) Open Assessment Technologies SA (under the project TAO-PRODUCT); |
| 19 | * |
| 20 | */ |
| 21 | |
| 22 | namespace oat\taoQtiItem\model\qti; |
| 23 | |
| 24 | use oat\taoQtiItem\model\qti\Element; |
| 25 | |
| 26 | /** |
| 27 | * Short description of class oat\taoQtiItem\model\qti\QtiObject |
| 28 | * |
| 29 | * @access public |
| 30 | * @author Joel Bout, <joel.bout@tudor.lu> |
| 31 | * @package taoQTI |
| 32 | |
| 33 | */ |
| 34 | class QtiObject extends Element |
| 35 | { |
| 36 | /** |
| 37 | * the QTI tag name as defined in QTI standard |
| 38 | * |
| 39 | * @access protected |
| 40 | * @var string |
| 41 | */ |
| 42 | protected static $qtiTagName = 'object'; |
| 43 | |
| 44 | /** |
| 45 | * The alternate object to be displayed, can be a nested object or some text/html |
| 46 | * |
| 47 | * @var mixed |
| 48 | */ |
| 49 | protected $alt = null; |
| 50 | |
| 51 | public function getUsedAttributes() |
| 52 | { |
| 53 | return [ |
| 54 | 'oat\\taoQtiItem\\model\\qti\\attribute\\Data', |
| 55 | 'oat\\taoQtiItem\\model\\qti\\attribute\\Type', |
| 56 | 'oat\\taoQtiItem\\model\\qti\\attribute\\Width', |
| 57 | 'oat\\taoQtiItem\\model\\qti\\attribute\\Height' |
| 58 | ]; |
| 59 | } |
| 60 | |
| 61 | public function setAlt($object) |
| 62 | { |
| 63 | if ($object instanceof Object || is_string($object)) { |
| 64 | $this->alt = $object; |
| 65 | } |
| 66 | } |
| 67 | |
| 68 | protected function getTemplateQtiVariables() |
| 69 | { |
| 70 | $variables = parent::getTemplateQtiVariables(); |
| 71 | if (!is_null($this->alt)) { |
| 72 | if ($this->alt instanceof Object) { |
| 73 | $variables['_alt'] = $this->alt->toQTI(); |
| 74 | } else { |
| 75 | $variables['_alt'] = (string) $this->alt; |
| 76 | } |
| 77 | } |
| 78 | return $variables; |
| 79 | } |
| 80 | |
| 81 | public function toArray($filterVariableContent = false, &$filtered = []) |
| 82 | { |
| 83 | $data = parent::toArray($filterVariableContent, $filtered); |
| 84 | if (!is_null($this->alt)) { |
| 85 | if ($this->alt instanceof Object) { |
| 86 | $data['_alt'] = $this->alt->toArray($filterVariableContent, $filtered); |
| 87 | } else { |
| 88 | $data['_alt'] = (string) $this->alt; |
| 89 | } |
| 90 | } |
| 91 | return $data; |
| 92 | } |
| 93 | } |