Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 25 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| QtiItemImportForm | |
0.00% |
0 / 25 |
|
0.00% |
0 / 2 |
12 | |
0.00% |
0 / 1 |
| initForm | |
0.00% |
0 / 8 |
|
0.00% |
0 / 1 |
2 | |||
| initElements | |
0.00% |
0 / 17 |
|
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 | namespace oat\taoQtiItem\model\import; |
| 25 | |
| 26 | use oat\generis\Helper\SystemHelper; |
| 27 | use tao_helpers_form_FormContainer; |
| 28 | use tao_helpers_form_xhtml_Form; |
| 29 | use tao_helpers_form_FormFactory; |
| 30 | use tao_helpers_Environment; |
| 31 | |
| 32 | /** |
| 33 | * Import form for QTI Items (xml files) |
| 34 | * |
| 35 | * @access public |
| 36 | * @author Joel Bout, <joel.bout@tudor.lu> |
| 37 | * @package taoQTI |
| 38 | |
| 39 | */ |
| 40 | class QtiItemImportForm extends tao_helpers_form_FormContainer |
| 41 | { |
| 42 | // --- ASSOCIATIONS --- |
| 43 | |
| 44 | |
| 45 | // --- ATTRIBUTES --- |
| 46 | |
| 47 | // --- OPERATIONS --- |
| 48 | /** |
| 49 | * (non-PHPdoc) |
| 50 | * @see tao_helpers_form_FormContainer::initForm() |
| 51 | */ |
| 52 | public function initForm() |
| 53 | { |
| 54 | $this->form = new tao_helpers_form_xhtml_Form('export'); |
| 55 | $submitElt = tao_helpers_form_FormFactory::getElement('import', 'Free'); |
| 56 | $submitElt->setValue( |
| 57 | '<a href="#" class="form-submitter btn-success small"><span class="icon-import"></span> ' |
| 58 | . __('Import') . '</a>' |
| 59 | ); |
| 60 | |
| 61 | $this->form->setActions([$submitElt], 'bottom'); |
| 62 | $this->form->setActions([], 'top'); |
| 63 | } |
| 64 | |
| 65 | /** |
| 66 | * (non-PHPdoc) |
| 67 | * @see tao_helpers_form_FormContainer::initElements() |
| 68 | */ |
| 69 | public function initElements() |
| 70 | { |
| 71 | |
| 72 | //create file upload form box |
| 73 | $fileElt = tao_helpers_form_FormFactory::getElement('source', 'AsyncFile'); |
| 74 | $fileElt->setDescription(__("Add a QTI/APIP XML Item Document")); |
| 75 | if (isset($_POST['import_sent_qti'])) { |
| 76 | $fileElt->addValidator(tao_helpers_form_FormFactory::getValidator('NotEmpty')); |
| 77 | } else { |
| 78 | $fileElt->addValidator(tao_helpers_form_FormFactory::getValidator('NotEmpty', ['message' => ''])); |
| 79 | } |
| 80 | $fileElt->addValidators([ |
| 81 | tao_helpers_form_FormFactory::getValidator( |
| 82 | 'FileMimeType', |
| 83 | ['mimetype' => ['text/xml', 'application/xml', 'application/x-xml'], 'extension' => ['xml']] |
| 84 | ), |
| 85 | tao_helpers_form_FormFactory::getValidator('FileSize', ['max' => SystemHelper::getFileUploadLimit()]) |
| 86 | ]); |
| 87 | |
| 88 | $this->form->addElement($fileElt); |
| 89 | $this->form->createGroup('file', __('Import a QTI/APIP XML Item Document'), ['source']); |
| 90 | |
| 91 | $qtiSentElt = tao_helpers_form_FormFactory::getElement('import_sent_qti', 'Hidden'); |
| 92 | $qtiSentElt->setValue(1); |
| 93 | $this->form->addElement($qtiSentElt); |
| 94 | } |
| 95 | } |