Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 35 |
|
0.00% |
0 / 7 |
CRAP | |
0.00% |
0 / 1 |
InteractionResponseProcessing | |
0.00% |
0 / 35 |
|
0.00% |
0 / 7 |
182 | |
0.00% |
0 / 1 |
getRule | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
2 | |||
create | |
0.00% |
0 / 22 |
|
0.00% |
0 / 1 |
56 | |||
generateOutcomeDefinition | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
__construct | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
getResponse | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getOutcome | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getIdentifier | |
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 | namespace oat\taoQtiItem\model\qti\response\interactionResponseProcessing; |
23 | |
24 | use oat\taoQtiItem\model\qti\response\interactionResponseProcessing\InteractionResponseProcessing; |
25 | use oat\taoQtiItem\model\qti\response\Rule; |
26 | use oat\taoQtiItem\model\qti\ResponseDeclaration; |
27 | use oat\taoQtiItem\model\qti\Item; |
28 | use oat\taoQtiItem\model\qti\response\interactionResponseProcessing\None; |
29 | use oat\taoQtiItem\model\qti\response\interactionResponseProcessing\MatchCorrectTemplate; |
30 | use oat\taoQtiItem\model\qti\response\interactionResponseProcessing\MapResponseTemplate; |
31 | use oat\taoQtiItem\model\qti\response\interactionResponseProcessing\MapResponsePointTemplate; |
32 | use oat\taoQtiItem\model\qti\response\interactionResponseProcessing\Custom; |
33 | use oat\taoQtiItem\model\qti\OutcomeDeclaration; |
34 | use common_Exception; |
35 | use common_exception_Error; |
36 | |
37 | /** |
38 | * The response processing of a single interaction |
39 | * |
40 | * @abstract |
41 | * @access public |
42 | * @author Joel Bout, <joel.bout@tudor.lu> |
43 | * @package taoQTI |
44 | |
45 | */ |
46 | abstract class InteractionResponseProcessing implements Rule |
47 | { |
48 | /** |
49 | * Short description of attribute SCORE_PREFIX |
50 | * |
51 | * @access private |
52 | * @var string |
53 | */ |
54 | |
55 | public const SCORE_PREFIX = 'SCORE_'; |
56 | |
57 | /** |
58 | * Short description of attribute response |
59 | * |
60 | * @access public |
61 | * @var Response |
62 | */ |
63 | public $response = null; |
64 | |
65 | /** |
66 | * Short description of attribute outcome |
67 | * |
68 | * @access public |
69 | * @var Outcome |
70 | */ |
71 | public $outcome = null; |
72 | |
73 | // --- OPERATIONS --- |
74 | |
75 | /** |
76 | * Short description of method getRule |
77 | * |
78 | * @access public |
79 | * @author Joel Bout, <joel.bout@tudor.lu> |
80 | * @return string |
81 | */ |
82 | public function getRule() |
83 | { |
84 | $returnValue = (string) ''; |
85 | |
86 | throw new common_Exception( |
87 | 'Missing getRule implementation for ' . get_class($this), |
88 | ['TAOITEMS', 'QTI', 'HARD'] |
89 | ); |
90 | |
91 | return (string) $returnValue; |
92 | } |
93 | |
94 | /** |
95 | * Short description of method create |
96 | * |
97 | * @access public |
98 | * @author Joel Bout, <joel.bout@tudor.lu> |
99 | * @param int classID |
100 | * @param Response response |
101 | * @param Item item |
102 | * @return oat\taoQtiItem\model\qti\response\interactionResponseProcessing\InteractionResponseProcessing |
103 | */ |
104 | public static function create($classID, ResponseDeclaration $response, Item $item) |
105 | { |
106 | switch ($classID) { |
107 | case None::CLASS_ID: |
108 | $className = 'oat\\taoQtiItem\\model\\qti\\response\\interactionResponseProcessing\\None'; |
109 | break; |
110 | case MatchCorrectTemplate::CLASS_ID: |
111 | // phpcs:disable Generic.Files.LineLength |
112 | $className = 'oat\\taoQtiItem\\model\\qti\\response\\interactionResponseProcessing\\MatchCorrectTemplate'; |
113 | // phpcs:enable Generic.Files.LineLength |
114 | break; |
115 | case MapResponseTemplate::CLASS_ID: |
116 | // phpcs:disable Generic.Files.LineLength |
117 | $className = 'oat\\taoQtiItem\\model\\qti\\response\\interactionResponseProcessing\\MapResponseTemplate'; |
118 | // phpcs:enable Generic.Files.LineLength |
119 | break; |
120 | case MapResponsePointTemplate::CLASS_ID: |
121 | // phpcs:disable Generic.Files.LineLength |
122 | $className = 'oat\\taoQtiItem\\model\\qti\\response\\interactionResponseProcessing\\MapResponsePointTemplate'; |
123 | // phpcs:enable Generic.Files.LineLength |
124 | break; |
125 | case Custom::CLASS_ID: |
126 | $className = 'oat\\taoQtiItem\\model\\qti\\response\\interactionResponseProcessing\\Custom'; |
127 | break; |
128 | default: |
129 | throw new common_exception_Error('Unknown InteractionResponseProcessing Class ID "' . $classID . '"'); |
130 | } |
131 | $outcome = self::generateOutcomeDefinition(); |
132 | $outcomes = $item->getOutcomes(); |
133 | $outcomes[] = $outcome; |
134 | $item->setOutcomes($outcomes); |
135 | $returnValue = new $className($response, $outcome); |
136 | |
137 | return $returnValue; |
138 | } |
139 | |
140 | /** |
141 | * Short description of method generateOutcomeDefinition |
142 | * |
143 | * @access public |
144 | * @author Joel Bout, <joel.bout@tudor.lu> |
145 | * @return oat\taoQtiItem\model\qti\OutcomeDeclaration |
146 | */ |
147 | public static function generateOutcomeDefinition() |
148 | { |
149 | return new OutcomeDeclaration(['baseType' => 'integer', 'cardinality' => 'single']); |
150 | } |
151 | |
152 | /** |
153 | * Short description of method __construct |
154 | * |
155 | * @access public |
156 | * @author Joel Bout, <joel.bout@tudor.lu> |
157 | * @param Response response |
158 | * @param Outcome outcome |
159 | * @return mixed |
160 | */ |
161 | public function __construct(ResponseDeclaration $response, OutcomeDeclaration $outcome) |
162 | { |
163 | $this->response = $response; |
164 | $this->outcome = $outcome; |
165 | } |
166 | |
167 | /** |
168 | * Short description of method getResponse |
169 | * |
170 | * @access public |
171 | * @author Joel Bout, <joel.bout@tudor.lu> |
172 | * @return oat\taoQtiItem\model\qti\ResponseDeclaration |
173 | */ |
174 | public function getResponse() |
175 | { |
176 | return $this->response; |
177 | } |
178 | |
179 | /** |
180 | * Short description of method getOutcome |
181 | * |
182 | * @access public |
183 | * @author Joel Bout, <joel.bout@tudor.lu> |
184 | * @return oat\taoQtiItem\model\qti\OutcomeDeclaration |
185 | */ |
186 | public function getOutcome() |
187 | { |
188 | return $this->outcome; |
189 | } |
190 | |
191 | /** |
192 | * Short description of method getIdentifier |
193 | * |
194 | * @access public |
195 | * @author Joel Bout, <joel.bout@tudor.lu> |
196 | * @return string |
197 | */ |
198 | public function getIdentifier() |
199 | { |
200 | $returnValue = $this->getResponse()->getIdentifier() . '_rp'; |
201 | return (string) $returnValue; |
202 | } |
203 | } |