Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
= committed Aug 10, 2016
2 parents 84a4290 + ea9a8b1 commit 69ff145
Show file tree
Hide file tree
Showing 27 changed files with 20,724 additions and 29,034 deletions.
2 changes: 1 addition & 1 deletion src/qtism/common/utils/Version.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ static public function isKnown($version)
*/
static public function knownVersions()
{
return array('2.0.0', '2.1.0', '2.1.1', '2.2.0');
return array('2.0.0', '2.1.0', '2.1.1', '2.2.0', '2.2.1');
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/qtism/data/content/xhtml/text/Acronym.php
Original file line number Diff line number Diff line change
Expand Up @@ -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-2014 (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 <jerome@taotesting.com>
* @license GPLv2
Expand All @@ -41,6 +41,6 @@ class Acronym extends SimpleInline
*/
public function getQtiClassName()
{
return 'accronym';
return 'acronym';
}
}
10 changes: 7 additions & 3 deletions src/qtism/data/storage/xml/Utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,13 @@ static public function getSchemaLocation($version = '2.1')
$version = Version::appendPatchVersion($version);

if ($version === '2.1.0') {
$filename = dirname(__FILE__) . $dS . 'schemes' . $dS . 'imsqti_v2p1.xsd';
$filename = dirname(__FILE__) . $dS . 'schemes' . $dS . 'qtiv2p1' . $dS . 'imsqti_v2p1.xsd';
} elseif ($version === '2.1.1') {
$filename = dirname(__FILE__) . $dS . 'schemes' . $dS . 'imsqti_v2p1p1.xsd';
$filename = dirname(__FILE__) . $dS . 'schemes' . $dS . 'qtiv2p1p1' . $dS . 'imsqti_v2p1p1.xsd';
} elseif ($version === '2.2.0') {
$filename = dirname(__FILE__) . $dS . 'schemes' . $dS . 'imsqti_v2p2.xsd';
$filename = dirname(__FILE__) . $dS . 'schemes' . $dS . 'qtiv2p2' . $dS . 'imsqti_v2p2.xsd';
} elseif ($version === '2.2.1') {
$filename = dirname(__FILE__) . $dS . 'schemes' . $dS . 'qtiv2p2p1' . $dS . 'imsqti_v2p2p1.xsd';
} else {
$filename = dirname(__FILE__) . $dS . 'schemes' . $dS . 'imsqti_v2p0.xsd';
}
Expand Down Expand Up @@ -92,6 +94,8 @@ static public function inferVersion(DOMDocument $document)

if ($nsLocation === 'http://www.imsglobal.org/xsd/qti/qtiv2p2/imsqti_v2p2.xsd') {
$version = '2.2.0';
} elseif ($nsLocation === 'http://www.imsglobal.org/xsd/qti/qtiv2p2/imsqti_v2p2p1.xsd') {
$version = '2.2.1';
}
}
}
Expand Down
14 changes: 11 additions & 3 deletions src/qtism/data/storage/xml/XmlDocument.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
use qtism\data\storage\xml\marshalling\Qti21MarshallerFactory;
use qtism\data\storage\xml\marshalling\Qti211MarshallerFactory;
use qtism\data\storage\xml\marshalling\Qti22MarshallerFactory;
use qtism\data\storage\xml\marshalling\Qti221MarshallerFactory;
use qtism\data\AssessmentTest;
use qtism\data\content\Flow;
use qtism\data\storage\xml\marshalling\Marshaller;
Expand Down Expand Up @@ -543,6 +544,11 @@ protected function decorateRootElement(DOMElement $rootElement)
$xsdLocation = 'http://www.imsglobal.org/xsd/qti/qtiv2p2/imsqti_v2p2.xsd';
$qtiSuffix = 'v2p2';
break;

case '2.2.1':
$xsdLocation = 'http://www.imsglobal.org/xsd/qti/qtiv2p2/imsqti_v2p2p1.xsd';
$qtiSuffix = 'v2p2';
break;
}

