Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 14 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| Summation | |
0.00% |
0 / 14 |
|
0.00% |
0 / 2 |
20 | |
0.00% |
0 / 1 |
| getCompositionRules | |
0.00% |
0 / 8 |
|
0.00% |
0 / 1 |
6 | |||
| getCompositionQTI | |
0.00% |
0 / 6 |
|
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\Summation; |
| 26 | use oat\taoQtiItem\model\qti\response\Composite; |
| 27 | use oat\taoQtiItem\model\qti\expression\CommonExpression; |
| 28 | use oat\taoQtiItem\model\qti\response\SetOutcomeVariable; |
| 29 | |
| 30 | /** |
| 31 | * Short description of class oat\taoQtiItem\model\qti\response\Summation |
| 32 | * |
| 33 | * @access public |
| 34 | * @author Joel Bout, <joel.bout@tudor.lu> |
| 35 | * @package taoQTI |
| 36 | |
| 37 | */ |
| 38 | class Summation extends Composite |
| 39 | { |
| 40 | /** |
| 41 | * Short description of method getCompositionRules |
| 42 | * |
| 43 | * @access public |
| 44 | * @author Joel Bout, <joel.bout@tudor.lu> |
| 45 | * @return array |
| 46 | */ |
| 47 | public function getCompositionRules() |
| 48 | { |
| 49 | $subExpressions = []; |
| 50 | foreach ($this->components as $irp) { |
| 51 | $subExpressions[] = new CommonExpression('variable', ['identifier' => $irp->getOutcome()->getIdentifier()]); |
| 52 | } |
| 53 | $sum = new CommonExpression('sum', []); |
| 54 | $sum->setSubExpressions($subExpressions); |
| 55 | $summationRule = new SetOutcomeVariable($this->outcomeIdentifier, $sum); |
| 56 | |
| 57 | $returnValue = [$summationRule]; |
| 58 | |
| 59 | return (array) $returnValue; |
| 60 | } |
| 61 | |
| 62 | /** |
| 63 | * Short description of method getCompositionQTI |
| 64 | * |
| 65 | * @access public |
| 66 | * @author Joel Bout, <joel.bout@tudor.lu> |
| 67 | * @return string |
| 68 | */ |
| 69 | public function getCompositionQTI() |
| 70 | { |
| 71 | $returnValue = (string) ''; |
| 72 | |
| 73 | $returnValue .= '<setOutcomeValue identifier="' . $this->outcomeIdentifier . '"><sum>'; |
| 74 | foreach ($this->components as $irp) { |
| 75 | $returnValue .= '<variable identifier="' . $irp->getOutcome()->getIdentifier() . '" />'; |
| 76 | } |
| 77 | $returnValue .= '</sum></setOutcomeValue>'; |
| 78 | |
| 79 | return (string) $returnValue; |
| 80 | } |
| 81 | } |