Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 15 |
|
0.00% |
0 / 7 |
CRAP | |
0.00% |
0 / 1 |
| BlockInteraction | |
0.00% |
0 / 15 |
|
0.00% |
0 / 7 |
72 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
2 | |||
| getPrompt | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getPromptObject | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| setPrompt | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| toArray | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
2 | |||
| getTemplateQti | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getTemplateQtiVariables | |
0.00% |
0 / 4 |
|
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\interaction; |
| 24 | |
| 25 | use oat\taoQtiItem\model\qti\interaction\BlockInteraction; |
| 26 | use oat\taoQtiItem\model\qti\interaction\Interaction; |
| 27 | use oat\taoQtiItem\model\qti\Item; |
| 28 | use oat\taoQtiItem\model\qti\interaction\Prompt; |
| 29 | |
| 30 | /** |
| 31 | * The QTI block interaction is a subclass of the main QTI Interaction class |
| 32 | * |
| 33 | * @access public |
| 34 | * @author Sam, <sam@taotesting.com> |
| 35 | * @package taoQTI |
| 36 | * @see http://www.imsglobal.org/question/qtiv2p1/imsqti_infov2p1.html#element10267 |
| 37 | |
| 38 | */ |
| 39 | abstract class BlockInteraction extends Interaction |
| 40 | { |
| 41 | /** |
| 42 | * The prompt of the block interaction |
| 43 | * |
| 44 | * @access protected |
| 45 | * @var Prompt |
| 46 | */ |
| 47 | protected $prompt = null; |
| 48 | |
| 49 | /** |
| 50 | * Create a new block interaction, init the prompt block |
| 51 | * |
| 52 | * @access public |
| 53 | * @author Sam, <sam@taotesting.com> |
| 54 | * @param array options |
| 55 | * @return mixed |
| 56 | */ |
| 57 | public function __construct($attributes = [], Item $relatedItem = null, $serial = '') |
| 58 | { |
| 59 | parent::__construct($attributes, $relatedItem, $serial); |
| 60 | $this->prompt = new Prompt([], $relatedItem); |
| 61 | } |
| 62 | |
| 63 | /** |
| 64 | * Return the ContainerStatic reprensenting the prompt |
| 65 | * |
| 66 | * @return oat\taoQtiItem\model\qti\container\ContainerStatic |
| 67 | */ |
| 68 | public function getPrompt() |
| 69 | { |
| 70 | return $this->prompt->getBody(); |
| 71 | } |
| 72 | |
| 73 | public function getPromptObject() |
| 74 | { |
| 75 | return $this->prompt; |
| 76 | } |
| 77 | |
| 78 | public function setPrompt($body) |
| 79 | { |
| 80 | $this->prompt->getBody()->edit($body); |
| 81 | } |
| 82 | |
| 83 | public function toArray($filterVariableContent = false, &$filtered = []) |
| 84 | { |
| 85 | $returnValue = parent::toArray($filterVariableContent, $filtered); |
| 86 | $returnValue['prompt'] = $this->getPrompt()->toArray($filterVariableContent, $filtered); |
| 87 | return $returnValue; |
| 88 | } |
| 89 | |
| 90 | public static function getTemplateQti() |
| 91 | { |
| 92 | return static::getTemplatePath() . 'interactions/qti.blockInteraction.tpl.php'; |
| 93 | } |
| 94 | |
| 95 | protected function getTemplateQtiVariables() |
| 96 | { |
| 97 | $variables = parent::getTemplateQtiVariables(); |
| 98 | if (trim($this->getPrompt()->getBody()) !== '') { |
| 99 | //prompt is optional: |
| 100 | $variables['prompt'] = $this->prompt->toQTI(); |
| 101 | } |
| 102 | return $variables; |
| 103 | } |
| 104 | } |