Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 22 |
|
0.00% |
0 / 6 |
CRAP | |
0.00% |
0 / 1 |
| Custom | |
0.00% |
0 / 22 |
|
0.00% |
0 / 6 |
72 | |
0.00% |
0 / 1 |
| getRule | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
6 | |||
| __construct | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
2 | |||
| setData | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getData | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| toQTI | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| toArray | |
0.00% |
0 / 12 |
|
0.00% |
0 / 1 |
6 | |||
| 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\response; |
| 24 | |
| 25 | use oat\taoQtiItem\model\qti\response\ResponseProcessing; |
| 26 | use oat\taoQtiItem\model\qti\response\Rule; |
| 27 | use oat\taoQtiItem\helpers\QtiSerializer; |
| 28 | |
| 29 | /** |
| 30 | * Short description of class oat\taoQtiItem\model\qti\response\Custom |
| 31 | * |
| 32 | * @access public |
| 33 | * @author Joel Bout, <joel.bout@tudor.lu> |
| 34 | * @package taoQTI |
| 35 | |
| 36 | */ |
| 37 | class Custom extends ResponseProcessing implements Rule |
| 38 | { |
| 39 | /** |
| 40 | * contains the raw qti rule xml |
| 41 | * |
| 42 | * @access protected |
| 43 | * @var string |
| 44 | */ |
| 45 | protected $data = ''; |
| 46 | |
| 47 | /** |
| 48 | * Short description of attribute responseRules |
| 49 | * |
| 50 | * @access protected |
| 51 | * @var array |
| 52 | */ |
| 53 | protected $responseRules = []; |
| 54 | |
| 55 | /** |
| 56 | * Short description of method getRule |
| 57 | * |
| 58 | * @access public |
| 59 | * @author Joel Bout, <joel.bout@tudor.lu> |
| 60 | * @return string |
| 61 | */ |
| 62 | public function getRule() |
| 63 | { |
| 64 | $returnValue = (string) ''; |
| 65 | |
| 66 | foreach ($this->responseRules as $responseRule) { |
| 67 | $returnValue .= $responseRule->getRule(); |
| 68 | } |
| 69 | |
| 70 | return (string) $returnValue; |
| 71 | } |
| 72 | |
| 73 | /** |
| 74 | * Short description of method __construct |
| 75 | * |
| 76 | * @access public |
| 77 | * @author Joel Bout, <joel.bout@tudor.lu> |
| 78 | * @param array responseRules |
| 79 | * @param string xml |
| 80 | * @return mixed |
| 81 | */ |
| 82 | public function __construct($responseRules, $xml) |
| 83 | { |
| 84 | $this->responseRules = $responseRules; |
| 85 | parent::__construct(); |
| 86 | $this->setData($xml, false); |
| 87 | } |
| 88 | |
| 89 | public function setData($xml) |
| 90 | { |
| 91 | $this->data = $xml; |
| 92 | } |
| 93 | |
| 94 | public function getData() |
| 95 | { |
| 96 | return $this->data; |
| 97 | } |
| 98 | |
| 99 | /** |
| 100 | * Short description of method toQTI |
| 101 | * |
| 102 | * @access public |
| 103 | * @author Joel Bout, <joel.bout@tudor.lu> |
| 104 | * @return string |
| 105 | */ |
| 106 | public function toQTI() |
| 107 | { |
| 108 | return (string) $this->getData(); |
| 109 | } |
| 110 | |
| 111 | public function toArray($filterVariableContent = false, &$filtered = []) |
| 112 | { |
| 113 | |
| 114 | $returnValue = parent::toArray($filterVariableContent, $filtered); |
| 115 | |
| 116 | $rpSerialized = QtiSerializer::parseResponseProcessingXml(simplexml_load_string($this->data)); |
| 117 | $protectedData = [ |
| 118 | 'processingType' => 'custom', |
| 119 | 'data' => $this->data, |
| 120 | 'responseRules' => $rpSerialized['responseRules'] |
| 121 | ]; |
| 122 | |
| 123 | if ($filterVariableContent) { |
| 124 | $filtered[$this->getSerial()] = $protectedData; |
| 125 | } else { |
| 126 | $returnValue = array_merge($returnValue, $protectedData); |
| 127 | } |
| 128 | |
| 129 | return $returnValue; |
| 130 | } |
| 131 | } |