Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 15 |
|
0.00% |
0 / 8 |
CRAP | |
0.00% |
0 / 1 |
| CustomInteraction | |
0.00% |
0 / 15 |
|
0.00% |
0 / 8 |
72 | |
0.00% |
0 / 1 |
| getMarkup | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| setMarkup | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| toArray | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
2 | |||
| getTemplateQti | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getTypeIdentifier | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getProperties | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getTemplateQtiVariables | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
2 | |||
| feed | |
0.00% |
0 / 2 |
|
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\interaction; |
| 24 | |
| 25 | use DOMElement; |
| 26 | use oat\taoQtiItem\model\qti\ParserFactory; |
| 27 | use oat\taoQtiItem\model\qti\QtiNamespace; |
| 28 | |
| 29 | /** |
| 30 | * The QTI custom interaction is a subclass of the main QTI Interaction class |
| 31 | * |
| 32 | * @access public |
| 33 | * @author Sam, <sam@taotesting.com> |
| 34 | * @package taoQtiItem |
| 35 | * @see http://www.imsglobal.org/question/qtiv2p1/imsqti_infov2p1.html#element10401 |
| 36 | |
| 37 | */ |
| 38 | abstract class CustomInteraction extends Interaction |
| 39 | { |
| 40 | protected static $qtiTagName = 'customInteraction'; |
| 41 | |
| 42 | protected $typeIdentifier = '';//to be set in advance, read only, non editable |
| 43 | protected $markup = ''; |
| 44 | |
| 45 | public function getMarkup() |
| 46 | { |
| 47 | return $this->markup; |
| 48 | } |
| 49 | |
| 50 | public function setMarkup($markup) |
| 51 | { |
| 52 | $this->markup = (string) $markup; |
| 53 | } |
| 54 | |
| 55 | public function toArray($filterVariableContent = false, &$filtered = []) |
| 56 | { |
| 57 | |
| 58 | $returnValue = parent::toArray($filterVariableContent, $filtered); |
| 59 | |
| 60 | $returnValue['typeIdentifier'] = $this->typeIdentifier; |
| 61 | $returnValue['markup'] = $this->markup; |
| 62 | |
| 63 | return $returnValue; |
| 64 | } |
| 65 | |
| 66 | public static function getTemplateQti() |
| 67 | { |
| 68 | return static::getTemplatePath() . 'interactions/qti.customInteraction.tpl.php'; |
| 69 | } |
| 70 | |
| 71 | /** |
| 72 | * @return string |
| 73 | */ |
| 74 | public function getTypeIdentifier() |
| 75 | { |
| 76 | return $this->typeIdentifier; |
| 77 | } |
| 78 | |
| 79 | public function getProperties() |
| 80 | { |
| 81 | return []; |
| 82 | } |
| 83 | |
| 84 | protected function getTemplateQtiVariables() |
| 85 | { |
| 86 | |
| 87 | $variables = parent::getTemplateQtiVariables(); |
| 88 | |
| 89 | $variables['typeIdentifier'] = $this->typeIdentifier; |
| 90 | $variables['markup'] = $this->markup; |
| 91 | |
| 92 | return $variables; |
| 93 | } |
| 94 | |
| 95 | /** |
| 96 | * Feed the custom interaction model with data from its XML DOM |
| 97 | * |
| 98 | * @param ParserFactory $parser |
| 99 | * @param DOMElement $data - the custom interaction dom element |
| 100 | * @param string $xmlns (optional) the name space used in inner custom interaction elements |
| 101 | */ |
| 102 | public function feed(ParserFactory $parser, DOMElement $data, QtiNamespace $xmlns = null) |
| 103 | { |
| 104 | |
| 105 | $markup = $parser->getBodyData($data->item(0), true); |
| 106 | $this->setMarkup($markup); |
| 107 | } |
| 108 | } |