Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 15 |
|
0.00% |
0 / 4 |
CRAP | |
0.00% |
0 / 1 |
| TextVariableChoice | |
0.00% |
0 / 15 |
|
0.00% |
0 / 4 |
56 | |
0.00% |
0 / 1 |
| getContent | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| setContent | |
0.00% |
0 / 7 |
|
0.00% |
0 / 1 |
20 | |||
| getTemplateQtiVariables | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
2 | |||
| toArray | |
0.00% |
0 / 4 |
|
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\choice; |
| 24 | |
| 25 | use oat\taoQtiItem\model\qti\choice\TextVariableChoice; |
| 26 | use oat\taoQtiItem\model\qti\choice\Choice; |
| 27 | use oat\taoQtiItem\model\qti\OutcomeDeclaration; |
| 28 | |
| 29 | /** |
| 30 | * A choice is a kind of interaction's proposition. |
| 31 | * |
| 32 | * @access public |
| 33 | * @author Sam, <sam@taotesting.com> |
| 34 | * @package taoQTI |
| 35 | |
| 36 | */ |
| 37 | abstract class TextVariableChoice extends Choice |
| 38 | { |
| 39 | protected $text = ''; |
| 40 | |
| 41 | public function getContent() |
| 42 | { |
| 43 | return $this->text; |
| 44 | } |
| 45 | |
| 46 | public function setContent($content) |
| 47 | { |
| 48 | if (empty($content)) { |
| 49 | $content = strval($content); |
| 50 | } |
| 51 | if (is_string($content)) { |
| 52 | $this->text = $content; |
| 53 | } elseif ($content instanceof OutcomeDeclaration) { |
| 54 | //@todo: check validity |
| 55 | $this->text = $content; |
| 56 | } else { |
| 57 | throw new InvalidArgumentException('a TextVariable Choice can only accept QTI_Outcome or text content'); |
| 58 | } |
| 59 | } |
| 60 | |
| 61 | protected function getTemplateQtiVariables() |
| 62 | { |
| 63 | //use the default qti.element.tpl.php |
| 64 | $variables = parent::getTemplateQtiVariables(); |
| 65 | $variables['body'] = (string) $this->text; |
| 66 | return $variables; |
| 67 | } |
| 68 | |
| 69 | public function toArray($filterVariableContent = false, &$filtered = []) |
| 70 | { |
| 71 | $returnValue = parent::toArray($filterVariableContent, $filtered); |
| 72 | $returnValue['text'] = (string) $this->text; |
| 73 | return $returnValue; |
| 74 | } |
| 75 | } |