Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 14 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| taoQtiTest_models_classes_QtiTestServiceException | |
0.00% |
0 / 14 |
|
0.00% |
0 / 2 |
56 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getUserMessage | |
0.00% |
0 / 13 |
|
0.00% |
0 / 1 |
42 | |||
| 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 | |
| 24 | /** |
| 25 | * The QtiTestServiceException is thrown when an error occurs |
| 26 | * at the QtiTestService level, in order to report an appropriate |
| 27 | * Exception to the client side. |
| 28 | * |
| 29 | * Error codes: |
| 30 | * |
| 31 | * * 0: Unknown error. |
| 32 | * * 1: The QTI-XML item involved in a test cannot be read. |
| 33 | * * 2: The QTI-XML item involved in a test cannot be written. |
| 34 | * * 3: The QTI-XML test cannot be read. |
| 35 | * * 4: The QTI-XML test cannot be written. |
| 36 | * |
| 37 | * @author Jérôme Bogaerts <jerome@taotesting.com> |
| 38 | * @package taoQtiTest |
| 39 | |
| 40 | */ |
| 41 | class taoQtiTest_models_classes_QtiTestServiceException extends common_Exception implements |
| 42 | common_exception_UserReadableException |
| 43 | { |
| 44 | public const TEST_WRITE_ERROR = 0; |
| 45 | public const ITEM_READ_ERROR = 1; |
| 46 | public const ITEM_WRITE_ERROR = 2; |
| 47 | public const TEST_READ_ERROR = 3; |
| 48 | |
| 49 | /** |
| 50 | * Create a new QtiTestServiceException object. |
| 51 | * |
| 52 | * @param string $message A technical infiormation message. |
| 53 | * @param integer $code A code to explicitely identify the nature of the error. |
| 54 | */ |
| 55 | public function __construct($message, $code = 0) |
| 56 | { |
| 57 | parent::__construct($message, $code); |
| 58 | } |
| 59 | |
| 60 | /** |
| 61 | * Returns a translated human-readable message destinated to the end-user. |
| 62 | * |
| 63 | * @return string A human-readable message. |
| 64 | */ |
| 65 | public function getUserMessage() |
| 66 | { |
| 67 | switch ($this->getCode()) { |
| 68 | case 3: |
| 69 | return __("The QTI test could not be retrieved correctly."); |
| 70 | break; |
| 71 | case 2: |
| 72 | return __("An item involved in the test cannot be written."); |
| 73 | break; |
| 74 | case 1: |
| 75 | return __("An item involved in the test cannot be read or is not QTI compliant."); |
| 76 | break; |
| 77 | case 0: |
| 78 | default: |
| 79 | return __("The QTI-XML test could not be written correctly."); |
| 80 | break; |
| 81 | } |
| 82 | } |
| 83 | } |