Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 9 |
|
0.00% |
0 / 5 |
CRAP | |
0.00% |
0 / 1 |
| UnexpectedResponseProcessing | |
0.00% |
0 / 9 |
|
0.00% |
0 / 5 |
42 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| getSeverity | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| setRequestedUri | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getRequestedUri | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getUserMessage | |
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\exception; |
| 24 | |
| 25 | use oat\taoQtiItem\model\qti\exception\UnexpectedResponseProcessing; |
| 26 | use oat\taoQtiItem\model\qti\exception\ParsingException; |
| 27 | use common_exception_UserReadableException; |
| 28 | use common_Logger; |
| 29 | |
| 30 | /** |
| 31 | * Exception to be thrown when an unknown/unexpected Response Processing |
| 32 | * template is requested for use. |
| 33 | * |
| 34 | * @access public |
| 35 | * @author Joel Bout, <joel.bout@tudor.lu> |
| 36 | * @package taoQTI |
| 37 | |
| 38 | */ |
| 39 | class UnexpectedResponseProcessing extends ParsingException implements common_exception_UserReadableException |
| 40 | { |
| 41 | /** |
| 42 | * The template URI to be dereferenced as a Response Processing template. |
| 43 | * |
| 44 | * @var string |
| 45 | */ |
| 46 | private $requestedUri; |
| 47 | |
| 48 | /** |
| 49 | * Create a new UnexpectedResponseProcessing object. |
| 50 | * |
| 51 | * @param string $message A message. |
| 52 | * @param integer $code An optional code enabling the client code to react. |
| 53 | * @param string $requestedUri An invalid Response processing template URI. |
| 54 | */ |
| 55 | public function __construct($message, $code = 0, $requestedUri = '') |
| 56 | { |
| 57 | parent::__construct($message, $code); |
| 58 | $this->setRequestedUri($requestedUri); |
| 59 | } |
| 60 | |
| 61 | /** |
| 62 | * Get the serverity of the error. |
| 63 | * |
| 64 | * @access public |
| 65 | * @author Joel Bout, <joel.bout@tudor.lu> |
| 66 | * @return int |
| 67 | */ |
| 68 | public function getSeverity() |
| 69 | { |
| 70 | return (int) common_Logger::TRACE_LEVEL; |
| 71 | } |
| 72 | |
| 73 | /** |
| 74 | * Set the URI that was requested for dereferencing. |
| 75 | * |
| 76 | * @param string $requestedUri |
| 77 | */ |
| 78 | protected function setRequestedUri($requestedUri) |
| 79 | { |
| 80 | $this->requestedUri = $requestedUri; |
| 81 | } |
| 82 | |
| 83 | /** |
| 84 | * Get the URI that was requested for dereferencing. |
| 85 | * |
| 86 | * @return string |
| 87 | */ |
| 88 | public function getRequestedUri() |
| 89 | { |
| 90 | return $this->requestedUri; |
| 91 | } |
| 92 | |
| 93 | /** |
| 94 | * Returns a human-readable message describing the error that occured. |
| 95 | * |
| 96 | * @return string |
| 97 | */ |
| 98 | public function getUserMessage() |
| 99 | { |
| 100 | $requestedUri = $this->getRequestedUri(); |
| 101 | if (empty($requestedUri) === true) { |
| 102 | return __('An unexpected error occured while dealing with Response Processing.'); |
| 103 | } else { |
| 104 | return __('The Response Processing Template "%s" is not supported.', $this->getRequestedUri()); |
| 105 | } |
| 106 | } |
| 107 | } |