Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
92.31% |
24 / 26 |
|
80.00% |
8 / 10 |
CRAP | |
0.00% |
0 / 1 |
| VariableColumn | |
92.31% |
24 / 26 |
|
80.00% |
8 / 10 |
10.05 | |
0.00% |
0 / 1 |
| fromArray | |
100.00% |
6 / 6 |
|
100.00% |
1 / 1 |
1 | |||
| __construct | |
100.00% |
6 / 6 |
|
100.00% |
1 / 1 |
1 | |||
| getColumnType | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| setDataProvider | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getDataProvider | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getContextIdentifier | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getIdentifier | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| toArray | |
100.00% |
7 / 7 |
|
100.00% |
1 / 1 |
1 | |||
| getVariableType | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
| getRefId | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getContextLabel | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 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) 2009-2012 (original work) Public Research Centre Henri Tudor (under the project TAO-SUSTAIN & TAO-DEV); |
| 19 | * 2012-2022 Open Assessment Technologies SA; |
| 20 | * |
| 21 | * |
| 22 | */ |
| 23 | |
| 24 | namespace oat\taoOutcomeUi\model\table; |
| 25 | |
| 26 | use oat\taoOutcomeUi\model\ItemResultStrategy; |
| 27 | use tao_models_classes_table_Column; |
| 28 | use tao_models_classes_table_DataProvider; |
| 29 | |
| 30 | /** |
| 31 | * Short description of class oat\taoOutcomeUi\model\table\VariableColumn |
| 32 | * |
| 33 | * @abstract |
| 34 | * @access public |
| 35 | * @author Joel Bout, <joel.bout@tudor.lu> |
| 36 | * @package taoOutcomeUi |
| 37 | */ |
| 38 | abstract class VariableColumn extends tao_models_classes_table_Column |
| 39 | { |
| 40 | // --- ATTRIBUTES --- |
| 41 | /** |
| 42 | * Identifier of the variable |
| 43 | * |
| 44 | * @var string |
| 45 | */ |
| 46 | public $identifier = ''; |
| 47 | |
| 48 | /** |
| 49 | * The identifier of the context usually correpsonds to the item URI |
| 50 | * |
| 51 | * @var string |
| 52 | */ |
| 53 | public $contextIdentifier = ''; |
| 54 | |
| 55 | /** |
| 56 | * The label of the context usually coresponds to the item label |
| 57 | * |
| 58 | * @var string |
| 59 | */ |
| 60 | public $contextLabel = ''; |
| 61 | |
| 62 | /** |
| 63 | * shared data providider to cache the variables |
| 64 | * |
| 65 | * @var VariableDataProvider |
| 66 | */ |
| 67 | public $dataProvider = null; |
| 68 | |
| 69 | /** |
| 70 | * @var string |
| 71 | */ |
| 72 | private $columnType; |
| 73 | |
| 74 | /** @var string|null */ |
| 75 | private $refId; |
| 76 | |
| 77 | // --- OPERATIONS --- |
| 78 | |
| 79 | /** |
| 80 | * |
| 81 | * @param array $array |
| 82 | * @return \oat\taoOutcomeUi\model\table\VariableColumn |
| 83 | */ |
| 84 | protected static function fromArray($array) |
| 85 | { |
| 86 | $contextId = $array['contextId']; |
| 87 | $contextLabel = $array['contextLabel']; |
| 88 | $variableIdentifier = $array['variableIdentifier']; |
| 89 | $columnType = $array['columnType']; |
| 90 | $refId = $array['refId'] ?? null; |
| 91 | |
| 92 | return new static($contextId, $contextLabel, $variableIdentifier, $columnType, $refId); |
| 93 | } |
| 94 | |
| 95 | /** |
| 96 | * |
| 97 | * @param string $contextIdentifier |
| 98 | * @param string $contextLabel |
| 99 | * @param string $identifier |
| 100 | * @param string|null $columnType |
| 101 | * @param string|null $refId |
| 102 | */ |
| 103 | public function __construct($contextIdentifier, $contextLabel, $identifier, $columnType = null, $refId = null) |
| 104 | { |
| 105 | parent::__construct($contextLabel . "-" . $identifier); |
| 106 | $this->identifier = $identifier; |
| 107 | $this->contextIdentifier = $contextIdentifier; |
| 108 | $this->contextLabel = $contextLabel; |
| 109 | $this->columnType = $columnType; |
| 110 | $this->refId = $refId; |
| 111 | } |
| 112 | |
| 113 | public function getColumnType() |
| 114 | { |
| 115 | return $this->columnType; |
| 116 | } |
| 117 | |
| 118 | public function setDataProvider(VariableDataProvider $provider) |
| 119 | { |
| 120 | $this->dataProvider = $provider; |
| 121 | } |
| 122 | |
| 123 | /** |
| 124 | * Short description of method getDataProvider |
| 125 | * |
| 126 | * @access public |
| 127 | * @author Joel Bout, <joel.bout@tudor.lu> |
| 128 | * @return tao_models_classes_table_DataProvider |
| 129 | */ |
| 130 | public function getDataProvider() |
| 131 | { |
| 132 | return $this->dataProvider; |
| 133 | } |
| 134 | |
| 135 | /** |
| 136 | * Short description of method getContextIdentifier |
| 137 | * |
| 138 | * @access public |
| 139 | * @author Joel Bout, <joel.bout@tudor.lu> |
| 140 | * @return string |
| 141 | */ |
| 142 | public function getContextIdentifier() |
| 143 | { |
| 144 | return $this->contextIdentifier; |
| 145 | } |
| 146 | |
| 147 | /** |
| 148 | * Short description of method getIdentifier |
| 149 | * |
| 150 | * @access public |
| 151 | * @author Joel Bout, <joel.bout@tudor.lu> |
| 152 | * @return string |
| 153 | */ |
| 154 | public function getIdentifier() |
| 155 | { |
| 156 | return $this->identifier; |
| 157 | } |
| 158 | |
| 159 | /** |
| 160 | * Short description of method toArray |
| 161 | * |
| 162 | * @access public |
| 163 | * @author Joel Bout, <joel.bout@tudor.lu> |
| 164 | * @return array |
| 165 | */ |
| 166 | public function toArray() |
| 167 | { |
| 168 | $returnValue = parent::toArray(); |
| 169 | //$returnValue['ca'] = "deprecated"; |
| 170 | $returnValue['contextId'] = $this->contextIdentifier; |
| 171 | $returnValue['contextLabel'] = $this->contextLabel; |
| 172 | $returnValue['variableIdentifier'] = $this->identifier; |
| 173 | $returnValue['columnType'] = $this->getColumnType(); |
| 174 | $returnValue['refId'] = $this->getRefId(); |
| 175 | |
| 176 | return $returnValue; |
| 177 | } |
| 178 | |
| 179 | /** |
| 180 | * Returns the variable type of the column |
| 181 | * |
| 182 | * @return string |
| 183 | */ |
| 184 | abstract public function getVariableType(); |
| 185 | |
| 186 | /** |
| 187 | * @return string|null |
| 188 | */ |
| 189 | public function getRefId(): ?string |
| 190 | { |
| 191 | return $this->refId; |
| 192 | } |
| 193 | |
| 194 | public function getContextLabel(): string |
| 195 | { |
| 196 | return $this->contextLabel; |
| 197 | } |
| 198 | } |