$rootElement->setAttribute('xmlns', "http://www.imsglobal.org/xsd/imsqti_${qtiSuffix}");
Expand Down Expand Up @@ -597,12 +603,14 @@ protected function createMarshallerFactory()
$version = $this->getVersion();
if ($version === '2.0.0') {
return new Qti20MarshallerFactory();
} else if ($version === '2.1.0') {
} elseif ($version === '2.1.0') {
return new Qti21MarshallerFactory();
} else if ($version === '2.1.1') {
} elseif ($version === '2.1.1') {
return new Qti211MarshallerFactory();
} else if ($version === '2.2.0') {
} elseif ($version === '2.2.0') {
return new Qti22MarshallerFactory();
} elseif ($version === '2.2.1') {
return new Qti221MarshallerFactory();
} else {
$msg = "No MarshallerFactory implementation found for QTI version '${version}'.";
throw new RuntimeException($msg);
Expand Down
6 changes: 3 additions & 3 deletions src/qtism/data/storage/xml/marshalling/ColgroupMarshaller.php
Original file line number Diff line number Diff line change
Expand Up @@ -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-2014 (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 <jerome@taotesting.com>
* @license GPLv2
Expand Down Expand Up @@ -49,7 +49,7 @@ protected function marshall(QtiComponent $component)

foreach ($component->getContent() as $col) {
$marshaller = $this->getMarshallerFactory()->createMarshaller($col);
$element->appendChild($marshaller->marshall());
$element->appendChild($marshaller->marshall($col));
}

$this->fillElement($element, $component);
Expand All @@ -68,7 +68,7 @@ protected function unmarshall(DOMElement $element)
{
$component = new Colgroup();

if ((self::getDOMElementAttributeAs($element, 'span', 'integer')) !== null) {
if (($span = self::getDOMElementAttributeAs($element, 'span', 'integer')) !== null) {
$component->setSpan($span);
}

Expand Down
7 changes: 6 additions & 1 deletion src/qtism/data/storage/xml/marshalling/ContentMarshaller.php
Original file line number Diff line number Diff line change
Expand Up @@ -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-2014 (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 <jerome@taotesting.com>
* @license GPLv2
Expand Down Expand Up @@ -307,6 +307,11 @@ protected function lookupClass(DOMElement $element)
if (class_exists($fqClass) === true) {
return $fqClass;
}

$fqClass = $fqClass . 'Element';
if (class_exists($fqClass) === true) {
return $fqClass;
}
}

$msg = "No class could be found for tag with name '" . $element->localName . "'.";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ protected function marshallChildrenKnown(QtiComponent $component, array $element
self::setDOMElementAttribute($element, 'minAssociations', $component->getMinAssociations());
}

if (Version::compare($version, '2.1.0', '<') === true || (Version::compare($version, '2.1.0', '>') && $component->getMaxAssociations() !== 1)) {
if (Version::compare($version, '2.1.0', '<') === true || (Version::compare($version, '2.1.0', '>=') && $component->getMaxAssociations() !== 1)) {
self::setDOMElementAttribute($element, 'maxAssociations', $component->getMaxAssociations());
}

Expand Down
3 changes: 2 additions & 1 deletion src/qtism/data/storage/xml/marshalling/MarshallerFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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-2015 (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 <jerome@taotesting.com>
* @license GPLv2
Expand Down Expand Up @@ -144,6 +144,7 @@ public function __construct()
$this->addMappingEntry('rubricBlock', 'qtism\\data\\storage\\xml\\marshalling\\RubricBlockMarshaller');
$this->addMappingEntry('object', 'qtism\\data\\storage\\xml\\marshalling\\ObjectMarshaller');
$this->addMappingEntry('col', 'qtism\\data\\storage\\xml\\marshalling\\ColMarshaller');
$this->addMappingEntry('colgroup', 'qtism\\data\\storage\\xml\\marshalling\\ColgroupMarshaller');
$this->addMappingEntry('equal', 'qtism\\data\\storage\\xml\\marshalling\\EqualMarshaller');
$this->addMappingEntry('sectionPart', 'qtism\\data\\storage\\xml\\marshalling\\SectionPartMarshaller');
$this->addMappingEntry('selectPointInteraction', 'qtism\\data\\storage\\xml\\marshalling\\SelectPointInteractionMarshaller');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class Qti21MarshallerFactory extends MarshallerFactory
{
protected function instantiateMarshaller(ReflectionClass $class, array $args)
{
array_unshift($args, '2.1.1');
array_unshift($args, '2.1.0');
return Reflection::newInstance($class, $args);
}
}
45 changes: 45 additions & 0 deletions src/qtism/data/storage/xml/marshalling/Qti221MarshallerFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php
/**
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; under version 2
* of the License (non-upgradable).
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* 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-2016 (original work) Open Assessment Technologies SA (under the project TAO-PRODUCT);
*
* @author Jérôme Bogaerts <jerome@taotesting.com>
* @license GPLv2
*/

namespace qtism\data\storage\xml\marshalling;

use qtism\common\utils\Reflection;
use \ReflectionClass;

/**
* A MarshallerFactory focusing on instantiating and configuring
* Marshallers for QTI 2.2.1.
*
* @author Jérôme Bogaerts <jerome@taotesting.com>
*
*/
class Qti221MarshallerFactory extends Qti22MarshallerFactory
{
/**
* @see \qtism\data\storage\xml\marshalling\MarshallerFactory::instantiateMarshaller()
*/
protected function instantiateMarshaller(ReflectionClass $class, array $args)
{
array_unshift($args, '2.2.1');
return Reflection::newInstance($class, $args);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -998,4 +998,4 @@

<!-- ================================================================================================== -->

</xs:schema>
</xs:schema>
2 changes: 1 addition & 1 deletion src/qtism/data/storage/xml/schemes/imscp_v1p1.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -419,4 +419,4 @@

<!-- Copyright (2) 2004 IMS Global Learning Consortium, Inc. -->

</xsd:schema>
</xsd:schema>
2 changes: 1 addition & 1 deletion src/qtism/data/storage/xml/schemes/imsqti_v2p0.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -4790,4 +4790,4 @@
</xsd:restriction>
</xsd:simpleType>

</xsd:schema>
</xsd:schema>
Loading

0 comments on commit 69ff145

Please sign in to comment.