diff --git a/composer.json b/composer.json index d78be1de3..a5b5914e4 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "qtism/qtism", "description": "OAT QTI Software Module Library", "type": "library", - "version": "0.9.20", + "version": "0.9.21", "authors": [ { "name": "Open Assessment Technologies S.A.", diff --git a/qtism/data/state/VariableDeclaration.php b/qtism/data/state/VariableDeclaration.php index 24c3e2408..be7b1c634 100644 --- a/qtism/data/state/VariableDeclaration.php +++ b/qtism/data/state/VariableDeclaration.php @@ -14,7 +14,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * Copyright (c) 2013 (original work) Open Assessment Technologies SA (under the project TAO-PRODUCT); + * Copyright (c) 2013-2015 (original work) Open Assessment Technologies SA (under the project TAO-PRODUCT); * * @author Jérôme Bogaerts, * @license GPLv2 @@ -32,6 +32,7 @@ use qtism\common\enums\Cardinality; use \SplObserver; use \SplObjectStorage; +use \InvalidArgumentException; /** * From IMS QTI: diff --git a/qtism/data/storage/xml/XmlCompactDocument.php b/qtism/data/storage/xml/XmlCompactDocument.php index 21acf2e58..33891e3c9 100644 --- a/qtism/data/storage/xml/XmlCompactDocument.php +++ b/qtism/data/storage/xml/XmlCompactDocument.php @@ -14,7 +14,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * Copyright (c) 2013 (original work) Open Assessment Technologies SA (under the project TAO-PRODUCT); + * Copyright (c) 2013-2016 (original work) Open Assessment Technologies SA (under the project TAO-PRODUCT); * * @author Jérôme Bogaerts, * @license GPLv2 @@ -242,7 +242,7 @@ protected static function resolveAssessmentItemRef(ExtendedAssessmentItemRef $co $compactAssessmentItemRef->setTimeDependent($doc->getDocumentComponent()->isTimeDependent()); } catch (Exception $e) { - $msg = "An error occured while unreferencing file '${href}'."; + $msg = "An error occured while unreferencing item reference with identifier '" . $compactAssessmentItemRef->getIdentifier() . "'."; throw new XmlStorageException($msg, $e); } } @@ -264,8 +264,8 @@ protected static function resolveAssessmentSectionRef(AssessmentSectionRef $asse return $doc->getDocumentComponent(); } catch (XmlStorageException $e) { - $msg = "An error occured while unreferencing file '${href}'."; - throw new XmlStorageException($msg); + $msg = "An error occured while unreferencing section reference with identifier '" . $assessmentSectionRef->getIdentifier() . "'."; + throw new XmlStorageException($msg, $e); } } diff --git a/test/qtism/data/storage/xml/XmlCompactAssessmentDocumentTest.php b/test/qtism/data/storage/xml/XmlCompactAssessmentDocumentTest.php index 3f4f6820d..eadedffc2 100644 --- a/test/qtism/data/storage/xml/XmlCompactAssessmentDocumentTest.php +++ b/test/qtism/data/storage/xml/XmlCompactAssessmentDocumentTest.php @@ -4,6 +4,7 @@ use qtism\data\storage\LocalFileResolver; use qtism\data\NavigationMode; use qtism\data\storage\xml\XmlDocument; +use qtism\data\storage\xml\XmlStorageException; require_once (dirname(__FILE__) . '/../../../../QtiSmTestCase.php'); @@ -215,4 +216,16 @@ public function testExplodeRubricBlocks() { unlink($file); } + + public function testCreateFromAssessmentTestInvalidAssessmentItemRefResolution() { + $this->setExpectedException( + '\\qtism\\data\\storage\\xml\\XmlStorageException', + "An error occured while unreferencing item reference with identifier 'Q01'." + ); + + $doc = new XmlDocument('2.1'); + $file = self::samplesDir() . 'custom/tests/invalidassessmentitemref.xml'; + $doc->load($file); + $compactDoc = XmlCompactDocument::createFromXmlAssessmentTestDocument($doc, new LocalFileResolver()); + } } diff --git a/test/samples/custom/tests/invalidassessmentitemref.xml b/test/samples/custom/tests/invalidassessmentitemref.xml new file mode 100644 index 000000000..dc5cd513d --- /dev/null +++ b/test/samples/custom/tests/invalidassessmentitemref.xml @@ -0,0 +1,11 @@ + + + + + + + + diff --git a/test/samples/invalid/invalidresponseidentifier.xml b/test/samples/invalid/invalidresponseidentifier.xml new file mode 100644 index 000000000..3b8552f6d --- /dev/null +++ b/test/samples/invalid/invalidresponseidentifier.xml @@ -0,0 +1,32 @@ + + + + + + H + O + + + + + + + + + + + Which of the following elements are used to form water? + Hydrogen + Helium + Carbon + Oxygen + Nitrogen + Chlorine + + + +