Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 28 |
|
0.00% |
0 / 7 |
CRAP | |
0.00% |
0 / 1 |
| XInclude | |
0.00% |
0 / 28 |
|
0.00% |
0 / 7 |
182 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| getBody | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getUsedAttributes | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| listOfNonQtiAttributes | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
2 | |||
| getTemplateQtiVariables | |
0.00% |
0 / 12 |
|
0.00% |
0 / 1 |
20 | |||
| getXIncludeNamespace | |
0.00% |
0 / 8 |
|
0.00% |
0 / 1 |
20 | |||
| getTemplateQti | |
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 | namespace oat\taoQtiItem\model\qti; |
| 23 | |
| 24 | use oat\taoQtiItem\model\qti\Element; |
| 25 | use oat\taoQtiItem\model\qti\container\FlowContainer; |
| 26 | use oat\taoQtiItem\model\qti\container\ContainerStatic; |
| 27 | |
| 28 | /** |
| 29 | * XInclude model of XInclude element, the href identified the location of the xml body string |
| 30 | * and the body represents the loaded content from the href. |
| 31 | * |
| 32 | * @access public |
| 33 | * @author Sam, <sam@taotesting.com> |
| 34 | * @package taoQtiItem |
| 35 | |
| 36 | */ |
| 37 | class XInclude extends Element implements FlowContainer |
| 38 | { |
| 39 | /** |
| 40 | * the QTI tag name as defined in QTI standard |
| 41 | * |
| 42 | * @access protected |
| 43 | * @var string |
| 44 | */ |
| 45 | protected static $qtiTagName = 'include'; |
| 46 | protected static $qtiNamespaceAlias = 'xi'; |
| 47 | protected $body = null; |
| 48 | |
| 49 | public function __construct($attributes = [], Item $relatedItem = null, $serial = '') |
| 50 | { |
| 51 | parent::__construct($attributes, $relatedItem, $serial); |
| 52 | $this->body = new ContainerStatic('', $relatedItem); |
| 53 | } |
| 54 | |
| 55 | /** |
| 56 | * Get the body of XInclude element |
| 57 | * |
| 58 | * @return oat\taoQtiItem\model\qti\container\ContainerStatic |
| 59 | */ |
| 60 | public function getBody() |
| 61 | { |
| 62 | return $this->body; |
| 63 | } |
| 64 | |
| 65 | /** |
| 66 | * Get the list of used attributes |
| 67 | * |
| 68 | * @return array |
| 69 | */ |
| 70 | public function getUsedAttributes() |
| 71 | { |
| 72 | return []; |
| 73 | } |
| 74 | |
| 75 | public function listOfNonQtiAttributes(): array |
| 76 | { |
| 77 | return [ |
| 78 | 'class' // Prefix for related stylesheet classes |
| 79 | ]; |
| 80 | } |
| 81 | |
| 82 | /** |
| 83 | * Get the variables for the qti template rendering |
| 84 | * |
| 85 | * @return array |
| 86 | */ |
| 87 | protected function getTemplateQtiVariables() |
| 88 | { |
| 89 | |
| 90 | $variables = parent::getTemplateQtiVariables(); |
| 91 | |
| 92 | $tag = static::$qtiTagName; |
| 93 | |
| 94 | //search existing mathML ns declaration: |
| 95 | $ns = $this->getXIncludeNamespace(); |
| 96 | if (empty($ns)) { |
| 97 | //add one! |
| 98 | $relatedItem = $this->getRelatedItem(); |
| 99 | if (!is_null($relatedItem)) { |
| 100 | $ns = 'xi'; |
| 101 | $relatedItem->addNamespace($ns, 'http://www.w3.org/2001/XInclude'); |
| 102 | } |
| 103 | } |
| 104 | if (!empty($ns)) { |
| 105 | //proceed to ns addition: |
| 106 | $tag = $ns . ':' . $tag; |
| 107 | } |
| 108 | |
| 109 | $variables['tag'] = $tag; |
| 110 | |
| 111 | return $variables; |
| 112 | } |
| 113 | |
| 114 | /** |
| 115 | * Get the xml namespace of the xinclude |
| 116 | * |
| 117 | * @return string |
| 118 | */ |
| 119 | public function getXIncludeNamespace() |
| 120 | { |
| 121 | $ns = ''; |
| 122 | $relatedItem = $this->getRelatedItem(); |
| 123 | if (!is_null($relatedItem)) { |
| 124 | foreach ($relatedItem->getNamespaces() as $name => $uri) { |
| 125 | if (strpos($uri, 'XInclude') > 0) { |
| 126 | $ns = $name; |
| 127 | break; |
| 128 | } |
| 129 | } |
| 130 | } |
| 131 | return $ns; |
| 132 | } |
| 133 | |
| 134 | /** |
| 135 | * Get the absolute path of the template of the qti.xml |
| 136 | * |
| 137 | * @return string |
| 138 | */ |
| 139 | public static function getTemplateQti() |
| 140 | { |
| 141 | return static::getTemplatePath() . '/qti.include.tpl.php'; |
| 142 | } |
| 143 | } |