Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 46 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
| taoQtiTest_models_forms_ImportForm | |
0.00% |
0 / 46 |
|
0.00% |
0 / 3 |
20 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| initForm | |
0.00% |
0 / 18 |
|
0.00% |
0 / 1 |
2 | |||
| initElements | |
0.00% |
0 / 27 |
|
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) 2008-2010 (original work) Deutsche Institut für Internationale Pädagogische Forschung |
| 19 | * (under the project TAO-TRANSFER); |
| 20 | * 2009-2012 (update and modification) Public Research Centre Henri Tudor |
| 21 | * (under the project TAO-SUSTAIN & TAO-DEV); |
| 22 | */ |
| 23 | |
| 24 | use oat\generis\Helper\SystemHelper; |
| 25 | |
| 26 | /** |
| 27 | * Export form for QTI packages |
| 28 | * |
| 29 | * @access public |
| 30 | * @author Joel Bout, <joel.bout@tudor.lu> |
| 31 | * @package taoItems |
| 32 | |
| 33 | */ |
| 34 | class taoQtiTest_models_forms_ImportForm extends tao_helpers_form_FormContainer |
| 35 | { |
| 36 | // --- ASSOCIATIONS --- |
| 37 | |
| 38 | // --- ATTRIBUTES --- |
| 39 | |
| 40 | // --- OPERATIONS --- |
| 41 | public function __construct(core_kernel_classes_Resource $test) |
| 42 | { |
| 43 | parent::__construct(['uri' => $test->getUri()]); |
| 44 | } |
| 45 | |
| 46 | /** |
| 47 | * (non-PHPdoc) |
| 48 | * @see tao_helpers_form_FormContainer::initForm() |
| 49 | */ |
| 50 | public function initForm() |
| 51 | { |
| 52 | $this->form = new tao_helpers_form_xhtml_Form('export'); |
| 53 | |
| 54 | $this->form->setDecorators([ |
| 55 | 'element' => new tao_helpers_form_xhtml_TagWrapper(['tag' => 'div']), |
| 56 | 'group' => new tao_helpers_form_xhtml_TagWrapper(['tag' => 'div', 'cssClass' => 'form-group']), |
| 57 | 'error' => new tao_helpers_form_xhtml_TagWrapper([ |
| 58 | 'tag' => 'div', |
| 59 | 'cssClass' => 'form-error ui-state-error ui-corner-all', |
| 60 | ]), |
| 61 | 'actions-bottom' => new tao_helpers_form_xhtml_TagWrapper(['tag' => 'div', 'cssClass' => 'form-toolbar']), |
| 62 | 'actions-top' => new tao_helpers_form_xhtml_TagWrapper(['tag' => 'div', 'cssClass' => 'form-toolbar']) |
| 63 | ]); |
| 64 | |
| 65 | $submitElt = tao_helpers_form_FormFactory::getElement('import', 'Free'); |
| 66 | $submitElt->setValue( |
| 67 | '<a href="#" class="form-submitter btn-success small"><span class="icon-import"></span> ' |
| 68 | . __('Import') . '</a>' |
| 69 | ); |
| 70 | |
| 71 | $this->form->setActions([$submitElt], 'bottom'); |
| 72 | $this->form->setActions([], 'top'); |
| 73 | } |
| 74 | |
| 75 | /** |
| 76 | * (non-PHPdoc) |
| 77 | * @see tao_helpers_form_FormContainer::initElements() |
| 78 | */ |
| 79 | public function initElements() |
| 80 | { |
| 81 | |
| 82 | /* |
| 83 | $descElt = tao_helpers_form_FormFactory::getElement('qtitest_desc', 'Label'); |
| 84 | $descElt->setValue(__('A qti testpackage')); |
| 85 | $this->form->addElement($descElt); |
| 86 | */ |
| 87 | |
| 88 | //create file upload form box |
| 89 | $fileElt = tao_helpers_form_FormFactory::getElement('source', 'AsyncFile'); |
| 90 | $fileElt->setDescription(__("Add the source file")); |
| 91 | if (isset($_POST['import_sent_xhtml'])) { |
| 92 | $fileElt->addValidator(tao_helpers_form_FormFactory::getValidator('NotEmpty')); |
| 93 | } else { |
| 94 | $fileElt->addValidator(tao_helpers_form_FormFactory::getValidator('NotEmpty', ['message' => ''])); |
| 95 | } |
| 96 | $fileElt->addValidators([ |
| 97 | tao_helpers_form_FormFactory::getValidator( |
| 98 | 'FileMimeType', |
| 99 | [ |
| 100 | 'mimetype' => [ |
| 101 | 'application/zip', |
| 102 | 'application/x-zip', |
| 103 | 'application/x-zip-compressed', |
| 104 | 'application/octet-stream', |
| 105 | ], |
| 106 | 'extension' => ['zip'], |
| 107 | ] |
| 108 | ), |
| 109 | tao_helpers_form_FormFactory::getValidator('FileSize', ['max' => SystemHelper::getFileUploadLimit()]) |
| 110 | ]); |
| 111 | |
| 112 | $this->form->addElement($fileElt); |
| 113 | |
| 114 | $this->form->createGroup('file', __('Upload a QTI 2.1 Test Package File'), ['source']); |
| 115 | |
| 116 | $element = tao_helpers_form_FormFactory::getElement('uri', 'Hidden'); |
| 117 | //$element->setValue(); |
| 118 | $this->getForm()->addElement($element); |
| 119 | |
| 120 | $xhtmlSentElt = tao_helpers_form_FormFactory::getElement('import_sent_qtitest', 'Hidden'); |
| 121 | $xhtmlSentElt->setValue(1); |
| 122 | $this->form->addElement($xhtmlSentElt); |
| 123 | } |
| 124 | } |