Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 14 |
|
0.00% |
0 / 4 |
CRAP | |
0.00% |
0 / 1 |
| ConditionalExpression | |
0.00% |
0 / 14 |
|
0.00% |
0 / 4 |
30 | |
0.00% |
0 / 1 |
| getRule | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
6 | |||
| __construct | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| getCondition | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
2 | |||
| getActions | |
0.00% |
0 / 3 |
|
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\response; |
| 24 | |
| 25 | use oat\taoQtiItem\model\qti\response\ConditionalExpression; |
| 26 | use oat\taoQtiItem\model\qti\response\Rule; |
| 27 | use oat\taoQtiItem\model\qti\expression\Expression; |
| 28 | |
| 29 | /** |
| 30 | * Short description of class |
| 31 | * |
| 32 | * @access public |
| 33 | * @author Joel Bout, <joel.bout@tudor.lu> |
| 34 | * @package taoQTI |
| 35 | |
| 36 | */ |
| 37 | class ConditionalExpression implements Rule |
| 38 | { |
| 39 | // --- ATTRIBUTES --- |
| 40 | |
| 41 | /** |
| 42 | * Short description of attribute condition |
| 43 | * |
| 44 | * @access protected |
| 45 | * @var Expression |
| 46 | */ |
| 47 | protected $condition = null; |
| 48 | |
| 49 | /** |
| 50 | * Short description of attribute actions |
| 51 | * |
| 52 | * @access protected |
| 53 | * @var array |
| 54 | */ |
| 55 | protected $actions = []; |
| 56 | |
| 57 | // --- OPERATIONS --- |
| 58 | |
| 59 | /** |
| 60 | * Short description of method getRule |
| 61 | * |
| 62 | * @access public |
| 63 | * @author Joel Bout, <joel.bout@tudor.lu> |
| 64 | * @return string |
| 65 | */ |
| 66 | public function getRule() |
| 67 | { |
| 68 | $returnValue = (string) ''; |
| 69 | |
| 70 | |
| 71 | |
| 72 | $returnValue = 'if(' . $this->getCondition()->getRule() . ') {'; |
| 73 | foreach ($this->getActions() as $actions) { |
| 74 | $returnValue .= $actions->getRule(); |
| 75 | } |
| 76 | $returnValue .= '}'; |
| 77 | |
| 78 | |
| 79 | |
| 80 | return (string) $returnValue; |
| 81 | } |
| 82 | |
| 83 | /** |
| 84 | * Short description of method __construct |
| 85 | * |
| 86 | * @access public |
| 87 | * @author Joel Bout, <joel.bout@tudor.lu> |
| 88 | * @param Expression condition |
| 89 | * @param array actions |
| 90 | * @return mixed |
| 91 | */ |
| 92 | public function __construct(Expression $condition, $actions) |
| 93 | { |
| 94 | |
| 95 | $this->condition = $condition; |
| 96 | $this->actions = $actions; |
| 97 | } |
| 98 | |
| 99 | /** |
| 100 | * Short description of method getCondition |
| 101 | * |
| 102 | * @access public |
| 103 | * @author Joel Bout, <joel.bout@tudor.lu> |
| 104 | * @return oat\taoQtiItem\model\qti\expression\Expression |
| 105 | */ |
| 106 | public function getCondition() |
| 107 | { |
| 108 | $returnValue = null; |
| 109 | |
| 110 | |
| 111 | $returnValue = $this->condition; |
| 112 | |
| 113 | |
| 114 | return $returnValue; |
| 115 | } |
| 116 | |
| 117 | /** |
| 118 | * Short description of method getActions |
| 119 | * |
| 120 | * @access public |
| 121 | * @author Joel Bout, <joel.bout@tudor.lu> |
| 122 | * @return array |
| 123 | */ |
| 124 | public function getActions() |
| 125 | { |
| 126 | $returnValue = []; |
| 127 | |
| 128 | |
| 129 | $returnValue = $this->actions; |
| 130 | |
| 131 | |
| 132 | return (array) $returnValue; |
| 133 | } |
| 134 | } |