From be6e6cb520ca6b897e52d455fe20dfadbef703d9 Mon Sep 17 00:00:00 2001 From: bugalot Date: Sun, 11 Oct 2015 02:49:00 +0200 Subject: [PATCH 1/2] First trial PHP7. All pass but seg faults and mm_heap corrupted. --- src/qtism/common/collections/Container.php | 12 +- .../datatypes/{Boolean.php => QtiBoolean.php} | 2 +- .../datatypes/{Coords.php => QtiCoords.php} | 22 +- .../{DirectedPair.php => QtiDirectedPair.php} | 2 +- .../{Duration.php => QtiDuration.php} | 12 +- .../datatypes/{File.php => QtiFile.php} | 2 +- .../datatypes/{Float.php => QtiFloat.php} | 2 +- .../{Identifier.php => QtiIdentifier.php} | 2 +- ...rIdentifier.php => QtiIntOrIdentifier.php} | 2 +- .../datatypes/{Integer.php => QtiInteger.php} | 2 +- .../datatypes/{Pair.php => QtiPair.php} | 2 +- .../datatypes/{Point.php => QtiPoint.php} | 2 +- .../datatypes/{Scalar.php => QtiScalar.php} | 4 +- .../datatypes/{Shape.php => QtiShape.php} | 2 +- .../datatypes/{String.php => QtiString.php} | 2 +- .../common/datatypes/{Uri.php => QtiUri.php} | 2 +- .../common/datatypes/files/FileManager.php | 4 +- .../common/datatypes/files/FileSystemFile.php | 6 +- .../datatypes/files/FileSystemFileManager.php | 4 +- src/qtism/data/TimeLimits.php | 6 +- .../interactions/AssociableHotspot.php | 10 +- .../data/content/interactions/Hotspot.php | 4 +- .../content/interactions/HotspotChoice.php | 10 +- .../PositionObjectInteraction.php | 4 +- .../data/expressions/operators/Inside.php | 10 +- src/qtism/data/state/AreaMapEntry.php | 10 +- src/qtism/data/storage/Utils.php | 20 +- src/qtism/data/storage/php/PhpDocument.php | 4 +- .../marshalling/PhpQtiDatatypeMarshaller.php | 22 +- .../marshalling/AreaMapEntryMarshaller.php | 6 +- .../xml/marshalling/HotspotMarshaller.php | 6 +- .../xml/marshalling/InsideMarshaller.php | 8 +- .../PositionObjectInteractionMarshaller.php | 4 +- src/qtism/runtime/common/OutcomeVariable.php | 8 +- src/qtism/runtime/common/Utils.php | 40 +- .../expressions/MapResponsePointProcessor.php | 12 +- .../expressions/MapResponseProcessor.php | 20 +- .../expressions/MathConstantProcessor.php | 6 +- .../expressions/NumberCorrectProcessor.php | 4 +- .../expressions/NumberIncorrectProcessor.php | 4 +- .../expressions/NumberPresentedProcessor.php | 4 +- .../expressions/NumberRespondedProcessor.php | 4 +- .../expressions/NumberSelectedProcessor.php | 4 +- .../expressions/OutcomeMaximumProcessor.php | 6 +- .../expressions/OutcomeMinimumProcessor.php | 6 +- .../expressions/RandomFloatProcessor.php | 4 +- .../expressions/RandomIntegerProcessor.php | 6 +- .../expressions/TestVariablesProcessor.php | 8 +- .../runtime/expressions/VariableProcessor.php | 6 +- .../expressions/operators/AndProcessor.php | 6 +- .../expressions/operators/AnyNProcessor.php | 14 +- .../operators/ContainerSizeProcessor.php | 6 +- .../operators/ContainsProcessor.php | 12 +- .../expressions/operators/DivideProcessor.php | 4 +- .../operators/DurationGTEProcessor.php | 4 +- .../operators/DurationLTProcessor.php | 4 +- .../expressions/operators/EqualProcessor.php | 14 +- .../operators/EqualRoundedProcessor.php | 8 +- .../expressions/operators/GcdProcessor.php | 10 +- .../expressions/operators/GtProcessor.php | 4 +- .../expressions/operators/GteProcessor.php | 4 +- .../expressions/operators/IndexProcessor.php | 4 +- .../expressions/operators/InsideProcessor.php | 4 +- .../operators/IntegerDivideProcessor.php | 4 +- .../operators/IntegerModulusProcessor.php | 4 +- .../operators/IntegerToFloatProcessor.php | 4 +- .../expressions/operators/IsNullProcessor.php | 4 +- .../expressions/operators/LcmProcessor.php | 12 +- .../expressions/operators/LtProcessor.php | 4 +- .../expressions/operators/LteProcessor.php | 4 +- .../expressions/operators/MatchProcessor.php | 6 +- .../operators/MathOperatorProcessor.php | 96 ++-- .../expressions/operators/MaxProcessor.php | 10 +- .../expressions/operators/MemberProcessor.php | 4 +- .../expressions/operators/MinProcessor.php | 10 +- .../expressions/operators/NotProcessor.php | 4 +- .../operators/OperandsCollection.php | 26 +- .../expressions/operators/OrProcessor.php | 8 +- .../operators/PatternMatchProcessor.php | 6 +- .../expressions/operators/PowerProcessor.php | 4 +- .../operators/ProductProcessor.php | 10 +- .../expressions/operators/RepeatProcessor.php | 4 +- .../expressions/operators/RoundProcessor.php | 4 +- .../operators/RoundToProcessor.php | 12 +- .../operators/StatsOperatorProcessor.php | 12 +- .../operators/StringMatchProcessor.php | 4 +- .../operators/SubstringProcessor.php | 4 +- .../operators/SubtractProcessor.php | 6 +- .../expressions/operators/SumProcessor.php | 12 +- .../operators/TruncateProcessor.php | 8 +- .../expressions/operators/custom/Explode.php | 4 +- .../expressions/operators/custom/Implode.php | 4 +- src/qtism/runtime/pci/json/Marshaller.php | 76 +-- src/qtism/runtime/pci/json/Unmarshaller.php | 44 +- .../processing/PrintedVariableEngine.php | 4 +- .../markup/AbstractMarkupRenderingEngine.php | 16 +- .../markup/xhtml/HotspotRenderer.php | 6 +- .../rules/LookupOutcomeValueProcessor.php | 10 +- src/qtism/runtime/rules/SetValueProcessor.php | 12 +- .../binary/AbstractQtiBinaryStreamAccess.php | 44 +- .../binary/QtiBinaryStreamAccessFsFile.php | 4 +- .../runtime/tests/AssessmentItemSession.php | 30 +- .../runtime/tests/AssessmentTestSession.php | 14 +- src/qtism/runtime/tests/TimeConstraint.php | 10 +- .../qtismtest/QtiSmAssessmentItemTestCase.php | 2 +- .../common/collections/ContainerTest.php | 122 ++--- .../common/datatypes/BooleanTest.php | 6 +- .../qtismtest/common/datatypes/CoordsTest.php | 56 +- .../common/datatypes/DirectedPairTest.php | 18 +- .../common/datatypes/DurationTest.php | 100 ++-- test/qtismtest/common/datatypes/FloatTest.php | 4 +- .../common/datatypes/IdentifierTest.php | 4 +- .../common/datatypes/IntOrIdentifierTest.php | 4 +- .../common/datatypes/IntegerTest.php | 4 +- test/qtismtest/common/datatypes/PairTest.php | 14 +- test/qtismtest/common/datatypes/PointTest.php | 8 +- .../qtismtest/common/utils/ReflectionTest.php | 4 +- test/qtismtest/data/AssessmentTestTest.php | 6 +- test/qtismtest/data/storage/UtilsTest.php | 62 +-- .../marshalling/PhpMarshallingContextTest.php | 16 +- .../marshalling/PhpMarshallingUtilsTest.php | 8 +- .../PhpQtiDatatypeMarshallerTest.php | 22 +- .../xml/XmlCompactAssessmentDocumentTest.php | 2 +- .../AreaMapEntryMarshallerTest.php | 12 +- .../marshalling/AreaMappingMarshallerTest.php | 8 +- .../AssessmentItemRefMarshallerTest.php | 4 +- .../AssociableHotspotMarshallerTest.php | 28 +- .../CorrectResponseMarshallerTest.php | 6 +- .../DefaultValueMarshallerTest.php | 6 +- .../ExtendedAssessmentTestMarshallerTest.php | 8 +- .../ExtendedTestPartMarshallerTest.php | 6 +- ...phicAssociateInteractionMarshallerTest.php | 28 +- ...aphicGapMatchInteractionMarshallerTest.php | 10 +- .../GraphicOrderInteractionMarshallerTest.php | 16 +- .../HotspotChoiceMarshallerTest.php | 14 +- .../HotspotInteractionMarshallerTest.php | 12 +- .../xml/marshalling/InsideMarshallerTest.php | 12 +- .../marshalling/MatchTableMarshallerTest.php | 8 +- .../OutcomeDeclarationMarshallerTest.php | 8 +- ...ositionObjectInteractionMarshallerTest.php | 6 +- .../PositionObjectStageMarshallerTest.php | 6 +- .../Qti21MarshallerFactoryTest.php | 8 +- .../ResponseDeclarationMarshallerTest.php | 6 +- .../marshalling/TimeLimitsMarshallerTest.php | 6 +- .../xml/marshalling/ValueMarshallerTest.php | 8 +- .../runtime/common/MultipleContainerTest.php | 24 +- .../runtime/common/OrderedContainerTest.php | 22 +- .../runtime/common/OutcomeVariableTest.php | 66 +-- .../runtime/common/RecordContainerTest.php | 26 +- .../runtime/common/ResponseVariableTest.php | 26 +- .../runtime/common/RuntimeUtilsTest.php | 68 +-- test/qtismtest/runtime/common/StateTest.php | 8 +- .../expressions/BaseValueProcessorTest.php | 4 +- .../expressions/CorrectProcessorTest.php | 8 +- .../expressions/DefaultProcessorTest.php | 10 +- .../expressions/ExpressionEngineTest.php | 4 +- .../MapResponsePointProcessorTest.php | 42 +- .../expressions/MapResponseProcessorTest.php | 46 +- .../expressions/MathConstantProcessorTest.php | 4 +- .../NumberCorrectProcessorTest.php | 22 +- .../NumberIncorrectProcessorTest.php | 22 +- .../NumberRespondedProcessorTest.php | 22 +- .../OutcomeMaximumProcessorTest.php | 16 +- .../OutcomeMinimumProcessorTest.php | 14 +- .../expressions/RandomFloatProcessorTest.php | 6 +- .../RandomIntegerProcessorTest.php | 6 +- .../TestVariablesProcessorTest.php | 84 +-- .../expressions/VariableProcessorTest.php | 28 +- .../operators/AndProcessorTest.php | 32 +- .../operators/AnyNProcessorTest.php | 68 +-- .../operators/ContainerSizeProcessorTest.php | 26 +- .../operators/ContainsProcessorTest.php | 240 ++++----- .../operators/DeleteProcessorTest.php | 80 +-- .../operators/DivideProcessorTest.php | 50 +- .../operators/DurationGTEProcessorTest.php | 24 +- .../operators/DurationLTProcessorTest.php | 20 +- .../operators/EqualProcessorTest.php | 106 ++-- .../operators/EqualRoundedProcessorTest.php | 32 +- .../operators/FieldValueProcessorTest.php | 12 +- .../operators/GcdProcessorTest.php | 40 +- .../expressions/operators/GtProcessorTest.php | 42 +- .../operators/GteProcessorTest.php | 42 +- .../operators/IndexProcessorTest.php | 36 +- .../operators/InsideProcessorTest.php | 72 +-- .../operators/IntegerDivideProcessorTest.php | 28 +- .../operators/IntegerModulusProcessorTest.php | 32 +- .../operators/IntegerToFloatTest.php | 36 +- .../operators/IsNullProcessorTest.php | 28 +- .../operators/LcmProcessorTest.php | 42 +- .../expressions/operators/LtProcessorTest.php | 42 +- .../operators/LteProcessorTest.php | 42 +- .../operators/MatchProcessorTest.php | 62 +-- .../operators/MathOperatorProcessorTest.php | 312 +++++------ .../operators/MaxProcessorTest.php | 44 +- .../operators/MemberProcessorTest.php | 60 +-- .../operators/MinProcessorTest.php | 44 +- .../operators/MultipleProcessorTest.php | 58 +- .../operators/NotProcessorTest.php | 18 +- .../operators/OperandsCollectionTest.php | 164 +++--- .../OperatorProcessorFactoryTest.php | 10 +- .../expressions/operators/OrProcessorTest.php | 36 +- .../operators/OrderedProcessorTest.php | 58 +- .../operators/PatternMatchProcessorTest.php | 36 +- .../operators/PowerProcessorTest.php | 60 +-- .../operators/ProductProcessorTest.php | 28 +- .../operators/RandomProcessorTest.php | 36 +- .../operators/RepeatProcessorTest.php | 44 +- .../operators/RoundProcessorTest.php | 58 +- .../operators/RoundToProcessorTest.php | 74 +-- .../operators/StatsOperatorProcessorTest.php | 52 +- .../operators/StringMatchProcessorTest.php | 32 +- .../operators/SubstringProcessorTest.php | 70 +-- .../operators/SubtractProcessorTest.php | 22 +- .../operators/SumProcessorTest.php | 32 +- .../operators/TruncateProcessorTest.php | 72 +-- .../operators/custom/ExplodeTest.php | 18 +- .../operators/custom/ImplodeTest.php | 20 +- .../custom/org/qtism/test/Explode.php | 4 +- .../runtime/pci/json/JsonMarshallerTest.php | 94 ++-- .../runtime/pci/json/JsonUnmarshallerTest.php | 82 +-- .../OutcomeProcessingEngineTest.php | 10 +- .../processing/PrintedVariableEngineTest.php | 150 +++--- .../ResponseProcessingEngineTest.php | 6 +- .../TemplateProcessingEngineTest.php | 6 +- .../markup/MarkupPostRendererTest.php | 16 +- .../rules/LookupOutcomeValueProcessorTest.php | 16 +- .../rules/OutcomeConditionProcessorTest.php | 14 +- .../rules/ResponseConditionProcessorTest.php | 16 +- .../rules/SetCorrectResponseProcessorTest.php | 2 +- .../rules/SetDefaultValueProcessorTest.php | 10 +- .../rules/SetOutcomeValueProcessorTest.php | 12 +- .../rules/SetTemplateValueProcessorTest.php | 12 +- .../rules/TemplateConditionProcessorTest.php | 4 +- .../QtiBinaryStreamAccessFsFileTest.php | 498 +++++++++--------- .../binary/TemporaryQtiBinaryStorageTest.php | 282 +++++----- .../AssessmentItemSessionTemplateTest.php | 6 +- .../tests/AssessmentItemSessionTest.php | 50 +- .../tests/AssessmentItemSessionTimingTest.php | 72 +-- .../AssessmentTestSessionAttemptsTest.php | 8 +- .../AssessmentTestSessionBranchingsTest.php | 24 +- .../AssessmentTestSessionCompletionTest.php | 4 +- ...ntTestSessionEndAttemptInteractionTest.php | 32 +- .../tests/AssessmentTestSessionExitTest.php | 16 +- .../AssessmentTestSessionFeedbackTest.php | 22 +- .../AssessmentTestSessionNumberXTest.php | 12 +- ...AssessmentTestSessionPreConditionsTest.php | 20 +- .../AssessmentTestSessionResultsTest.php | 14 +- .../AssessmentTestSessionTemplatesTest.php | 6 +- .../tests/AssessmentTestSessionTest.php | 168 +++--- .../tests/AssessmentTestSessionTimingTest.php | 162 +++--- .../runtime/tests/DurationStoreTest.php | 44 +- .../tests/PendingResponsesStoreTest.php | 10 +- .../runtime/tests/SessionManagerTest.php | 2 +- .../runtime/tests/TimeConstraintTest.php | 30 +- .../samples/custom/php/php_storage_simple.php | 12 +- .../postrendering/templateoriented_1.xml | 8 +- .../postrendering/templateoriented_2.xml | 2 +- test/scripts/BasicTestSessionSpeed.php | 4 +- test/scripts/BasicTestSessionSpeed10.php | 4 +- test/scripts/BasicTestSessionSpeed15.php | 4 +- test/scripts/BasicTestSessionSpeed20.php | 4 +- test/scripts/BasicTestSessionSpeed25.php | 4 +- test/scripts/BasicTestSessionSpeed30.php | 4 +- test/scripts/BasicTestSessionSpeed35.php | 4 +- test/scripts/BasicTestSessionSpeed40.php | 4 +- test/scripts/BasicTestSessionSpeed5.php | 4 +- test/scripts/BasicTestSessionSpeed50.php | 4 +- test/scripts/BasicTestSessionSpeed60.php | 4 +- test/scripts/ChoiceInteraction1Rendering.php | 6 +- .../ChoiceInteraction1TemplateRendering.php | 2 +- .../ItemBodyWithFeedback1Rendering.php | 10 +- test/scripts/ItemFeedback1Rendering.php | 6 +- test/scripts/PrintedVariable1Rendering.php | 14 +- 273 files changed, 3507 insertions(+), 3507 deletions(-) rename src/qtism/common/datatypes/{Boolean.php => QtiBoolean.php} (98%) rename src/qtism/common/datatypes/{Coords.php => QtiCoords.php} (91%) rename src/qtism/common/datatypes/{DirectedPair.php => QtiDirectedPair.php} (98%) rename src/qtism/common/datatypes/{Duration.php => QtiDuration.php} (97%) rename src/qtism/common/datatypes/{File.php => QtiFile.php} (98%) rename src/qtism/common/datatypes/{Float.php => QtiFloat.php} (98%) rename src/qtism/common/datatypes/{Identifier.php => QtiIdentifier.php} (98%) rename src/qtism/common/datatypes/{IntOrIdentifier.php => QtiIntOrIdentifier.php} (98%) rename src/qtism/common/datatypes/{Integer.php => QtiInteger.php} (98%) rename src/qtism/common/datatypes/{Pair.php => QtiPair.php} (99%) rename src/qtism/common/datatypes/{Point.php => QtiPoint.php} (99%) rename src/qtism/common/datatypes/{Scalar.php => QtiScalar.php} (97%) rename src/qtism/common/datatypes/{Shape.php => QtiShape.php} (99%) rename src/qtism/common/datatypes/{String.php => QtiString.php} (98%) rename src/qtism/common/datatypes/{Uri.php => QtiUri.php} (98%) diff --git a/src/qtism/common/collections/Container.php b/src/qtism/common/collections/Container.php index f78d125c1..bb4e26c37 100644 --- a/src/qtism/common/collections/Container.php +++ b/src/qtism/common/collections/Container.php @@ -22,9 +22,9 @@ namespace qtism\common\collections; -use qtism\common\datatypes\File; -use qtism\common\datatypes\Boolean; -use qtism\common\datatypes\String; +use qtism\common\datatypes\QtiFile; +use qtism\common\datatypes\QtiBoolean; +use qtism\common\datatypes\QtiString; use qtism\data\state\ValueCollection; use qtism\common\enums\Cardinality; use qtism\common\collections\AbstractCollection; @@ -241,12 +241,12 @@ public function __toString() if (is_null($d) === true) { $strings[] = 'NULL'; - } elseif ($d instanceof String) { + } elseif ($d instanceof QtiString) { $strings[] = "'${d}'"; - } elseif ($d instanceof Boolean) { + } elseif ($d instanceof QtiBoolean) { // PHP boolean primitive type. $strings[] = ($d->getValue() === true) ? 'true' : 'false'; - } elseif ($d instanceof File) { + } elseif ($d instanceof QtiFile) { $strings[] = $d->getFilename(); } else { // Other PHP primitive/object type. diff --git a/src/qtism/common/datatypes/Boolean.php b/src/qtism/common/datatypes/QtiBoolean.php similarity index 98% rename from src/qtism/common/datatypes/Boolean.php rename to src/qtism/common/datatypes/QtiBoolean.php index 2e5a13b81..6f28b085c 100644 --- a/src/qtism/common/datatypes/Boolean.php +++ b/src/qtism/common/datatypes/QtiBoolean.php @@ -32,7 +32,7 @@ * @author Jérôme Bogaerts * */ -class Boolean extends Scalar +class QtiBoolean extends QtiScalar { /** * Check whether or not the intrinsic $value is a PHP boolean. diff --git a/src/qtism/common/datatypes/Coords.php b/src/qtism/common/datatypes/QtiCoords.php similarity index 91% rename from src/qtism/common/datatypes/Coords.php rename to src/qtism/common/datatypes/QtiCoords.php index 41d8fba4c..42dcde1c2 100644 --- a/src/qtism/common/datatypes/Coords.php +++ b/src/qtism/common/datatypes/QtiCoords.php @@ -32,7 +32,7 @@ * @author Jérôme Bogaerts * */ -class Coords extends IntegerCollection implements QtiDatatype +class QtiCoords extends IntegerCollection implements QtiDatatype { /** * A value from the Shape enumeration. @@ -54,28 +54,28 @@ public function __construct($shape, array $coords = array()) $this->setShape($shape); switch ($this->getShape()) { - case Shape::DEF: + case QtiShape::DEF: if (count($this->getDataPlaceHolder()) > 0) { $msg = "No coordinates should be given when the default shape is used."; throw new InvalidArgumentException($msg); } break; - case Shape::RECT: + case QtiShape::RECT: if (count($this->getDataPlaceHolder()) != 4) { $msg = "The rectangle coordinates must be composed by 4 values (x1, y1, x2, y2)."; throw new InvalidArgumentException($msg); } break; - case Shape::CIRCLE: + case QtiShape::CIRCLE: if (count($this->getDataPlaceHolder()) != 3) { $msg = "The circle coordinates must be composed by 3 values (x, y, r)."; throw new InvalidArgumentException($msg); } break; - case Shape::POLY: + case QtiShape::POLY: if (count($this->getDataPlaceHolder()) % 2 > 0) { $msg = "The polygon coordinates must be composed by a pair amount of values (x1, y1, x2, y2, ...)."; throw new InvalidArgumentException($msg); @@ -92,7 +92,7 @@ public function __construct($shape, array $coords = array()) */ protected function setShape($shape) { - if (in_array($shape, Shape::asArray())) { + if (in_array($shape, QtiShape::asArray())) { $this->shape = $shape; } else { $msg = "The shape argument must be a value from the Shape enumeration except 'default', '" . $shape . "' given."; @@ -117,13 +117,13 @@ public function getShape() * @param Point $point A Point object. * @return boolean */ - public function inside(Point $point) + public function inside(QtiPoint $point) { - if ($this->getShape() === Shape::DEF) { + if ($this->getShape() === QtiShape::DEF) { return true; - } elseif ($this->getShape() === Shape::RECT) { + } elseif ($this->getShape() === QtiShape::RECT) { return $point->getX() >= $this[0] && $point->getX() <= $this[2] && $point->getY() >= $this[1] && $point->getY() <= $this[3]; - } elseif ($this->getShape() === Shape::CIRCLE) { + } elseif ($this->getShape() === QtiShape::CIRCLE) { return pow($point->getX() - $this[0], 2) + pow($point->getY() - $this[1], 2) < pow($this[2], 2); } else { // we consider it is a polygon. @@ -187,7 +187,7 @@ public function __toString() */ public function equals($obj) { - return $obj instanceof Coords && $this->getShape() === $obj->getShape() && $this->getArrayCopy() == $obj->getArrayCopy(); + return $obj instanceof QtiCoords && $this->getShape() === $obj->getShape() && $this->getArrayCopy() == $obj->getArrayCopy(); } /** diff --git a/src/qtism/common/datatypes/DirectedPair.php b/src/qtism/common/datatypes/QtiDirectedPair.php similarity index 98% rename from src/qtism/common/datatypes/DirectedPair.php rename to src/qtism/common/datatypes/QtiDirectedPair.php index ff02b6784..07d5223fa 100644 --- a/src/qtism/common/datatypes/DirectedPair.php +++ b/src/qtism/common/datatypes/QtiDirectedPair.php @@ -34,7 +34,7 @@ * @author Jérôme Bogaerts * */ -class DirectedPair extends Pair +class QtiDirectedPair extends QtiPair { /** * Whether or not $obj is equal to $this. Two DirectedPair objects diff --git a/src/qtism/common/datatypes/Duration.php b/src/qtism/common/datatypes/QtiDuration.php similarity index 97% rename from src/qtism/common/datatypes/Duration.php rename to src/qtism/common/datatypes/QtiDuration.php index 888955838..00efc39b0 100644 --- a/src/qtism/common/datatypes/Duration.php +++ b/src/qtism/common/datatypes/QtiDuration.php @@ -38,7 +38,7 @@ * @author Jérôme Bogaerts * */ -class Duration implements QtiDatatype +class QtiDuration implements QtiDatatype { /** * Internally, the Duration class always @@ -112,7 +112,7 @@ public function __construct($intervalSpec) */ public static function createFromDateInterval(DateInterval $interval) { - $duration = new Duration('PT0S'); + $duration = new QtiDuration('PT0S'); $duration->setInterval($interval); return $duration; @@ -271,7 +271,7 @@ public function equals($obj) * @param \qtism\common\datatypes\Duration $duration A Duration object to compare with this one. * @return boolean */ - public function shorterThan(Duration $duration) + public function shorterThan(QtiDuration $duration) { return $this->getSeconds(true) < $duration->getSeconds(true); } @@ -283,7 +283,7 @@ public function shorterThan(Duration $duration) * @param \qtism\common\datatypes\Duration $duration A Duration object to compare with this one. * @return boolean */ - public function longerThanOrEquals(Duration $duration) + public function longerThanOrEquals(QtiDuration $duration) { return $this->getSeconds(true) >= $duration->getSeconds(true); } @@ -300,7 +300,7 @@ public function add($duration) $d1 = $this->refDate; $d2 = clone $d1; - if ($duration instanceof Duration) { + if ($duration instanceof QtiDuration) { $toAdd = $duration; } elseif ($duration instanceof DateInterval) { $toAdd = self::createFromDateInterval($duration); @@ -321,7 +321,7 @@ public function add($duration) * * For instance P2S - P1S = P1S */ - public function sub(Duration $duration) + public function sub(QtiDuration $duration) { if ($duration->longerThanOrEquals($this) === true) { $this->setInterval(new DateInterval('PT0S')); diff --git a/src/qtism/common/datatypes/File.php b/src/qtism/common/datatypes/QtiFile.php similarity index 98% rename from src/qtism/common/datatypes/File.php rename to src/qtism/common/datatypes/QtiFile.php index 7c87c2b1c..202deed82 100644 --- a/src/qtism/common/datatypes/File.php +++ b/src/qtism/common/datatypes/QtiFile.php @@ -37,7 +37,7 @@ * @author Jérôme Bogaerts * */ -interface File extends QtiDatatype +interface QtiFile extends QtiDatatype { /** * Get the sequence of bytes composing the file. diff --git a/src/qtism/common/datatypes/Float.php b/src/qtism/common/datatypes/QtiFloat.php similarity index 98% rename from src/qtism/common/datatypes/Float.php rename to src/qtism/common/datatypes/QtiFloat.php index c1fe77a3b..e77db8def 100644 --- a/src/qtism/common/datatypes/Float.php +++ b/src/qtism/common/datatypes/QtiFloat.php @@ -32,7 +32,7 @@ * @author Jérôme Bogaerts * */ -class Float extends Scalar +class QtiFloat extends QtiScalar { /** * Check whether or not $value is a Float object. diff --git a/src/qtism/common/datatypes/Identifier.php b/src/qtism/common/datatypes/QtiIdentifier.php similarity index 98% rename from src/qtism/common/datatypes/Identifier.php rename to src/qtism/common/datatypes/QtiIdentifier.php index 90b58a915..4136e9953 100644 --- a/src/qtism/common/datatypes/Identifier.php +++ b/src/qtism/common/datatypes/QtiIdentifier.php @@ -32,7 +32,7 @@ * @author Jérôme Bogaerts * */ -class Identifier extends String +class QtiIdentifier extends QtiString { /** * Checks whether or not $value is a string value. diff --git a/src/qtism/common/datatypes/IntOrIdentifier.php b/src/qtism/common/datatypes/QtiIntOrIdentifier.php similarity index 98% rename from src/qtism/common/datatypes/IntOrIdentifier.php rename to src/qtism/common/datatypes/QtiIntOrIdentifier.php index e1f1161f2..2b86dac18 100644 --- a/src/qtism/common/datatypes/IntOrIdentifier.php +++ b/src/qtism/common/datatypes/QtiIntOrIdentifier.php @@ -32,7 +32,7 @@ * @author Jérôme Bogaerts * */ -class IntOrIdentifier extends Scalar +class QtiIntOrIdentifier extends QtiScalar { /** * Checks whether or not $value is a valid integer or string to be diff --git a/src/qtism/common/datatypes/Integer.php b/src/qtism/common/datatypes/QtiInteger.php similarity index 98% rename from src/qtism/common/datatypes/Integer.php rename to src/qtism/common/datatypes/QtiInteger.php index 7854d0fbd..1b2adfa72 100644 --- a/src/qtism/common/datatypes/Integer.php +++ b/src/qtism/common/datatypes/QtiInteger.php @@ -37,7 +37,7 @@ * @author Jérôme Bogaerts * */ -class Integer extends Scalar +class QtiInteger extends QtiScalar { /** * Checks whether or not $value is an integer compliant diff --git a/src/qtism/common/datatypes/Pair.php b/src/qtism/common/datatypes/QtiPair.php similarity index 99% rename from src/qtism/common/datatypes/Pair.php rename to src/qtism/common/datatypes/QtiPair.php index 76e6bb933..906558da4 100644 --- a/src/qtism/common/datatypes/Pair.php +++ b/src/qtism/common/datatypes/QtiPair.php @@ -37,7 +37,7 @@ * @author Jérôme Bogaerts * */ -class Pair implements QtiDatatype +class QtiPair implements QtiDatatype { /** * The first identifier of the Pair. diff --git a/src/qtism/common/datatypes/Point.php b/src/qtism/common/datatypes/QtiPoint.php similarity index 99% rename from src/qtism/common/datatypes/Point.php rename to src/qtism/common/datatypes/QtiPoint.php index 6d4922473..5815eed1f 100644 --- a/src/qtism/common/datatypes/Point.php +++ b/src/qtism/common/datatypes/QtiPoint.php @@ -38,7 +38,7 @@ * @author Jérôme Bogaerts * */ -class Point implements QtiDatatype +class QtiPoint implements QtiDatatype { /** * The position on the x-axis. diff --git a/src/qtism/common/datatypes/Scalar.php b/src/qtism/common/datatypes/QtiScalar.php similarity index 97% rename from src/qtism/common/datatypes/Scalar.php rename to src/qtism/common/datatypes/QtiScalar.php index 329e3fc48..009776cc5 100644 --- a/src/qtism/common/datatypes/Scalar.php +++ b/src/qtism/common/datatypes/QtiScalar.php @@ -37,7 +37,7 @@ * @author Jérôme Bogaerts * */ -abstract class Scalar implements QtiDatatype +abstract class QtiScalar implements QtiDatatype { /** * The value of the Scalar object. @@ -88,7 +88,7 @@ public function getValue() */ public function equals($obj) { - if ($obj instanceof Scalar) { + if ($obj instanceof QtiScalar) { return $obj->getValue() === $this->getValue(); } else { return $this->getValue() === $obj; diff --git a/src/qtism/common/datatypes/Shape.php b/src/qtism/common/datatypes/QtiShape.php similarity index 99% rename from src/qtism/common/datatypes/Shape.php rename to src/qtism/common/datatypes/QtiShape.php index ac3f77f37..14148f36f 100644 --- a/src/qtism/common/datatypes/Shape.php +++ b/src/qtism/common/datatypes/QtiShape.php @@ -32,7 +32,7 @@ * @author Jérôme Bogaerts * */ -class Shape implements Enumeration +class QtiShape implements Enumeration { /** * Note: Corresponds to QTI shape::default. Unfortunately, 'default' is a reserved diff --git a/src/qtism/common/datatypes/String.php b/src/qtism/common/datatypes/QtiString.php similarity index 98% rename from src/qtism/common/datatypes/String.php rename to src/qtism/common/datatypes/QtiString.php index 1d30fc69d..38aa5fa6a 100644 --- a/src/qtism/common/datatypes/String.php +++ b/src/qtism/common/datatypes/QtiString.php @@ -32,7 +32,7 @@ * @author Jérôme Bogaerts * */ -class String extends Scalar +class QtiString extends QtiScalar { /** * Checks whether or not $value is a valid string. diff --git a/src/qtism/common/datatypes/Uri.php b/src/qtism/common/datatypes/QtiUri.php similarity index 98% rename from src/qtism/common/datatypes/Uri.php rename to src/qtism/common/datatypes/QtiUri.php index 0da4222a4..7046dcfcf 100644 --- a/src/qtism/common/datatypes/Uri.php +++ b/src/qtism/common/datatypes/QtiUri.php @@ -32,7 +32,7 @@ * @author Jérôme Bogaerts * */ -class Uri extends String +class QtiUri extends QtiString { /** * Checks whether or not $value is a string. diff --git a/src/qtism/common/datatypes/files/FileManager.php b/src/qtism/common/datatypes/files/FileManager.php index 4554caf22..22c64eb86 100644 --- a/src/qtism/common/datatypes/files/FileManager.php +++ b/src/qtism/common/datatypes/files/FileManager.php @@ -22,7 +22,7 @@ namespace qtism\common\datatypes\files; -use qtism\common\datatypes\File; +use qtism\common\datatypes\QtiFile; /** * The File Management System of QTISM is an augmented implementation @@ -76,5 +76,5 @@ public function retrieve($identifier); * @param \qtism\common\datatypes\File $file A persistent file to be deleted gracefully. * @throws \qtism\common\datatypes\files\FileManagerException */ - public function delete(File $file); + public function delete(QtiFile $file); } diff --git a/src/qtism/common/datatypes/files/FileSystemFile.php b/src/qtism/common/datatypes/files/FileSystemFile.php index 2440117ff..fe010ca03 100644 --- a/src/qtism/common/datatypes/files/FileSystemFile.php +++ b/src/qtism/common/datatypes/files/FileSystemFile.php @@ -24,7 +24,7 @@ use qtism\common\enums\BaseType; use qtism\common\enums\Cardinality; -use qtism\common\datatypes\File; +use qtism\common\datatypes\QtiFile; use \RuntimeException; /** @@ -34,7 +34,7 @@ * @author Jérôme Bogaerts * */ -class FileSystemFile implements File +class FileSystemFile implements QtiFile { /** * The path to the file on the persistent storage. @@ -344,7 +344,7 @@ public function hasFilename() */ public function equals($obj) { - if ($obj instanceof File) { + if ($obj instanceof QtiFile) { if ($this->getFilename() !== $obj->getFilename()) { return false; } elseif ($this->getMimeType() !== $obj->getMimeType()) { diff --git a/src/qtism/common/datatypes/files/FileSystemFileManager.php b/src/qtism/common/datatypes/files/FileSystemFileManager.php index 323cdb409..05c020f76 100644 --- a/src/qtism/common/datatypes/files/FileSystemFileManager.php +++ b/src/qtism/common/datatypes/files/FileSystemFileManager.php @@ -22,7 +22,7 @@ namespace qtism\common\datatypes\files; -use qtism\common\datatypes\File; +use qtism\common\datatypes\QtiFile; use \RuntimeException; /** @@ -127,7 +127,7 @@ public function retrieve($identifier) * * @throws \qtism\common\datatypes\files\FileManagerException */ - public function delete(File $file) + public function delete(QtiFile $file) { $deletion = @unlink($file->getPath()); if ($deletion === false) { diff --git a/src/qtism/data/TimeLimits.php b/src/qtism/data/TimeLimits.php index 7d9f69929..e479857d9 100644 --- a/src/qtism/data/TimeLimits.php +++ b/src/qtism/data/TimeLimits.php @@ -22,7 +22,7 @@ namespace qtism\data; -use qtism\common\datatypes\Duration; +use qtism\common\datatypes\QtiDuration; use \InvalidArgumentException; /** @@ -116,7 +116,7 @@ public function hasMinTime() * * @param \qtism\common\datatypes\Duration $minTime A Duration object or null if unlimited. */ - public function setMinTime(Duration $minTime = null) + public function setMinTime(QtiDuration $minTime = null) { // Prevent to get 0s durations stored. if (is_null($minTime) === false && $minTime->getSeconds(true) === 0) { @@ -151,7 +151,7 @@ public function hasMaxTime() * * @param \qtism\common\datatypes\Duration $maxTime A duration object or null if unlimited. */ - public function setMaxTime(Duration $maxTime = null) + public function setMaxTime(QtiDuration $maxTime = null) { // Prevent to get 0s durations stored. if (is_null($maxTime) === false && $maxTime->getSeconds(true) === 0) { diff --git a/src/qtism/data/content/interactions/AssociableHotspot.php b/src/qtism/data/content/interactions/AssociableHotspot.php index 88d1389b7..c5f960fc0 100644 --- a/src/qtism/data/content/interactions/AssociableHotspot.php +++ b/src/qtism/data/content/interactions/AssociableHotspot.php @@ -23,8 +23,8 @@ namespace qtism\data\content\interactions; use qtism\common\collections\IdentifierCollection; -use qtism\common\datatypes\Shape; -use qtism\common\datatypes\Coords; +use qtism\common\datatypes\QtiShape; +use qtism\common\datatypes\QtiCoords; use qtism\common\utils\Format; use qtism\data\QtiComponentCollection; use \InvalidArgumentException; @@ -119,7 +119,7 @@ class AssociableHotspot extends Choice implements AssociableChoice, Hotspot * @param string $label The label of the bodyElement. * @throws \InvalidArgument If one of the constructor's argument is invalid. */ - public function __construct($identifier, $matchMax, $shape, Coords $coords, $id = '', $class = '', $lang = '', $label = '') + public function __construct($identifier, $matchMax, $shape, QtiCoords $coords, $id = '', $class = '', $lang = '', $label = '') { parent::__construct($identifier, $id, $class, $lang, $label); $this->setMatchMax($matchMax); @@ -187,7 +187,7 @@ public function getMatchMin() */ public function setShape($shape) { - if (in_array($shape, Shape::asArray()) === true) { + if (in_array($shape, QtiShape::asArray()) === true) { $this->shape = $shape; } else { $msg = "The 'shape' argument must be a value from the Shape enumeration, '" . $shape . "' given."; @@ -210,7 +210,7 @@ public function getShape() * * @param \qtism\common\datatypes\Coords $coords A Coords object. */ - public function setCoords(Coords $coords) + public function setCoords(QtiCoords $coords) { $this->coords = $coords; } diff --git a/src/qtism/data/content/interactions/Hotspot.php b/src/qtism/data/content/interactions/Hotspot.php index 65ec1a0e2..ae68aceff 100644 --- a/src/qtism/data/content/interactions/Hotspot.php +++ b/src/qtism/data/content/interactions/Hotspot.php @@ -22,7 +22,7 @@ namespace qtism\data\content\interactions; -use qtism\common\datatypes\Coords; +use qtism\common\datatypes\QtiCoords; use \InvalidArgumentException; /** @@ -56,7 +56,7 @@ public function getShape(); * * @param \qtism\common\datatypes\Coords $coords A Coords object. */ - public function setCoords(Coords $coords); + public function setCoords(QtiCoords $coords); /** * Get the coords of the hotspot. diff --git a/src/qtism/data/content/interactions/HotspotChoice.php b/src/qtism/data/content/interactions/HotspotChoice.php index ebc58eea6..a552c79b7 100644 --- a/src/qtism/data/content/interactions/HotspotChoice.php +++ b/src/qtism/data/content/interactions/HotspotChoice.php @@ -22,8 +22,8 @@ namespace qtism\data\content\interactions; -use qtism\common\datatypes\Shape; -use qtism\common\datatypes\Coords; +use qtism\common\datatypes\QtiShape; +use qtism\common\datatypes\QtiCoords; use qtism\common\utils\Format; use qtism\data\QtiComponentCollection; use \InvalidArgumentException; @@ -80,7 +80,7 @@ class HotspotChoice extends Choice implements Hotspot * @param string $label The label of the bodyElement. * @throws \InvalidArgumentException If one of the argument is invalid. */ - public function __construct($identifier, $shape, Coords $coords, $id = '', $class = '', $lang = '', $label = '') + public function __construct($identifier, $shape, QtiCoords $coords, $id = '', $class = '', $lang = '', $label = '') { parent::__construct($identifier, $id, $class, $lang, $label); $this->setShape($shape); @@ -94,7 +94,7 @@ public function __construct($identifier, $shape, Coords $coords, $id = '', $clas */ public function setShape($shape) { - if (in_array($shape, Shape::asArray()) === true) { + if (in_array($shape, QtiShape::asArray()) === true) { $this->shape = $shape; } else { $msg = "The 'shape' argument must be a value from the Shape enumeration, '" . $shape . "' given."; @@ -117,7 +117,7 @@ public function getShape() * * @param \qtism\common\datatypes\Coords $coords A Coords object. */ - public function setCoords(Coords $coords) + public function setCoords(QtiCoords $coords) { $this->coords = $coords; } diff --git a/src/qtism/data/content/interactions/PositionObjectInteraction.php b/src/qtism/data/content/interactions/PositionObjectInteraction.php index 9c77b6231..da6b41bb8 100644 --- a/src/qtism/data/content/interactions/PositionObjectInteraction.php +++ b/src/qtism/data/content/interactions/PositionObjectInteraction.php @@ -24,7 +24,7 @@ use qtism\data\QtiComponentCollection; use qtism\data\content\xhtml\Object; -use qtism\common\datatypes\Point; +use qtism\common\datatypes\QtiPoint; use \InvalidArgumentException; /** @@ -120,7 +120,7 @@ public function __construct($responseIdentifier, Object $object, $id = '', $clas * * @param \qtism\common\datatypes\Point $centerPoint A Point object or null. */ - public function setCenterPoint(Point $centerPoint = null) + public function setCenterPoint(QtiPoint $centerPoint = null) { $this->centerPoint = $centerPoint; } diff --git a/src/qtism/data/expressions/operators/Inside.php b/src/qtism/data/expressions/operators/Inside.php index 747c41be3..dc3b3d047 100644 --- a/src/qtism/data/expressions/operators/Inside.php +++ b/src/qtism/data/expressions/operators/Inside.php @@ -22,8 +22,8 @@ namespace qtism\data\expressions\operators; -use qtism\common\datatypes\Shape; -use qtism\common\datatypes\Coords; +use qtism\common\datatypes\QtiShape; +use qtism\common\datatypes\QtiCoords; use qtism\data\expressions\ExpressionCollection; use \InvalidArgumentException; @@ -69,7 +69,7 @@ class Inside extends Operator * @param \qtism\common\datatypes\Coords $coords A Coords object as the size and position of the area, interpreted in conjunction with $shape. * @throws \InvalidArgumentException If the $expressions count exceeds 1 or if $shape is not a value from the Shape enumeration. */ - public function __construct(ExpressionCollection $expressions, $shape, Coords $coords) + public function __construct(ExpressionCollection $expressions, $shape, QtiCoords $coords) { parent::__construct($expressions, 1, 1, array(OperatorCardinality::SINGLE, OperatorCardinality::MULTIPLE, OperatorCardinality::ORDERED), array(OperatorBaseType::POINT)); $this->setShape($shape); @@ -84,7 +84,7 @@ public function __construct(ExpressionCollection $expressions, $shape, Coords $c */ public function setShape($shape) { - if (in_array($shape, Shape::asArray())) { + if (in_array($shape, QtiShape::asArray())) { $this->shape = $shape; } else { $msg = "The shape argument must be a value from the Shape enumeration, '" . $shape . "' given."; @@ -107,7 +107,7 @@ public function getShape() * * @param \qtism\common\datatypes\Coords $coords A Coords object. */ - public function setCoords(Coords $coords) + public function setCoords(QtiCoords $coords) { $this->coords = $coords; } diff --git a/src/qtism/data/state/AreaMapEntry.php b/src/qtism/data/state/AreaMapEntry.php index 115258c8b..efbe08bf1 100644 --- a/src/qtism/data/state/AreaMapEntry.php +++ b/src/qtism/data/state/AreaMapEntry.php @@ -24,8 +24,8 @@ use qtism\data\QtiComponentCollection; use qtism\data\QtiComponent; -use qtism\common\datatypes\Shape; -use qtism\common\datatypes\Coords; +use qtism\common\datatypes\QtiShape; +use qtism\common\datatypes\QtiCoords; use \InvalidArgumentException; /** @@ -75,7 +75,7 @@ class AreaMapEntry extends QtiComponent * @param float $mappedValue A mapped value. * @throws \InvalidArgumentException If $shape is not a value from the Shape enumeration or if $mappedValue is not a float. */ - public function __construct($shape, Coords $coords, $mappedValue) + public function __construct($shape, QtiCoords $coords, $mappedValue) { $this->setShape($shape); $this->setCoords($coords); @@ -90,7 +90,7 @@ public function __construct($shape, Coords $coords, $mappedValue) */ public function setShape($shape) { - if (in_array($shape, Shape::asArray())) { + if (in_array($shape, QtiShape::asArray())) { $this->shape = $shape; } else { $msg = "The shape argument must be a value from the Shape enumeration, '" . $shape . "' given."; @@ -114,7 +114,7 @@ public function getShape() * * @param \qtism\common\datatypes\Coords $coords A Coords object. */ - public function setCoords(Coords $coords) + public function setCoords(QtiCoords $coords) { $this->coords = $coords; } diff --git a/src/qtism/data/storage/Utils.php b/src/qtism/data/storage/Utils.php index b4edd7378..bf53b2a6b 100644 --- a/src/qtism/data/storage/Utils.php +++ b/src/qtism/data/storage/Utils.php @@ -22,14 +22,14 @@ namespace qtism\data\storage; -use qtism\common\datatypes\Point; +use qtism\common\datatypes\QtiPoint; use qtism\data\state\Value; use qtism\common\enums\BaseType; use qtism\common\utils\Format; -use qtism\common\datatypes\Pair; -use qtism\common\datatypes\DirectedPair; -use qtism\common\datatypes\Duration; -use qtism\common\datatypes\Coords; +use qtism\common\datatypes\QtiPair; +use qtism\common\datatypes\QtiDirectedPair; +use qtism\common\datatypes\QtiDuration; +use qtism\common\datatypes\QtiCoords; use \InvalidArgumentException; use \UnexpectedValueException; @@ -123,7 +123,7 @@ public static function stringToDatatype($string, $baseType) if (Format::isPair($string)) { $pair = explode("\x20", $string); - return new Pair($pair[0], $pair[1]); + return new QtiPair($pair[0], $pair[1]); } else { $msg = "'${string}' is not a valid pair."; throw new UnexpectedValueException($msg); @@ -134,7 +134,7 @@ public static function stringToDatatype($string, $baseType) if (Format::isDirectedPair($string)) { $pair = explode("\x20", $string); - return new DirectedPair($pair[0], $pair[1]); + return new QtiDirectedPair($pair[0], $pair[1]); } else { $msg = "'${string}' is not a valid directed pair."; throw new UnexpectedValueException($msg); @@ -143,7 +143,7 @@ public static function stringToDatatype($string, $baseType) case BaseType::DURATION: if (Format::isDuration($string)) { - return new Duration($string); + return new QtiDuration($string); } else { $msg = "'${string}' is not a valid duration."; throw new UnexpectedValueException($msg); @@ -162,7 +162,7 @@ public static function stringToDatatype($string, $baseType) if (Format::isPoint($string)) { $parts = explode("\x20", $string); - return new Point(intval($parts[0]), intval($parts[1])); + return new QtiPoint(intval($parts[0]), intval($parts[1])); } else { $msg = "'${string}' is not valid point."; throw new UnexpectedValueException($msg); @@ -201,7 +201,7 @@ public static function stringToCoords($string, $shape) // Maybe it was accepted has coords, but is it buildable with // the given shape? - return new Coords($shape, $intCoords); + return new QtiCoords($shape, $intCoords); } else { throw new UnexpectedValueException("'${string}' cannot be converted to Coords."); } diff --git a/src/qtism/data/storage/php/PhpDocument.php b/src/qtism/data/storage/php/PhpDocument.php index c7f4e32cf..5f7d9970b 100644 --- a/src/qtism/data/storage/php/PhpDocument.php +++ b/src/qtism/data/storage/php/PhpDocument.php @@ -23,7 +23,7 @@ namespace qtism\data\storage\php; use qtism\data\ExtendedAssessmentTest; -use qtism\common\datatypes\Coords; +use qtism\common\datatypes\QtiCoords; use qtism\data\ExtendedAssessmentSection; use qtism\data\QtiDocument; use qtism\data\storage\php\marshalling\PhpQtiDatatypeMarshaller; @@ -113,7 +113,7 @@ public function save($url) } } // Warning!!! Check for Coords Datatype objects. Indeed, it extends AbstractCollection, but must not be considered as it is. - elseif ($isMarked === false && ($component instanceof AbstractCollection && !$component instanceof Coords)) { + elseif ($isMarked === false && ($component instanceof AbstractCollection && !$component instanceof QtiCoords)) { // AbstractCollection node, 1st pass. // Mark as explored. array_push($marker, $component); diff --git a/src/qtism/data/storage/php/marshalling/PhpQtiDatatypeMarshaller.php b/src/qtism/data/storage/php/marshalling/PhpQtiDatatypeMarshaller.php index eeaaa4c70..4ffe6b544 100644 --- a/src/qtism/data/storage/php/marshalling/PhpQtiDatatypeMarshaller.php +++ b/src/qtism/data/storage/php/marshalling/PhpQtiDatatypeMarshaller.php @@ -25,12 +25,12 @@ use qtism\data\storage\php\PhpVariable; use qtism\data\storage\php\PhpArgument; use qtism\data\storage\php\PhpArgumentCollection; -use qtism\common\datatypes\Shape; -use qtism\common\datatypes\Point; -use qtism\common\datatypes\Duration; -use qtism\common\datatypes\Pair; -use qtism\common\datatypes\Coords; -use qtism\common\datatypes\Identifier; +use qtism\common\datatypes\QtiShape; +use qtism\common\datatypes\QtiPoint; +use qtism\common\datatypes\QtiDuration; +use qtism\common\datatypes\QtiPair; +use qtism\common\datatypes\QtiCoords; +use qtism\common\datatypes\QtiIdentifier; use qtism\common\datatypes\QtiDatatype; /** @@ -51,23 +51,23 @@ public function marshall() $toMarshall = $this->getToMarshall(); try { - if ($toMarshall instanceof Coords) { + if ($toMarshall instanceof QtiCoords) { $this->marshallCoords(); return; - } elseif ($toMarshall instanceof Pair) { + } elseif ($toMarshall instanceof QtiPair) { $this->marshallPair(); return; - } elseif ($toMarshall instanceof Duration) { + } elseif ($toMarshall instanceof QtiDuration) { $this->marshallDuration(); return; - } elseif ($toMarshall instanceof Point) { + } elseif ($toMarshall instanceof QtiPoint) { $this->marshallPoint(); return; - } else if ($toMarshall instanceof Identifier) { + } else if ($toMarshall instanceof QtiIdentifier) { $this->marshallIdentifier(); return; diff --git a/src/qtism/data/storage/xml/marshalling/AreaMapEntryMarshaller.php b/src/qtism/data/storage/xml/marshalling/AreaMapEntryMarshaller.php index 1e484c538..b044ae4c5 100644 --- a/src/qtism/data/storage/xml/marshalling/AreaMapEntryMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/AreaMapEntryMarshaller.php @@ -22,7 +22,7 @@ namespace qtism\data\storage\xml\marshalling; -use qtism\common\datatypes\Shape; +use qtism\common\datatypes\QtiShape; use qtism\data\QtiComponent; use qtism\data\state\AreaMapEntry; use qtism\data\storage\Utils; @@ -47,7 +47,7 @@ protected function marshall(QtiComponent $component) { $element = static::getDOMCradle()->createElement($component->getQtiClassName()); - self::setDOMElementAttribute($element, 'shape', Shape::getNameByConstant($component->getShape())); + self::setDOMElementAttribute($element, 'shape', QtiShape::getNameByConstant($component->getShape())); self::setDOMElementAttribute($element, 'coords', $component->getCoords()); self::setDOMElementAttribute($element, 'mappedValue', $component->getMappedValue()); @@ -65,7 +65,7 @@ protected function unmarshall(DOMElement $element) { if (($shape = static::getDOMElementAttributeAs($element, 'shape')) !== null) { - $shape = Shape::getConstantByName($shape); + $shape = QtiShape::getConstantByName($shape); if ($shape !== false) { diff --git a/src/qtism/data/storage/xml/marshalling/HotspotMarshaller.php b/src/qtism/data/storage/xml/marshalling/HotspotMarshaller.php index d25073179..2b1c94cb1 100644 --- a/src/qtism/data/storage/xml/marshalling/HotspotMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/HotspotMarshaller.php @@ -27,7 +27,7 @@ use qtism\data\storage\Utils; use qtism\data\content\interactions\HotspotChoice; use qtism\data\content\interactions\AssociableHotspot; -use qtism\common\datatypes\Shape; +use qtism\common\datatypes\QtiShape; use qtism\data\ShowHide; use qtism\data\QtiComponent; use \DOMElement; @@ -52,7 +52,7 @@ protected function marshall(QtiComponent $component) $version = $this->getVersion(); $element = self::getDOMCradle()->createElement($component->getQtiClassName()); self::setDOMElementAttribute($element, 'identifier', $component->getIdentifier()); - self::setDOMElementAttribute($element, 'shape', Shape::getNameByConstant($component->getShape())); + self::setDOMElementAttribute($element, 'shape', QtiShape::getNameByConstant($component->getShape())); self::setDOMElementAttribute($element, 'coords', $component->getCoords()->__toString()); if ($component->isFixed() === true) { @@ -112,7 +112,7 @@ protected function unmarshall(DOMElement $element) if (($coords = self::getDOMElementAttributeAs($element, 'coords')) !== null) { - $shape = Shape::getConstantByName($shape); + $shape = QtiShape::getConstantByName($shape); if ($shape === false) { $msg = "The value of the mandatory attribute 'shape' is not a value from the 'shape' enumeration."; throw new UnmarshallingException($msg, $element); diff --git a/src/qtism/data/storage/xml/marshalling/InsideMarshaller.php b/src/qtism/data/storage/xml/marshalling/InsideMarshaller.php index ac5a650a6..791c49362 100644 --- a/src/qtism/data/storage/xml/marshalling/InsideMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/InsideMarshaller.php @@ -25,8 +25,8 @@ use qtism\data\QtiComponentCollection; use qtism\data\QtiComponent; use qtism\data\expressions\operators\Inside; -use qtism\common\datatypes\Shape; -use qtism\common\datatypes\Coords; +use qtism\common\datatypes\QtiShape; +use qtism\common\datatypes\QtiCoords; use qtism\data\storage\Utils; use \DOMElement; @@ -45,7 +45,7 @@ class InsideMarshaller extends OperatorMarshaller protected function marshallChildrenKnown(QtiComponent $component, array $elements) { $element = self::getDOMCradle()->createElement($component->getQtiClassName()); - self::setDOMElementAttribute($element, 'shape', Shape::getNameByConstant($component->getShape())); + self::setDOMElementAttribute($element, 'shape', QtiShape::getNameByConstant($component->getShape())); self::setDOMElementAttribute($element, 'coords', $component->getCoords()); foreach ($elements as $elt) { @@ -64,7 +64,7 @@ protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentColl if (($coords = static::getDOMElementAttributeAs($element, 'coords')) !== null ) { - $shape = Shape::getConstantByName($shape); + $shape = QtiShape::getConstantByName($shape); $coords = Utils::stringToCoords($coords, $shape); $object = new Inside($children, $shape, $coords); diff --git a/src/qtism/data/storage/xml/marshalling/PositionObjectInteractionMarshaller.php b/src/qtism/data/storage/xml/marshalling/PositionObjectInteractionMarshaller.php index 995a9ad3e..9d9595de9 100644 --- a/src/qtism/data/storage/xml/marshalling/PositionObjectInteractionMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/PositionObjectInteractionMarshaller.php @@ -22,7 +22,7 @@ namespace qtism\data\storage\xml\marshalling; -use qtism\common\datatypes\Point; +use qtism\common\datatypes\QtiPoint; use qtism\common\utils\Format; use qtism\common\utils\Version; use qtism\data\content\interactions\PositionObjectInteraction; @@ -102,7 +102,7 @@ protected function unmarshall(DOMElement $element) if (Format::isInteger($points[1]) === true) { - $component->setCenterPoint(new Point(intval($points[0]), intval($points[1]))); + $component->setCenterPoint(new QtiPoint(intval($points[0]), intval($points[1]))); } else { $msg = "The 2nd integer of the 'centerPoint' attribute value is not a valid integer for element 'positionObjectInteraction'."; throw new UnmarshallingException($msg, $element); diff --git a/src/qtism/runtime/common/OutcomeVariable.php b/src/qtism/runtime/common/OutcomeVariable.php index fe6028eeb..49dbf6521 100644 --- a/src/qtism/runtime/common/OutcomeVariable.php +++ b/src/qtism/runtime/common/OutcomeVariable.php @@ -24,8 +24,8 @@ namespace qtism\runtime\common; use qtism\common\datatypes\QtiDatatype; -use qtism\common\datatypes\Float; -use qtism\common\datatypes\Integer; +use qtism\common\datatypes\QtiFloat; +use qtism\common\datatypes\QtiInteger; use qtism\common\enums\BaseType; use qtism\data\state\OutcomeDeclaration; use qtism\data\state\VariableDeclaration; @@ -249,9 +249,9 @@ public function applyDefaultValue() if (is_null($this->getDefaultValue()) === true && $this->getCardinality() === Cardinality::SINGLE) { if ($this->getBaseType() === BaseType::INTEGER) { - $this->setValue(new Integer(0)); + $this->setValue(new QtiInteger(0)); } elseif ($this->getBaseType() === BaseType::FLOAT) { - $this->setValue(new Float(0.0)); + $this->setValue(new QtiFloat(0.0)); } } } diff --git a/src/qtism/runtime/common/Utils.php b/src/qtism/runtime/common/Utils.php index 737c148f5..c6c9dd12b 100644 --- a/src/qtism/runtime/common/Utils.php +++ b/src/qtism/runtime/common/Utils.php @@ -24,19 +24,19 @@ namespace qtism\runtime\common; use qtism\common\collections\Container; -use qtism\common\datatypes\Identifier; -use qtism\common\datatypes\IntOrIdentifier; -use qtism\common\datatypes\Uri; -use qtism\common\datatypes\String; -use qtism\common\datatypes\Boolean; -use qtism\common\datatypes\Float; -use qtism\common\datatypes\Integer; +use qtism\common\datatypes\QtiIdentifier; +use qtism\common\datatypes\QtiIntOrIdentifier; +use qtism\common\datatypes\QtiUri; +use qtism\common\datatypes\QtiString; +use qtism\common\datatypes\QtiBoolean; +use qtism\common\datatypes\QtiFloat; +use qtism\common\datatypes\QtiInteger; use qtism\common\datatypes\QtiDatatype; use qtism\common\enums\Cardinality; -use qtism\common\datatypes\Duration; -use qtism\common\datatypes\Pair; -use qtism\common\datatypes\DirectedPair; -use qtism\common\datatypes\Point; +use qtism\common\datatypes\QtiDuration; +use qtism\common\datatypes\QtiPair; +use qtism\common\datatypes\QtiDirectedPair; +use qtism\common\datatypes\QtiPoint; use qtism\common\enums\BaseType; use \InvalidArgumentException; @@ -294,26 +294,26 @@ static public function valueToRuntime($v, $baseType) if (is_int($v) === true) { if ($baseType === -1 || $baseType === BaseType::INTEGER) { - return new Integer($v); + return new QtiInteger($v); } elseif ($baseType === BaseType::INT_OR_IDENTIFIER) { - return new IntOrIdentifier($v); + return new QtiIntOrIdentifier($v); } } elseif (is_string($v) === true) { if ($baseType === BaseType::IDENTIFIER) { - return new Identifier($v); + return new QtiIdentifier($v); } if ($baseType === -1 || $baseType === BaseType::STRING) { - return new String($v); + return new QtiString($v); } elseif ($baseType === BaseType::URI) { - return new Uri($v); + return new QtiUri($v); } elseif ($baseType === BaseType::INT_OR_IDENTIFIER) { - return new IntOrIdentifier($v); + return new QtiIntOrIdentifier($v); } } elseif (is_float($v) === true) { - return new Float($v); + return new QtiFloat($v); } elseif (is_bool($v) === true) { - return new Boolean($v); + return new QtiBoolean($v); } } @@ -332,7 +332,7 @@ static public function valueToRuntime($v, $baseType) */ static public function isNull(QtiDatatype $value = null) { - return is_null($value) === true || ($value instanceof String && $value->getValue() === '') || ($value instanceof Container && count($value) === 0); + return is_null($value) === true || ($value instanceof QtiString && $value->getValue() === '') || ($value instanceof Container && count($value) === 0); } /** diff --git a/src/qtism/runtime/expressions/MapResponsePointProcessor.php b/src/qtism/runtime/expressions/MapResponsePointProcessor.php index 7598cb477..832741f02 100644 --- a/src/qtism/runtime/expressions/MapResponsePointProcessor.php +++ b/src/qtism/runtime/expressions/MapResponsePointProcessor.php @@ -23,7 +23,7 @@ namespace qtism\runtime\expressions; -use qtism\common\datatypes\Float; +use qtism\common\datatypes\QtiFloat; use qtism\runtime\common\MultipleContainer; use qtism\common\enums\BaseType; use qtism\common\enums\Cardinality; @@ -82,7 +82,7 @@ public function process() // -- Null value, nothing will match if ($var->isNull()) { - return new Float($areaMapping->getDefaultValue()); + return new QtiFloat($areaMapping->getDefaultValue()); } if ($var->isSingle()) { @@ -108,15 +108,15 @@ public function process() // If no relevant mapping found, return the default. if (count($mapped) === 0) { - return new Float($areaMapping->getDefaultValue()); + return new QtiFloat($areaMapping->getDefaultValue()); } else { // Check upper and lower bound. if ($areaMapping->hasLowerBound() && $result < $areaMapping->getLowerBound()) { - return new Float($areaMapping->getLowerBound()); + return new QtiFloat($areaMapping->getLowerBound()); } elseif ($areaMapping->hasUpperBound() && $result > $areaMapping->getUpperBound()) { - return new Float($areaMapping->getUpperBound()); + return new QtiFloat($areaMapping->getUpperBound()); } else { - return new Float(floatval($result)); + return new QtiFloat(floatval($result)); } } } else { diff --git a/src/qtism/runtime/expressions/MapResponseProcessor.php b/src/qtism/runtime/expressions/MapResponseProcessor.php index 92a355389..f6ddaea27 100644 --- a/src/qtism/runtime/expressions/MapResponseProcessor.php +++ b/src/qtism/runtime/expressions/MapResponseProcessor.php @@ -23,8 +23,8 @@ namespace qtism\runtime\expressions; -use qtism\common\datatypes\String; -use qtism\common\datatypes\Float; +use qtism\common\datatypes\QtiString; +use qtism\common\datatypes\QtiFloat; use qtism\common\Comparable; use qtism\runtime\common\ResponseVariable; use qtism\data\expressions\Expression; @@ -87,7 +87,7 @@ public function process() $val = $state[$identifier]; $mapKey = $mapEntry->getMapKey(); - if ($val instanceof String && $mapEntry->isCaseSensitive() === false) { + if ($val instanceof QtiString && $mapEntry->isCaseSensitive() === false) { $val = mb_strtolower($val->getValue(), 'UTF-8'); $mapKey = mb_strtolower($mapKey, 'UTF-8'); } @@ -96,12 +96,12 @@ public function process() // relevant mapping found. $mappedValue = $mapEntry->getMappedValue(); - return new Float($mappedValue); + return new QtiFloat($mappedValue); } } // No relevant mapping found, return mapping default. - return new Float($mapping->getDefaultValue()); + return new QtiFloat($mapping->getDefaultValue()); } elseif ($variable->isMultiple()) { $result = 0.0; @@ -116,7 +116,7 @@ public function process() $mapKey = $rawMapKey = $mapEntries[$i]->getMapKey(); - if ($val instanceof String && $mapEntries[$i]->isCaseSensitive() === false) { + if ($val instanceof QtiString && $mapEntries[$i]->isCaseSensitive() === false) { $val = mb_strtolower($val->getValue(), 'UTF-8'); $mapKey = mb_strtolower($mapKey, 'UTF-8'); } @@ -142,15 +142,15 @@ public function process() // When mapping a container, try to apply lower or upper bound. if ($mapping->hasLowerBound() && $result < $mapping->getLowerBound()) { - return new Float($mapping->getLowerBound()); + return new QtiFloat($mapping->getLowerBound()); } elseif ($mapping->hasUpperBound() && $result > $mapping->getUpperBound()) { - return new Float($mapping->getUpperBound()); + return new QtiFloat($mapping->getUpperBound()); } else { - return new Float($result); + return new QtiFloat($result); } } else { // Returns a 0.0 result. - return new Float($result); + return new QtiFloat($result); } } else { diff --git a/src/qtism/runtime/expressions/MathConstantProcessor.php b/src/qtism/runtime/expressions/MathConstantProcessor.php index 629de84c4..e3aab28cd 100644 --- a/src/qtism/runtime/expressions/MathConstantProcessor.php +++ b/src/qtism/runtime/expressions/MathConstantProcessor.php @@ -23,7 +23,7 @@ namespace qtism\runtime\expressions; -use qtism\common\datatypes\Float; +use qtism\common\datatypes\QtiFloat; use qtism\data\expressions\MathEnumeration; use qtism\data\expressions\Expression; use qtism\data\expressions\MathConstant; @@ -49,9 +49,9 @@ public function process() { $expr = $this->getExpression(); if ($expr->getName() === MathEnumeration::E) { - return new Float(M_E); + return new QtiFloat(M_E); } else { - return new Float(M_PI); + return new QtiFloat(M_PI); } } diff --git a/src/qtism/runtime/expressions/NumberCorrectProcessor.php b/src/qtism/runtime/expressions/NumberCorrectProcessor.php index b0e23ce5c..a160054ea 100644 --- a/src/qtism/runtime/expressions/NumberCorrectProcessor.php +++ b/src/qtism/runtime/expressions/NumberCorrectProcessor.php @@ -23,7 +23,7 @@ namespace qtism\runtime\expressions; -use qtism\common\datatypes\Integer; +use qtism\common\datatypes\QtiInteger; use qtism\data\expressions\NumberCorrect; use qtism\data\expressions\Expression; @@ -67,7 +67,7 @@ public function process() } } - return new Integer($numberCorrect); + return new QtiInteger($numberCorrect); } /** diff --git a/src/qtism/runtime/expressions/NumberIncorrectProcessor.php b/src/qtism/runtime/expressions/NumberIncorrectProcessor.php index 91e4b4f51..8f21f19d0 100644 --- a/src/qtism/runtime/expressions/NumberIncorrectProcessor.php +++ b/src/qtism/runtime/expressions/NumberIncorrectProcessor.php @@ -23,7 +23,7 @@ namespace qtism\runtime\expressions; -use qtism\common\datatypes\Integer; +use qtism\common\datatypes\QtiInteger; use qtism\data\expressions\NumberIncorrect; use qtism\data\expressions\Expression; @@ -68,7 +68,7 @@ public function process() } } - return new Integer($numberIncorrect); + return new QtiInteger($numberIncorrect); } /** diff --git a/src/qtism/runtime/expressions/NumberPresentedProcessor.php b/src/qtism/runtime/expressions/NumberPresentedProcessor.php index a3d65831e..a55c0a95a 100644 --- a/src/qtism/runtime/expressions/NumberPresentedProcessor.php +++ b/src/qtism/runtime/expressions/NumberPresentedProcessor.php @@ -23,7 +23,7 @@ namespace qtism\runtime\expressions; -use qtism\common\datatypes\Integer; +use qtism\common\datatypes\QtiInteger; use qtism\data\expressions\NumberPresented; use qtism\data\expressions\Expression; @@ -69,7 +69,7 @@ public function process() } } - return new Integer($numberPresented); + return new QtiInteger($numberPresented); } /** diff --git a/src/qtism/runtime/expressions/NumberRespondedProcessor.php b/src/qtism/runtime/expressions/NumberRespondedProcessor.php index c8cd7e8e9..dda77fedf 100644 --- a/src/qtism/runtime/expressions/NumberRespondedProcessor.php +++ b/src/qtism/runtime/expressions/NumberRespondedProcessor.php @@ -23,7 +23,7 @@ namespace qtism\runtime\expressions; -use qtism\common\datatypes\Integer; +use qtism\common\datatypes\QtiInteger; use qtism\data\expressions\NumberResponded; use qtism\data\expressions\Expression; @@ -68,7 +68,7 @@ public function process() } } - return new Integer($numberResponded); + return new QtiInteger($numberResponded); } /** diff --git a/src/qtism/runtime/expressions/NumberSelectedProcessor.php b/src/qtism/runtime/expressions/NumberSelectedProcessor.php index 6279b71d2..42e23e090 100644 --- a/src/qtism/runtime/expressions/NumberSelectedProcessor.php +++ b/src/qtism/runtime/expressions/NumberSelectedProcessor.php @@ -23,7 +23,7 @@ namespace qtism\runtime\expressions; -use qtism\common\datatypes\Integer; +use qtism\common\datatypes\QtiInteger; use qtism\data\expressions\NumberSelected; use qtism\data\expressions\Expression; @@ -67,7 +67,7 @@ public function process() } } - return new Integer($numberSelected); + return new QtiInteger($numberSelected); } /** diff --git a/src/qtism/runtime/expressions/OutcomeMaximumProcessor.php b/src/qtism/runtime/expressions/OutcomeMaximumProcessor.php index cdcf32413..a35b17336 100644 --- a/src/qtism/runtime/expressions/OutcomeMaximumProcessor.php +++ b/src/qtism/runtime/expressions/OutcomeMaximumProcessor.php @@ -23,7 +23,7 @@ namespace qtism\runtime\expressions; -use qtism\common\datatypes\Float; +use qtism\common\datatypes\QtiFloat; use qtism\common\enums\BaseType; use qtism\runtime\common\OutcomeVariable; use qtism\runtime\common\MultipleContainer; @@ -88,10 +88,10 @@ public function process() if ($weight === false) { // No weight to be applied. - $result[] = new Float($normalMaximum); + $result[] = new QtiFloat($normalMaximum); } else { // A weight has to be applied. - $result[] = new Float(floatval($normalMaximum *= $weight->getValue())); + $result[] = new QtiFloat(floatval($normalMaximum *= $weight->getValue())); } } else { // If any of the items in the given subset have no declared maximum diff --git a/src/qtism/runtime/expressions/OutcomeMinimumProcessor.php b/src/qtism/runtime/expressions/OutcomeMinimumProcessor.php index e5a94ebdb..46fd74251 100644 --- a/src/qtism/runtime/expressions/OutcomeMinimumProcessor.php +++ b/src/qtism/runtime/expressions/OutcomeMinimumProcessor.php @@ -23,7 +23,7 @@ namespace qtism\runtime\expressions; -use qtism\common\datatypes\Float; +use qtism\common\datatypes\QtiFloat; use qtism\common\enums\BaseType; use qtism\runtime\common\OutcomeVariable; use qtism\runtime\common\MultipleContainer; @@ -82,11 +82,11 @@ public function process() if (($normalMinimum = $var->getNormalMinimum()) !== false) { if ($weight === false) { // No weight to be applied. - $result[] = new Float($normalMinimum); + $result[] = new QtiFloat($normalMinimum); } else { // A weight has to be applied. - $result[] = new Float(floatval($normalMinimum *= $weight->getValue())); + $result[] = new QtiFloat(floatval($normalMinimum *= $weight->getValue())); } } // else ... items with no declared minimum are ignored. diff --git a/src/qtism/runtime/expressions/RandomFloatProcessor.php b/src/qtism/runtime/expressions/RandomFloatProcessor.php index 3dd86a838..094f4dbd1 100644 --- a/src/qtism/runtime/expressions/RandomFloatProcessor.php +++ b/src/qtism/runtime/expressions/RandomFloatProcessor.php @@ -23,7 +23,7 @@ namespace qtism\runtime\expressions; -use qtism\common\datatypes\Float; +use qtism\common\datatypes\QtiFloat; use qtism\data\expressions\Expression; use qtism\data\expressions\RandomFloat; @@ -61,7 +61,7 @@ public function process() if (is_float($min) && is_float($max)) { if ($min <= $max) { - return new Float(($min + lcg_value() * (abs($max - $min)))); + return new QtiFloat(($min + lcg_value() * (abs($max - $min)))); } else { $msg = "'min':'${min}' is greater than 'max':'${max}'."; throw new ExpressionProcessingException($msg, $this, ExpressionProcessingException::LOGIC_ERROR); diff --git a/src/qtism/runtime/expressions/RandomIntegerProcessor.php b/src/qtism/runtime/expressions/RandomIntegerProcessor.php index c0e331f0c..306217227 100644 --- a/src/qtism/runtime/expressions/RandomIntegerProcessor.php +++ b/src/qtism/runtime/expressions/RandomIntegerProcessor.php @@ -23,7 +23,7 @@ namespace qtism\runtime\expressions; -use qtism\common\datatypes\Integer; +use qtism\common\datatypes\QtiInteger; use qtism\data\expressions\Expression; use qtism\data\expressions\RandomInteger; @@ -69,11 +69,11 @@ public function process() } if ($step === 1) { - return new Integer(mt_rand($min, $max)); + return new QtiInteger(mt_rand($min, $max)); } else { $distance = ($min < 0) ? ($max + abs($min)) : ($max - $min); $mult = mt_rand(0, intval(floor($distance / $step))); - $random = new Integer($min + ($mult * $step)); + $random = new QtiInteger($min + ($mult * $step)); return $random; } diff --git a/src/qtism/runtime/expressions/TestVariablesProcessor.php b/src/qtism/runtime/expressions/TestVariablesProcessor.php index 7752dd37e..4c8c4d8d3 100644 --- a/src/qtism/runtime/expressions/TestVariablesProcessor.php +++ b/src/qtism/runtime/expressions/TestVariablesProcessor.php @@ -22,8 +22,8 @@ */ namespace qtism\runtime\expressions; -use qtism\common\datatypes\Float; -use qtism\common\datatypes\Integer; +use qtism\common\datatypes\QtiFloat; +use qtism\common\datatypes\QtiInteger; use qtism\runtime\common\MultipleContainer; use qtism\common\enums\Cardinality; use qtism\common\enums\BaseType; @@ -115,7 +115,7 @@ public function process() if ($var->getCardinality() === Cardinality::SINGLE && in_array($var->getBaseType(), $baseTypes) === true && $var->getValue() !== null) { $val = clone($var->getValue()); - if ($weight !== false && in_array(BaseType::FLOAT, $baseTypes) === true && ($val instanceof Integer || $val instanceof Float)) { + if ($weight !== false && in_array(BaseType::FLOAT, $baseTypes) === true && ($val instanceof QtiInteger || $val instanceof QtiFloat)) { // A weight has to be applied. $val->setValue($val->getValue() * $weight->getValue()); } @@ -143,7 +143,7 @@ public function process() // values are subject to type promotion. foreach ($values as $v) { - $result[] = new Float(floatval($v->getValue())); + $result[] = new QtiFloat(floatval($v->getValue())); } } } else { diff --git a/src/qtism/runtime/expressions/VariableProcessor.php b/src/qtism/runtime/expressions/VariableProcessor.php index 6797c4eae..7d698fddc 100644 --- a/src/qtism/runtime/expressions/VariableProcessor.php +++ b/src/qtism/runtime/expressions/VariableProcessor.php @@ -25,7 +25,7 @@ use qtism\runtime\common\OrderedContainer; use qtism\runtime\common\MultipleContainer; -use qtism\common\datatypes\Float; +use qtism\common\datatypes\QtiFloat; use qtism\runtime\common\VariableIdentifier; use qtism\common\enums\Cardinality; use qtism\common\enums\BaseType; @@ -117,7 +117,7 @@ public function process() if (!empty($weight) && ($baseType === BaseType::INTEGER || $baseType === BaseType::FLOAT)) { if ($cardinality === Cardinality::SINGLE) { - return new Float($variableValue->getValue() * $weight->getValue()); + return new QtiFloat($variableValue->getValue() * $weight->getValue()); } elseif ($cardinality === Cardinality::MULTIPLE || $cardinality === Cardinality::ORDERED) { // variableValue is an object, the weighting should not @@ -125,7 +125,7 @@ public function process() $finalValue = ($cardinality === Cardinality::MULTIPLE) ? new MultipleContainer(BaseType::FLOAT) : new OrderedContainer(BaseType::FLOAT); for ($i = 0; $i < count($variableValue); $i++) { if ($variableValue[$i] !== null) { - $finalValue[] = new Float($variableValue[$i]->getValue() * $weight->getValue()) ; + $finalValue[] = new QtiFloat($variableValue[$i]->getValue() * $weight->getValue()) ; } else { $finalValue[] = null; } diff --git a/src/qtism/runtime/expressions/operators/AndProcessor.php b/src/qtism/runtime/expressions/operators/AndProcessor.php index fcc65c6b8..2159928e7 100644 --- a/src/qtism/runtime/expressions/operators/AndProcessor.php +++ b/src/qtism/runtime/expressions/operators/AndProcessor.php @@ -23,7 +23,7 @@ namespace qtism\runtime\expressions\operators; -use qtism\common\datatypes\Boolean; +use qtism\common\datatypes\QtiBoolean; use qtism\data\expressions\Expression; use qtism\data\expressions\operators\AndOperator; @@ -72,11 +72,11 @@ public function process() foreach ($operands as $operand) { if ($operand->getValue() === false) { - return new Boolean(false); + return new QtiBoolean(false); } } - return new Boolean(true); + return new QtiBoolean(true); } /** diff --git a/src/qtism/runtime/expressions/operators/AnyNProcessor.php b/src/qtism/runtime/expressions/operators/AnyNProcessor.php index 087ae132f..1ffeeea9b 100644 --- a/src/qtism/runtime/expressions/operators/AnyNProcessor.php +++ b/src/qtism/runtime/expressions/operators/AnyNProcessor.php @@ -23,8 +23,8 @@ namespace qtism\runtime\expressions\operators; -use qtism\common\datatypes\Boolean; -use qtism\common\datatypes\Integer; +use qtism\common\datatypes\QtiBoolean; +use qtism\common\datatypes\QtiInteger; use qtism\data\expressions\operators\AnyN; use qtism\data\expressions\Expression; use qtism\runtime\expressions\Utils; @@ -77,7 +77,7 @@ public function process() if (is_null($varValue)) { $msg = "The variable with name '${varName}' could not be resolved or is null."; throw new OperatorProcessingException($msg, $this, OperatorProcessingException::NONEXISTENT_VARIABLE); - } elseif (!$varValue instanceof Integer) { + } elseif (!$varValue instanceof QtiInteger) { $msg = "The variable with name '${varName}' is not an integer."; throw new OperatorProcessingException($msg, $this, OperatorProcessingException::WRONG_BASETYPE); } else { @@ -94,7 +94,7 @@ public function process() if (is_null($varValue)) { $msg = "The variable with name '${varName}' could not be resolved or is null."; throw new OperatorProcessingException($msg, $this, OperatorProcessingException::NONEXISTENT_VARIABLE); - } elseif (!$varValue instanceof Integer) { + } elseif (!$varValue instanceof QtiInteger) { $msg = "The variable with name '${varName}' is not an integer."; throw new OperatorProcessingException($msg, $this, OperatorProcessingException::WRONG_VARIABLE_BASETYPE); } else { @@ -109,7 +109,7 @@ public function process() if (is_null($operand)) { $nullCount++; continue; - } elseif ($operand instanceof Boolean) { + } elseif ($operand instanceof QtiBoolean) { if ($operand->getValue() === true) { $trueCount++; } @@ -121,14 +121,14 @@ public function process() } if ($trueCount >= $min && $trueCount <= $max) { - return new Boolean(true); + return new QtiBoolean(true); } else { // Should we return false or null? if ($trueCount + $nullCount >= $min && $trueCount + $nullCount <= $max) { // It could have match if nulls were true values. return null; } else { - return new Boolean(false); + return new QtiBoolean(false); } } } diff --git a/src/qtism/runtime/expressions/operators/ContainerSizeProcessor.php b/src/qtism/runtime/expressions/operators/ContainerSizeProcessor.php index 03d07094e..885e6156f 100644 --- a/src/qtism/runtime/expressions/operators/ContainerSizeProcessor.php +++ b/src/qtism/runtime/expressions/operators/ContainerSizeProcessor.php @@ -23,7 +23,7 @@ namespace qtism\runtime\expressions\operators; -use qtism\common\datatypes\Integer; +use qtism\common\datatypes\QtiInteger; use qtism\data\expressions\Expression; use qtism\data\expressions\operators\ContainerSize; @@ -53,7 +53,7 @@ public function process() $operands = $this->getOperands(); if ($operands->containsNull() === true) { - return new Integer(0); + return new QtiInteger(0); } if ($operands->exclusivelyMultipleOrOrdered() === false) { @@ -61,7 +61,7 @@ public function process() throw new OperatorProcessingException($msg, $this, OperatorProcessingException::WRONG_CARDINALITY); } - return new Integer(count($operands[0])); + return new QtiInteger(count($operands[0])); } /** diff --git a/src/qtism/runtime/expressions/operators/ContainsProcessor.php b/src/qtism/runtime/expressions/operators/ContainsProcessor.php index cb6a97dd7..7eb44e3bb 100644 --- a/src/qtism/runtime/expressions/operators/ContainsProcessor.php +++ b/src/qtism/runtime/expressions/operators/ContainsProcessor.php @@ -24,7 +24,7 @@ */ namespace qtism\runtime\expressions\operators; -use qtism\common\datatypes\Boolean; +use qtism\common\datatypes\QtiBoolean; use qtism\common\Comparable; use qtism\common\enums\Cardinality; use qtism\data\expressions\Expression; @@ -80,11 +80,11 @@ public function process() if ($operand1->getCardinality() === Cardinality::MULTIPLE) { foreach ($operand2 as $value) { if ($operand1->contains($value) === false || $operand1->occurences($value) !== $operand2->occurences($value)) { - return new Boolean(false); + return new QtiBoolean(false); } } - return new Boolean(true); + return new QtiBoolean(true); } else { // $operand1->getCardinality() === Cardinality::ORDERED $op1Index = 0; @@ -101,7 +101,7 @@ public function process() if ($lastFoundIndex >= 0 && ($op1Index - $lastFoundIndex) > 1) { // Sequence not respected. - return new Boolean(false); + return new QtiBoolean(false); } else { $lastFoundIndex = $op1Index; $foundCount++; @@ -112,9 +112,9 @@ public function process() } if ($foundCount > 0 && $foundCount === count($operand2)) { - return new Boolean(true); + return new QtiBoolean(true); } else { - return new Boolean(false); + return new QtiBoolean(false); } } } diff --git a/src/qtism/runtime/expressions/operators/DivideProcessor.php b/src/qtism/runtime/expressions/operators/DivideProcessor.php index 0bedb2ad4..e6b745977 100644 --- a/src/qtism/runtime/expressions/operators/DivideProcessor.php +++ b/src/qtism/runtime/expressions/operators/DivideProcessor.php @@ -23,7 +23,7 @@ namespace qtism\runtime\expressions\operators; -use qtism\common\datatypes\Float; +use qtism\common\datatypes\QtiFloat; use qtism\data\expressions\operators\Divide; use qtism\data\expressions\Expression; @@ -80,7 +80,7 @@ public function process() $divide = floatval($operand1->getValue() / $operand2->getValue()); - return is_nan($divide) ? null : new Float($divide); + return is_nan($divide) ? null : new QtiFloat($divide); } /** diff --git a/src/qtism/runtime/expressions/operators/DurationGTEProcessor.php b/src/qtism/runtime/expressions/operators/DurationGTEProcessor.php index a8f361211..38d356253 100644 --- a/src/qtism/runtime/expressions/operators/DurationGTEProcessor.php +++ b/src/qtism/runtime/expressions/operators/DurationGTEProcessor.php @@ -23,7 +23,7 @@ namespace qtism\runtime\expressions\operators; -use qtism\common\datatypes\Boolean; +use qtism\common\datatypes\QtiBoolean; use qtism\data\expressions\operators\DurationGTE; use qtism\data\expressions\Expression; @@ -69,7 +69,7 @@ public function process() throw new OperatorProcessingException($msg, $this, OperatorProcessingException::WRONG_BASETYPE); } - return new Boolean($operands[0]->longerThanOrEquals($operands[1])); + return new QtiBoolean($operands[0]->longerThanOrEquals($operands[1])); } /** diff --git a/src/qtism/runtime/expressions/operators/DurationLTProcessor.php b/src/qtism/runtime/expressions/operators/DurationLTProcessor.php index 3af83af3b..c38abaf49 100644 --- a/src/qtism/runtime/expressions/operators/DurationLTProcessor.php +++ b/src/qtism/runtime/expressions/operators/DurationLTProcessor.php @@ -22,7 +22,7 @@ */ namespace qtism\runtime\expressions\operators; -use qtism\common\datatypes\Boolean; +use qtism\common\datatypes\QtiBoolean; use qtism\data\expressions\operators\DurationLT; use qtism\data\expressions\Expression; @@ -75,7 +75,7 @@ public function process() throw new OperatorProcessingException($msg, $this, OperatorProcessingException::WRONG_BASETYPE); } - return new Boolean($operands[0]->shorterThan($operands[1])); + return new QtiBoolean($operands[0]->shorterThan($operands[1])); } /** diff --git a/src/qtism/runtime/expressions/operators/EqualProcessor.php b/src/qtism/runtime/expressions/operators/EqualProcessor.php index 0ed84b2f8..373769028 100644 --- a/src/qtism/runtime/expressions/operators/EqualProcessor.php +++ b/src/qtism/runtime/expressions/operators/EqualProcessor.php @@ -22,8 +22,8 @@ */ namespace qtism\runtime\expressions\operators; -use qtism\common\datatypes\Float; -use qtism\common\datatypes\Boolean; +use qtism\common\datatypes\QtiFloat; +use qtism\common\datatypes\QtiBoolean; use qtism\data\expressions\operators\ToleranceMode; use qtism\data\expressions\operators\Equal; use qtism\data\expressions\Expression; @@ -93,7 +93,7 @@ public function process() $expression = $this->getExpression(); if ($expression->getToleranceMode() === ToleranceMode::EXACT) { - return new Boolean($operand1->getValue() == $operand2->getValue()); + return new QtiBoolean($operand1->getValue() == $operand2->getValue()); } else { $tolerance = $expression->getTolerance(); @@ -109,7 +109,7 @@ public function process() if (is_null($varValue)) { $msg = "The variable with name '${tolerance0Name}' could not be resolved."; throw new OperatorProcessingException($msg, $this, OperatorProcessingException::NONEXISTENT_VARIABLE); - } elseif (!$varValue instanceof Float) { + } elseif (!$varValue instanceof QtiFloat) { $msg = "The variable with name '${tolerance0Name}' is not a float."; throw new OperatorProcessingException($msg, $this, OperatorProcessingException::WRONG_VARIABLE_BASETYPE); } @@ -120,7 +120,7 @@ public function process() // A second variableRef to handle. $tolerance1Name = Utils::sanitizeVariableRef($strTolerance[1]); - if (($varValue = $state[$tolerance1Name]) !== null && $varValue instanceof Float) { + if (($varValue = $state[$tolerance1Name]) !== null && $varValue instanceof QtiFloat) { $tolerance[] = $varValue->getValue(); } } @@ -134,7 +134,7 @@ public function process() $moreThanLower = ($expression->doesIncludeLowerBound()) ? $operand2->getValue() >= $t0 : $operand2->getValue() > $t0; $lessThanUpper = ($expression->doesIncludeUpperBound()) ? $operand2->getValue() <= $t1 : $operand2->getValue() < $t1; - return new Boolean($moreThanLower && $lessThanUpper); + return new QtiBoolean($moreThanLower && $lessThanUpper); } else { // Tolerance mode RELATIVE $tolerance = $expression->getTolerance(); @@ -144,7 +144,7 @@ public function process() $moreThanLower = ($expression->doesIncludeLowerBound()) ? $operand2->getValue() >= $t0 : $operand2->getValue() > $t0; $lessThanUpper = ($expression->doesIncludeUpperBound()) ? $operand2->getValue() <= $t1 : $operand2->getValue() < $t1; - return new Boolean($moreThanLower && $lessThanUpper); + return new QtiBoolean($moreThanLower && $lessThanUpper); } } } diff --git a/src/qtism/runtime/expressions/operators/EqualRoundedProcessor.php b/src/qtism/runtime/expressions/operators/EqualRoundedProcessor.php index 989ed10c7..b979b1f9d 100644 --- a/src/qtism/runtime/expressions/operators/EqualRoundedProcessor.php +++ b/src/qtism/runtime/expressions/operators/EqualRoundedProcessor.php @@ -23,8 +23,8 @@ namespace qtism\runtime\expressions\operators; -use qtism\common\datatypes\Boolean; -use qtism\common\datatypes\Integer; +use qtism\common\datatypes\QtiBoolean; +use qtism\common\datatypes\QtiInteger; use qtism\data\expressions\ExpressionCollection; use qtism\data\expressions\BaseValue; use qtism\data\expressions\operators\RoundTo; @@ -98,7 +98,7 @@ public function process() if (is_null($varValue) === true) { $msg = "The variable with name '${varName}' could not be resolved."; throw new OperatorProcessingException($msg, $this, OperatorProcessingException::NONEXISTENT_VARIABLE); - } elseif (!$varValue instanceof Integer) { + } elseif (!$varValue instanceof QtiInteger) { $msg = "The variable with name '${varName}' is not an integer."; throw new OperatorProcessingException($msg, $this, OperatorProcessingException::WRONG_VARIABLE_BASETYPE); } @@ -122,7 +122,7 @@ public function process() } } - return new Boolean($rounded[0]->getValue() == $rounded[1]->getValue()); + return new QtiBoolean($rounded[0]->getValue() == $rounded[1]->getValue()); } /** diff --git a/src/qtism/runtime/expressions/operators/GcdProcessor.php b/src/qtism/runtime/expressions/operators/GcdProcessor.php index dd2202742..8c624da43 100644 --- a/src/qtism/runtime/expressions/operators/GcdProcessor.php +++ b/src/qtism/runtime/expressions/operators/GcdProcessor.php @@ -23,8 +23,8 @@ namespace qtism\runtime\expressions\operators; -use qtism\common\datatypes\Integer; -use qtism\common\datatypes\Scalar; +use qtism\common\datatypes\QtiInteger; +use qtism\common\datatypes\QtiScalar; use qtism\common\enums\BaseType; use qtism\common\collections\Container; use qtism\data\expressions\operators\Gcd; @@ -79,7 +79,7 @@ public function process() $zeroCount = 0; $valueCount = 0; foreach ($operands as $operand) { - if ($operand instanceof Scalar) { + if ($operand instanceof QtiScalar) { $valueCount++; @@ -108,14 +108,14 @@ public function process() if ($zeroCount === $valueCount) { // All arguments of gcd() are 0. - return new Integer(0); + return new QtiInteger(0); } else { $g = $flatCollection[0]; $loopLimit = count($flatCollection) - 1; $i = 0; while ($i < $loopLimit) { - $g = new Integer(Utils::gcd($g->getValue(), $flatCollection[$i + 1]->getValue())); + $g = new QtiInteger(Utils::gcd($g->getValue(), $flatCollection[$i + 1]->getValue())); $i++; } diff --git a/src/qtism/runtime/expressions/operators/GtProcessor.php b/src/qtism/runtime/expressions/operators/GtProcessor.php index 03134c590..ddfe841ac 100644 --- a/src/qtism/runtime/expressions/operators/GtProcessor.php +++ b/src/qtism/runtime/expressions/operators/GtProcessor.php @@ -23,7 +23,7 @@ namespace qtism\runtime\expressions\operators; -use qtism\common\datatypes\Boolean; +use qtism\common\datatypes\QtiBoolean; use qtism\data\expressions\operators\Gt; use qtism\data\expressions\Expression; @@ -67,7 +67,7 @@ public function process() throw new OperatorProcessingException($msg, $this, OperatorProcessingException::WRONG_BASETYPE); } - return new Boolean($operands[0]->getValue() > $operands[1]->getValue()); + return new QtiBoolean($operands[0]->getValue() > $operands[1]->getValue()); } /** diff --git a/src/qtism/runtime/expressions/operators/GteProcessor.php b/src/qtism/runtime/expressions/operators/GteProcessor.php index 552eed41c..1d3798e9b 100644 --- a/src/qtism/runtime/expressions/operators/GteProcessor.php +++ b/src/qtism/runtime/expressions/operators/GteProcessor.php @@ -23,7 +23,7 @@ namespace qtism\runtime\expressions\operators; -use qtism\common\datatypes\Boolean; +use qtism\common\datatypes\QtiBoolean; use qtism\data\expressions\operators\Gte; use qtism\data\expressions\Expression; @@ -67,7 +67,7 @@ public function process() throw new OperatorProcessingException($msg, $this, OperatorProcessingException::WRONG_BASETYPE); } - return new Boolean($operands[0]->getValue() >= $operands[1]->getValue()); + return new QtiBoolean($operands[0]->getValue() >= $operands[1]->getValue()); } /** diff --git a/src/qtism/runtime/expressions/operators/IndexProcessor.php b/src/qtism/runtime/expressions/operators/IndexProcessor.php index a8caae1d1..34cc68895 100644 --- a/src/qtism/runtime/expressions/operators/IndexProcessor.php +++ b/src/qtism/runtime/expressions/operators/IndexProcessor.php @@ -23,7 +23,7 @@ namespace qtism\runtime\expressions\operators; -use qtism\common\datatypes\Integer; +use qtism\common\datatypes\QtiInteger; use qtism\data\expressions\operators\Index; use qtism\data\expressions\Expression; use qtism\runtime\expressions\Utils as ProcessingUtils; @@ -70,7 +70,7 @@ public function process() // The value of $n comes from the state. $state = $this->getState(); if (($index = $state[ProcessingUtils::sanitizeVariableRef($n)]) !== null) { - if ($index instanceof Integer) { + if ($index instanceof QtiInteger) { $n = $index->getValue(); } else { $msg = "The value '${index}' is not an integer. Ordered containers can be only accessed by integers."; diff --git a/src/qtism/runtime/expressions/operators/InsideProcessor.php b/src/qtism/runtime/expressions/operators/InsideProcessor.php index c896be62f..4d814f360 100644 --- a/src/qtism/runtime/expressions/operators/InsideProcessor.php +++ b/src/qtism/runtime/expressions/operators/InsideProcessor.php @@ -23,7 +23,7 @@ namespace qtism\runtime\expressions\operators; -use qtism\common\datatypes\Boolean; +use qtism\common\datatypes\QtiBoolean; use qtism\data\expressions\operators\Inside; use qtism\data\expressions\Expression; @@ -70,7 +70,7 @@ public function process() $operand = $operands[0]; $coords = $this->getExpression()->getCoords(); - return new Boolean($coords->inside($operand)); + return new QtiBoolean($coords->inside($operand)); } /** diff --git a/src/qtism/runtime/expressions/operators/IntegerDivideProcessor.php b/src/qtism/runtime/expressions/operators/IntegerDivideProcessor.php index 195069732..8aa8e10f8 100644 --- a/src/qtism/runtime/expressions/operators/IntegerDivideProcessor.php +++ b/src/qtism/runtime/expressions/operators/IntegerDivideProcessor.php @@ -23,7 +23,7 @@ namespace qtism\runtime\expressions\operators; -use qtism\common\datatypes\Integer; +use qtism\common\datatypes\QtiInteger; use qtism\data\expressions\operators\IntegerDivide; use qtism\data\expressions\Expression; @@ -74,7 +74,7 @@ public function process() return null; } - return new Integer(intval(floor($operand1->getValue() / $operand2->getValue()))); + return new QtiInteger(intval(floor($operand1->getValue() / $operand2->getValue()))); } /** diff --git a/src/qtism/runtime/expressions/operators/IntegerModulusProcessor.php b/src/qtism/runtime/expressions/operators/IntegerModulusProcessor.php index d87d292ef..52831521b 100644 --- a/src/qtism/runtime/expressions/operators/IntegerModulusProcessor.php +++ b/src/qtism/runtime/expressions/operators/IntegerModulusProcessor.php @@ -23,7 +23,7 @@ namespace qtism\runtime\expressions\operators; -use qtism\common\datatypes\Integer; +use qtism\common\datatypes\QtiInteger; use qtism\data\expressions\operators\IntegerModulus; use qtism\data\expressions\Expression; @@ -76,7 +76,7 @@ public function process() return null; } - return new Integer(intval($operand1->getValue() % $operand2->getValue())); + return new QtiInteger(intval($operand1->getValue() % $operand2->getValue())); } /** diff --git a/src/qtism/runtime/expressions/operators/IntegerToFloatProcessor.php b/src/qtism/runtime/expressions/operators/IntegerToFloatProcessor.php index 64632445e..689123115 100644 --- a/src/qtism/runtime/expressions/operators/IntegerToFloatProcessor.php +++ b/src/qtism/runtime/expressions/operators/IntegerToFloatProcessor.php @@ -23,7 +23,7 @@ namespace qtism\runtime\expressions\operators; -use qtism\common\datatypes\Float; +use qtism\common\datatypes\QtiFloat; use qtism\data\expressions\operators\IntegerToFloat; use qtism\data\expressions\Expression; @@ -68,7 +68,7 @@ public function process() $operand = $operands[0]; - return new Float(floatval($operand->getValue())); + return new QtiFloat(floatval($operand->getValue())); } /** diff --git a/src/qtism/runtime/expressions/operators/IsNullProcessor.php b/src/qtism/runtime/expressions/operators/IsNullProcessor.php index 95f50d2b0..d2a47d8cf 100644 --- a/src/qtism/runtime/expressions/operators/IsNullProcessor.php +++ b/src/qtism/runtime/expressions/operators/IsNullProcessor.php @@ -23,7 +23,7 @@ namespace qtism\runtime\expressions\operators; -use qtism\common\datatypes\Boolean; +use qtism\common\datatypes\QtiBoolean; use qtism\data\expressions\operators\IsNull; use qtism\data\expressions\Expression; use \InvalidArgumentException; @@ -54,7 +54,7 @@ public function process() $operands = $this->getOperands(); $expression = $this->getExpression(); - return new Boolean($operands->containsNull()); + return new QtiBoolean($operands->containsNull()); } /** diff --git a/src/qtism/runtime/expressions/operators/LcmProcessor.php b/src/qtism/runtime/expressions/operators/LcmProcessor.php index 8974c90bc..c9f37f79b 100644 --- a/src/qtism/runtime/expressions/operators/LcmProcessor.php +++ b/src/qtism/runtime/expressions/operators/LcmProcessor.php @@ -23,8 +23,8 @@ namespace qtism\runtime\expressions\operators; -use qtism\common\datatypes\Integer; -use qtism\common\datatypes\Scalar; +use qtism\common\datatypes\QtiInteger; +use qtism\common\datatypes\QtiScalar; use qtism\data\expressions\operators\Lcm; use qtism\data\expressions\Expression; @@ -74,13 +74,13 @@ public function process() $flatCollection = new OperandsCollection(); foreach ($operands as $operand) { - if ($operand instanceof Scalar) { + if ($operand instanceof QtiScalar) { if ($operand->getValue() !== 0) { $flatCollection[] = $operand; } else { // Operand is 0, return 0. - return new Integer(0); + return new QtiInteger(0); } } elseif ($operand->contains(null)) { // Container with at least one null value inside. @@ -94,7 +94,7 @@ public function process() $flatCollection[] = $o; } else { // If any of the operand is 0, return 0. - return new Integer(0); + return new QtiInteger(0); } } } @@ -105,7 +105,7 @@ public function process() $i = 0; while ($i < $loopLimit) { - $g = new Integer(Utils::lcm($g->getValue(), $flatCollection[$i + 1]->getValue())); + $g = new QtiInteger(Utils::lcm($g->getValue(), $flatCollection[$i + 1]->getValue())); $i++; } diff --git a/src/qtism/runtime/expressions/operators/LtProcessor.php b/src/qtism/runtime/expressions/operators/LtProcessor.php index a4531543b..19406496f 100644 --- a/src/qtism/runtime/expressions/operators/LtProcessor.php +++ b/src/qtism/runtime/expressions/operators/LtProcessor.php @@ -23,7 +23,7 @@ namespace qtism\runtime\expressions\operators; -use qtism\common\datatypes\Boolean; +use qtism\common\datatypes\QtiBoolean; use qtism\data\expressions\operators\Lt; use qtism\data\expressions\Expression; @@ -67,7 +67,7 @@ public function process() throw new OperatorProcessingException($msg, $this, OperatorProcessingException::WRONG_BASETYPE); } - return new Boolean($operands[0]->getValue() < $operands[1]->getValue()); + return new QtiBoolean($operands[0]->getValue() < $operands[1]->getValue()); } /** diff --git a/src/qtism/runtime/expressions/operators/LteProcessor.php b/src/qtism/runtime/expressions/operators/LteProcessor.php index 2f685b5e8..5113148d0 100644 --- a/src/qtism/runtime/expressions/operators/LteProcessor.php +++ b/src/qtism/runtime/expressions/operators/LteProcessor.php @@ -24,7 +24,7 @@ */ namespace qtism\runtime\expressions\operators; -use qtism\common\datatypes\Boolean; +use qtism\common\datatypes\QtiBoolean; use qtism\data\expressions\operators\Lte; use qtism\data\expressions\Expression; @@ -68,7 +68,7 @@ public function process() throw new OperatorProcessingException($msg, $this, OperatorProcessingException::WRONG_BASETYPE); } - return new Boolean($operands[0]->getValue() <= $operands[1]->getValue()); + return new QtiBoolean($operands[0]->getValue() <= $operands[1]->getValue()); } /** diff --git a/src/qtism/runtime/expressions/operators/MatchProcessor.php b/src/qtism/runtime/expressions/operators/MatchProcessor.php index 8fe98ed81..c7c53aa4d 100644 --- a/src/qtism/runtime/expressions/operators/MatchProcessor.php +++ b/src/qtism/runtime/expressions/operators/MatchProcessor.php @@ -23,7 +23,7 @@ namespace qtism\runtime\expressions\operators; -use qtism\common\datatypes\Boolean; +use qtism\common\datatypes\QtiBoolean; use qtism\common\Comparable; use qtism\data\expressions\Expression; use qtism\data\expressions\operators\Match; @@ -77,9 +77,9 @@ public function process() if ($operands[0] instanceof Comparable) { // 2 containers to compare. - return new Boolean($operands[0]->equals($operands[1])); + return new QtiBoolean($operands[0]->equals($operands[1])); } else { - return new Boolean($operands[0] === $operands[1]); + return new QtiBoolean($operands[0] === $operands[1]); } } diff --git a/src/qtism/runtime/expressions/operators/MathOperatorProcessor.php b/src/qtism/runtime/expressions/operators/MathOperatorProcessor.php index 8e304c726..ee704ab98 100644 --- a/src/qtism/runtime/expressions/operators/MathOperatorProcessor.php +++ b/src/qtism/runtime/expressions/operators/MathOperatorProcessor.php @@ -22,8 +22,8 @@ */ namespace qtism\runtime\expressions\operators; -use qtism\common\datatypes\Integer; -use qtism\common\datatypes\Float; +use qtism\common\datatypes\QtiInteger; +use qtism\common\datatypes\QtiFloat; use qtism\data\expressions\operators\MathFunctions; use qtism\data\expressions\operators\MathOperator; use qtism\data\expressions\Expression; @@ -104,7 +104,7 @@ public function process() $methodName = 'process' . ucfirst($qtiFuncName); $result = call_user_func_array(array($this, $methodName), array()); - if ($result instanceof Float && is_nan($result->getValue()) === true) { + if ($result instanceof QtiFloat && is_nan($result->getValue()) === true) { // outside the domain of the function. return null; } else { @@ -120,7 +120,7 @@ protected function processSin() { $operands = $this->getOperands(); - return new Float(sin($operands[0]->getValue())); + return new QtiFloat(sin($operands[0]->getValue())); } /** @@ -131,7 +131,7 @@ protected function processCos() { $operands = $this->getOperands(); - return new Float(cos($operands[0]->getValue())); + return new QtiFloat(cos($operands[0]->getValue())); } /** @@ -142,7 +142,7 @@ protected function processTan() { $operands = $this->getOperands(); - return new Float(tan($operands[0]->getValue())); + return new QtiFloat(tan($operands[0]->getValue())); } /** @@ -156,7 +156,7 @@ protected function processSec() if ($cos == 0) { return null; } else { - return new Float(1 / $cos); + return new QtiFloat(1 / $cos); } } @@ -171,7 +171,7 @@ protected function processCsc() if ($sin == 0) { return null; } else { - return new Float(1 / $sin); + return new QtiFloat(1 / $sin); } } @@ -184,11 +184,11 @@ protected function processCot() $operands = $this->getOperands(); $tan = tan($operands[0]->getValue()); if (is_infinite($tan)) { - return new Float(0.0); + return new QtiFloat(0.0); } elseif ($tan == 0) { return null; } else { - return new Float(1 / $tan); + return new QtiFloat(1 / $tan); } } @@ -200,7 +200,7 @@ protected function processAsin() { $operands = $this->getOperands(); - return new Float(asin($operands[0]->getValue())); + return new QtiFloat(asin($operands[0]->getValue())); } /** @@ -211,7 +211,7 @@ protected function processAcos() { $operands = $this->getOperands(); - return new Float(acos($operands[0]->getValue())); + return new QtiFloat(acos($operands[0]->getValue())); } /** @@ -222,7 +222,7 @@ protected function processAtan() { $operands = $this->getOperands(); - return new Float(atan($operands[0]->getValue())); + return new QtiFloat(atan($operands[0]->getValue())); } /** @@ -245,7 +245,7 @@ protected function processAtan2() $operand1 = $operands[0]; $operand2 = $operands[1]; - return new Float(atan2($operand1->getValue(), $operand2->getValue())); + return new QtiFloat(atan2($operand1->getValue(), $operand2->getValue())); } /** @@ -261,7 +261,7 @@ protected function processAsec() return null; } - return new Float(acos(1 / $operand->getValue())); + return new QtiFloat(acos(1 / $operand->getValue())); } /** @@ -277,7 +277,7 @@ protected function processAcsc() return null; } - return new Float(asin(1 / $operand->getValue())); + return new QtiFloat(asin(1 / $operand->getValue())); } /** @@ -290,10 +290,10 @@ protected function processAcot() $operand = $operands[0]; if ($operand->getValue() === 0) { - return new Float(M_PI_2); + return new QtiFloat(M_PI_2); } - return new Float(atan(1 / $operand->getValue())); + return new QtiFloat(atan(1 / $operand->getValue())); } /** @@ -304,7 +304,7 @@ protected function processSinh() { $operands = $this->getOperands(); - return new Float(sinh($operands[0]->getValue())); + return new QtiFloat(sinh($operands[0]->getValue())); } /** @@ -315,7 +315,7 @@ protected function processCosh() { $operands = $this->getOperands(); - return new Float(cosh($operands[0]->getValue())); + return new QtiFloat(cosh($operands[0]->getValue())); } /** @@ -326,7 +326,7 @@ protected function processTanh() { $operands = $this->getOperands(); - return new Float(tanh($operands[0]->getValue())); + return new QtiFloat(tanh($operands[0]->getValue())); } /** @@ -342,7 +342,7 @@ protected function processSech() return null; } - return new Float(1 / cosh($operand->getValue())); + return new QtiFloat(1 / cosh($operand->getValue())); } /** @@ -358,7 +358,7 @@ protected function processCsch() return null; } - return new Float(1 / sinh($operand->getValue())); + return new QtiFloat(1 / sinh($operand->getValue())); } /** @@ -373,10 +373,10 @@ protected function processCoth() if ($operand->getValue() == 0) { return null; } elseif (is_infinite($operand->getValue())) { - return new Float(0.0); + return new QtiFloat(0.0); } - return new Float(1 / tanh($operand->getValue())); + return new QtiFloat(1 / tanh($operand->getValue())); } /** @@ -391,10 +391,10 @@ protected function processLog() if ($operand->getValue() < 0) { return null; } elseif ($operand->getValue() == 0) { - return new Float(-INF); + return new QtiFloat(-INF); } - return new Float(log($operand->getValue(), 10)); + return new QtiFloat(log($operand->getValue(), 10)); } /** @@ -409,10 +409,10 @@ protected function processLn() if ($operand->getValue() < 0) { return null; } elseif ($operand->getValue() == 0) { - return new Float(-INF); + return new QtiFloat(-INF); } - return new Float(log($operand->getValue())); + return new QtiFloat(log($operand->getValue())); } /** @@ -427,12 +427,12 @@ protected function processExp() if (is_nan($operand->getValue()) === true) { return null; } elseif (is_infinite($operand->getValue()) === true && $operand->getValue() > 0) { - return new Float(INF); + return new QtiFloat(INF); } elseif (is_infinite($operand->getValue()) === true && $operand->getValue() < 0) { - return new Float(0.0); + return new QtiFloat(0.0); } - return new Float(exp($operand->getValue())); + return new QtiFloat(exp($operand->getValue())); } /** @@ -448,7 +448,7 @@ protected function processAbs() return null; } - return new Float(floatval(abs($operand->getValue()))); + return new QtiFloat(floatval(abs($operand->getValue()))); } /** @@ -464,11 +464,11 @@ protected function processSignum() if (is_nan($operand->getValue())) { return null; } elseif ($operand->getValue() < 0) { - return new Integer(-1); + return new QtiInteger(-1); } elseif ($operand->getValue() > 0) { - return new Integer(1); + return new QtiInteger(1); } else { - return new Integer(0); + return new QtiInteger(0); } } @@ -484,12 +484,12 @@ protected function processFloor() if (is_nan($operand->getValue())) { return null; } elseif (is_infinite($operand->getValue()) === true && $operand->getValue() > 0) { - return new Float(INF); + return new QtiFloat(INF); } elseif (is_infinite($operand->getValue()) === true && $operand->getValue() < 0) { - return new Float(-INF); + return new QtiFloat(-INF); } - return new Integer(intval(floor($operand->getValue()))); + return new QtiInteger(intval(floor($operand->getValue()))); } /** @@ -504,12 +504,12 @@ protected function processCeil() if (is_nan($operand->getValue())) { return null; } elseif (is_infinite($operand->getValue()) === true && $operand->getValue() > 0) { - return new Float(INF); + return new QtiFloat(INF); } elseif (is_infinite($operand->getValue()) === true && $operand->getValue() < 0) { - return new Float(-INF); + return new QtiFloat(-INF); } - return new Integer(intval(ceil($operand->getValue()))); + return new QtiInteger(intval(ceil($operand->getValue()))); } /** @@ -524,12 +524,12 @@ protected function processToDegrees() if (is_nan($operand->getValue())) { return null; } elseif (is_infinite($operand->getValue()) === true && $operand->getValue() > 0) { - return new Float(INF); + return new QtiFloat(INF); } elseif (is_infinite($operand->getValue()) === true && $operand->getValue() < 0) { - return new Float(-INF); + return new QtiFloat(-INF); } - return new Float(floatval(rad2deg($operand->getValue()))); + return new QtiFloat(floatval(rad2deg($operand->getValue()))); } /** @@ -544,12 +544,12 @@ protected function processToRadians() if (is_nan($operand->getValue())) { return null; } elseif (is_infinite($operand->getValue()) === true && $operand->getValue() > 0) { - return new Float(INF); + return new QtiFloat(INF); } elseif (is_infinite($operand->getValue()) === true && $operand->getValue() < 0) { - return new Float(-INF); + return new QtiFloat(-INF); } - return new Float(floatval(deg2rad($operand->getValue()))); + return new QtiFloat(floatval(deg2rad($operand->getValue()))); } /** diff --git a/src/qtism/runtime/expressions/operators/MaxProcessor.php b/src/qtism/runtime/expressions/operators/MaxProcessor.php index 33a395249..182f8ba1a 100644 --- a/src/qtism/runtime/expressions/operators/MaxProcessor.php +++ b/src/qtism/runtime/expressions/operators/MaxProcessor.php @@ -23,8 +23,8 @@ namespace qtism\runtime\expressions\operators; -use qtism\common\datatypes\Integer; -use qtism\common\datatypes\Float; +use qtism\common\datatypes\QtiInteger; +use qtism\common\datatypes\QtiFloat; use qtism\common\enums\BaseType; use qtism\runtime\common\MultipleContainer; use qtism\common\collections\Container; @@ -82,7 +82,7 @@ public function process() $max = -PHP_INT_MAX; foreach ($operands as $operand) { if (!$operand instanceof Container) { - $baseType = ($operand instanceof Float) ? BaseType::FLOAT : BaseType::INTEGER; + $baseType = ($operand instanceof QtiFloat) ? BaseType::FLOAT : BaseType::INTEGER; $value = new MultipleContainer($baseType, array($operand)); } else { $value = $operand; @@ -95,7 +95,7 @@ public function process() } $valueCount++; - $integerCount += ($v instanceof Integer) ? 1 : 0; + $integerCount += ($v instanceof QtiInteger) ? 1 : 0; if ($v->getValue() > $max) { $max = $v->getValue(); @@ -103,7 +103,7 @@ public function process() } } - return ($integerCount === $valueCount) ? new Integer(intval($max)) : new Float(floatval($max)); + return ($integerCount === $valueCount) ? new QtiInteger(intval($max)) : new QtiFloat(floatval($max)); } /** diff --git a/src/qtism/runtime/expressions/operators/MemberProcessor.php b/src/qtism/runtime/expressions/operators/MemberProcessor.php index 806847509..e9d70fbd5 100644 --- a/src/qtism/runtime/expressions/operators/MemberProcessor.php +++ b/src/qtism/runtime/expressions/operators/MemberProcessor.php @@ -23,7 +23,7 @@ namespace qtism\runtime\expressions\operators; -use qtism\common\datatypes\Boolean; +use qtism\common\datatypes\QtiBoolean; use qtism\common\enums\Cardinality; use qtism\runtime\common\Utils as CommonUtils; use qtism\data\expressions\operators\Member; @@ -82,7 +82,7 @@ public function process() throw new OperatorProcessingException($msg, $this, OperatorProcessingException::WRONG_CARDINALITY); } - return new Boolean($operand2->contains($operand1)); + return new QtiBoolean($operand2->contains($operand1)); } /** diff --git a/src/qtism/runtime/expressions/operators/MinProcessor.php b/src/qtism/runtime/expressions/operators/MinProcessor.php index 1408408e1..f5623ee5c 100644 --- a/src/qtism/runtime/expressions/operators/MinProcessor.php +++ b/src/qtism/runtime/expressions/operators/MinProcessor.php @@ -23,8 +23,8 @@ namespace qtism\runtime\expressions\operators; -use qtism\common\datatypes\Integer; -use qtism\common\datatypes\Float; +use qtism\common\datatypes\QtiInteger; +use qtism\common\datatypes\QtiFloat; use qtism\common\enums\BaseType; use qtism\runtime\common\MultipleContainer; use qtism\common\collections\Container; @@ -84,7 +84,7 @@ public function process() $min = PHP_INT_MAX; foreach ($operands as $operand) { if (!$operand instanceof Container) { - $baseType = ($operand instanceof Float) ? BaseType::FLOAT : BaseType::INTEGER; + $baseType = ($operand instanceof QtiFloat) ? BaseType::FLOAT : BaseType::INTEGER; $value = new MultipleContainer($baseType, array($operand)); } else { $value = $operand; @@ -96,7 +96,7 @@ public function process() } $valueCount++; - $integerCount += ($v instanceof Integer) ? 1 : 0; + $integerCount += ($v instanceof QtiInteger) ? 1 : 0; if ($v->getValue() < $min) { $min = $v->getValue(); @@ -104,7 +104,7 @@ public function process() } } - return ($integerCount === $valueCount) ? new Integer(intval($min)) : new Float(floatval($min)); + return ($integerCount === $valueCount) ? new QtiInteger(intval($min)) : new QtiFloat(floatval($min)); } /** diff --git a/src/qtism/runtime/expressions/operators/NotProcessor.php b/src/qtism/runtime/expressions/operators/NotProcessor.php index c4092a57f..a23b0d98d 100644 --- a/src/qtism/runtime/expressions/operators/NotProcessor.php +++ b/src/qtism/runtime/expressions/operators/NotProcessor.php @@ -23,7 +23,7 @@ namespace qtism\runtime\expressions\operators; -use qtism\common\datatypes\Boolean; +use qtism\common\datatypes\QtiBoolean; use qtism\data\expressions\Expression; use qtism\data\expressions\operators\Not; @@ -68,7 +68,7 @@ public function process() $operand = $operands[0]; - return new Boolean(!$operand->getValue()); + return new QtiBoolean(!$operand->getValue()); } /** diff --git a/src/qtism/runtime/expressions/operators/OperandsCollection.php b/src/qtism/runtime/expressions/operators/OperandsCollection.php index 484dd482a..c7e52e7b6 100644 --- a/src/qtism/runtime/expressions/operators/OperandsCollection.php +++ b/src/qtism/runtime/expressions/operators/OperandsCollection.php @@ -22,13 +22,13 @@ */ namespace qtism\runtime\expressions\operators; -use qtism\common\datatypes\Boolean; -use qtism\common\datatypes\String; -use qtism\common\datatypes\Float; -use qtism\common\datatypes\Integer; +use qtism\common\datatypes\QtiBoolean; +use qtism\common\datatypes\QtiString; +use qtism\common\datatypes\QtiFloat; +use qtism\common\datatypes\QtiInteger; use qtism\common\collections\Stack; -use qtism\common\datatypes\Point; -use qtism\common\datatypes\Duration; +use qtism\common\datatypes\QtiPoint; +use qtism\common\datatypes\QtiDuration; use qtism\common\enums\Cardinality; use qtism\common\enums\BaseType; use qtism\common\collections\Container; @@ -81,7 +81,7 @@ public function containsNull() $v = $this[$key]; if ($v instanceof Container && $v->isNull()) { return true; - } elseif (($v instanceof String && $v->getValue() === '') || is_null($v)) { + } elseif (($v instanceof QtiString && $v->getValue() === '') || is_null($v)) { return true; } } @@ -111,7 +111,7 @@ public function exclusivelyNumeric() $v = $this[$key]; if (($v instanceof MultipleContainer || $v instanceof OrderedContainer) && ($v->isNull() || ($v->getBaseType() !== BaseType::FLOAT && $v->getBaseType() !== BaseType::INTEGER))) { return false; - } elseif (!$v instanceof Integer && !$v instanceof Float && !$v instanceof MultipleContainer && !$v instanceof OrderedContainer) { + } elseif (!$v instanceof QtiInteger && !$v instanceof QtiFloat && !$v instanceof MultipleContainer && !$v instanceof OrderedContainer) { return false; } } @@ -139,7 +139,7 @@ public function exclusivelyBoolean() $v = $this[$key]; if (($v instanceof MultipleContainer || $v instanceof OrderedContainer) && ($v->isNull() || $v->getBaseType() !== BaseType::BOOLEAN)) { return false; - } elseif (!$v instanceof Boolean && !$v instanceof MultipleContainer && !$v instanceof OrderedContainer) { + } elseif (!$v instanceof QtiBoolean && !$v instanceof MultipleContainer && !$v instanceof OrderedContainer) { return false; } } @@ -191,7 +191,7 @@ public function exclusivelyString() $v = $this[$key]; if (($v instanceof MultipleContainer || $v instanceof OrderedContainer) && ($v->isNull() || $v->getBaseType() !== BaseType::STRING)) { return false; - } elseif (!$v instanceof MultipleContainer && !$v instanceof OrderedContainer && (!$v instanceof String || $v->getValue() === '')) { + } elseif (!$v instanceof MultipleContainer && !$v instanceof OrderedContainer && (!$v instanceof QtiString || $v->getValue() === '')) { return false; } } @@ -240,7 +240,7 @@ public function exclusivelyInteger() $v = $this[$key]; if (($v instanceof MultipleContainer || $v instanceof OrderedContainer) && ($v->isNull() || $v->getBaseType() !== BaseType::INTEGER)) { return false; - } elseif (!$v instanceof Integer && !$v instanceof MultipleContainer && !$v instanceof OrderedContainer) { + } elseif (!$v instanceof QtiInteger && !$v instanceof MultipleContainer && !$v instanceof OrderedContainer) { return false; } } @@ -450,7 +450,7 @@ public function exclusivelyPoint() $v = $this[$key]; if (($v instanceof MultipleContainer || $v instanceof OrderedContainer) && ($v->isNull() || $v->getBaseType() !== BaseType::POINT)) { return false; - } elseif (!$v instanceof Point && !$v instanceof MultipleContainer && !$v instanceof OrderedContainer) { + } elseif (!$v instanceof QtiPoint && !$v instanceof MultipleContainer && !$v instanceof OrderedContainer) { return false; } } @@ -477,7 +477,7 @@ public function exclusivelyDuration() $v = $this[$key]; if (($v instanceof MultipleContainer || $v instanceof OrderedContainer) && ($v->isNull() || $v->getBaseType() !== BaseType::DURATION)) { return false; - } elseif (!$v instanceof Duration && !$v instanceof MultipleContainer && !$v instanceof OrderedContainer) { + } elseif (!$v instanceof QtiDuration && !$v instanceof MultipleContainer && !$v instanceof OrderedContainer) { return false; } } diff --git a/src/qtism/runtime/expressions/operators/OrProcessor.php b/src/qtism/runtime/expressions/operators/OrProcessor.php index d88adc203..53f7fe3a0 100644 --- a/src/qtism/runtime/expressions/operators/OrProcessor.php +++ b/src/qtism/runtime/expressions/operators/OrProcessor.php @@ -23,7 +23,7 @@ namespace qtism\runtime\expressions\operators; use qtism\common\collections\Container; -use qtism\common\datatypes\Boolean; +use qtism\common\datatypes\QtiBoolean; use qtism\data\expressions\Expression; use qtism\data\expressions\operators\OrOperator; @@ -63,7 +63,7 @@ public function process() } elseif ($op === null) { continue; } else { - if (!$op instanceof Boolean) { + if (!$op instanceof QtiBoolean) { $msg = "The Or Expression only accept operands with boolean baseType."; throw new OperatorProcessingException($msg, $this, OperatorProcessingException::WRONG_BASETYPE); } else { @@ -80,11 +80,11 @@ public function process() foreach ($operands as $operand) { if ($operand !== null && $operand->getValue() === true) { - return new Boolean(true); + return new QtiBoolean(true); } } - return new Boolean(false); + return new QtiBoolean(false); } /** diff --git a/src/qtism/runtime/expressions/operators/PatternMatchProcessor.php b/src/qtism/runtime/expressions/operators/PatternMatchProcessor.php index a4971f448..552b6bae1 100644 --- a/src/qtism/runtime/expressions/operators/PatternMatchProcessor.php +++ b/src/qtism/runtime/expressions/operators/PatternMatchProcessor.php @@ -22,7 +22,7 @@ */ namespace qtism\runtime\expressions\operators; -use qtism\common\datatypes\Boolean; +use qtism\common\datatypes\QtiBoolean; use qtism\data\expressions\operators\PatternMatch; use qtism\data\expressions\Expression; use qtism\runtime\expressions\operators\Utils as OperatorUtils; @@ -86,9 +86,9 @@ public function process() $result = @preg_match($pattern, $operands[0]->getValue()); if ($result === 1) { - return new Boolean(true); + return new QtiBoolean(true); } elseif ($result === 0) { - return new Boolean(false); + return new QtiBoolean(false); } else { $error = preg_last_error(); $errorType = 'PCRE Engine compilation error'; diff --git a/src/qtism/runtime/expressions/operators/PowerProcessor.php b/src/qtism/runtime/expressions/operators/PowerProcessor.php index ab1bbf105..01d4ecb64 100644 --- a/src/qtism/runtime/expressions/operators/PowerProcessor.php +++ b/src/qtism/runtime/expressions/operators/PowerProcessor.php @@ -22,7 +22,7 @@ */ namespace qtism\runtime\expressions\operators; -use qtism\common\datatypes\Float; +use qtism\common\datatypes\QtiFloat; use qtism\data\expressions\operators\Power; use qtism\data\expressions\Expression; @@ -99,7 +99,7 @@ public function process() // overflow return null; } else { - return new Float($floatval); + return new QtiFloat($floatval); } } diff --git a/src/qtism/runtime/expressions/operators/ProductProcessor.php b/src/qtism/runtime/expressions/operators/ProductProcessor.php index 2ff646db7..be213d55e 100644 --- a/src/qtism/runtime/expressions/operators/ProductProcessor.php +++ b/src/qtism/runtime/expressions/operators/ProductProcessor.php @@ -22,9 +22,9 @@ */ namespace qtism\runtime\expressions\operators; -use qtism\common\datatypes\Float; -use qtism\common\datatypes\Integer; -use qtism\common\datatypes\Scalar; +use qtism\common\datatypes\QtiFloat; +use qtism\common\datatypes\QtiInteger; +use qtism\common\datatypes\QtiScalar; use qtism\common\enums\BaseType; use qtism\data\expressions\operators\Product; use qtism\data\expressions\Expression; @@ -67,7 +67,7 @@ public function process() $returnValue = 1; foreach ($this->getOperands() as $operand) { - if ($operand instanceof Scalar) { + if ($operand instanceof QtiScalar) { $returnValue *= $operand->getValue(); } else { foreach ($operand as $val) { @@ -76,7 +76,7 @@ public function process() } } - return (is_int($returnValue)) ? new Integer($returnValue) : new Float($returnValue); + return (is_int($returnValue)) ? new QtiInteger($returnValue) : new QtiFloat($returnValue); } /** diff --git a/src/qtism/runtime/expressions/operators/RepeatProcessor.php b/src/qtism/runtime/expressions/operators/RepeatProcessor.php index cd5becd0c..7cb15f578 100644 --- a/src/qtism/runtime/expressions/operators/RepeatProcessor.php +++ b/src/qtism/runtime/expressions/operators/RepeatProcessor.php @@ -23,7 +23,7 @@ namespace qtism\runtime\expressions\operators; use qtism\common\datatypes\QtiDatatype; -use qtism\common\datatypes\Integer; +use qtism\common\datatypes\QtiInteger; use qtism\common\enums\BaseType; use qtism\common\enums\Cardinality; use qtism\common\collections\Container; @@ -80,7 +80,7 @@ public function process() if (is_null($varValue) === true) { $msg = "The variable with name '${varName}' could not be resolved."; throw new OperatorProcessingException($msg, $this); - } elseif ($varValue instanceof Integer) { + } elseif ($varValue instanceof QtiInteger) { $msg = "The variable with name '${varName}' is not an integer value."; throw new OperatorProcessingException($msg, $this); } diff --git a/src/qtism/runtime/expressions/operators/RoundProcessor.php b/src/qtism/runtime/expressions/operators/RoundProcessor.php index 9dcd61a54..f96fd494e 100644 --- a/src/qtism/runtime/expressions/operators/RoundProcessor.php +++ b/src/qtism/runtime/expressions/operators/RoundProcessor.php @@ -22,7 +22,7 @@ */ namespace qtism\runtime\expressions\operators; -use qtism\common\datatypes\Integer; +use qtism\common\datatypes\QtiInteger; use qtism\data\expressions\operators\Round; use qtism\data\expressions\Expression; @@ -72,7 +72,7 @@ public function process() $operand = $operands[0]; $mode = ($operand->getValue() >= 0) ? PHP_ROUND_HALF_UP : PHP_ROUND_HALF_DOWN; - return new Integer(intval(round($operand->getValue(), 0, $mode))); + return new QtiInteger(intval(round($operand->getValue(), 0, $mode))); } /** diff --git a/src/qtism/runtime/expressions/operators/RoundToProcessor.php b/src/qtism/runtime/expressions/operators/RoundToProcessor.php index 80fca99e7..501e47930 100644 --- a/src/qtism/runtime/expressions/operators/RoundToProcessor.php +++ b/src/qtism/runtime/expressions/operators/RoundToProcessor.php @@ -23,8 +23,8 @@ namespace qtism\runtime\expressions\operators; -use qtism\common\datatypes\Float; -use qtism\common\datatypes\Integer; +use qtism\common\datatypes\QtiFloat; +use qtism\common\datatypes\QtiInteger; use qtism\data\expressions\operators\RoundingMode; use qtism\data\expressions\Expression; use qtism\data\expressions\operators\RoundTo; @@ -111,7 +111,7 @@ public function process() if (is_null($figures)) { $msg = "The variable '${figuresIdentifier}' used to set up the 'figures' attribute is null or nonexisting."; throw new OperatorProcessingException($msg, $this, OperatorProcessingException::NONEXISTENT_VARIABLE); - } elseif (!$figures instanceof Integer) { + } elseif (!$figures instanceof QtiInteger) { $msg = "The variable '${figuresIdentifier}' used to set up the 'figures' attribute is not an integer."; throw new OperatorProcessingException($msg, $this, OperatorProcessingException::WRONG_VARIABLE_BASETYPE); } @@ -127,7 +127,7 @@ public function process() } if ($operand->getValue() == 0) { - return new Float(0.0); + return new QtiFloat(0.0); } $d = ceil(log10($operand->getValue() < 0 ? -$operand->getValue() : $operand->getValue())); @@ -136,7 +136,7 @@ public function process() $magnitude = pow(10, $power); $shifted = round($operand->getValue() * $magnitude); - return new Float(floatval($shifted / $magnitude)); + return new QtiFloat(floatval($shifted / $magnitude)); } else { // As per QTI 2.1 spec. @@ -145,7 +145,7 @@ public function process() throw new OperatorProcessingException($msg, $this); } - return new Float(round($operand->getValue(), $figures)); + return new QtiFloat(round($operand->getValue(), $figures)); } } diff --git a/src/qtism/runtime/expressions/operators/StatsOperatorProcessor.php b/src/qtism/runtime/expressions/operators/StatsOperatorProcessor.php index be8620366..f26356eec 100644 --- a/src/qtism/runtime/expressions/operators/StatsOperatorProcessor.php +++ b/src/qtism/runtime/expressions/operators/StatsOperatorProcessor.php @@ -23,7 +23,7 @@ namespace qtism\runtime\expressions\operators; -use qtism\common\datatypes\Float; +use qtism\common\datatypes\QtiFloat; use qtism\data\expressions\operators\Statistics; use qtism\runtime\expressions\operators\Utils as OperatorsUtils; use qtism\data\expressions\operators\StatsOperator; @@ -99,7 +99,7 @@ protected function processMean() $result = OperatorsUtils::mean(self::filterValues($operand->getArrayCopy())); - return ($result !== false) ? new Float(floatval($result)) : null; + return ($result !== false) ? new QtiFloat(floatval($result)) : null; } /** @@ -113,7 +113,7 @@ protected function processSampleVariance() $result = OperatorsUtils::variance(self::filterValues($operand->getArrayCopy()), true); - return ($result !== false) ? new Float(floatval($result)) : null; + return ($result !== false) ? new QtiFloat(floatval($result)) : null; } /** @@ -127,7 +127,7 @@ protected function processSampleSD() $result = OperatorsUtils::standardDeviation(self::filterValues($operand->getArrayCopy()), true); - return ($result !== false) ? new Float(floatval($result)) : null; + return ($result !== false) ? new QtiFloat(floatval($result)) : null; } /** @@ -141,7 +141,7 @@ protected function processPopVariance() $result = OperatorsUtils::variance(self::filterValues($operand->getArrayCopy()), false); - return ($result !== false) ? new Float(floatval($result)) : null; + return ($result !== false) ? new QtiFloat(floatval($result)) : null; } /** @@ -155,7 +155,7 @@ protected function processPopSD() $result = OperatorsUtils::standardDeviation(self::filterValues($operand->getArrayCopy()), false); - return ($result !== false) ? new Float(floatval($result)) : null; + return ($result !== false) ? new QtiFloat(floatval($result)) : null; } /** diff --git a/src/qtism/runtime/expressions/operators/StringMatchProcessor.php b/src/qtism/runtime/expressions/operators/StringMatchProcessor.php index 40e88d78b..545c12e28 100644 --- a/src/qtism/runtime/expressions/operators/StringMatchProcessor.php +++ b/src/qtism/runtime/expressions/operators/StringMatchProcessor.php @@ -23,7 +23,7 @@ namespace qtism\runtime\expressions\operators; -use qtism\common\datatypes\Boolean; +use qtism\common\datatypes\QtiBoolean; use qtism\data\expressions\operators\StringMatch; use qtism\data\expressions\Expression; @@ -77,7 +77,7 @@ public function process() // Please note that strcmp and strcasecmp are binary-safe *\0/* Hourray! *\0/* $func = ($expression->isCaseSensitive() === true) ? 'strcmp' : 'strcasecmp'; - return new Boolean($func($operands[0]->getValue(), $operands[1]->getValue()) === 0); + return new QtiBoolean($func($operands[0]->getValue(), $operands[1]->getValue()) === 0); } /** diff --git a/src/qtism/runtime/expressions/operators/SubstringProcessor.php b/src/qtism/runtime/expressions/operators/SubstringProcessor.php index f0ccea707..980da68f7 100644 --- a/src/qtism/runtime/expressions/operators/SubstringProcessor.php +++ b/src/qtism/runtime/expressions/operators/SubstringProcessor.php @@ -23,7 +23,7 @@ namespace qtism\runtime\expressions\operators; -use qtism\common\datatypes\Boolean; +use qtism\common\datatypes\QtiBoolean; use qtism\data\expressions\operators\Substring; use qtism\data\expressions\Expression; @@ -72,7 +72,7 @@ public function process() $call = ($this->getExpression()->isCaseSensitive() === true) ? 'mb_strpos' : 'mb_stripos'; - return new Boolean($call($operand2->getValue(), $operand1->getValue(), 0, 'UTF-8') !== false); + return new QtiBoolean($call($operand2->getValue(), $operand1->getValue(), 0, 'UTF-8') !== false); } /** diff --git a/src/qtism/runtime/expressions/operators/SubtractProcessor.php b/src/qtism/runtime/expressions/operators/SubtractProcessor.php index 29ffed584..e332d0b31 100644 --- a/src/qtism/runtime/expressions/operators/SubtractProcessor.php +++ b/src/qtism/runtime/expressions/operators/SubtractProcessor.php @@ -23,8 +23,8 @@ namespace qtism\runtime\expressions\operators; -use qtism\common\datatypes\Float; -use qtism\common\datatypes\Integer; +use qtism\common\datatypes\QtiFloat; +use qtism\common\datatypes\QtiInteger; use qtism\data\expressions\operators\Subtract; use qtism\data\expressions\Expression; @@ -73,7 +73,7 @@ public function process() $subtract = $operand1->getValue() - $operand2->getValue(); - return (is_int($subtract) === true) ? new Integer($subtract) : new Float($subtract); + return (is_int($subtract) === true) ? new QtiInteger($subtract) : new QtiFloat($subtract); } /** diff --git a/src/qtism/runtime/expressions/operators/SumProcessor.php b/src/qtism/runtime/expressions/operators/SumProcessor.php index 240597c4a..90c3b86f1 100644 --- a/src/qtism/runtime/expressions/operators/SumProcessor.php +++ b/src/qtism/runtime/expressions/operators/SumProcessor.php @@ -23,8 +23,8 @@ namespace qtism\runtime\expressions\operators; -use qtism\common\datatypes\Float; -use qtism\common\datatypes\Integer; +use qtism\common\datatypes\QtiFloat; +use qtism\common\datatypes\QtiInteger; use qtism\common\enums\BaseType; use qtism\data\expressions\operators\Sum; use qtism\data\expressions\Expression; @@ -69,9 +69,9 @@ public function process() $floatCount = 0; foreach ($this->getOperands() as $operand) { - if ($operand instanceof Integer) { + if ($operand instanceof QtiInteger) { $returnValue += $operand->getValue(); - } elseif ($operand instanceof Float) { + } elseif ($operand instanceof QtiFloat) { $returnValue += $operand->getValue(); $floatCount++; } else { @@ -79,7 +79,7 @@ public function process() if ($val !== null) { - if ($val instanceof Float) { + if ($val instanceof QtiFloat) { $floatCount++; } @@ -89,7 +89,7 @@ public function process() } } - return ($floatCount > 0) ? new Float(floatval($returnValue)) : new Integer(intval($returnValue)); + return ($floatCount > 0) ? new QtiFloat(floatval($returnValue)) : new QtiInteger(intval($returnValue)); } /** diff --git a/src/qtism/runtime/expressions/operators/TruncateProcessor.php b/src/qtism/runtime/expressions/operators/TruncateProcessor.php index 1517968a9..b999f136c 100644 --- a/src/qtism/runtime/expressions/operators/TruncateProcessor.php +++ b/src/qtism/runtime/expressions/operators/TruncateProcessor.php @@ -23,8 +23,8 @@ namespace qtism\runtime\expressions\operators; -use qtism\common\datatypes\Integer; -use qtism\common\datatypes\Float; +use qtism\common\datatypes\QtiInteger; +use qtism\common\datatypes\QtiFloat; use qtism\data\expressions\operators\Truncate; use qtism\data\expressions\Expression; @@ -76,9 +76,9 @@ public function process() if (is_nan($operand->getValue())) { return null; } elseif (is_infinite($operand->getValue())) { - return new Float(INF); + return new QtiFloat(INF); } else { - return new Integer(intval($operand->getValue())); + return new QtiInteger(intval($operand->getValue())); } } diff --git a/src/qtism/runtime/expressions/operators/custom/Explode.php b/src/qtism/runtime/expressions/operators/custom/Explode.php index e41c5cb5a..624e200c5 100644 --- a/src/qtism/runtime/expressions/operators/custom/Explode.php +++ b/src/qtism/runtime/expressions/operators/custom/Explode.php @@ -23,7 +23,7 @@ namespace qtism\runtime\expressions\operators\custom; -use qtism\common\datatypes\String; +use qtism\common\datatypes\QtiString; use qtism\common\enums\BaseType; use qtism\runtime\common\OrderedContainer; use qtism\runtime\expressions\operators\CustomOperatorProcessor; @@ -81,7 +81,7 @@ public function process() $ordered = new OrderedContainer(BaseType::STRING); foreach ($strings as $str) { - $ordered[] = new String($str); + $ordered[] = new QtiString($str); } return $ordered; diff --git a/src/qtism/runtime/expressions/operators/custom/Implode.php b/src/qtism/runtime/expressions/operators/custom/Implode.php index 63b6dbd25..c59156704 100644 --- a/src/qtism/runtime/expressions/operators/custom/Implode.php +++ b/src/qtism/runtime/expressions/operators/custom/Implode.php @@ -24,7 +24,7 @@ namespace qtism\runtime\expressions\operators\custom; use qtism\common\enums\Cardinality; -use qtism\common\datatypes\String; +use qtism\common\datatypes\QtiString; use qtism\runtime\expressions\operators\OperatorProcessingException; use qtism\runtime\expressions\operators\CustomOperatorProcessor; @@ -74,6 +74,6 @@ public function process() // Note: implode() is binary-safe \0/! $string = implode($glue, $pieces->getArrayCopy()); - return new String($string); + return new QtiString($string); } } diff --git a/src/qtism/runtime/pci/json/Marshaller.php b/src/qtism/runtime/pci/json/Marshaller.php index 21886b59b..ac232b96e 100644 --- a/src/qtism/runtime/pci/json/Marshaller.php +++ b/src/qtism/runtime/pci/json/Marshaller.php @@ -23,21 +23,21 @@ namespace qtism\runtime\pci\json; -use qtism\common\datatypes\File; +use qtism\common\datatypes\QtiFile; use qtism\common\enums\BaseType; use qtism\runtime\common\RecordContainer; -use qtism\common\datatypes\Duration; -use qtism\common\datatypes\DirectedPair; -use qtism\common\datatypes\Pair; -use qtism\common\datatypes\String; -use qtism\common\datatypes\Uri; -use qtism\common\datatypes\IntOrIdentifier; -use qtism\common\datatypes\Identifier; -use qtism\common\datatypes\Integer; -use qtism\common\datatypes\Float; -use qtism\common\datatypes\Boolean; -use qtism\common\datatypes\Point; -use qtism\common\datatypes\Scalar; +use qtism\common\datatypes\QtiDuration; +use qtism\common\datatypes\QtiDirectedPair; +use qtism\common\datatypes\QtiPair; +use qtism\common\datatypes\QtiString; +use qtism\common\datatypes\QtiUri; +use qtism\common\datatypes\QtiIntOrIdentifier; +use qtism\common\datatypes\QtiIdentifier; +use qtism\common\datatypes\QtiInteger; +use qtism\common\datatypes\QtiFloat; +use qtism\common\datatypes\QtiBoolean; +use qtism\common\datatypes\QtiPoint; +use qtism\common\datatypes\QtiScalar; use qtism\runtime\common\MultipleContainer; use qtism\runtime\common\State; use qtism\common\datatypes\QtiDatatype; @@ -127,7 +127,7 @@ protected function marshallUnit($unit) { if (is_null($unit) === true) { $json = array('base' => null); - } elseif ($unit instanceof Scalar) { + } elseif ($unit instanceof QtiScalar) { $json = $this->marshallScalar($unit); } elseif ($unit instanceof MultipleContainer) { $json = array(); @@ -177,19 +177,19 @@ protected function marshallScalar($scalar) if (is_null($scalar) === true) { return $scalar; } elseif ($scalar instanceof QtiDatatype) { - if ($scalar instanceof Boolean) { + if ($scalar instanceof QtiBoolean) { return $this->marshallBoolean($scalar); - } elseif ($scalar instanceof Integer) { + } elseif ($scalar instanceof QtiInteger) { return $this->marshallInteger($scalar); - } elseif ($scalar instanceof Float) { + } elseif ($scalar instanceof QtiFloat) { return $this->marshallFloat($scalar); - } elseif ($scalar instanceof Identifier) { + } elseif ($scalar instanceof QtiIdentifier) { return $this->marshallIdentifier($scalar); - } elseif ($scalar instanceof Uri) { + } elseif ($scalar instanceof QtiUri) { return $this->marshallUri($scalar); - } elseif ($scalar instanceof String) { + } elseif ($scalar instanceof QtiString) { return $this->marshallString($scalar); - } elseif ($scalar instanceof IntOrIdentifier) { + } elseif ($scalar instanceof QtiIntOrIdentifier) { return $this->marshallIntOrIdentifier($scalar); } } else { @@ -217,15 +217,15 @@ protected function marshallComplex(QtiDatatype $complex) { if (is_null($complex) === true) { return $complex; - } elseif ($complex instanceof Point) { + } elseif ($complex instanceof QtiPoint) { return $this->marshallPoint($complex); - } elseif ($complex instanceof DirectedPair) { + } elseif ($complex instanceof QtiDirectedPair) { return $this->marshallDirectedPair($complex); - } elseif ($complex instanceof Pair) { + } elseif ($complex instanceof QtiPair) { return $this->marshallPair($complex); - } elseif ($complex instanceof Duration) { + } elseif ($complex instanceof QtiDuration) { return $this->marshallDuration($complex); - } elseif ($complex instanceof File) { + } elseif ($complex instanceof QtiFile) { return $this->marshallFile($complex); } else { $msg = "The '" . get_class($this) . "::marshallComplex' method only accepts to marshall Complex QTI Datatypes, '"; @@ -247,7 +247,7 @@ protected function marshallComplex(QtiDatatype $complex) * @param \qtism\common\datatypes\Boolean $boolean * @return array */ - protected function marshallBoolean(Boolean $boolean) + protected function marshallBoolean(QtiBoolean $boolean) { return array('base' => array('boolean' => $boolean->getValue())); } @@ -258,7 +258,7 @@ protected function marshallBoolean(Boolean $boolean) * @param \qtism\common\datatypes\Integer $integer * @return array */ - protected function marshallInteger(Integer $integer) + protected function marshallInteger(QtiInteger $integer) { return array('base' => array('integer' => $integer->getValue())); } @@ -269,7 +269,7 @@ protected function marshallInteger(Integer $integer) * @param \qtism\common\datatypes\Float $float * @return array */ - protected function marshallFloat(Float $float) + protected function marshallFloat(QtiFloat $float) { return array('base' => array('float' => $float->getValue())); } @@ -280,7 +280,7 @@ protected function marshallFloat(Float $float) * @param \qtism\common\datatypes\Identifier $identifier * @return array */ - protected function marshallIdentifier(Identifier $identifier) + protected function marshallIdentifier(QtiIdentifier $identifier) { return array('base' => array('identifier' => $identifier->getValue())); } @@ -291,7 +291,7 @@ protected function marshallIdentifier(Identifier $identifier) * @param \qtism\common\datatypes\Uri $uri * @return array */ - protected function marshallUri(Uri $uri) + protected function marshallUri(QtiUri $uri) { return array('base' => array('uri' => $uri->getValue())); } @@ -302,7 +302,7 @@ protected function marshallUri(Uri $uri) * @param \qtism\common\datatypes\String $string * @return array */ - protected function marshallString(String $string) + protected function marshallString(QtiString $string) { return array('base' => array('string' => $string->getValue())); } @@ -313,7 +313,7 @@ protected function marshallString(String $string) * @param \qtism\common\datatypes\IntOrIdentifier $intOrIdentifier * @return array */ - protected function marshallIntOrIdentifier(IntOrIdentifier $intOrIdentifier) + protected function marshallIntOrIdentifier(QtiIntOrIdentifier $intOrIdentifier) { return array('base' => array('intOrIdentifier' => $intOrIdentifier->getValue())); } @@ -324,7 +324,7 @@ protected function marshallIntOrIdentifier(IntOrIdentifier $intOrIdentifier) * @param \qtism\common\datatypes\Point $point * @return array */ - protected function marshallPoint(Point $point) + protected function marshallPoint(QtiPoint $point) { return array('base' => array('point' => array($point->getX(), $point->getY()))); } @@ -335,7 +335,7 @@ protected function marshallPoint(Point $point) * @param \qtism\common\datatypes\DirectedPair $directedPair * @return array */ - protected function marshallDirectedPair(DirectedPair $directedPair) + protected function marshallDirectedPair(QtiDirectedPair $directedPair) { return array('base' => array('directedPair' => array($directedPair->getFirst(), $directedPair->getSecond()))); } @@ -346,7 +346,7 @@ protected function marshallDirectedPair(DirectedPair $directedPair) * @param \qtism\common\datatypes\Pair $pair * @return array */ - protected function marshallPair(Pair $pair) + protected function marshallPair(QtiPair $pair) { return array('base' => array('pair' => array($pair->getFirst(), $pair->getSecond()))); } @@ -357,7 +357,7 @@ protected function marshallPair(Pair $pair) * @param \qtism\common\datatypes\Duration $duration * @return array */ - protected function marshallDuration(Duration $duration) + protected function marshallDuration(QtiDuration $duration) { return array('base' => array('duration' => $duration->__toString())); } @@ -368,7 +368,7 @@ protected function marshallDuration(Duration $duration) * @param \qtism\common\datatypes\File $file * @return array */ - protected function marshallFile(File $file) + protected function marshallFile(QtiFile $file) { $data = array('base' => array('file' => array('mime' => $file->getMimeType(), 'data' => base64_encode($file->getData())))); diff --git a/src/qtism/runtime/pci/json/Unmarshaller.php b/src/qtism/runtime/pci/json/Unmarshaller.php index 1347c498c..3ce7211fc 100644 --- a/src/qtism/runtime/pci/json/Unmarshaller.php +++ b/src/qtism/runtime/pci/json/Unmarshaller.php @@ -24,17 +24,17 @@ namespace qtism\runtime\pci\json; use qtism\common\datatypes\files\FileManager; -use qtism\common\datatypes\Point; -use qtism\common\datatypes\Float; -use qtism\common\datatypes\Identifier; -use qtism\common\datatypes\IntOrIdentifier; -use qtism\common\datatypes\Uri; -use qtism\common\datatypes\Duration; -use qtism\common\datatypes\DirectedPair; -use qtism\common\datatypes\Pair; -use qtism\common\datatypes\String; -use qtism\common\datatypes\Integer; -use qtism\common\datatypes\Boolean; +use qtism\common\datatypes\QtiPoint; +use qtism\common\datatypes\QtiFloat; +use qtism\common\datatypes\QtiIdentifier; +use qtism\common\datatypes\QtiIntOrIdentifier; +use qtism\common\datatypes\QtiUri; +use qtism\common\datatypes\QtiDuration; +use qtism\common\datatypes\QtiDirectedPair; +use qtism\common\datatypes\QtiPair; +use qtism\common\datatypes\QtiString; +use qtism\common\datatypes\QtiInteger; +use qtism\common\datatypes\QtiBoolean; use qtism\runtime\common\RecordContainer; use qtism\common\enums\BaseType; use qtism\runtime\common\MultipleContainer; @@ -305,7 +305,7 @@ protected function unmarshallUnit(array $unit) */ protected function unmarshallBoolean(array $unit) { - return new Boolean($unit['base']['boolean']); + return new QtiBoolean($unit['base']['boolean']); } /** @@ -316,7 +316,7 @@ protected function unmarshallBoolean(array $unit) */ protected function unmarshallInteger(array $unit) { - return new Integer($unit['base']['integer']); + return new QtiInteger($unit['base']['integer']); } /** @@ -333,7 +333,7 @@ protected function unmarshallFloat(array $unit) $val = floatval($val); } - return new Float($val); + return new QtiFloat($val); } /** @@ -344,7 +344,7 @@ protected function unmarshallFloat(array $unit) */ protected function unmarshallString(array $unit) { - return new String($unit['base']['string']); + return new QtiString($unit['base']['string']); } /** @@ -355,7 +355,7 @@ protected function unmarshallString(array $unit) */ protected function unmarshallPoint(array $unit) { - return new Point($unit['base']['point'][0], $unit['base']['point'][1]); + return new QtiPoint($unit['base']['point'][0], $unit['base']['point'][1]); } /** @@ -366,7 +366,7 @@ protected function unmarshallPoint(array $unit) */ protected function unmarshallPair(array $unit) { - return new Pair($unit['base']['pair'][0], $unit['base']['pair'][1]); + return new QtiPair($unit['base']['pair'][0], $unit['base']['pair'][1]); } /** @@ -377,7 +377,7 @@ protected function unmarshallPair(array $unit) */ protected function unmarshallDirectedPair(array $unit) { - return new DirectedPair($unit['base']['directedPair'][0], $unit['base']['directedPair'][1]); + return new QtiDirectedPair($unit['base']['directedPair'][0], $unit['base']['directedPair'][1]); } /** @@ -388,7 +388,7 @@ protected function unmarshallDirectedPair(array $unit) */ protected function unmarshallDuration(array $unit) { - return new Duration($unit['base']['duration']); + return new QtiDuration($unit['base']['duration']); } /** @@ -412,7 +412,7 @@ protected function unmarshallFile(array $unit) */ protected function unmarshallUri(array $unit) { - return new Uri($unit['base']['uri']); + return new QtiUri($unit['base']['uri']); } /** @@ -423,7 +423,7 @@ protected function unmarshallUri(array $unit) */ protected function unmarshallIntOrIdentifier(array $unit) { - return new IntOrIdentifier($unit['base']['intOrIdentifier']); + return new QtiIntOrIdentifier($unit['base']['intOrIdentifier']); } /** @@ -434,6 +434,6 @@ protected function unmarshallIntOrIdentifier(array $unit) */ protected function unmarshallIdentifier(array $unit) { - return new Identifier($unit['base']['identifier']); + return new QtiIdentifier($unit['base']['identifier']); } } diff --git a/src/qtism/runtime/processing/PrintedVariableEngine.php b/src/qtism/runtime/processing/PrintedVariableEngine.php index 466b8cfce..5be6c3e87 100644 --- a/src/qtism/runtime/processing/PrintedVariableEngine.php +++ b/src/qtism/runtime/processing/PrintedVariableEngine.php @@ -23,7 +23,7 @@ namespace qtism\runtime\processing; -use qtism\common\datatypes\Integer; +use qtism\common\datatypes\QtiInteger; use qtism\runtime\common\Variable; use qtism\data\QtiComponent; use qtism\common\utils\Format; @@ -134,7 +134,7 @@ public function process() if (is_string($index) === true && $state[$index] !== null) { $refIndex = $state[$index]; - if ($refIndex instanceof Integer) { + if ($refIndex instanceof QtiInteger) { // $index references an integer, that's correct. $index = $refIndex->getValue(); } else { diff --git a/src/qtism/runtime/rendering/markup/AbstractMarkupRenderingEngine.php b/src/qtism/runtime/rendering/markup/AbstractMarkupRenderingEngine.php index 8d7c4bcf5..0c77be79d 100644 --- a/src/qtism/runtime/rendering/markup/AbstractMarkupRenderingEngine.php +++ b/src/qtism/runtime/rendering/markup/AbstractMarkupRenderingEngine.php @@ -27,8 +27,8 @@ use qtism\data\content\interactions\Gap; use qtism\common\collections\Container; -use qtism\common\datatypes\Identifier; -use qtism\common\datatypes\Scalar; +use qtism\common\datatypes\QtiIdentifier; +use qtism\common\datatypes\QtiScalar; use qtism\runtime\rendering\RenderingException; use qtism\runtime\rendering\Renderable; use qtism\data\content\ModalFeedback; @@ -654,14 +654,14 @@ protected function mustIgnoreComponent(QtiComponent $component) protected function identifierMatches(QtiComponent $component) { $variableIdentifier = ($component instanceof FeedbackElement || $component instanceof ModalFeedback) ? $component->getOutcomeIdentifier() : $component->getTemplateIdentifier(); - $identifier = new Identifier($component->getIdentifier()); + $identifier = new QtiIdentifier($component->getIdentifier()); $showHide = $component->getShowHide(); $state = $this->getState(); $matches = false; if (($val = $state[$variableIdentifier]) !== null) { - if ($val instanceof Scalar) { + if ($val instanceof QtiScalar) { $matches = $val->equals($identifier); } elseif ($val instanceof Container) { $matches = $val->contains($identifier); @@ -1019,8 +1019,8 @@ protected function templateFeedbackComponent(QtiComponent $component, DOMDocumen $operator = ($component->getShowHide() === ShowHide::SHOW) ? '' : '!'; $val = '$' . $this->getStateName() . "['" . $component->getOutcomeIdentifier() . "']"; $identifier = $component->getIdentifier(); - $identifierType = 'qtism\\common\\datatypes\\Identifier'; - $scalarType = 'qtism\\common\\datatypes\\Scalar'; + $identifierType = 'qtism\\common\\datatypes\\QtiIdentifier'; + $scalarType = 'qtism\\common\\datatypes\\QtiScalar'; $containerType = 'qtism\\common\\collections\\Container'; $scalarCheck = "${val} instanceof ${identifierType} && ${val}->equals(new ${identifierType}('${identifier}'))"; $containerCheck = "${val} instanceof ${containerType} && ${val}->contains(new ${identifierType}('${identifier}'))"; @@ -1086,8 +1086,8 @@ protected function templateChoiceComponent(QtiComponent $component, DOMDocumentF $operator = ($component->getShowHide() === ShowHide::SHOW) ? '' : '!'; $val = '$' . $this->getStateName() . "['" . $component->getTemplateIdentifier() . "']"; $identifier = $component->getIdentifier(); - $identifierType = 'qtism\\common\\datatypes\\Identifier'; - $scalarType = 'qtism\\common\\datatypes\\Scalar'; + $identifierType = 'qtism\\common\\datatypes\\QtiIdentifier'; + $scalarType = 'qtism\\common\\datatypes\\QtiScalar'; $containerType = 'qtism\\common\\collections\\Container'; $scalarCheck = "${val} instanceof ${identifierType} && ${val}->equals(new ${identifierType}('${identifier}'))"; $containerCheck = "${val} instanceof ${containerType} && ${val}->contains(new ${identifierType}('${identifier}'))"; diff --git a/src/qtism/runtime/rendering/markup/xhtml/HotspotRenderer.php b/src/qtism/runtime/rendering/markup/xhtml/HotspotRenderer.php index 40253c30c..68bba3c5a 100644 --- a/src/qtism/runtime/rendering/markup/xhtml/HotspotRenderer.php +++ b/src/qtism/runtime/rendering/markup/xhtml/HotspotRenderer.php @@ -23,8 +23,8 @@ namespace qtism\runtime\rendering\markup\xhtml; -use qtism\common\datatypes\Coords; -use qtism\common\datatypes\Shape; +use qtism\common\datatypes\QtiCoords; +use qtism\common\datatypes\QtiShape; use qtism\data\QtiComponent; use \DOMDocumentFragment; @@ -45,7 +45,7 @@ protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent parent::appendAttributes($fragment, $component, $base); $this->additionalClass('qti-hotspot'); - $fragment->firstChild->setAttribute('data-shape', Shape::getNameByConstant($component->getShape())); + $fragment->firstChild->setAttribute('data-shape', QtiShape::getNameByConstant($component->getShape())); $fragment->firstChild->setAttribute('data-coords', $component->getCoords()->__toString()); if ($component->hasHotspotLabel() === true) { diff --git a/src/qtism/runtime/rules/LookupOutcomeValueProcessor.php b/src/qtism/runtime/rules/LookupOutcomeValueProcessor.php index aa7e029af..9aa9abe99 100644 --- a/src/qtism/runtime/rules/LookupOutcomeValueProcessor.php +++ b/src/qtism/runtime/rules/LookupOutcomeValueProcessor.php @@ -24,9 +24,9 @@ use qtism\data\state\Value; use qtism\runtime\common\Utils as RuntimeUtils; -use qtism\common\datatypes\Integer; -use qtism\common\datatypes\Float; -use qtism\common\datatypes\Duration; +use qtism\common\datatypes\QtiInteger; +use qtism\common\datatypes\QtiFloat; +use qtism\common\datatypes\QtiDuration; use qtism\data\state\InterpolationTable; use qtism\runtime\common\OutcomeVariable; use qtism\runtime\expressions\ExpressionEngine; @@ -99,7 +99,7 @@ public function process() $targetVal = $table->getDefaultValue(); if ($table instanceof InterpolationTable) { - if (!$val instanceof Float && !$val instanceof Integer && !$val instanceof Duration) { + if (!$val instanceof QtiFloat && !$val instanceof QtiInteger && !$val instanceof QtiDuration) { $msg = "The value of variable '${identifier}' must be integer, float or duration when used with an interpolationTable"; throw new RuleProcessingException($msg, $this, RuleProcessingException::LOGIC_ERROR); } @@ -118,7 +118,7 @@ public function process() } } else { // $table instanceof MatchTable - if (!$val instanceof Integer) { + if (!$val instanceof QtiInteger) { $msg = "The value of the variable '${identifier}' must be integer when used with a matchTable."; throw new RuleProcessingException($msg, $this, RuleProcessingException::LOGIC_ERROR); } diff --git a/src/qtism/runtime/rules/SetValueProcessor.php b/src/qtism/runtime/rules/SetValueProcessor.php index 389e7b0bd..391f59331 100644 --- a/src/qtism/runtime/rules/SetValueProcessor.php +++ b/src/qtism/runtime/rules/SetValueProcessor.php @@ -24,8 +24,8 @@ namespace qtism\runtime\rules; use qtism\common\enums\Cardinality; -use qtism\common\datatypes\Integer; -use qtism\common\datatypes\Float; +use qtism\common\datatypes\QtiInteger; +use qtism\common\datatypes\QtiFloat; use qtism\runtime\expressions\ExpressionEngine; use qtism\data\rules\Rule; use qtism\common\enums\BaseType; @@ -83,10 +83,10 @@ public function process() if ($val !== null && $var->getCardinality() === Cardinality::SINGLE) { $baseType = $var->getBaseType(); - if ($baseType === BaseType::INTEGER && $val instanceof Float) { - $val = new Integer(intval($val->getValue())); - } elseif ($baseType === BaseType::FLOAT && $val instanceof Integer) { - $val = new Float(floatval($val->getValue())); + if ($baseType === BaseType::INTEGER && $val instanceof QtiFloat) { + $val = new QtiInteger(intval($val->getValue())); + } elseif ($baseType === BaseType::FLOAT && $val instanceof QtiInteger) { + $val = new QtiFloat(floatval($val->getValue())); } } diff --git a/src/qtism/runtime/storage/binary/AbstractQtiBinaryStreamAccess.php b/src/qtism/runtime/storage/binary/AbstractQtiBinaryStreamAccess.php index e7cbb0d43..4c3dc38c1 100644 --- a/src/qtism/runtime/storage/binary/AbstractQtiBinaryStreamAccess.php +++ b/src/qtism/runtime/storage/binary/AbstractQtiBinaryStreamAccess.php @@ -29,10 +29,10 @@ use qtism\runtime\common\TemplateVariable; use qtism\runtime\tests\AbstractSessionManager; -use qtism\common\datatypes\File; -use qtism\common\datatypes\Scalar; -use qtism\common\datatypes\Identifier; -use qtism\common\datatypes\Integer; +use qtism\common\datatypes\QtiFile; +use qtism\common\datatypes\QtiScalar; +use qtism\common\datatypes\QtiIdentifier; +use qtism\common\datatypes\QtiInteger; use qtism\common\collections\IdentifierCollection; use qtism\data\state\Value; use qtism\data\state\Shuffling; @@ -52,10 +52,10 @@ use qtism\runtime\tests\PendingResponses; use qtism\data\AssessmentItemRef; use qtism\runtime\common\Utils; -use qtism\common\datatypes\Duration; -use qtism\common\datatypes\DirectedPair; -use qtism\common\datatypes\Pair; -use qtism\common\datatypes\Point; +use qtism\common\datatypes\QtiDuration; +use qtism\common\datatypes\QtiDirectedPair; +use qtism\common\datatypes\QtiPair; +use qtism\common\datatypes\QtiPoint; use qtism\runtime\common\OrderedContainer; use qtism\runtime\common\MultipleContainer; use qtism\runtime\common\RecordContainer; @@ -221,7 +221,7 @@ public function writeVariableValue(Variable $variable, $valueType = self::RW_VAL $this->writeBoolean(true); // content - $this->$toCall(($value instanceof Scalar) ? $value->getValue() : $value); + $this->$toCall(($value instanceof QtiScalar) ? $value->getValue() : $value); } else { // is-scalar $this->writeBoolean(false); @@ -233,7 +233,7 @@ public function writeVariableValue(Variable $variable, $valueType = self::RW_VAL foreach ($value as $v) { if (is_null($v) === false) { $this->writeBoolean(false); - $this->$toCall(($v instanceof Scalar) ? $v->getValue() : $v); + $this->$toCall(($v instanceof QtiScalar) ? $v->getValue() : $v); } else { $this->writeBoolean(true); } @@ -294,7 +294,7 @@ public function writeRecordField(array $recordField, $isNull = false) $this->writeTinyInt($baseType); $toCall = 'write' . ucfirst(BaseType::getNameByConstant($baseType)); - call_user_func(array($this, $toCall), ($value instanceof Scalar) ? $value->getValue() : $value); + call_user_func(array($this, $toCall), ($value instanceof QtiScalar) ? $value->getValue() : $value); } } catch (BinaryStreamAccessException $e) { $msg = "An error occured while reading a Record Field."; @@ -343,7 +343,7 @@ public function writeIdentifier($identifier) public function readPoint() { try { - return new Point($this->readShort(), $this->readShort()); + return new QtiPoint($this->readShort(), $this->readShort()); } catch (BinaryStreamAccessException $e) { $msg = "An error occured while reading a point."; throw new QtiBinaryStreamAccessException($msg, $this, QtiBinaryStreamAccessException::POINT, $e); @@ -356,7 +356,7 @@ public function readPoint() * @param \qtism\common\datatypes\Point $point A Point object. * @throws \qtism\runtime\storage\binary\QtiBinaryStreamAccessException */ - public function writePoint(Point $point) + public function writePoint(QtiPoint $point) { try { $this->writeShort($point->getX()); @@ -376,7 +376,7 @@ public function writePoint(Point $point) public function readPair() { try { - return new Pair($this->readString(), $this->readString()); + return new QtiPair($this->readString(), $this->readString()); } catch (BinaryStreamAccessException $e) { $msg = "An error occured while reading a pair."; throw new QtiBinaryStreamAccessException($msg, $this, QtiBinaryStreamAccessException::PAIR, $e); @@ -389,7 +389,7 @@ public function readPair() * @param \qtism\common\datatypes\Pair $pair A Pair object. * @throws \qtism\runtime\storage\binary\QtiBinaryStreamAccessException */ - public function writePair(Pair $pair) + public function writePair(QtiPair $pair) { try { $this->writeString($pair->getFirst()); @@ -409,7 +409,7 @@ public function writePair(Pair $pair) public function readDirectedPair() { try { - return new DirectedPair($this->readString(), $this->readString()); + return new QtiDirectedPair($this->readString(), $this->readString()); } catch (BinaryStreamAccessException $e) { $msg = "An error occured while reading a directedPair."; throw new QtiBinaryStreamAccessException($msg, $this, QtiBinaryStreamAccessException::DIRECTEDPAIR, $e); @@ -422,7 +422,7 @@ public function readDirectedPair() * @param \qtism\common\datatypes\DirectedPair $directedPair A DirectedPair object. * @throws \qtism\runtime\storage\binary\QtiBinaryStreamAccessException */ - public function writeDirectedPair(DirectedPair $directedPair) + public function writeDirectedPair(QtiDirectedPair $directedPair) { try { $this->writeString($directedPair->getFirst()); @@ -550,7 +550,7 @@ public function writeShufflingState(Shuffling $shufflingState) public function readDuration() { try { - return new Duration($this->readString()); + return new QtiDuration($this->readString()); } catch (BinaryStreamAccessException $e) { $msg = "An error occured while reading a duration."; throw new QtiBinaryStreamAccessException($msg, $this, QtiBinaryStreamAccessException::DURATION, $e); @@ -563,7 +563,7 @@ public function readDuration() * @param \qtism\common\datatypes\Duration $duration A Duration object. * @throws \qtism\runtime\storage\binary\QtiBinaryStreamAccessException */ - public function writeDuration(Duration $duration) + public function writeDuration(QtiDuration $duration) { try { $this->writeString($duration->__toString()); @@ -619,7 +619,7 @@ abstract public function readFile(); * @param \qtism\common\datatypes\File $file A File object * @throws \qtism\runtime\storage\binary\QtiBinaryStreamAccessException */ - abstract public function writeFile(File $file); + abstract public function writeFile(QtiFile $file); /** * Read an intOrIdentifier from the current binary stream. @@ -688,9 +688,9 @@ public function readAssessmentItemSession(AbstractSessionManager $manager, Asses $session->setItemSessionControl($itemSessionControl); } - $session['numAttempts'] = new Integer($this->readTinyInt()); + $session['numAttempts'] = new QtiInteger($this->readTinyInt()); $session['duration'] = $this->readDuration(); - $session['completionStatus'] = new Identifier($this->readString()); + $session['completionStatus'] = new QtiIdentifier($this->readString()); if ($this->readBoolean() === true) { // A time reference is set. diff --git a/src/qtism/runtime/storage/binary/QtiBinaryStreamAccessFsFile.php b/src/qtism/runtime/storage/binary/QtiBinaryStreamAccessFsFile.php index ccd164671..7ef94130f 100644 --- a/src/qtism/runtime/storage/binary/QtiBinaryStreamAccessFsFile.php +++ b/src/qtism/runtime/storage/binary/QtiBinaryStreamAccessFsFile.php @@ -24,7 +24,7 @@ namespace qtism\runtime\storage\binary; use qtism\common\datatypes\files\FileSystemFile; -use qtism\common\datatypes\File; +use qtism\common\datatypes\QtiFile; /** * An implementation of AbstractQtiBinaryStreamAccess working with file system @@ -38,7 +38,7 @@ class QtiBinaryStreamAccessFsFile extends AbstractQtiBinaryStreamAccess /** * @see \qtism\runtime\storage\binary\AbstractQtiBinaryStreamAccess::writeFile() */ - public function writeFile(File $file) + public function writeFile(QtiFile $file) { try { $this->writeString($file->getPath()); diff --git a/src/qtism/runtime/tests/AssessmentItemSession.php b/src/qtism/runtime/tests/AssessmentItemSession.php index 5623399de..d69964a3b 100644 --- a/src/qtism/runtime/tests/AssessmentItemSession.php +++ b/src/qtism/runtime/tests/AssessmentItemSession.php @@ -23,17 +23,17 @@ namespace qtism\runtime\tests; -use qtism\common\datatypes\Boolean; +use qtism\common\datatypes\QtiBoolean; use qtism\runtime\processing\TemplateProcessingEngine; use qtism\runtime\common\Utils; use qtism\runtime\common\TemplateVariable; use qtism\data\ShowHide; -use qtism\common\datatypes\Scalar; +use qtism\common\datatypes\QtiScalar; use qtism\common\utils\Time; use qtism\data\processing\ResponseProcessing; use qtism\common\collections\Container; -use qtism\common\datatypes\Identifier; -use qtism\common\datatypes\Integer; +use qtism\common\datatypes\QtiIdentifier; +use qtism\common\datatypes\QtiInteger; use qtism\data\IAssessmentItem; use qtism\data\expressions\Correct; use qtism\runtime\expressions\CorrectProcessor; @@ -45,7 +45,7 @@ use qtism\runtime\processing\ResponseProcessingEngine; use qtism\runtime\common\OutcomeVariable; use qtism\data\ItemSessionControl; -use qtism\common\datatypes\Duration; +use qtism\common\datatypes\QtiDuration; use qtism\common\enums\BaseType; use qtism\common\enums\Cardinality; use qtism\runtime\common\ResponseVariable; @@ -261,11 +261,11 @@ public function __construct(IAssessmentItem $assessmentItem, $navigationMode = N $this->setSubmissionMode($submissionMode); // -- Create the built-in response variables. - $this->setVariable(new ResponseVariable('numAttempts', Cardinality::SINGLE, BaseType::INTEGER, new Integer(0))); - $this->setVariable(new ResponseVariable('duration', Cardinality::SINGLE, BaseType::DURATION, new Duration('PT0S'))); + $this->setVariable(new ResponseVariable('numAttempts', Cardinality::SINGLE, BaseType::INTEGER, new QtiInteger(0))); + $this->setVariable(new ResponseVariable('duration', Cardinality::SINGLE, BaseType::DURATION, new QtiDuration('PT0S'))); // -- Create the built-in outcome variables. - $this->setVariable(new OutcomeVariable('completionStatus', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier(self::COMPLETION_STATUS_NOT_ATTEMPTED))); + $this->setVariable(new OutcomeVariable('completionStatus', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier(self::COMPLETION_STATUS_NOT_ATTEMPTED))); // -- Create item specific outcome, response and template variables. foreach ($assessmentItem->getOutcomeDeclarations() as $outcomeDeclaration) { @@ -562,7 +562,7 @@ public function setTime(DateTime $time) // The session state is INTERACTING. Thus, we need to update the built-in // duration variable. $diffSeconds = Time::timeDiffSeconds($this->getTimeReference(), $time); - $diffDuration = new Duration("PT${diffSeconds}S"); + $diffDuration = new QtiDuration("PT${diffSeconds}S"); $this['duration']->add($diffDuration); } @@ -622,7 +622,7 @@ public function beginItemSession() // The session gets the INITIAL state, ready for a first attempt, and // built-in variables get their initial value set. $this->setState(AssessmentItemSessionState::INITIAL); - $this['duration'] = new Duration('PT0S'); + $this['duration'] = new QtiDuration('PT0S'); $this['numAttempts']->setValue(0); $this['completionStatus']->setValue(self::COMPLETION_STATUS_NOT_ATTEMPTED); } @@ -698,8 +698,8 @@ public function beginAttempt() } } - $this['duration'] = new Duration('PT0S'); - $this['numAttempts'] = new Integer(0); + $this['duration'] = new QtiDuration('PT0S'); + $this['numAttempts'] = new QtiInteger(0); // At the start of the first attempt, the completionStatus goes // to 'unknown'. @@ -708,7 +708,7 @@ public function beginAttempt() // For any attempt, the variables related to endAttemptInteractions are reset to false. foreach ($this->getAssessmentItem()->getEndAttemptIdentifiers() as $endAttemptIdentifier) { - $this[$endAttemptIdentifier] = new Boolean(false); + $this[$endAttemptIdentifier] = new QtiBoolean(false); } // Increment the built-in variable 'numAttempts' by one. @@ -1262,12 +1262,12 @@ private function mustModalFeedback() foreach ($this->getAssessmentItem()->getModalFeedbackRules() as $rule) { $outcomeValue = $this[$rule->getOutcomeIdentifier()]; - $identifierValue = new Identifier($rule->getIdentifier()); + $identifierValue = new QtiIdentifier($rule->getIdentifier()); $showHide = $rule->getShowHide(); $match = false; if (is_null($outcomeValue) === false) { - $match = ($outcomeValue instanceof Scalar) ? $outcomeValue->equals($identifierValue) : $outcomeValue->contains($identifierValue); + $match = ($outcomeValue instanceof QtiScalar) ? $outcomeValue->equals($identifierValue) : $outcomeValue->contains($identifierValue); } if (($showHide === ShowHide::SHOW && $match === true) || ($showHide === ShowHide::HIDE && $match === false)) { diff --git a/src/qtism/runtime/tests/AssessmentTestSession.php b/src/qtism/runtime/tests/AssessmentTestSession.php index 6b0e958c1..b999bf7a0 100644 --- a/src/qtism/runtime/tests/AssessmentTestSession.php +++ b/src/qtism/runtime/tests/AssessmentTestSession.php @@ -24,8 +24,8 @@ namespace qtism\runtime\tests; use qtism\data\ShowHide; -use qtism\common\datatypes\Scalar; -use qtism\common\datatypes\Identifier; +use qtism\common\datatypes\QtiScalar; +use qtism\common\datatypes\QtiIdentifier; use qtism\common\utils\Time; use qtism\data\processing\ResponseProcessing; use qtism\data\IAssessmentItem; @@ -33,7 +33,7 @@ use qtism\common\enums\Cardinality; use qtism\runtime\expressions\ExpressionEngine; use qtism\data\TimeLimits; -use qtism\common\datatypes\Duration; +use qtism\common\datatypes\QtiDuration; use qtism\runtime\processing\ResponseProcessingEngine; use qtism\data\SubmissionMode; use qtism\runtime\common\ProcessingException; @@ -213,7 +213,7 @@ public function setTime(DateTime $time) if ($this->getState() === AssessmentTestSessionState::INTERACTING) { $diffSeconds = abs(Time::timeDiffSeconds($this->getTimeReference(), $time)); - $diffDuration = new Duration("PT${diffSeconds}S"); + $diffDuration = new QtiDuration("PT${diffSeconds}S"); // Update the duration store. $routeItem = $this->getCurrentRouteItem(); @@ -1858,7 +1858,7 @@ protected function initializeTestDurations() $ids = array_merge(array($assessmentTestId), array($testPartId), $assessmentSectionIds); foreach ($ids as $id) { if (isset($durationStore[$id]) === false) { - $durationStore->setVariable(new OutcomeVariable($id, Cardinality::SINGLE, BaseType::DURATION, new Duration('PT0S'))); + $durationStore->setVariable(new OutcomeVariable($id, Cardinality::SINGLE, BaseType::DURATION, new QtiDuration('PT0S'))); } } } @@ -2606,12 +2606,12 @@ protected function mustShowTestFeedback() // Checking if one of them must be shown... foreach ($feedbackRefs as $feedbackRef) { $outcomeValue = $this[$feedbackRef->getOutcomeIdentifier()]; - $identifierValue = new Identifier($feedbackRef->getIdentifier()); + $identifierValue = new QtiIdentifier($feedbackRef->getIdentifier()); $showHide = $feedbackRef->getShowHide(); $match = false; if (is_null($outcomeValue) === false) { - $match = ($outcomeValue instanceof Scalar) ? $outcomeValue->equals($identifierValue) : $outcomeValue->contains($identifierValue); + $match = ($outcomeValue instanceof QtiScalar) ? $outcomeValue->equals($identifierValue) : $outcomeValue->contains($identifierValue); } if (($showHide === ShowHide::SHOW && $match === true) || ($showHide === ShowHide::HIDE && $match === false)) { diff --git a/src/qtism/runtime/tests/TimeConstraint.php b/src/qtism/runtime/tests/TimeConstraint.php index 00e451cf9..a580a7f56 100644 --- a/src/qtism/runtime/tests/TimeConstraint.php +++ b/src/qtism/runtime/tests/TimeConstraint.php @@ -24,7 +24,7 @@ namespace qtism\runtime\tests; use qtism\data\SectionPart; -use qtism\common\datatypes\Duration; +use qtism\common\datatypes\QtiDuration; use qtism\data\NavigationMode; use qtism\data\QtiComponent; @@ -69,7 +69,7 @@ class TimeConstraint * @param \qtism\common\datatypes\Duration $duration The already spent duration by the candidate on $source. * @param integer $navigationMode The current navigation mode. */ - public function __construct(QtiComponent $source, Duration $duration, $navigationMode = NavigationMode::LINEAR) + public function __construct(QtiComponent $source, QtiDuration $duration, $navigationMode = NavigationMode::LINEAR) { $this->setSource($source); $this->setDuration($duration); @@ -102,7 +102,7 @@ public function getSource() * * @param \qtism\common\datatypes\Duration $duration A Duration object. */ - protected function setDuration(Duration $duration) + protected function setDuration(QtiDuration $duration) { $this->duration = $duration; } @@ -150,7 +150,7 @@ public function getMaximumRemainingTime() $remaining = clone $maxTime; $remaining->sub($this->getDuration()); - return ($remaining->isNegative() === true) ? new Duration('PT0S') : $remaining; + return ($remaining->isNegative() === true) ? new QtiDuration('PT0S') : $remaining; } else { return false; } @@ -169,7 +169,7 @@ public function getMinimumRemainingTime() $remaining = clone $this->getSource()->getTimeLimits()->getMinTime(); $remaining->sub($this->getDuration()); - return ($remaining->isNegative() === true) ? new Duration('PT0S') : $remaining; + return ($remaining->isNegative() === true) ? new QtiDuration('PT0S') : $remaining; } else { return false; } diff --git a/test/qtismtest/QtiSmAssessmentItemTestCase.php b/test/qtismtest/QtiSmAssessmentItemTestCase.php index 37b2bbbf2..33f098c0e 100644 --- a/test/qtismtest/QtiSmAssessmentItemTestCase.php +++ b/test/qtismtest/QtiSmAssessmentItemTestCase.php @@ -2,7 +2,7 @@ namespace qtismtest; use qtismtest\QtiSmTestCase; -use qtism\common\datatypes\Duration; +use qtism\common\datatypes\QtiDuration; use qtism\runtime\tests\SessionManager; use qtism\data\storage\xml\marshalling\ExtendedAssessmentItemRefMarshaller; use qtism\runtime\tests\AssessmentItemSession; diff --git a/test/qtismtest/common/collections/ContainerTest.php b/test/qtismtest/common/collections/ContainerTest.php index 8bf998384..87ea53cdd 100644 --- a/test/qtismtest/common/collections/ContainerTest.php +++ b/test/qtismtest/common/collections/ContainerTest.php @@ -2,19 +2,19 @@ namespace qtismtest\common\collections; use qtismtest\QtiSmTestCase; -use qtism\common\datatypes\Boolean; -use qtism\common\datatypes\Identifier; -use qtism\common\datatypes\String; -use qtism\common\datatypes\Float; -use qtism\common\datatypes\Integer; +use qtism\common\datatypes\QtiBoolean; +use qtism\common\datatypes\QtiIdentifier; +use qtism\common\datatypes\QtiString; +use qtism\common\datatypes\QtiFloat; +use qtism\common\datatypes\QtiInteger; use qtism\common\enums\BaseType; use qtism\data\state\Value; use qtism\data\state\ValueCollection; use qtism\common\collections\Container; -use qtism\common\datatypes\Pair; -use qtism\common\datatypes\DirectedPair; -use qtism\common\datatypes\Point; -use qtism\common\datatypes\Duration; +use qtism\common\datatypes\QtiPair; +use qtism\common\datatypes\QtiDirectedPair; +use qtism\common\datatypes\QtiPoint; +use qtism\common\datatypes\QtiDuration; use qtism\common\enums\Cardinality; class ContainerTest extends QtiSmTestCase { @@ -72,7 +72,7 @@ public function testIsNull() { $this->assertTrue($container->isNull()); - $container[] = new Integer(1); + $container[] = new QtiInteger(1); $this->assertFalse($container->isNull()); } @@ -107,17 +107,17 @@ public function testOccurences($container, $lookup, $expected) { public function validValueProvider() { return array( - array(new Integer(25)), - array(new Float(25.3)), - array(new Integer(0)), - array(new String('')), - array(new String('super')), - array(new Boolean(true)), - array(new Boolean(false)), - array(new Duration('P1D')), - array(new Point(20, 20)), - array(new Pair('A', 'B')), - array(new DirectedPair('C', 'D')), + array(new QtiInteger(25)), + array(new QtiFloat(25.3)), + array(new QtiInteger(0)), + array(new QtiString('')), + array(new QtiString('super')), + array(new QtiBoolean(true)), + array(new QtiBoolean(false)), + array(new QtiDuration('P1D')), + array(new QtiPoint(20, 20)), + array(new QtiPair('A', 'B')), + array(new QtiDirectedPair('C', 'D')), array(null) ); } @@ -131,44 +131,44 @@ public function invalidValueProvider() { public function validEqualsPrimitiveProvider() { return array( - array(new Container(array(new Boolean(true), new Boolean(false))), new Container(array(new Boolean(false), new Boolean(true)))), - array(new Container(array(new Integer(14), new Integer(13))), new Container(array(new Integer(13), new Integer(14)))), + array(new Container(array(new QtiBoolean(true), new QtiBoolean(false))), new Container(array(new QtiBoolean(false), new QtiBoolean(true)))), + array(new Container(array(new QtiInteger(14), new QtiInteger(13))), new Container(array(new QtiInteger(13), new QtiInteger(14)))), array(new Container(array(null)), new Container(array(null))), - array(new Container(array(new Integer(0))), new Container(array(new Integer(0)))), - array(new Container(array(new String('string'))), new Container(array(new String('string')))), - array(new Container(array(new Float(14.5))), new Container(array(new Float(14.5)))), - array(new Container(array(new String('string1'), new String('string2'))), new Container(array(new String('string1'), new String('string2')))), + array(new Container(array(new QtiInteger(0))), new Container(array(new QtiInteger(0)))), + array(new Container(array(new QtiString('string'))), new Container(array(new QtiString('string')))), + array(new Container(array(new QtiFloat(14.5))), new Container(array(new QtiFloat(14.5)))), + array(new Container(array(new QtiString('string1'), new QtiString('string2'))), new Container(array(new QtiString('string1'), new QtiString('string2')))), array(new Container(), new Container()), ); } public function invalidEqualsPrimitiveProvider() { return array( - array(new Container(array(new Integer(14))), new Container(array(new Integer(13)))), - array(new Container(array(new Integer(14))), new Container(array(new String('string')))), - array(new Container(array(null)), new Container(array(new Integer(0)))), - array(new Container(), new Container(array(new Integer(13)))), - array(new Container(array(new Boolean(true))), new Boolean(true)), + array(new Container(array(new QtiInteger(14))), new Container(array(new QtiInteger(13)))), + array(new Container(array(new QtiInteger(14))), new Container(array(new QtiString('string')))), + array(new Container(array(null)), new Container(array(new QtiInteger(0)))), + array(new Container(), new Container(array(new QtiInteger(13)))), + array(new Container(array(new QtiBoolean(true))), new QtiBoolean(true)), ); } public function occurencesProvider() { return array( - array(new Container(array(new Integer(15))), new Integer(15), 1), - array(new Container(array(new Float(14.3))), new Float(14.3), 1), - array(new Container(array(new Boolean(true))), new Boolean(true), 1), - array(new Container(array(new Boolean(false))), new Boolean(false), 1), - array(new Container(array(new String('string'))), new String('string'), 1), - array(new Container(array(new Integer(0))), new Integer(0), 1), + array(new Container(array(new QtiInteger(15))), new QtiInteger(15), 1), + array(new Container(array(new QtiFloat(14.3))), new QtiFloat(14.3), 1), + array(new Container(array(new QtiBoolean(true))), new QtiBoolean(true), 1), + array(new Container(array(new QtiBoolean(false))), new QtiBoolean(false), 1), + array(new Container(array(new QtiString('string'))), new QtiString('string'), 1), + array(new Container(array(new QtiInteger(0))), new QtiInteger(0), 1), array(new Container(array(null)), null, 1), - array(new Container(array(new Integer(15), new String('string'), new Integer(15))), new Integer(15), 2), - array(new Container(array(new Float(14.3), new Integer(143), new Float(14.3))), new Float(14.3), 2), - array(new Container(array(new Boolean(true), new Boolean(false), new Boolean(false))), new Boolean(false), 2), - array(new Container(array(new String('string'), new Integer(2), new String('str'), new String('string'), new String('string'))), new String('string'), 3), - array(new Container(array(new String('null'), null)), null, 1), - array(new Container(array(new Integer(14), new Integer(15), new Integer(16))), true, 0), - array(new Container(array(new String('string'), new Integer(1), new Boolean(true), new Float(14.3), new Point(20, 20), new Point(20, 21))), new Point(20, 20), 1), - array(new Container(array(null)), new Integer(1), 0) + array(new Container(array(new QtiInteger(15), new QtiString('string'), new QtiInteger(15))), new QtiInteger(15), 2), + array(new Container(array(new QtiFloat(14.3), new QtiInteger(143), new QtiFloat(14.3))), new QtiFloat(14.3), 2), + array(new Container(array(new QtiBoolean(true), new QtiBoolean(false), new QtiBoolean(false))), new QtiBoolean(false), 2), + array(new Container(array(new QtiString('string'), new QtiInteger(2), new QtiString('str'), new QtiString('string'), new QtiString('string'))), new QtiString('string'), 3), + array(new Container(array(new QtiString('null'), null)), null, 1), + array(new Container(array(new QtiInteger(14), new QtiInteger(15), new QtiInteger(16))), true, 0), + array(new Container(array(new QtiString('string'), new QtiInteger(1), new QtiBoolean(true), new QtiFloat(14.3), new QtiPoint(20, 20), new QtiPoint(20, 21))), new QtiPoint(20, 20), 1), + array(new Container(array(null)), new QtiInteger(1), 0) ); } @@ -189,14 +189,14 @@ public function validValueCollectionProvider() { public function testClone() { $container = $this->getContainer(); - $container[] = new Point(10, 20); - $container[] = new Duration('P2D'); // 2 days. - $container[] = new Pair('A', 'B'); - $container[] = new DirectedPair('C', 'D'); - $container[] = new Integer(20); - $container[] = new Float(20.1); - $container[] = new Boolean(true); - $container[] = new String('String!'); + $container[] = new QtiPoint(10, 20); + $container[] = new QtiDuration('P2D'); // 2 days. + $container[] = new QtiPair('A', 'B'); + $container[] = new QtiDirectedPair('C', 'D'); + $container[] = new QtiInteger(20); + $container[] = new QtiFloat(20.1); + $container[] = new QtiBoolean(true); + $container[] = new QtiString('String!'); $clone = clone $container; $this->assertFalse($clone === $container); @@ -211,17 +211,17 @@ public function testClone() { } public function testContains() { - $pair = new Pair('A', 'B'); + $pair = new QtiPair('A', 'B'); $container = $this->getContainer(); $container[] = $pair; - $this->assertTrue($container->contains(new Pair('A', 'B'))); + $this->assertTrue($container->contains(new QtiPair('A', 'B'))); } public function testContains2() { - $identifier = new Identifier('test'); + $identifier = new QtiIdentifier('test'); $container = $this->getContainer(); $container[] = $identifier; - $this->assertTrue($container->contains(new Identifier('test'))); + $this->assertTrue($container->contains(new QtiIdentifier('test'))); } /** @@ -238,9 +238,9 @@ public function toStringProvider() { $returnValue = array(); $returnValue[] = array(new Container(), '[]'); - $returnValue[] = array(new Container(array(new Integer(10))), '[10]'); - $returnValue[] = array(new Container(array(new Boolean(true), new Boolean(false))), '[true; false]'); - $returnValue[] = array(new Container(array(new Duration('P2DT2S'), new Point(10, 15), new Pair('A', 'B'), new DirectedPair('C', 'D'), new String('String!'))), '[P2DT2S; 10 15; A B; C D; \'String!\']'); + $returnValue[] = array(new Container(array(new QtiInteger(10))), '[10]'); + $returnValue[] = array(new Container(array(new QtiBoolean(true), new QtiBoolean(false))), '[true; false]'); + $returnValue[] = array(new Container(array(new QtiDuration('P2DT2S'), new QtiPoint(10, 15), new QtiPair('A', 'B'), new QtiDirectedPair('C', 'D'), new QtiString('String!'))), '[P2DT2S; 10 15; A B; C D; \'String!\']'); return $returnValue; } diff --git a/test/qtismtest/common/datatypes/BooleanTest.php b/test/qtismtest/common/datatypes/BooleanTest.php index 3743ce064..a80fd2dc4 100644 --- a/test/qtismtest/common/datatypes/BooleanTest.php +++ b/test/qtismtest/common/datatypes/BooleanTest.php @@ -1,18 +1,18 @@ setExpectedException('\\InvalidArgumentException'); - $boolean = new Boolean('string'); + $boolean = new QtiBoolean('string'); } public function testClone() { - $boolean = new Boolean(true); + $boolean = new QtiBoolean(true); $otherBoolean = clone $boolean; $this->assertEquals($boolean->getValue(), $otherBoolean->getValue()); diff --git a/test/qtismtest/common/datatypes/CoordsTest.php b/test/qtismtest/common/datatypes/CoordsTest.php index 76549d460..e827f0940 100644 --- a/test/qtismtest/common/datatypes/CoordsTest.php +++ b/test/qtismtest/common/datatypes/CoordsTest.php @@ -2,89 +2,89 @@ namespace qtismtest\common\datatypes; use qtismtest\QtiSmTestCase; -use qtism\common\datatypes\Shape; -use qtism\common\datatypes\Coords; -use qtism\common\datatypes\Point; +use qtism\common\datatypes\QtiShape; +use qtism\common\datatypes\QtiCoords; +use qtism\common\datatypes\QtiPoint; use qtism\common\enums\Cardinality; use qtism\common\enums\BaseType; class CoordsTest extends QtiSmTestCase { public function testInstantiate() { - $coords = new Coords(Shape::POLY, array(0, 0, 0, 3, 3, 0)); + $coords = new QtiCoords(QtiShape::POLY, array(0, 0, 0, 3, 3, 0)); $this->assertEquals(BaseType::COORDS, $coords->getBaseType()); $this->assertEquals(Cardinality::SINGLE, $coords->getCardinality()); } public function testInsideCircle() { - $coords = new Coords(Shape::CIRCLE, array(5, 5, 5)); + $coords = new QtiCoords(QtiShape::CIRCLE, array(5, 5, 5)); - $point = new Point(1, 1); // 1,1 is outside + $point = new QtiPoint(1, 1); // 1,1 is outside $this->assertFalse($coords->inside($point)); - $point = new Point(3, 3); // 3,3 is inside + $point = new QtiPoint(3, 3); // 3,3 is inside $this->assertTrue($coords->inside($point)); - $point = new Point(5, 5); // 5,5 is inside + $point = new QtiPoint(5, 5); // 5,5 is inside $this->assertTrue($coords->inside($point)); - $point = new Point(10, 10); // 10,10 is outside + $point = new QtiPoint(10, 10); // 10,10 is outside $this->assertFalse($coords->inside($point)); } public function testInsideRectangle() { // Do not forget (x1, y1) -> left top corner, (x2, y2) -> right bottom corner. - $coords = new Coords(Shape::RECT, array(0, 0, 5, 3)); + $coords = new QtiCoords(QtiShape::RECT, array(0, 0, 5, 3)); - $point = new Point(0, 0); // 0, 0 is inside. + $point = new QtiPoint(0, 0); // 0, 0 is inside. $this->assertTrue($coords->inside($point)); - $point = new Point(-1, -1); // -1, -1 is outside. + $point = new QtiPoint(-1, -1); // -1, -1 is outside. $this->assertFalse($coords->inside($point)); - $point = new Point(2, 1); // 2, 1 is inside. + $point = new QtiPoint(2, 1); // 2, 1 is inside. $this->assertTrue($coords->inside($point)); - $point = new Point(5, 3); // 5, 3 is inside. + $point = new QtiPoint(5, 3); // 5, 3 is inside. $this->assertTrue($coords->inside($point)); - $point = new Point(5, 4); // 5, 4 is outside. + $point = new QtiPoint(5, 4); // 5, 4 is outside. $this->assertFalse($coords->inside($point)); } public function testInsidePolygon() { - $coords = new Coords(Shape::POLY, array(0, 8, 7, 4, 2, 2, 8, -4, -2, 1)); + $coords = new QtiCoords(QtiShape::POLY, array(0, 8, 7, 4, 2, 2, 8, -4, -2, 1)); - $point = new Point(0, 8); // 0, 8 is inside. + $point = new QtiPoint(0, 8); // 0, 8 is inside. $this->assertTrue($coords->inside($point)); - $point = new Point(10, 9); // 10, 9 is outside. + $point = new QtiPoint(10, 9); // 10, 9 is outside. $this->assertFalse($coords->inside($point)); - $point = new Point(3, 2); // 3, 2 is outside. + $point = new QtiPoint(3, 2); // 3, 2 is outside. $this->assertFalse($coords->inside($point)); - $point = new Point(1, 2); // 1, 2 is inside; + $point = new QtiPoint(1, 2); // 1, 2 is inside; $this->assertTrue($coords->inside($point)); - $point = new Point(-1, -1); // -1, -1 is outside. + $point = new QtiPoint(-1, -1); // -1, -1 is outside. $this->assertFalse($coords->inside($point)); - $point = new Point(6, 4); // 6, 4 is inside. + $point = new QtiPoint(6, 4); // 6, 4 is inside. $this->assertTrue($coords->inside($point)); } public function testOnEdgePolygon() { - $coords = new Coords(Shape::POLY, array(0, 0, 0, 3, 3, 0)); - $point = new Point(0, 2); + $coords = new QtiCoords(QtiShape::POLY, array(0, 0, 0, 3, 3, 0)); + $point = new QtiPoint(0, 2); $this->assertTrue($coords->inside($point)); } public function testInsideDefault() { // always true. - $coords = new Coords(Shape::DEF); - $this->assertTrue($coords->inside(new Point(0, 0))); - $this->assertTrue($coords->inside(new Point(100, 200))); - $this->assertTrue($coords->inside(new Point(-200, -100))); + $coords = new QtiCoords(QtiShape::DEF); + $this->assertTrue($coords->inside(new QtiPoint(0, 0))); + $this->assertTrue($coords->inside(new QtiPoint(100, 200))); + $this->assertTrue($coords->inside(new QtiPoint(-200, -100))); } } \ No newline at end of file diff --git a/test/qtismtest/common/datatypes/DirectedPairTest.php b/test/qtismtest/common/datatypes/DirectedPairTest.php index 91e92c3bc..10b2c8d5e 100644 --- a/test/qtismtest/common/datatypes/DirectedPairTest.php +++ b/test/qtismtest/common/datatypes/DirectedPairTest.php @@ -2,17 +2,17 @@ namespace qtismtest\common\datatypes; use qtismtest\QtiSmTestCase; -use qtism\common\datatypes\Pair; -use qtism\common\datatypes\DirectedPair; +use qtism\common\datatypes\QtiPair; +use qtism\common\datatypes\QtiDirectedPair; class DirectedPairTest extends QtiSmTestCase { public function testEquality() { - $p1 = new DirectedPair('A', 'B'); - $p2 = new DirectedPair('A', 'B'); - $p3 = new DirectedPair('C', 'D'); - $p4 = new Pair('A', 'B'); - $p5 = new DirectedPair('D', 'C'); + $p1 = new QtiDirectedPair('A', 'B'); + $p2 = new QtiDirectedPair('A', 'B'); + $p3 = new QtiDirectedPair('C', 'D'); + $p4 = new QtiPair('A', 'B'); + $p5 = new QtiDirectedPair('D', 'C'); $this->assertTrue($p1->equals($p2)); $this->assertTrue($p2->equals($p1)); @@ -23,8 +23,8 @@ public function testEquality() { $this->assertFalse($p1->equals($p4)); $this->assertFalse($p3->equals($p5)); - $p7 = new DirectedPair('abc', 'def'); - $p8 = new DirectedPair('def', 'abc'); + $p7 = new QtiDirectedPair('abc', 'def'); + $p8 = new QtiDirectedPair('def', 'abc'); $this->assertFalse($p7->equals($p8)); $this->assertFalse($p8->equals($p7)); } diff --git a/test/qtismtest/common/datatypes/DurationTest.php b/test/qtismtest/common/datatypes/DurationTest.php index e440674b2..205c2a039 100644 --- a/test/qtismtest/common/datatypes/DurationTest.php +++ b/test/qtismtest/common/datatypes/DurationTest.php @@ -2,7 +2,7 @@ namespace qtismtest\common\datatypes; use qtismtest\QtiSmTestCase; -use qtism\common\datatypes\Duration; +use qtism\common\datatypes\QtiDuration; use \DateInterval; class DurationTest extends QtiSmTestCase { @@ -11,8 +11,8 @@ class DurationTest extends QtiSmTestCase { * @dataProvider validDurationProvider */ public function testValidDurationCreation($intervalSpec) { - $duration = new Duration($intervalSpec); - $this->assertInstanceOf('qtism\\common\\datatypes\\Duration', $duration); + $duration = new QtiDuration($intervalSpec); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiDuration', $duration); } /** @@ -20,11 +20,11 @@ public function testValidDurationCreation($intervalSpec) { */ public function testInvalidDurationCreation($intervalSpec) { $this->setExpectedException('\\InvalidArgumentException'); - $duration = new Duration($intervalSpec); + $duration = new QtiDuration($intervalSpec); } public function testPositiveDuration() { - $duration = new Duration('P3Y4DT6H8M'); // 2 years, 4 days, 6 hours, 8 minutes. + $duration = new QtiDuration('P3Y4DT6H8M'); // 2 years, 4 days, 6 hours, 8 minutes. $this->assertEquals(3, $duration->getYears()); $this->assertEquals(4, $duration->getDays()); $this->assertEquals(6, $duration->getHours()); @@ -34,9 +34,9 @@ public function testPositiveDuration() { } public function testEquality() { - $d1 = new Duration('P1DT12H'); // 1 day + 12 hours. - $d2 = new Duration('P1DT12H'); - $d3 = new Duration('PT3600S'); // 3600 seconds. + $d1 = new QtiDuration('P1DT12H'); // 1 day + 12 hours. + $d2 = new QtiDuration('P1DT12H'); + $d3 = new QtiDuration('PT3600S'); // 3600 seconds. $this->assertTrue($d1->equals($d2)); $this->assertTrue($d2->equals($d1)); @@ -46,11 +46,11 @@ public function testEquality() { } public function testNegativeDuration() { - $duration = new Duration('P2Y4DT6H8M'); // - 2 years, 4 days, 6 hours, 8 minutes. + $duration = new QtiDuration('P2Y4DT6H8M'); // - 2 years, 4 days, 6 hours, 8 minutes. } public function testClone() { - $d = new Duration('P1DT12H'); // 1 day + 12 hours. + $d = new QtiDuration('P1DT12H'); // 1 day + 12 hours. $c = clone $d; $this->assertFalse($c === $d); $this->assertTrue($c->equals($d)); @@ -68,57 +68,57 @@ public function testClone() { * @param Duration $duration * @param string $expected */ - public function testToString(Duration $duration, $expected) { + public function testToString(QtiDuration $duration, $expected) { $this->assertEquals($duration->__toString(), $expected); } public function testAdd() { - $d1 = new Duration('PT1S'); - $d2 = new Duration('PT1S'); + $d1 = new QtiDuration('PT1S'); + $d2 = new QtiDuration('PT1S'); $d1->add($d2); $this->assertEquals('PT2S', $d1->__toString()); - $d1 = new Duration('PT23H59M59S'); - $d2 = new Duration('PT10S'); + $d1 = new QtiDuration('PT23H59M59S'); + $d2 = new QtiDuration('PT10S'); $d1->add($d2); $this->assertEquals('P1DT9S', $d1->__toString()); - $d1 = new Duration('PT1S'); + $d1 = new QtiDuration('PT1S'); $d2 = new DateInterval('PT1S'); $d1->add($d2); $this->assertEquals('PT2S', $d1->__toString()); } public function testSub() { - $d1 = new Duration('PT2S'); - $d2 = new Duration('PT1S'); + $d1 = new QtiDuration('PT2S'); + $d2 = new QtiDuration('PT1S'); $d1->sub($d2); $this->assertEquals('PT1S', $d1->__toString()); - $d1 = new Duration('PT2S'); - $d2 = new Duration('PT4S'); + $d1 = new QtiDuration('PT2S'); + $d2 = new QtiDuration('PT4S'); $d1->sub($d2); $this->assertEquals('PT0S', $d1->__toString()); - $d1 = new Duration('P1DT2H25M30S'); - $d2 = new Duration('P1DT2H'); + $d1 = new QtiDuration('P1DT2H25M30S'); + $d2 = new QtiDuration('P1DT2H'); $d1->sub($d2); $this->assertEquals('PT25M30S', $d1->__toString()); - $d1 = new Duration('PT20S'); - $d2 = new Duration('PT20S'); + $d1 = new QtiDuration('PT20S'); + $d2 = new QtiDuration('PT20S'); $d1->sub($d2); $this->assertEquals('PT0S', $d1->__toString()); - $d1 = new Duration('PT20S'); - $d2 = new Duration('PT21S'); + $d1 = new QtiDuration('PT20S'); + $d2 = new QtiDuration('PT21S'); $d1->sub($d2); $this->assertTrue($d1->isNegative()); } public function createFromDateInterval() { $interval = new DateInterval('PT5S'); - $duration = Duration::createFromDateInterval($interval); + $duration = QtiDuration::createFromDateInterval($interval); $this->assertEquals(5, $duration->getSeconds(true)); } @@ -129,7 +129,7 @@ public function createFromDateInterval() { * @param Duration $duration2 * @param boolean $expected */ - public function testShorterThan(Duration $duration1, Duration $duration2, $expected) { + public function testShorterThan(QtiDuration $duration1, QtiDuration $duration2, $expected) { $this->assertSame($expected, $duration1->shorterThan($duration2)); } @@ -140,35 +140,35 @@ public function testShorterThan(Duration $duration1, Duration $duration2, $expec * @param Duration $duration2 * @param boolean $expected */ - public function testLongerThanOrEquals(Duration $duration1, Duration $duration2, $expected) { + public function testLongerThanOrEquals(QtiDuration $duration1, QtiDuration $duration2, $expected) { $this->assertSame($expected, $duration1->longerThanOrEquals($duration2)); } public function shorterThanProvider() { $returnValue = array(); - $returnValue[] = array(new Duration('P1Y'), new Duration('P2Y'), true); - $returnValue[] = array(new Duration('P1Y'), new Duration('P1Y'), false); - $returnValue[] = array(new Duration('P1Y'), new Duration('P1YT2S'), true); - $returnValue[] = array(new Duration('P2Y'), new Duration('P1Y'), false); - $returnValue[] = array(new Duration('PT0S'), new Duration('PT1S'), true); - $returnValue[] = array(new Duration('PT1H25M0S'), new Duration('PT1H26M12S'), true); - $returnValue[] = array(new Duration('PT1H26M12S'), new Duration('PT1H25M0S'), false); + $returnValue[] = array(new QtiDuration('P1Y'), new QtiDuration('P2Y'), true); + $returnValue[] = array(new QtiDuration('P1Y'), new QtiDuration('P1Y'), false); + $returnValue[] = array(new QtiDuration('P1Y'), new QtiDuration('P1YT2S'), true); + $returnValue[] = array(new QtiDuration('P2Y'), new QtiDuration('P1Y'), false); + $returnValue[] = array(new QtiDuration('PT0S'), new QtiDuration('PT1S'), true); + $returnValue[] = array(new QtiDuration('PT1H25M0S'), new QtiDuration('PT1H26M12S'), true); + $returnValue[] = array(new QtiDuration('PT1H26M12S'), new QtiDuration('PT1H25M0S'), false); return $returnValue; } public function longerThanOrEqualsProvider() { $returnValue = array(); - $returnValue[] = array(new Duration('P1Y'), new Duration('P2Y'), false); - $returnValue[] = array(new Duration('P1Y'), new Duration('P1Y'), true); - $returnValue[] = array(new Duration('P1Y'), new Duration('P1YT2S'), false); - $returnValue[] = array(new Duration('P2Y'), new Duration('P1Y'), true); - $returnValue[] = array(new Duration('PT0S'), new Duration('PT1S'), false); - $returnValue[] = array(new Duration('PT1H25M0S'), new Duration('PT1H26M12S'), false); - $returnValue[] = array(new Duration('PT1H26M12S'), new Duration('PT1H25M0S'), true); - $returnValue[] = array(new Duration('PT1H26M'), new Duration('PT1H26M'), true); - $returnValue[] = array(new Duration('PT1M5S'), new Duration('PT1M'), true); - $returnValue[] = array(new Duration('PT1M15S'), new Duration('PT45S'), true); + $returnValue[] = array(new QtiDuration('P1Y'), new QtiDuration('P2Y'), false); + $returnValue[] = array(new QtiDuration('P1Y'), new QtiDuration('P1Y'), true); + $returnValue[] = array(new QtiDuration('P1Y'), new QtiDuration('P1YT2S'), false); + $returnValue[] = array(new QtiDuration('P2Y'), new QtiDuration('P1Y'), true); + $returnValue[] = array(new QtiDuration('PT0S'), new QtiDuration('PT1S'), false); + $returnValue[] = array(new QtiDuration('PT1H25M0S'), new QtiDuration('PT1H26M12S'), false); + $returnValue[] = array(new QtiDuration('PT1H26M12S'), new QtiDuration('PT1H25M0S'), true); + $returnValue[] = array(new QtiDuration('PT1H26M'), new QtiDuration('PT1H26M'), true); + $returnValue[] = array(new QtiDuration('PT1M5S'), new QtiDuration('PT1M'), true); + $returnValue[] = array(new QtiDuration('PT1M15S'), new QtiDuration('PT45S'), true); return $returnValue; } @@ -192,10 +192,10 @@ public function invalidDurationProvider() { public function toStringProvider() { return array( - array(new Duration('P2D'), 'P2D'), // 2 days - array(new Duration('PT2S'), 'PT2S'), // 2 seconds - array(new Duration('P6YT5M'), 'P6YT5M'), // 6 years, 5 months - array(new Duration('PT0S'), 'PT0S'), // 0 seconds + array(new QtiDuration('P2D'), 'P2D'), // 2 days + array(new QtiDuration('PT2S'), 'PT2S'), // 2 seconds + array(new QtiDuration('P6YT5M'), 'P6YT5M'), // 6 years, 5 months + array(new QtiDuration('PT0S'), 'PT0S'), // 0 seconds ); } } \ No newline at end of file diff --git a/test/qtismtest/common/datatypes/FloatTest.php b/test/qtismtest/common/datatypes/FloatTest.php index 671d750cd..2e07b4f0e 100644 --- a/test/qtismtest/common/datatypes/FloatTest.php +++ b/test/qtismtest/common/datatypes/FloatTest.php @@ -1,13 +1,13 @@ setExpectedException('\\InvalidArgumentException'); - $float = new Float(null); + $float = new QtiFloat(null); } } \ No newline at end of file diff --git a/test/qtismtest/common/datatypes/IdentifierTest.php b/test/qtismtest/common/datatypes/IdentifierTest.php index 23cad1965..7451c800f 100644 --- a/test/qtismtest/common/datatypes/IdentifierTest.php +++ b/test/qtismtest/common/datatypes/IdentifierTest.php @@ -1,13 +1,13 @@ setExpectedException('\\InvalidArgumentException'); - $float = new Identifier(1337); + $float = new QtiIdentifier(1337); } } \ No newline at end of file diff --git a/test/qtismtest/common/datatypes/IntOrIdentifierTest.php b/test/qtismtest/common/datatypes/IntOrIdentifierTest.php index 3ac9ad822..b0668c36c 100644 --- a/test/qtismtest/common/datatypes/IntOrIdentifierTest.php +++ b/test/qtismtest/common/datatypes/IntOrIdentifierTest.php @@ -1,13 +1,13 @@ setExpectedException('\\InvalidArgumentException'); - $intOrIdentifier = new IntOrIdentifier(13.37); + $intOrIdentifier = new QtiIntOrIdentifier(13.37); } } \ No newline at end of file diff --git a/test/qtismtest/common/datatypes/IntegerTest.php b/test/qtismtest/common/datatypes/IntegerTest.php index aa4a6b5b2..7a88bbdb1 100644 --- a/test/qtismtest/common/datatypes/IntegerTest.php +++ b/test/qtismtest/common/datatypes/IntegerTest.php @@ -1,13 +1,13 @@ setExpectedException('\\InvalidArgumentException'); - $integer = new Integer(13.37); + $integer = new QtiInteger(13.37); } } \ No newline at end of file diff --git a/test/qtismtest/common/datatypes/PairTest.php b/test/qtismtest/common/datatypes/PairTest.php index 203c4606b..009dad7df 100644 --- a/test/qtismtest/common/datatypes/PairTest.php +++ b/test/qtismtest/common/datatypes/PairTest.php @@ -2,15 +2,15 @@ namespace qtismtest\common\datatypes; use qtismtest\QtiSmTestCase; -use qtism\common\datatypes\Pair; +use qtism\common\datatypes\QtiPair; class PairTest extends QtiSmTestCase { public function testEquality() { - $p1 = new Pair('A', 'B'); - $p2 = new Pair('A', 'B'); - $p3 = new Pair('C', 'D'); - $p4 = new Pair('D', 'C'); + $p1 = new QtiPair('A', 'B'); + $p2 = new QtiPair('A', 'B'); + $p3 = new QtiPair('C', 'D'); + $p4 = new QtiPair('D', 'C'); $this->assertTrue($p1->equals($p2)); $this->assertTrue($p2->equals($p1)); @@ -23,11 +23,11 @@ public function testEquality() { public function testInvalidFirstIdentifier() { $this->setExpectedException('\\InvalidArgumentException'); - $pair = new Pair('_33', '33tt'); + $pair = new QtiPair('_33', '33tt'); } public function testInvalidSecondIdentifier() { $this->setExpectedException('\\InvalidArgumentException'); - $pair = new Pair('33tt', '_33'); + $pair = new QtiPair('33tt', '_33'); } } \ No newline at end of file diff --git a/test/qtismtest/common/datatypes/PointTest.php b/test/qtismtest/common/datatypes/PointTest.php index 4acca17bb..3adf06e1b 100644 --- a/test/qtismtest/common/datatypes/PointTest.php +++ b/test/qtismtest/common/datatypes/PointTest.php @@ -2,14 +2,14 @@ namespace qtismtest\common\datatypes; use qtismtest\QtiSmTestCase; -use qtism\common\datatypes\Point; +use qtism\common\datatypes\QtiPoint; class PointTest extends QtiSmTestCase { public function testEquality() { - $p1 = new Point(10, 10); - $p2 = new Point(10, 10); - $p3 = new Point(100, 100); + $p1 = new QtiPoint(10, 10); + $p2 = new QtiPoint(10, 10); + $p3 = new QtiPoint(100, 100); $this->assertTrue($p1->equals($p2)); $this->assertTrue($p2->equals($p1)); diff --git a/test/qtismtest/common/utils/ReflectionTest.php b/test/qtismtest/common/utils/ReflectionTest.php index fdfbaa97e..1f9d97fe4 100644 --- a/test/qtismtest/common/utils/ReflectionTest.php +++ b/test/qtismtest/common/utils/ReflectionTest.php @@ -2,7 +2,7 @@ namespace qtismtest\common\utils; use qtismtest\QtiSmTestCase; -use qtism\common\datatypes\Integer; +use qtism\common\datatypes\QtiInteger; use qtism\common\utils\Reflection; use \ReflectionClass; @@ -42,7 +42,7 @@ public function shortClassNameProvider() { array("Class", "\\My\\Super\\Class"), array("stdClass", new \stdClass()), - array("Integer", new Integer(10)), + array("QtiInteger", new QtiInteger(10)), array("My_Stupid_Class", "My_Stupid_Class"), array(false, 12), diff --git a/test/qtismtest/data/AssessmentTestTest.php b/test/qtismtest/data/AssessmentTestTest.php index b26438c13..1dc6aab0e 100644 --- a/test/qtismtest/data/AssessmentTestTest.php +++ b/test/qtismtest/data/AssessmentTestTest.php @@ -2,7 +2,7 @@ namespace qtismtest\data; use qtismtest\QtiSmTestCase; -use qtism\common\datatypes\Duration; +use qtism\common\datatypes\QtiDuration; use qtism\data\storage\xml\XmlDocument; class AssessmentTestTest extends QtiSmTestCase { @@ -15,8 +15,8 @@ public function testTimeLimits() { $this->assertTrue($testPart->hasTimeLimits()); $timeLimits = $testPart->getTimeLimits(); - $this->assertTrue($timeLimits->getMinTime()->equals(new Duration('PT60S'))); - $this->assertTrue($timeLimits->getMaxTime()->equals(new Duration('PT120S'))); + $this->assertTrue($timeLimits->getMinTime()->equals(new QtiDuration('PT60S'))); + $this->assertTrue($timeLimits->getMaxTime()->equals(new QtiDuration('PT120S'))); $this->assertTrue($timeLimits->doesAllowLateSubmission()); } } \ No newline at end of file diff --git a/test/qtismtest/data/storage/UtilsTest.php b/test/qtismtest/data/storage/UtilsTest.php index 6ef2c79ca..18c778c71 100644 --- a/test/qtismtest/data/storage/UtilsTest.php +++ b/test/qtismtest/data/storage/UtilsTest.php @@ -2,12 +2,12 @@ namespace qtismtest\data\storage; use qtismtest\QtiSmTestCase; -use qtism\common\datatypes\Pair; -use qtism\common\datatypes\Duration; -use qtism\common\datatypes\Point; +use qtism\common\datatypes\QtiPair; +use qtism\common\datatypes\QtiDuration; +use qtism\common\datatypes\QtiPoint; use qtism\data\storage\Utils; use qtism\common\enums\BaseType; -use qtism\common\datatypes\Shape; +use qtism\common\datatypes\QtiShape; use \stdClass; class UtilsTest extends QtiSmTestCase { @@ -87,7 +87,7 @@ public function testStringToPointInvalid($string) { */ public function testStringToDurationValid($string, $expected) { $value = Utils::stringToDatatype($string, BaseType::DURATION); - $this->assertInstanceOf('qtism\\common\\datatypes\\Duration', $value); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiDuration', $value); $this->assertEquals($value->getDays(), $expected->getDays()); $this->assertEquals($value->getYears(), $expected->getYears()); $this->assertEquals($value->getHours(), $expected->getHours()); @@ -109,7 +109,7 @@ public function testStringToDurationInvalid($string) { */ public function testStringToPairValid($string, $expected) { $value = Utils::stringToDatatype($string, BaseType::PAIR); - $this->assertInstanceOf('qtism\\common\\datatypes\\Pair', $value); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiPair', $value); $this->assertEquals($expected->getFirst(), $value->getFirst()); $this->assertEquals($expected->getSecond(), $value->getSecond()); } @@ -127,7 +127,7 @@ public function testStringToPairInvalid($string) { */ public function testStringToDirectedPairValid($string, $expected) { $value = Utils::stringToDatatype($string, BaseType::DIRECTED_PAIR); - $this->assertInstanceOf('qtism\\common\\datatypes\\DirectedPair', $value); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiDirectedPair', $value); $this->assertEquals($expected->getFirst(), $value->getFirst()); $this->assertEquals($expected->getSecond(), $value->getSecond()); } @@ -145,7 +145,7 @@ public function testStringToDirectedPairInvalid($string) { */ public function testStringToCoords($string, $shape) { $coords = Utils::stringToCoords($string, $shape); - $this->assertInstanceOf('qtism\\common\\datatypes\\Coords', $coords); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiCoords', $coords); $intCoords = explode(",", $string); $this->assertEquals(count($intCoords), count($coords)); @@ -188,27 +188,27 @@ public function testInvalidUriToSanitize($uri) { public function validCoordsProvider() { return array( - array('30, 30, 60, 30', Shape::RECT), - array('10, 10, 10', Shape::CIRCLE), - array('10,10,10', Shape::CIRCLE), - array('0,8,7,4,2,2,8,-4,-2,1', Shape::POLY), - array('30.1, 30, 50, 30.1', Shape::RECT), - array('184,237,18.38', Shape::CIRCLE), - array('-184 ,237, -18.38', Shape::CIRCLE) + array('30, 30, 60, 30', QtiShape::RECT), + array('10, 10, 10', QtiShape::CIRCLE), + array('10,10,10', QtiShape::CIRCLE), + array('0,8,7,4,2,2,8,-4,-2,1', QtiShape::POLY), + array('30.1, 30, 50, 30.1', QtiShape::RECT), + array('184,237,18.38', QtiShape::CIRCLE), + array('-184 ,237, -18.38', QtiShape::CIRCLE) ); } public function invalidCoordsProvider() { return array( - array('invalid', SHAPE::RECT), - array('20;40;30', SHAPE::CIRCLE), - array('184.456,237.,18', SHAPE::CIRCLE), + array('invalid', QtiShape::RECT), + array('20;40;30', QtiShape::CIRCLE), + array('184.456,237.,18', QtiShape::CIRCLE), ); } public function invalidShapeProvider() { return array( - array('10, 10, 10', SHAPE::DEF), + array('10, 10, 10', QtiShape::DEF), array('10', 25) ); } @@ -281,9 +281,9 @@ public function invalidBooleanProvider() { public function validPointProvider() { return array( - array('20 30', new Point(20, 30)), - array('240 30', new Point(240, 30)), - array('-10 3', new Point(-10, 3)) + array('20 30', new QtiPoint(20, 30)), + array('240 30', new QtiPoint(240, 30)), + array('-10 3', new QtiPoint(-10, 3)) ); } @@ -302,13 +302,13 @@ public function invalidPointProvider() { public function validDurationProvider() { return array( - array('P1D', new Duration('P1D')), // 1 day - array('P2W', new Duration('P2W')), // 2 weeks - array('P3M', new Duration('P3M')), // 3 months - array('P4Y', new Duration('P4Y')), // 4 years - array('P1Y1D', new Duration('P1Y1D')), // 1 year + 1 day - array('P1DT12H', new Duration('P1DT12H')), // 1 day + 12 hours - array('PT3600S', new Duration('PT3600S')) // 3600 seconds + array('P1D', new QtiDuration('P1D')), // 1 day + array('P2W', new QtiDuration('P2W')), // 2 weeks + array('P3M', new QtiDuration('P3M')), // 3 months + array('P4Y', new QtiDuration('P4Y')), // 4 years + array('P1Y1D', new QtiDuration('P1Y1D')), // 1 year + 1 day + array('P1DT12H', new QtiDuration('P1DT12H')), // 1 day + 12 hours + array('PT3600S', new QtiDuration('PT3600S')) // 3600 seconds ); } @@ -324,8 +324,8 @@ public function invalidDurationProvider() { public function validPairProvider() { return array( - array('Bidule Trucmuche', new Pair('Bidule', 'Trucmuche')), - array('C D', new Pair('C', 'D')) + array('Bidule Trucmuche', new QtiPair('Bidule', 'Trucmuche')), + array('C D', new QtiPair('C', 'D')) ); } diff --git a/test/qtismtest/data/storage/php/marshalling/PhpMarshallingContextTest.php b/test/qtismtest/data/storage/php/marshalling/PhpMarshallingContextTest.php index c7817cfbd..b1681e0d7 100644 --- a/test/qtismtest/data/storage/php/marshalling/PhpMarshallingContextTest.php +++ b/test/qtismtest/data/storage/php/marshalling/PhpMarshallingContextTest.php @@ -2,9 +2,9 @@ namespace qtismtest\data\storage\php\marshalling; use qtismtest\QtiSmTestCase; -use qtism\common\datatypes\Point; -use qtism\common\datatypes\Shape; -use qtism\common\datatypes\Coords; +use qtism\common\datatypes\QtiPoint; +use qtism\common\datatypes\QtiShape; +use qtism\common\datatypes\QtiCoords; use qtism\common\storage\MemoryStream; use qtism\data\storage\php\marshalling\PhpMarshallingContext; use qtism\data\storage\php\PhpStreamAccess; @@ -113,10 +113,10 @@ public function testGenerateVariableName() { $this->assertEquals('string_1', $ctx->generateVariableName('String!')); $this->assertEquals('integer_2', $ctx->generateVariableName(1337)); - $this->assertEquals('coords_0', $ctx->generateVariableName(new Coords(Shape::CIRCLE, array(10, 10, 5)))); - $this->assertEquals('coords_1', $ctx->generateVariableName(new Coords(Shape::CIRCLE, array(10, 10, 3)))); - $this->assertEquals('point_0', $ctx->generateVariableName(new Point(0, 0))); - $this->assertEquals('point_1', $ctx->generateVariableName(new Point(0, 1))); - $this->assertEquals('coords_2', $ctx->generateVariableName(new Coords(Shape::CIRCLE, array(5, 5, 3)))); + $this->assertEquals('qticoords_0', $ctx->generateVariableName(new QtiCoords(QtiShape::CIRCLE, array(10, 10, 5)))); + $this->assertEquals('qticoords_1', $ctx->generateVariableName(new QtiCoords(QtiShape::CIRCLE, array(10, 10, 3)))); + $this->assertEquals('qtipoint_0', $ctx->generateVariableName(new QtiPoint(0, 0))); + $this->assertEquals('qtipoint_1', $ctx->generateVariableName(new QtiPoint(0, 1))); + $this->assertEquals('qticoords_2', $ctx->generateVariableName(new QtiCoords(QtiShape::CIRCLE, array(5, 5, 3)))); } } diff --git a/test/qtismtest/data/storage/php/marshalling/PhpMarshallingUtilsTest.php b/test/qtismtest/data/storage/php/marshalling/PhpMarshallingUtilsTest.php index 1ed18c5c6..56f882487 100644 --- a/test/qtismtest/data/storage/php/marshalling/PhpMarshallingUtilsTest.php +++ b/test/qtismtest/data/storage/php/marshalling/PhpMarshallingUtilsTest.php @@ -2,8 +2,8 @@ namespace qtismtest\data\storage\php\marshalling; use qtismtest\QtiSmTestCase; -use qtism\common\datatypes\Pair; -use qtism\common\datatypes\Point; +use qtism\common\datatypes\QtiPair; +use qtism\common\datatypes\QtiPoint; use qtism\data\storage\php\marshalling\Utils as PhpMarshallingUtils; class PhpMarshallingUtilsTest extends QtiSmTestCase { @@ -30,8 +30,8 @@ public function variableNameDataProvider() { array(24.3, 4, 'double_4'), array(true, 0, 'boolean_0'), array(false, 5, 'boolean_5'), - array(new Point(0, 0), 0, 'point_0'), - array(new Pair('A', 'B'), 6, 'pair_6'), + array(new QtiPoint(0, 0), 0, 'qtipoint_0'), + array(new QtiPair('A', 'B'), 6, 'qtipair_6'), array(array('a', true, false), 0, 'array_0'), array(array(), 7, 'array_7') ); diff --git a/test/qtismtest/data/storage/php/marshalling/PhpQtiDatatypeMarshallerTest.php b/test/qtismtest/data/storage/php/marshalling/PhpQtiDatatypeMarshallerTest.php index 827c4c9f3..e9abe4899 100644 --- a/test/qtismtest/data/storage/php/marshalling/PhpQtiDatatypeMarshallerTest.php +++ b/test/qtismtest/data/storage/php/marshalling/PhpQtiDatatypeMarshallerTest.php @@ -2,12 +2,12 @@ namespace qtismtest\data\storage\php\marshalling; use qtismtest\QtiSmPhpMarshallerTestCase; -use qtism\common\datatypes\Point; -use qtism\common\datatypes\Duration; -use qtism\common\datatypes\Pair; -use qtism\common\datatypes\DirectedPair; -use qtism\common\datatypes\Shape; -use qtism\common\datatypes\Coords; +use qtism\common\datatypes\QtiPoint; +use qtism\common\datatypes\QtiDuration; +use qtism\common\datatypes\QtiPair; +use qtism\common\datatypes\QtiDirectedPair; +use qtism\common\datatypes\QtiShape; +use qtism\common\datatypes\QtiCoords; use qtism\common\datatypes\QtiDatatype; use qtism\data\storage\php\marshalling\PhpQtiDatatypeMarshaller; use \stdClass; @@ -36,11 +36,11 @@ public function testMarshallWrongDataType() { public function marshallDataProvider() { return array( - array("\$array_0 = array(10, 10, 5);\n\$coords_0 = new qtism\\common\\datatypes\\Coords(2, \$array_0);\n", new Coords(Shape::CIRCLE, array(10, 10, 5))), - array("\$pair_0 = new qtism\\common\\datatypes\\Pair(\"A\", \"B\");\n", new Pair('A', 'B')), - array("\$directedpair_0 = new qtism\\common\\datatypes\\DirectedPair(\"A\", \"B\");\n", new DirectedPair('A', 'B')), - array("\$duration_0 = new qtism\\common\\datatypes\\Duration(\"PT30S\");\n", new Duration("PT30S")), - array("\$point_0 = new qtism\\common\\datatypes\\Point(10, 15);\n", new Point(10, 15)) + array("\$array_0 = array(10, 10, 5);\n\$qticoords_0 = new qtism\\common\\datatypes\\QtiCoords(2, \$array_0);\n", new QtiCoords(QtiShape::CIRCLE, array(10, 10, 5))), + array("\$qtipair_0 = new qtism\\common\\datatypes\\QtiPair(\"A\", \"B\");\n", new QtiPair('A', 'B')), + array("\$qtidirectedpair_0 = new qtism\\common\\datatypes\\QtiDirectedPair(\"A\", \"B\");\n", new QtiDirectedPair('A', 'B')), + array("\$qtiduration_0 = new qtism\\common\\datatypes\\QtiDuration(\"PT30S\");\n", new QtiDuration("PT30S")), + array("\$qtipoint_0 = new qtism\\common\\datatypes\\QtiPoint(10, 15);\n", new QtiPoint(10, 15)) ); } } \ No newline at end of file diff --git a/test/qtismtest/data/storage/xml/XmlCompactAssessmentDocumentTest.php b/test/qtismtest/data/storage/xml/XmlCompactAssessmentDocumentTest.php index 1e258371b..4f141d613 100644 --- a/test/qtismtest/data/storage/xml/XmlCompactAssessmentDocumentTest.php +++ b/test/qtismtest/data/storage/xml/XmlCompactAssessmentDocumentTest.php @@ -2,7 +2,7 @@ namespace qtismtest\data\storage\xml; use qtismtest\QtiSmTestCase; -use qtism\common\datatypes\Identifier; +use qtism\common\datatypes\QtiIdentifier; use qtism\data\ShowHide; use qtism\data\storage\xml\XmlCompactDocument; use qtism\data\storage\LocalFileResolver; diff --git a/test/qtismtest/data/storage/xml/marshalling/AreaMapEntryMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/AreaMapEntryMarshallerTest.php index c0928698f..f2fb9c8a4 100644 --- a/test/qtismtest/data/storage/xml/marshalling/AreaMapEntryMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/AreaMapEntryMarshallerTest.php @@ -4,16 +4,16 @@ use qtismtest\QtiSmTestCase; use qtism\data\storage\xml\marshalling\Marshaller; use qtism\data\state\AreaMapEntry; -use qtism\common\datatypes\Shape; -use qtism\common\datatypes\Coords; +use qtism\common\datatypes\QtiShape; +use qtism\common\datatypes\QtiCoords; use \DOMDocument; class AreaMapEntryMarshallerTest extends QtiSmTestCase { public function testMarshall() { $mappedValue = 1.337; - $shape = Shape::RECT; - $coords = new Coords($shape, array(0, 20, 100, 0)); + $shape = QtiShape::RECT; + $coords = new QtiCoords($shape, array(0, 20, 100, 0)); $component = new AreaMapEntry($shape, $coords, $mappedValue); $marshaller = $this->getMarshallerFactory('2.1.0')->createMarshaller($component); @@ -35,9 +35,9 @@ public function testUnmarshall() { $component = $marshaller->unmarshall($element); $this->assertInstanceOf('qtism\\data\\state\\AreaMapEntry', $component); - $this->assertInstanceOf('qtism\\common\\datatypes\\Coords', $component->getCoords()); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiCoords', $component->getCoords()); $this->assertEquals(array(0, 20, 100, 0), $component->getCoords()->getArrayCopy()); - $this->assertEquals(Shape::RECT, $component->getShape()); + $this->assertEquals(QtiShape::RECT, $component->getShape()); $this->assertInternalType('float', $component->getMappedValue()); $this->assertEquals(1.337, $component->getMappedValue()); } diff --git a/test/qtismtest/data/storage/xml/marshalling/AreaMappingMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/AreaMappingMarshallerTest.php index 5c6fafc68..7c03e031b 100644 --- a/test/qtismtest/data/storage/xml/marshalling/AreaMappingMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/AreaMappingMarshallerTest.php @@ -2,8 +2,8 @@ namespace qtismtest\data\storage\xml\marshalling; use qtismtest\QtiSmTestCase; -use qtism\common\datatypes\Coords; -use qtism\common\datatypes\Shape; +use qtism\common\datatypes\QtiCoords; +use qtism\common\datatypes\QtiShape; use qtism\data\storage\xml\marshalling\Marshaller; use qtism\data\state\AreaMapping; use qtism\data\state\AreaMapEntry; @@ -16,8 +16,8 @@ public function testMarshallMinimal() { $defaultValue = 6.66; $areaMapEntries = new AreaMapEntryCollection(); - $shape = Shape::RECT; - $coords = new Coords($shape, array(0, 20, 100, 0)); + $shape = QtiShape::RECT; + $coords = new QtiCoords($shape, array(0, 20, 100, 0)); $mappedValue = 1.377; $areaMapEntries[] = new AreaMapEntry($shape, $coords, $mappedValue); diff --git a/test/qtismtest/data/storage/xml/marshalling/AssessmentItemRefMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/AssessmentItemRefMarshallerTest.php index 02ea939e3..8746e6d4b 100644 --- a/test/qtismtest/data/storage/xml/marshalling/AssessmentItemRefMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/AssessmentItemRefMarshallerTest.php @@ -2,7 +2,7 @@ namespace qtismtest\data\storage\xml\marshalling; use qtismtest\QtiSmTestCase; -use qtism\common\datatypes\Duration; +use qtism\common\datatypes\QtiDuration; use qtism\common\enums\BaseType; use qtism\data\storage\xml\marshalling\Marshaller; use qtism\data\AssessmentItemRef; @@ -55,7 +55,7 @@ public function testMarshallMaximal() { $itemSessionControl = new ItemSessionControl(); $timeLimits = new TimeLimits(); - $timeLimits->setMaxTime(new Duration('PT50S')); // 50 seconds. + $timeLimits->setMaxTime(new QtiDuration('PT50S')); // 50 seconds. $variableMappings = new VariableMappingCollection(); $variableMappings[] = new VariableMapping('var1', 'var2'); diff --git a/test/qtismtest/data/storage/xml/marshalling/AssociableHotspotMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/AssociableHotspotMarshallerTest.php index b5800e016..e27ac88f5 100644 --- a/test/qtismtest/data/storage/xml/marshalling/AssociableHotspotMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/AssociableHotspotMarshallerTest.php @@ -5,15 +5,15 @@ use qtism\data\content\interactions\AssociableHotspot; use qtism\data\ShowHide; use qtism\common\collections\IdentifierCollection; -use qtism\common\datatypes\Coords; -use qtism\common\datatypes\Shape; +use qtism\common\datatypes\QtiCoords; +use qtism\common\datatypes\QtiShape; use \DOMDocument; class AssociableHotspotMarshallerTest extends QtiSmTestCase { public function testMarshall21() { - $shape = Shape::RECT; - $coords = new Coords($shape, array(92, 19, 261, 66)); + $shape = QtiShape::RECT; + $coords = new QtiCoords($shape, array(92, 19, 261, 66)); $matchMax = 2; $matchMin = 1; $fixed = true; @@ -37,8 +37,8 @@ public function testMarshall21() { public function testMarshallNoOutputForDefaultMatchMinFixedShowHide21() { // Aims at testing that fixed, matchMin, showHide attributes are not // in the output if default values are set. - $shape = Shape::RECT; - $coords = new Coords($shape, array(92, 19, 261, 66)); + $shape = QtiShape::RECT; + $coords = new QtiCoords($shape, array(92, 19, 261, 66)); $matchMax = 0; $associableHotspot = new AssociableHotspot('hotspot1', $matchMax, $shape, $coords); @@ -55,8 +55,8 @@ public function testMarshallNoOutputForDefaultMatchMinFixedShowHide21() { public function testMarshallNoOutputForMatchGroup21() { // Aims that testing that matchGroup is never in the output // in a QTI 2.1 context. - $shape = Shape::RECT; - $coords = new Coords($shape, array(92, 19, 261, 66)); + $shape = QtiShape::RECT; + $coords = new QtiCoords($shape, array(92, 19, 261, 66)); $matchMax = 0; $associableHotspot = new AssociableHotspot('hotspot1', $matchMax, $shape, $coords); @@ -78,7 +78,7 @@ public function testUnmarshall21() { $this->assertInstanceOf('qtism\\data\\content\\interactions\\AssociableHotspot', $component); $this->assertEquals('hotspot1', $component->getIdentifier()); - $this->assertEquals(Shape::RECT, $component->getShape()); + $this->assertEquals(QtiShape::RECT, $component->getShape()); $this->assertEquals('92,19,261,66', $component->getCoords()->__toString()); $this->assertTrue($component->isFixed()); $this->assertEquals(ShowHide::HIDE, $component->getShowHide()); @@ -89,8 +89,8 @@ public function testUnmarshall21() { } public function testMarshall20() { - $shape = Shape::RECT; - $coords = new Coords($shape, array(92, 19, 261, 66)); + $shape = QtiShape::RECT; + $coords = new QtiCoords($shape, array(92, 19, 261, 66)); $matchMax = 2; $matchMin = 1; $fixed = true; @@ -109,8 +109,8 @@ public function testMarshall20() { * @depends testMarshall20 */ public function testMarshallMatchGroup20() { - $shape = Shape::RECT; - $coords = new Coords($shape, array(92, 19, 261, 66)); + $shape = QtiShape::RECT; + $coords = new QtiCoords($shape, array(92, 19, 261, 66)); $matchMax = 2; $matchMin = 1; $showHide = ShowHide::HIDE; @@ -137,7 +137,7 @@ public function testUnmarshall20() { $this->assertInstanceOf('qtism\\data\\content\\interactions\\AssociableHotspot', $component); $this->assertEquals('hotspot1', $component->getIdentifier()); - $this->assertEquals(Shape::RECT, $component->getShape()); + $this->assertEquals(QtiShape::RECT, $component->getShape()); $this->assertEquals('92,19,261,66', $component->getCoords()->__toString()); $this->assertTrue($component->isFixed()); $this->assertEquals(0, $component->getMatchMax()); diff --git a/test/qtismtest/data/storage/xml/marshalling/CorrectResponseMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/CorrectResponseMarshallerTest.php index ae8080320..38321346e 100644 --- a/test/qtismtest/data/storage/xml/marshalling/CorrectResponseMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/CorrectResponseMarshallerTest.php @@ -7,14 +7,14 @@ use qtism\data\state\Value; use qtism\data\state\ValueCollection; use qtism\common\enums\BaseType; -use qtism\common\datatypes\Pair; +use qtism\common\datatypes\QtiPair; use \DOMDocument; class CorrectResponseMarshallerTest extends QtiSmTestCase { public function testMarshall() { $interpretation = 'It is up to you to interpret...'; - $pair = new Pair('id1', 'id2'); + $pair = new QtiPair('id1', 'id2'); $values = new ValueCollection(); $values[] = new Value($pair); $component = new CorrectResponse($values, $interpretation); @@ -79,7 +79,7 @@ public function testUnmarshallTwo() { foreach ($component->getValues() as $value) { $this->assertInstanceOf('qtism\\data\\state\\Value', $value); $this->assertEquals(BaseType::DIRECTED_PAIR, $value->getBaseType()); - $this->assertInstanceOf('qtism\\common\\datatypes\\DirectedPair', $value->getValue()); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiDirectedPair', $value->getValue()); $this->assertFalse($value->isPartOfRecord()); } } diff --git a/test/qtismtest/data/storage/xml/marshalling/DefaultValueMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/DefaultValueMarshallerTest.php index e6935a74a..c231532eb 100644 --- a/test/qtismtest/data/storage/xml/marshalling/DefaultValueMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/DefaultValueMarshallerTest.php @@ -7,14 +7,14 @@ use qtism\data\state\Value; use qtism\data\state\ValueCollection; use qtism\common\enums\BaseType; -use qtism\common\datatypes\Pair; +use qtism\common\datatypes\QtiPair; use \DOMDocument; class DefaultValueMarshallerTest extends QtiSmTestCase { public function testMarshall() { $interpretation = 'It is up to you to interpret...'; - $pair = new Pair('id1', 'id2'); + $pair = new QtiPair('id1', 'id2'); $values = new ValueCollection(); $values[] = new Value($pair); $component = new DefaultValue($values, $interpretation); @@ -79,7 +79,7 @@ public function testUnmarshallTwo() { foreach ($component->getValues() as $value) { $this->assertInstanceOf('qtism\\data\\state\\Value', $value); $this->assertEquals(BaseType::DIRECTED_PAIR, $value->getBaseType()); - $this->assertInstanceOf('qtism\\common\\datatypes\\DirectedPair', $value->getValue()); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiDirectedPair', $value->getValue()); $this->assertFalse($value->isPartOfRecord()); } } diff --git a/test/qtismtest/data/storage/xml/marshalling/ExtendedAssessmentTestMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/ExtendedAssessmentTestMarshallerTest.php index e4a2d8b06..cc2cc3bbf 100644 --- a/test/qtismtest/data/storage/xml/marshalling/ExtendedAssessmentTestMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/ExtendedAssessmentTestMarshallerTest.php @@ -31,7 +31,7 @@ use qtism\data\expressions\BaseValue; use qtism\data\rules\PreCondition; use qtism\data\ExtendedAssessmentSection; -use qtism\common\datatypes\Duration; +use qtism\common\datatypes\QtiDuration; use qtism\data\storage\xml\marshalling\CompactMarshallerFactory; use \DOMDocument; @@ -47,7 +47,7 @@ public function testMarshallMaximal() { $itemSessionControl = new ItemSessionControl(); $itemSessionControl->setShowSolution(true); - $timeLimits = new TimeLimits(null, new Duration('PT1M40S')); + $timeLimits = new TimeLimits(null, new QtiDuration('PT1M40S')); $p = new P(); $p->setContent(new InlineCollection(array(new TextRun('Prima!')))); @@ -75,7 +75,7 @@ public function testMarshallMaximal() { $outcomeDeclaration = new OutcomeDeclaration('COUNT', BaseType::INTEGER, Cardinality::SINGLE); $outcomeDeclarations = new OutcomeDeclarationCollection(array($outcomeDeclaration)); - $timeLimits = new TimeLimits(null, new Duration('PT10M')); + $timeLimits = new TimeLimits(null, new QtiDuration('PT10M')); $outcomeRules = new OutcomeRuleCollection(array(new SetOutcomeValue('COUNT', new BaseValue(BaseType::INTEGER, 1)))); $outcomeProcessing = new OutcomeProcessing($outcomeRules); @@ -167,7 +167,7 @@ public function testUnmarshallMaximal() { $this->assertEquals(1, count($testPart->getPreConditions())); $this->assertEquals(1, count($testPart->getBranchRules())); $this->assertTrue($testPart->getItemSessionControl()->mustShowSolution()); - $this->assertTrue($testPart->getTimeLimits()->getMaxTime()->equals(new Duration('PT1M40S'))); + $this->assertTrue($testPart->getTimeLimits()->getMaxTime()->equals(new QtiDuration('PT1M40S'))); $this->assertEquals(1, count($testPart->getTestFeedbacks())); $this->assertEquals(1, count($testPart->getTestFeedbackRefs())); $this->assertEquals(2, count($testPart->getAssessmentSections())); diff --git a/test/qtismtest/data/storage/xml/marshalling/ExtendedTestPartMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/ExtendedTestPartMarshallerTest.php index aacacf73e..42c102683 100644 --- a/test/qtismtest/data/storage/xml/marshalling/ExtendedTestPartMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/ExtendedTestPartMarshallerTest.php @@ -23,7 +23,7 @@ use qtism\data\expressions\BaseValue; use qtism\data\rules\PreCondition; use qtism\data\ExtendedAssessmentSection; -use qtism\common\datatypes\Duration; +use qtism\common\datatypes\QtiDuration; use qtism\data\storage\xml\marshalling\CompactMarshallerFactory; use \DOMDocument; @@ -39,7 +39,7 @@ public function testMarshallMaximal() { $itemSessionControl = new ItemSessionControl(); $itemSessionControl->setShowSolution(true); - $timeLimits = new TimeLimits(null, new Duration('PT1M40S')); + $timeLimits = new TimeLimits(null, new QtiDuration('PT1M40S')); $p = new P(); $p->setContent(new InlineCollection(array(new TextRun('Prima!')))); @@ -102,7 +102,7 @@ public function testUnmarshallMaximal() { $this->assertEquals(1, count($component->getPreConditions())); $this->assertEquals(1, count($component->getBranchRules())); $this->assertTrue($component->getItemSessionControl()->mustShowSolution()); - $this->assertTrue($component->getTimeLimits()->getMaxTime()->equals(new Duration('PT1M40S'))); + $this->assertTrue($component->getTimeLimits()->getMaxTime()->equals(new QtiDuration('PT1M40S'))); $this->assertEquals(1, count($component->getTestFeedbacks())); $this->assertEquals(1, count($component->getTestFeedbackRefs())); $this->assertEquals(2, count($component->getAssessmentSections())); diff --git a/test/qtismtest/data/storage/xml/marshalling/GraphicAssociateInteractionMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/GraphicAssociateInteractionMarshallerTest.php index ac4e05be8..73b878fe6 100644 --- a/test/qtismtest/data/storage/xml/marshalling/GraphicAssociateInteractionMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/GraphicAssociateInteractionMarshallerTest.php @@ -5,8 +5,8 @@ use qtism\data\content\FlowStaticCollection; use qtism\data\content\interactions\GraphicAssociateInteraction; use qtism\data\content\interactions\AssociableHotspotCollection; -use qtism\common\datatypes\Coords; -use qtism\common\datatypes\Shape; +use qtism\common\datatypes\QtiCoords; +use qtism\common\datatypes\QtiShape; use qtism\data\content\interactions\AssociableHotspot; use qtism\data\content\xhtml\Object; use qtism\data\content\TextRun; @@ -23,10 +23,10 @@ public function testMarshall21() { $object = new Object('myimg.png', 'image/png'); - $choice1 = new AssociableHotspot('choice1', 2, Shape::CIRCLE, new Coords(Shape::CIRCLE, array(0, 0, 15))); + $choice1 = new AssociableHotspot('choice1', 2, QtiShape::CIRCLE, new QtiCoords(QtiShape::CIRCLE, array(0, 0, 15))); $choice1->setMatchMin(1); - $choice2 = new AssociableHotspot('choice2', 1, Shape::CIRCLE, new Coords(Shape::CIRCLE, array(2, 2, 15))); - $choice3 = new AssociableHotspot('choice3', 1, Shape::CIRCLE, new Coords(Shape::CIRCLE, array(4, 4, 15))); + $choice2 = new AssociableHotspot('choice2', 1, QtiShape::CIRCLE, new QtiCoords(QtiShape::CIRCLE, array(2, 2, 15))); + $choice3 = new AssociableHotspot('choice3', 1, QtiShape::CIRCLE, new QtiCoords(QtiShape::CIRCLE, array(4, 4, 15))); $choices = new AssociableHotspotCollection(array($choice1, $choice2, $choice3)); $graphicAssociateInteraction = new GraphicAssociateInteraction('RESPONSE', $object, $choices, 'prout'); @@ -49,10 +49,10 @@ public function testMarshall20() { // Make sure that maxAssociations is always in the output but never minAssociations. $object = new Object('myimg.png', 'image/png'); - $choice1 = new AssociableHotspot('choice1', 2, Shape::CIRCLE, new Coords(Shape::CIRCLE, array(0, 0, 15))); + $choice1 = new AssociableHotspot('choice1', 2, QtiShape::CIRCLE, new QtiCoords(QtiShape::CIRCLE, array(0, 0, 15))); $choice1->setMatchMin(1); - $choice2 = new AssociableHotspot('choice2', 1, Shape::CIRCLE, new Coords(Shape::CIRCLE, array(2, 2, 15))); - $choice3 = new AssociableHotspot('choice3', 1, Shape::CIRCLE, new Coords(Shape::CIRCLE, array(4, 4, 15))); + $choice2 = new AssociableHotspot('choice2', 1, QtiShape::CIRCLE, new QtiCoords(QtiShape::CIRCLE, array(2, 2, 15))); + $choice3 = new AssociableHotspot('choice3', 1, QtiShape::CIRCLE, new QtiCoords(QtiShape::CIRCLE, array(4, 4, 15))); $choices = new AssociableHotspotCollection(array($choice1, $choice2, $choice3)); $graphicAssociateInteraction = new GraphicAssociateInteraction('RESPONSE', $object, $choices); @@ -99,20 +99,20 @@ public function testUnmarshall21() { $this->assertEquals('choice1', $choices[0]->getIdentifier()); $this->assertEquals(2, $choices[0]->getMatchMax()); $this->assertEquals(1, $choices[0]->getMatchMin()); - $this->assertEquals(Shape::CIRCLE, $choices[0]->getShape()); - $this->assertTrue($choices[0]->getCoords()->equals(new Coords(Shape::CIRCLE, array(0, 0, 15)))); + $this->assertEquals(QtiShape::CIRCLE, $choices[0]->getShape()); + $this->assertTrue($choices[0]->getCoords()->equals(new QtiCoords(QtiShape::CIRCLE, array(0, 0, 15)))); $this->assertEquals('choice2', $choices[1]->getIdentifier()); $this->assertEquals(1, $choices[1]->getMatchMax()); $this->assertEquals(0, $choices[1]->getMatchMin()); - $this->assertEquals(Shape::CIRCLE, $choices[1]->getShape()); - $this->assertTrue($choices[1]->getCoords()->equals(new Coords(Shape::CIRCLE, array(2, 2, 15)))); + $this->assertEquals(QtiShape::CIRCLE, $choices[1]->getShape()); + $this->assertTrue($choices[1]->getCoords()->equals(new QtiCoords(QtiShape::CIRCLE, array(2, 2, 15)))); $this->assertEquals('choice3', $choices[2]->getIdentifier()); $this->assertEquals(1, $choices[2]->getMatchMax()); $this->assertEquals(0, $choices[2]->getMatchMin()); - $this->assertEquals(Shape::CIRCLE, $choices[2]->getShape()); - $this->assertTrue($choices[2]->getCoords()->equals(new Coords(Shape::CIRCLE, array(4, 4, 15)))); + $this->assertEquals(QtiShape::CIRCLE, $choices[2]->getShape()); + $this->assertTrue($choices[2]->getCoords()->equals(new QtiCoords(QtiShape::CIRCLE, array(4, 4, 15)))); } public function testUnmarshall20() { diff --git a/test/qtismtest/data/storage/xml/marshalling/GraphicGapMatchInteractionMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/GraphicGapMatchInteractionMarshallerTest.php index e542f1795..23c234ddf 100644 --- a/test/qtismtest/data/storage/xml/marshalling/GraphicGapMatchInteractionMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/GraphicGapMatchInteractionMarshallerTest.php @@ -5,8 +5,8 @@ use qtism\data\content\FlowStaticCollection; use qtism\data\content\interactions\GraphicGapMatchInteraction; use qtism\data\content\interactions\AssociableHotspotCollection; -use qtism\common\datatypes\Coords; -use qtism\common\datatypes\Shape; +use qtism\common\datatypes\QtiCoords; +use qtism\common\datatypes\QtiShape; use qtism\data\content\interactions\AssociableHotspot; use qtism\data\content\interactions\GapImgCollection; use qtism\data\content\interactions\GapImg; @@ -33,9 +33,9 @@ public function testMarshall() { $gapImg3 = new GapImg('gapImg3', 1, $img3); $gapImgs = new GapImgCollection(array($gapImg1, $gapImg2, $gapImg3)); - $choice1 = new AssociableHotspot('choice1', 1, Shape::CIRCLE, new Coords(Shape::CIRCLE, array(0, 0, 15))); - $choice2 = new AssociableHotspot('choice2', 1, Shape::CIRCLE, new Coords(Shape::CIRCLE, array(2, 2, 15))); - $choice3 = new AssociableHotspot('choice3', 1, Shape::CIRCLE, new Coords(Shape::CIRCLE, array(4, 4, 15))); + $choice1 = new AssociableHotspot('choice1', 1, QtiShape::CIRCLE, new QtiCoords(QtiShape::CIRCLE, array(0, 0, 15))); + $choice2 = new AssociableHotspot('choice2', 1, QtiShape::CIRCLE, new QtiCoords(QtiShape::CIRCLE, array(2, 2, 15))); + $choice3 = new AssociableHotspot('choice3', 1, QtiShape::CIRCLE, new QtiCoords(QtiShape::CIRCLE, array(4, 4, 15))); $choices = new AssociableHotspotCollection(array($choice1, $choice2, $choice3)); $graphicGapMatchInteraction = new GraphicGapMatchInteraction('RESPONSE', $object, $gapImgs, $choices, 'my-gaps'); diff --git a/test/qtismtest/data/storage/xml/marshalling/GraphicOrderInteractionMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/GraphicOrderInteractionMarshallerTest.php index 73489f7d5..2c0ab7e4a 100644 --- a/test/qtismtest/data/storage/xml/marshalling/GraphicOrderInteractionMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/GraphicOrderInteractionMarshallerTest.php @@ -6,8 +6,8 @@ use qtism\data\content\xhtml\Object; use qtism\data\content\interactions\GraphicOrderInteraction; use qtism\data\content\interactions\HotspotChoiceCollection; -use qtism\common\datatypes\Coords; -use qtism\common\datatypes\Shape; +use qtism\common\datatypes\QtiCoords; +use qtism\common\datatypes\QtiShape; use qtism\data\content\interactions\HotspotChoice; use qtism\data\content\TextRun; use qtism\data\content\InlineStaticCollection; @@ -21,9 +21,9 @@ public function testMarshall21() { $prompt = new Prompt(); $prompt->setContent(new FlowStaticCollection(array(new TextRun('Prompt...')))); - $choice1 = new HotspotChoice('choice1', Shape::CIRCLE, new Coords(Shape::CIRCLE, array(0, 0, 15))); - $choice2 = new HotspotChoice('choice2', Shape::CIRCLE, new Coords(Shape::CIRCLE, array(2, 2, 15))); - $choice3 = new HotspotChoice('choice3', Shape::CIRCLE, new Coords(Shape::CIRCLE, array(4, 4, 15))); + $choice1 = new HotspotChoice('choice1', QtiShape::CIRCLE, new QtiCoords(QtiShape::CIRCLE, array(0, 0, 15))); + $choice2 = new HotspotChoice('choice2', QtiShape::CIRCLE, new QtiCoords(QtiShape::CIRCLE, array(2, 2, 15))); + $choice3 = new HotspotChoice('choice3', QtiShape::CIRCLE, new QtiCoords(QtiShape::CIRCLE, array(4, 4, 15))); $choices = new HotspotChoiceCollection(array($choice1, $choice2, $choice3)); $object = new Object('my-img.png', 'image/png'); @@ -46,9 +46,9 @@ public function testMarshall21() { public function testMarshall20() { // make sure minChoices and maxChoices attributes // are not in the output in a QTI 2.0 context. - $choice1 = new HotspotChoice('choice1', Shape::CIRCLE, new Coords(Shape::CIRCLE, array(0, 0, 15))); - $choice2 = new HotspotChoice('choice2', Shape::CIRCLE, new Coords(Shape::CIRCLE, array(2, 2, 15))); - $choice3 = new HotspotChoice('choice3', Shape::CIRCLE, new Coords(Shape::CIRCLE, array(4, 4, 15))); + $choice1 = new HotspotChoice('choice1', QtiShape::CIRCLE, new QtiCoords(QtiShape::CIRCLE, array(0, 0, 15))); + $choice2 = new HotspotChoice('choice2', QtiShape::CIRCLE, new QtiCoords(QtiShape::CIRCLE, array(2, 2, 15))); + $choice3 = new HotspotChoice('choice3', QtiShape::CIRCLE, new QtiCoords(QtiShape::CIRCLE, array(4, 4, 15))); $choices = new HotspotChoiceCollection(array($choice1, $choice2, $choice3)); $object = new Object('my-img.png', 'image/png'); diff --git a/test/qtismtest/data/storage/xml/marshalling/HotspotChoiceMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/HotspotChoiceMarshallerTest.php index d7fb91ee4..16c0fbf4e 100644 --- a/test/qtismtest/data/storage/xml/marshalling/HotspotChoiceMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/HotspotChoiceMarshallerTest.php @@ -4,16 +4,16 @@ use qtismtest\QtiSmTestCase; use qtism\data\ShowHide; use qtism\data\content\interactions\HotspotChoice; -use qtism\common\datatypes\Coords; -use qtism\common\datatypes\Shape; +use qtism\common\datatypes\QtiCoords; +use qtism\common\datatypes\QtiShape; use \DOMDocument; class HotspotChoiceMarshallerTest extends QtiSmTestCase { public function testMarshall() { - $shape = Shape::CIRCLE; - $coords = new Coords($shape, array(0, 0, 5)); + $shape = QtiShape::CIRCLE; + $coords = new QtiCoords($shape, array(0, 0, 5)); $hotspotLabel = "This is a circle."; $hotspotChoice = new HotspotChoice('hotspotchoice1', $shape, $coords, 'my-hotspotchoice'); $hotspotChoice->setFixed(true); @@ -39,7 +39,7 @@ public function testUnmarshall() { $this->assertInstanceOf('qtism\\data\\content\\interactions\\Choice', $component); $this->assertEquals('hotspotchoice1', $component->getIdentifier()); - $this->assertEquals(Shape::CIRCLE, $component->getShape()); + $this->assertEquals(QtiShape::CIRCLE, $component->getShape()); $this->assertEquals('0,0,5', $component->getCoords()->__toString()); $this->assertTrue($component->isFixed()); $this->assertEquals('mytpl1', $component->getTemplateIdentifier()); @@ -60,7 +60,7 @@ public function testUnmarshallFloatCoords() { $this->assertInstanceOf('qtism\\data\\content\\interactions\\HotspotChoice', $component); $this->assertEquals('r_50', $component->getIdentifier()); $this->assertFalse($component->isFixed()); - $this->assertEquals(Shape::CIRCLE, $component->getShape()); - $this->assertTrue($component->getCoords()->equals(new Coords(Shape::CIRCLE, array(128, 222, 18)))); + $this->assertEquals(QtiShape::CIRCLE, $component->getShape()); + $this->assertTrue($component->getCoords()->equals(new QtiCoords(QtiShape::CIRCLE, array(128, 222, 18)))); } } \ No newline at end of file diff --git a/test/qtismtest/data/storage/xml/marshalling/HotspotInteractionMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/HotspotInteractionMarshallerTest.php index 0907be960..a7971dbe9 100644 --- a/test/qtismtest/data/storage/xml/marshalling/HotspotInteractionMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/HotspotInteractionMarshallerTest.php @@ -3,10 +3,10 @@ use qtismtest\QtiSmTestCase; use qtism\data\content\FlowStaticCollection; -use qtism\common\datatypes\Coords; +use qtism\common\datatypes\QtiCoords; use qtism\data\content\interactions\HotspotInteraction; use qtism\data\content\xhtml\Object; -use qtism\common\datatypes\Shape; +use qtism\common\datatypes\QtiShape; use qtism\data\content\interactions\HotspotChoice; use qtism\data\content\interactions\HotspotChoiceCollection; use qtism\data\content\TextRun; @@ -20,9 +20,9 @@ public function testMarshall21() { $prompt = new Prompt(); $prompt->setContent(new FlowStaticCollection(array(new TextRun('Prompt...')))); - $choice1 = new HotspotChoice('hotspotchoice1', Shape::CIRCLE, new Coords(Shape::CIRCLE, array(77, 115, 8))); - $choice2 = new HotspotChoice('hotspotchoice2', Shape::CIRCLE, new Coords(Shape::CIRCLE, array(118, 184, 8))); - $choice3 = new HotspotChoice('hotspotchoice3', Shape::CIRCLE, new Coords(Shape::CIRCLE, array(150, 235, 8))); + $choice1 = new HotspotChoice('hotspotchoice1', QtiShape::CIRCLE, new QtiCoords(QtiShape::CIRCLE, array(77, 115, 8))); + $choice2 = new HotspotChoice('hotspotchoice2', QtiShape::CIRCLE, new QtiCoords(QtiShape::CIRCLE, array(118, 184, 8))); + $choice3 = new HotspotChoice('hotspotchoice3', QtiShape::CIRCLE, new QtiCoords(QtiShape::CIRCLE, array(150, 235, 8))); $object = new Object('./img/img.png', 'image/png'); $hotspotInteraction = new HotspotInteraction('RESPONSE', $object, 1, new HotspotChoiceCollection(array($choice1, $choice2, $choice3)), 'my-hotspot'); @@ -42,7 +42,7 @@ public function testMarshall21() { */ public function testMarshall20() { // minChoices must be ignored. - $choice1 = new HotspotChoice('hotspotchoice1', Shape::CIRCLE, new Coords(Shape::CIRCLE, array(77, 115, 8))); + $choice1 = new HotspotChoice('hotspotchoice1', QtiShape::CIRCLE, new QtiCoords(QtiShape::CIRCLE, array(77, 115, 8))); $object = new Object('./img/img.png', 'image/png'); $hotspotInteraction = new HotspotInteraction('RESPONSE', $object, 1, new HotspotChoiceCollection(array($choice1))); diff --git a/test/qtismtest/data/storage/xml/marshalling/InsideMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/InsideMarshallerTest.php index fa99953e0..104668c9a 100644 --- a/test/qtismtest/data/storage/xml/marshalling/InsideMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/InsideMarshallerTest.php @@ -5,8 +5,8 @@ use qtism\data\storage\xml\marshalling\Marshaller; use qtism\data\expressions\ExpressionCollection; use qtism\data\expressions\operators\Inside; -use qtism\common\datatypes\Shape; -use qtism\common\datatypes\Coords; +use qtism\common\datatypes\QtiShape; +use qtism\common\datatypes\QtiCoords; use qtism\data\expressions\Variable; use \DOMDocument; @@ -17,8 +17,8 @@ public function testMarshall() { $subs = new ExpressionCollection(); $subs[] = new Variable('pointVariable'); - $shape = Shape::RECT; - $coords = new Coords($shape, array(0, 0, 100, 20)); + $shape = QtiShape::RECT; + $coords = new QtiCoords($shape, array(0, 0, 100, 20)); $component = new Inside($subs, $shape, $coords); $marshaller = $this->getMarshallerFactory('2.1.0')->createMarshaller($component); @@ -46,9 +46,9 @@ public function testUnmarshall() { $component = $marshaller->unmarshall($element); $this->assertInstanceOf('qtism\\data\\expressions\\operators\\Inside', $component); - $this->assertInstanceOf('qtism\\common\\datatypes\\Coords', $component->getCoords()); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiCoords', $component->getCoords()); $this->assertInternalType('integer', $component->getShape()); - $this->assertEquals(Shape::RECT, $component->getShape()); + $this->assertEquals(QtiShape::RECT, $component->getShape()); $this->assertEquals(1, count($component->getExpressions())); } } \ No newline at end of file diff --git a/test/qtismtest/data/storage/xml/marshalling/MatchTableMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/MatchTableMarshallerTest.php index f6e62071e..063f33d13 100644 --- a/test/qtismtest/data/storage/xml/marshalling/MatchTableMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/MatchTableMarshallerTest.php @@ -8,7 +8,7 @@ use qtism\data\state\MatchTableEntryCollection; use qtism\common\enums\BaseType; use qtism\data\state\Value; -use qtism\common\datatypes\Pair; +use qtism\common\datatypes\QtiPair; use \DOMDocument; class MatchTableMarshallerTest extends QtiSmTestCase { @@ -16,8 +16,8 @@ class MatchTableMarshallerTest extends QtiSmTestCase { public function testMarshall() { $matchTableEntryCollection = new MatchTableEntryCollection(); - $matchTableEntryCollection[] = new MatchTableEntry(1, new Pair('A', 'B')); - $matchTableEntryCollection[] = new MatchTableEntry(2, new Pair('A', 'C')); + $matchTableEntryCollection[] = new MatchTableEntry(1, new QtiPair('A', 'B')); + $matchTableEntryCollection[] = new MatchTableEntry(2, new QtiPair('A', 'C')); $component = new MatchTable($matchTableEntryCollection); $marshaller = $this->getMarshallerFactory('2.1.0')->createMarshaller($component, array(BaseType::PAIR)); @@ -55,6 +55,6 @@ public function testUnmarshall() { $entry = $matchTableEntries[0]; $this->assertInstanceOf('qtism\\data\\state\\MatchTableEntry', $entry); $this->assertEquals(1, $entry->getSourceValue()); - $this->assertInstanceOf('qtism\\common\\datatypes\\DirectedPair', $entry->getTargetValue()); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiDirectedPair', $entry->getTargetValue()); } } \ No newline at end of file diff --git a/test/qtismtest/data/storage/xml/marshalling/OutcomeDeclarationMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/OutcomeDeclarationMarshallerTest.php index e0dba36ec..1bcb7f14a 100644 --- a/test/qtismtest/data/storage/xml/marshalling/OutcomeDeclarationMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/OutcomeDeclarationMarshallerTest.php @@ -4,7 +4,7 @@ use qtism\data\View; use qtism\data\ViewCollection; use qtismtest\QtiSmTestCase; -use qtism\common\datatypes\Duration; +use qtism\common\datatypes\QtiDuration; use qtism\data\storage\xml\marshalling\Marshaller; use qtism\data\state\OutcomeDeclaration; use qtism\common\enums\Cardinality; @@ -211,10 +211,10 @@ public function testUnmarshallDefaultValue21() { $this->assertEquals(2, count($values)); $this->assertInstanceOf('qtism\\data\\state\\Value', $values[0]); - $this->assertInstanceOf('qtism\\common\\datatypes\\Duration', $values[0]->getValue()); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiDuration', $values[0]->getValue()); $this->assertInstanceOf('qtism\\data\\state\\Value', $values[1]); - $this->assertInstanceOf('qtism\\common\\datatypes\\Duration', $values[1]->getValue()); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiDuration', $values[1]->getValue()); } public function testUnmarshallRecord21() { @@ -253,7 +253,7 @@ public function testUnmarshallRecord21() { $this->assertTrue($values[0]->hasBaseType()); $this->assertEquals('A', $values[0]->getFieldIdentifier()); $this->assertEquals(BaseType::DURATION, $values[0]->getBaseType()); - $this->assertTrue($values[0]->getValue()->equals(new Duration('P2D'))); + $this->assertTrue($values[0]->getValue()->equals(new QtiDuration('P2D'))); $this->assertInstanceOf('qtism\\data\\state\\Value', $values[1]); $this->assertTrue($values[1]->hasFieldIdentifier()); diff --git a/test/qtismtest/data/storage/xml/marshalling/PositionObjectInteractionMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/PositionObjectInteractionMarshallerTest.php index b304c5941..b1fa8dd4a 100644 --- a/test/qtismtest/data/storage/xml/marshalling/PositionObjectInteractionMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/PositionObjectInteractionMarshallerTest.php @@ -3,7 +3,7 @@ use qtismtest\QtiSmTestCase; use qtism\data\content\FlowStaticCollection; -use qtism\common\datatypes\Point; +use qtism\common\datatypes\QtiPoint; use qtism\data\content\interactions\PositionObjectInteraction; use qtism\data\content\TextRun; use qtism\data\content\InlineStaticCollection; @@ -23,7 +23,7 @@ public function testMarshall21() { $prompt->setContent(new FlowStaticCollection(array(new TextRun('Prompt...')))); $positionObjectInteraction = new PositionObjectInteraction('RESPONSE', $object, 'my-pos'); - $positionObjectInteraction->setCenterPoint(new Point(150, 74)); + $positionObjectInteraction->setCenterPoint(new QtiPoint(150, 74)); $positionObjectInteraction->setMaxChoices(2); $positionObjectInteraction->setMinChoices(1); @@ -66,7 +66,7 @@ public function testUnmarshall21() { $this->assertEquals('RESPONSE', $component->getResponseIdentifier()); $this->assertEquals(2, $component->getMaxChoices()); $this->assertEquals(1, $component->getMinChoices()); - $this->assertTrue($component->getCenterPoint()->equals(new Point(150, 74))); + $this->assertTrue($component->getCenterPoint()->equals(new QtiPoint(150, 74))); $this->assertEquals('my-pos', $component->getId()); $this->assertEquals('myimg.jpg', $component->getObject()->getData()); diff --git a/test/qtismtest/data/storage/xml/marshalling/PositionObjectStageMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/PositionObjectStageMarshallerTest.php index 3e456600a..09f991381 100644 --- a/test/qtismtest/data/storage/xml/marshalling/PositionObjectStageMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/PositionObjectStageMarshallerTest.php @@ -4,7 +4,7 @@ use qtismtest\QtiSmTestCase; use qtism\data\content\interactions\PositionObjectInteractionCollection; use qtism\data\content\interactions\PositionObjectStage; -use qtism\common\datatypes\Point; +use qtism\common\datatypes\QtiPoint; use qtism\data\content\interactions\PositionObjectInteraction; use qtism\data\content\xhtml\Object; use \DOMDocument; @@ -17,7 +17,7 @@ public function testMarshall() { $interactionObject->setWidth(16); $interaction = new PositionObjectInteraction('RESPONSE', $interactionObject); - $interaction->setCenterPoint(new Point(8, 8)); + $interaction->setCenterPoint(new QtiPoint(8, 8)); $stageObject = new Object('country.jpg', 'image/jpeg'); $positionObjectStage = new PositionObjectStage($stageObject, new PositionObjectInteractionCollection(array($interaction))); @@ -52,7 +52,7 @@ public function testUnmarshall() { $interaction = $interactions[0]; $this->assertEquals('RESPONSE', $interaction->getResponseIdentifier()); $this->assertEquals(1, $interaction->getMaxChoices()); - $this->assertTrue($interaction->getCenterPoint()->equals(new Point(8, 8))); + $this->assertTrue($interaction->getCenterPoint()->equals(new QtiPoint(8, 8))); $interactionObject = $interaction->getObject(); $this->assertEquals('airplane.jpg', $interactionObject->getData()); diff --git a/test/qtismtest/data/storage/xml/marshalling/Qti21MarshallerFactoryTest.php b/test/qtismtest/data/storage/xml/marshalling/Qti21MarshallerFactoryTest.php index 8fecb1f7a..0b31d8cdc 100644 --- a/test/qtismtest/data/storage/xml/marshalling/Qti21MarshallerFactoryTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/Qti21MarshallerFactoryTest.php @@ -2,8 +2,8 @@ namespace qtismtest\data\storage\xml\marshalling; use qtismtest\QtiSmTestCase; -use qtism\common\datatypes\Coords; -use qtism\common\datatypes\Shape; +use qtism\common\datatypes\QtiCoords; +use qtism\common\datatypes\QtiShape; use qtism\data\state\AreaMapEntry; use qtism\data\storage\xml\marshalling\Marshaller; use qtism\data\storage\xml\marshalling\Qti21MarshallerFactory; @@ -23,8 +23,8 @@ public function testFromDomElement() { } public function testFromQtiComponent() { - $shape = Shape::RECT; - $coords = new Coords($shape, array(0, 20, 100, 0)); + $shape = QtiShape::RECT; + $coords = new QtiCoords($shape, array(0, 20, 100, 0)); $component = new AreaMapEntry($shape, $coords, 1.337); $factory = new Qti21MarshallerFactory(); diff --git a/test/qtismtest/data/storage/xml/marshalling/ResponseDeclarationMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/ResponseDeclarationMarshallerTest.php index 809c575ca..c02bde162 100644 --- a/test/qtismtest/data/storage/xml/marshalling/ResponseDeclarationMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/ResponseDeclarationMarshallerTest.php @@ -6,7 +6,7 @@ use qtism\data\state\MapEntry; use qtism\data\state\Mapping; use qtism\data\state\CorrectResponse; -use qtism\common\datatypes\Duration; +use qtism\common\datatypes\QtiDuration; use qtism\data\storage\xml\marshalling\Marshaller; use qtism\data\state\ResponseDeclaration; use qtism\common\enums\Cardinality; @@ -162,10 +162,10 @@ public function testUnmarshallCorrectResponse() { $this->assertEquals(2, count($values)); $this->assertInstanceOf('qtism\\data\\state\\Value', $values[0]); - $this->assertInstanceOf('qtism\\common\\datatypes\\Duration', $values[0]->getValue()); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiDuration', $values[0]->getValue()); $this->assertInstanceOf('qtism\\data\\state\\Value', $values[1]); - $this->assertInstanceOf('qtism\\common\\datatypes\\Duration', $values[1]->getValue()); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiDuration', $values[1]->getValue()); } public function testUnmarshallMatchTable() { diff --git a/test/qtismtest/data/storage/xml/marshalling/TimeLimitsMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/TimeLimitsMarshallerTest.php index c79bac141..41b3c7be2 100644 --- a/test/qtismtest/data/storage/xml/marshalling/TimeLimitsMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/TimeLimitsMarshallerTest.php @@ -4,15 +4,15 @@ use qtismtest\QtiSmTestCase; use qtism\data\storage\xml\marshalling\Marshaller; use qtism\data\TimeLimits; -use qtism\common\datatypes\Duration; +use qtism\common\datatypes\QtiDuration; use \DOMDocument; class TimeLimitsMarshallerTest extends QtiSmTestCase { public function testMarshall() { - $minTime = new Duration('PT50S'); - $maxTime = new Duration('PT100S'); + $minTime = new QtiDuration('PT50S'); + $maxTime = new QtiDuration('PT100S'); $component = new TimeLimits($minTime, $maxTime); $marshaller = $this->getMarshallerFactory('2.1.0')->createMarshaller($component); diff --git a/test/qtismtest/data/storage/xml/marshalling/ValueMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/ValueMarshallerTest.php index 3fe2a8fb2..8d3f8d139 100644 --- a/test/qtismtest/data/storage/xml/marshalling/ValueMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/ValueMarshallerTest.php @@ -5,7 +5,7 @@ use qtism\data\storage\xml\marshalling\Marshaller; use qtism\data\state\Value; use qtism\common\enums\BaseType; -use qtism\common\datatypes\Pair; +use qtism\common\datatypes\QtiPair; use \DOMDocument; class ValueMarshallerTest extends QtiSmTestCase { @@ -44,7 +44,7 @@ public function testMarshallBaseTypeBoolean() { public function testMarshallNoBaseType() { - $value = new Pair('id1', 'id2'); + $value = new QtiPair('id1', 'id2'); $component = new Value($value); $marshaller = $this->getMarshallerFactory('2.1.0')->createMarshaller($component); @@ -77,7 +77,7 @@ public function testUnmarshallNoBaseTypeButForced() { $component = $marshaller->unmarshall($element); $this->assertInstanceOf('qtism\\data\\state\\Value', $component); - $this->assertInstanceOf('qtism\\common\\datatypes\\Pair', $component->getValue()); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiPair', $component->getValue()); $this->assertEquals($component->getValue()->getFirst(), 'A'); $this->assertEquals($component->getValue()->getSecond(), 'B'); } @@ -126,7 +126,7 @@ public function testUnmarshallBaseType() { $component = $marshaller->unmarshall($element); $this->assertInstanceOf('qtism\\data\\state\\Value', $component); - $this->assertInstanceOf('qtism\\common\\datatypes\\Pair', $component->getValue()); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiPair', $component->getValue()); $this->assertEquals($component->getValue()->getFirst(), 'A'); $this->assertEquals($component->getValue()->getSecond(), 'B'); $this->assertEquals($component->getFieldIdentifier(), 'fieldIdentifier1'); diff --git a/test/qtismtest/runtime/common/MultipleContainerTest.php b/test/qtismtest/runtime/common/MultipleContainerTest.php index a83b1cb12..24ef2cb68 100644 --- a/test/qtismtest/runtime/common/MultipleContainerTest.php +++ b/test/qtismtest/runtime/common/MultipleContainerTest.php @@ -2,11 +2,11 @@ namespace qtismtest\runtime\common; use qtismtest\QtiSmTestCase; -use qtism\common\datatypes\Float; -use qtism\common\datatypes\Integer; +use qtism\common\datatypes\QtiFloat; +use qtism\common\datatypes\QtiInteger; use qtism\data\state\ValueCollection; use qtism\data\state\Value; -use qtism\common\datatypes\Point; +use qtism\common\datatypes\QtiPoint; use qtism\common\enums\Cardinality; use qtism\runtime\common\MultipleContainer; use qtism\common\enums\BaseType; @@ -21,7 +21,7 @@ public function testCreationEmpty() { } public function testCreationWithValues() { - $data = array(new Integer(10), new Integer(20), new Integer(20), new Integer(30), new Integer(40), new Integer(50)); + $data = array(new QtiInteger(10), new QtiInteger(20), new QtiInteger(20), new QtiInteger(30), new QtiInteger(40), new QtiInteger(50)); $container = new MultipleContainer(BaseType::INTEGER, $data); $this->assertEquals(6, count($container)); $this->assertEquals(BaseType::INTEGER, $container->getBaseType()); @@ -41,14 +41,14 @@ public function testCreationEmptyWrongBaseType2() { public function testCreationWithWrongValues() { $this->setExpectedException('\\InvalidArgumentException'); - $data = array(new Point(20, 20)); + $data = array(new QtiPoint(20, 20)); $container = new MultipleContainer(BaseType::DURATION, $data); } public function testCreateFromDataModel() { $valueCollection = new ValueCollection(); - $valueCollection[] = new Value(new Point(10, 30), BaseType::POINT); - $valueCollection[] = new Value(new Point(20, 40), BaseType::POINT); + $valueCollection[] = new Value(new QtiPoint(10, 30), BaseType::POINT); + $valueCollection[] = new Value(new QtiPoint(20, 40), BaseType::POINT); $container = MultipleContainer::createFromDataModel($valueCollection, BaseType::POINT); $this->assertInstanceOf('qtism\\runtime\\common\\MultipleContainer', $container); @@ -79,7 +79,7 @@ public function invalidCreateFromDataModelProvider() { $returnValue = array(); $valueCollection = new ValueCollection(); - $valueCollection[] = new Value(new Point(20, 30), BaseType::POINT); + $valueCollection[] = new Value(new QtiPoint(20, 30), BaseType::POINT); $valueCollection[] = new Value(10, BaseType::INTEGER); $returnValue[] = array(BaseType::INTEGER, $valueCollection); @@ -101,14 +101,14 @@ public function validCreateFromDataModelProvider() { } public function testEquals() { - $c1 = new MultipleContainer(BaseType::INTEGER, array(new Integer(5), new Integer(4), new Integer(3), new Integer(2), new Integer(1))); - $c2 = new MultipleContainer(BaseType::INTEGER, array(new Integer(1), new Integer(6), new Integer(7), new Integer(8), new Integer(5))); + $c1 = new MultipleContainer(BaseType::INTEGER, array(new QtiInteger(5), new QtiInteger(4), new QtiInteger(3), new QtiInteger(2), new QtiInteger(1))); + $c2 = new MultipleContainer(BaseType::INTEGER, array(new QtiInteger(1), new QtiInteger(6), new QtiInteger(7), new QtiInteger(8), new QtiInteger(5))); $this->assertFalse($c1->equals($c2)); } public function testEqualsTwo() { - $c1 = new MultipleContainer(BaseType::FLOAT, array(new Float(2.75), new Float(1.65))); - $c2 = new MultipleContainer(BaseType::FLOAT, array(new Float(2.75), new Float(1.65))); + $c1 = new MultipleContainer(BaseType::FLOAT, array(new QtiFloat(2.75), new QtiFloat(1.65))); + $c2 = new MultipleContainer(BaseType::FLOAT, array(new QtiFloat(2.75), new QtiFloat(1.65))); $this->assertTrue($c1->equals($c2)); } } \ No newline at end of file diff --git a/test/qtismtest/runtime/common/OrderedContainerTest.php b/test/qtismtest/runtime/common/OrderedContainerTest.php index de74cfbe4..29c5f7dce 100644 --- a/test/qtismtest/runtime/common/OrderedContainerTest.php +++ b/test/qtismtest/runtime/common/OrderedContainerTest.php @@ -2,13 +2,13 @@ namespace qtismtest\runtime\common; use qtismtest\QtiSmTestCase; -use qtism\common\datatypes\Uri; -use qtism\common\datatypes\Integer; +use qtism\common\datatypes\QtiUri; +use qtism\common\datatypes\QtiInteger; use qtism\common\enums\Cardinality; use qtism\runtime\common\OrderedContainer; -use qtism\common\datatypes\Point; -use qtism\common\datatypes\Pair; -use qtism\common\datatypes\DirectedPair; +use qtism\common\datatypes\QtiPoint; +use qtism\common\datatypes\QtiPair; +use qtism\common\datatypes\QtiDirectedPair; use qtism\runtime\common\MultipleContainer; use qtism\common\enums\BaseType; @@ -40,17 +40,17 @@ public function testCreationEmpty() { public function equalsValidProvider() { return array( array(new OrderedContainer(BaseType::INTEGER), new OrderedContainer(BaseType::INTEGER)), - array(new OrderedContainer(BaseType::INTEGER, array(new Integer(20))), new OrderedContainer(BaseType::INTEGER, array(new Integer(20)))), - array(new OrderedContainer(BaseType::URI, array(new Uri('http://www.taotesting.com'), new Uri('http://www.tao.lu'))), new OrderedContainer(BaseType::URI, array(new Uri('http://www.taotesting.com'), new Uri('http://www.tao.lu')))), - array(new OrderedContainer(BaseType::PAIR, array(new Pair('abc', 'def'))), new OrderedContainer(BaseType::PAIR, array(new Pair('def', 'abc')))) + array(new OrderedContainer(BaseType::INTEGER, array(new QtiInteger(20))), new OrderedContainer(BaseType::INTEGER, array(new QtiInteger(20)))), + array(new OrderedContainer(BaseType::URI, array(new QtiUri('http://www.taotesting.com'), new QtiUri('http://www.tao.lu'))), new OrderedContainer(BaseType::URI, array(new QtiUri('http://www.taotesting.com'), new QtiUri('http://www.tao.lu')))), + array(new OrderedContainer(BaseType::PAIR, array(new QtiPair('abc', 'def'))), new OrderedContainer(BaseType::PAIR, array(new QtiPair('def', 'abc')))) ); } public function equalsInvalidProvider() { return array( - array(new OrderedContainer(BaseType::INTEGER, array(new Integer(20))), new OrderedContainer(BaseType::INTEGER, array(new Integer(30)))), - array(new OrderedContainer(BaseType::URI, array(new Uri('http://www.taotesting.com'), new Uri('http://www.tao.lu'))), new OrderedContainer(BaseType::URI, array(new Uri('http://www.tao.lu'), new Uri('http://www.taotesting.com')))), - array(new OrderedContainer(BaseType::DIRECTED_PAIR, array(new DirectedPair('abc', 'def'))), new OrderedContainer(BaseType::DIRECTED_PAIR, array(new DirectedPair('def', 'abc')))), + array(new OrderedContainer(BaseType::INTEGER, array(new QtiInteger(20))), new OrderedContainer(BaseType::INTEGER, array(new QtiInteger(30)))), + array(new OrderedContainer(BaseType::URI, array(new QtiUri('http://www.taotesting.com'), new QtiUri('http://www.tao.lu'))), new OrderedContainer(BaseType::URI, array(new QtiUri('http://www.tao.lu'), new QtiUri('http://www.taotesting.com')))), + array(new OrderedContainer(BaseType::DIRECTED_PAIR, array(new QtiDirectedPair('abc', 'def'))), new OrderedContainer(BaseType::DIRECTED_PAIR, array(new QtiDirectedPair('def', 'abc')))), ); } } \ No newline at end of file diff --git a/test/qtismtest/runtime/common/OutcomeVariableTest.php b/test/qtismtest/runtime/common/OutcomeVariableTest.php index 69a7dc40c..b5d933406 100644 --- a/test/qtismtest/runtime/common/OutcomeVariableTest.php +++ b/test/qtismtest/runtime/common/OutcomeVariableTest.php @@ -2,12 +2,12 @@ namespace qtismtest\runtime\common; use qtismtest\QtiSmTestCase; -use qtism\common\datatypes\Boolean; -use qtism\common\datatypes\Float; -use qtism\common\datatypes\String; -use qtism\common\datatypes\Integer; -use qtism\common\datatypes\Point; -use qtism\common\datatypes\Pair; +use qtism\common\datatypes\QtiBoolean; +use qtism\common\datatypes\QtiFloat; +use qtism\common\datatypes\QtiString; +use qtism\common\datatypes\QtiInteger; +use qtism\common\datatypes\QtiPoint; +use qtism\common\datatypes\QtiPair; use qtism\runtime\common\OrderedContainer; use qtism\runtime\common\OutcomeVariable; use qtism\runtime\common\MultipleContainer; @@ -44,11 +44,11 @@ public function testCardinalitySingle() { $this->assertFalse($variable->getMasteryValue()); $this->assertTrue(null === $variable->getLookupTable()); - $variable->setValue(new Integer(16)); - $variable->setDefaultValue(new Integer(-1)); - $this->assertInstanceOf('qtism\\common\\datatypes\\Integer', $variable->getValue()); + $variable->setValue(new QtiInteger(16)); + $variable->setDefaultValue(new QtiInteger(-1)); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiInteger', $variable->getValue()); $this->assertEquals(16, $variable->getValue()->getValue()); - $this->assertInstanceOf('qtism\\common\\datatypes\\Integer', $variable->getDefaultValue()); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiInteger', $variable->getDefaultValue()); $this->assertEquals(-1, $variable->getDefaultValue()->getValue()); // If I reinit the variable, I should see the NULL value inside. @@ -60,7 +60,7 @@ public function testCardinalitySingle() { // was given. $variable->setDefaultValue(null); $variable->applyDefaultValue(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Integer', $variable->getValue()); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiInteger', $variable->getValue()); $this->assertEquals(0, $variable->getValue()->getValue()); } @@ -92,7 +92,7 @@ public function testCardinalityMultiple() { // Try to set up a value with an incorrect cardinality (2). try { - $variable->setValue(new Integer(25)); + $variable->setValue(new QtiInteger(25)); $this->assertTrue(false, 'Developer: Exception not thrown but not compliant cardinality?!'); } catch (InvalidArgumentException $e) { @@ -124,7 +124,7 @@ public function testCreateFromVariableDeclarationDefaultValueSingleCardinality() $outcomeDeclaration = $factory->createMarshaller($element)->unmarshall($element); $outcomeVariable = OutcomeVariable::createFromDataModel($outcomeDeclaration); - $pair = new Pair('A', 'B'); + $pair = new QtiPair('A', 'B'); $this->assertTrue($pair->equals($outcomeVariable->getDefaultValue())); } @@ -145,8 +145,8 @@ public function testCreateFromVariableDeclarationDefaultValueMultipleCardinality $this->assertInstanceOf('qtism\\runtime\\common\\MultipleContainer', $defaultValue); $this->assertEquals(2, count($defaultValue)); $this->assertEquals(Cardinality::MULTIPLE, $defaultValue->getCardinality()); - $this->assertTrue($defaultValue[0]->equals(new Pair('A', 'B'))); - $this->assertTrue($defaultValue[1]->equals(new Pair('B', 'C'))); + $this->assertTrue($defaultValue[0]->equals(new QtiPair('A', 'B'))); + $this->assertTrue($defaultValue[1]->equals(new QtiPair('B', 'C'))); } public function testCreateFromVariableDeclarationDefaultValueRecordCardinality() { @@ -166,8 +166,8 @@ public function testCreateFromVariableDeclarationDefaultValueRecordCardinality() $this->assertInstanceOf('qtism\\runtime\\common\\RecordContainer', $defaultValue); $this->assertEquals(2, count($defaultValue)); - $this->assertInstanceOf('qtism\\common\\datatypes\\Pair', $defaultValue['A']); - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $defaultValue['B']); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiPair', $defaultValue['A']); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $defaultValue['B']); } public function testCreateFromVariableDeclarationExtended() { @@ -210,64 +210,64 @@ public function testCreateFromVariableDeclarationExtended() { $this->assertEquals(2, count($matchTableEntries)); $this->assertEquals(0, $matchTableEntries[0]->getSourceValue()); $targetValue = $matchTableEntries[0]->getTargetValue(); - $this->assertTrue($targetValue->equals(new Pair('E', 'F'))); + $this->assertTrue($targetValue->equals(new QtiPair('E', 'F'))); } public function testIsNull() { $outcome = new OutcomeVariable('var1', Cardinality::SINGLE, BaseType::STRING); $this->assertTrue($outcome->isNull()); - $outcome->setValue(new String('')); + $outcome->setValue(new QtiString('')); $this->assertTrue($outcome->isNull()); - $outcome->setValue(new String('String!')); + $outcome->setValue(new QtiString('String!')); $this->assertFalse($outcome->isNull()); $outcome = new OutcomeVariable('var1', Cardinality::SINGLE, BaseType::INTEGER); $this->assertTrue($outcome->isNull()); - $outcome->setValue(new Integer(0)); + $outcome->setValue(new QtiInteger(0)); $this->assertFalse($outcome->isNull()); - $outcome->setValue(new Integer(-1)); + $outcome->setValue(new QtiInteger(-1)); $this->assertFalse($outcome->isNull()); - $outcome->setValue(new Integer(100)); + $outcome->setValue(new QtiInteger(100)); $this->assertFalse($outcome->isNull()); $outcome = new OutcomeVariable('var1', Cardinality::SINGLE, BaseType::FLOAT); $this->assertTrue($outcome->isNull()); - $outcome->setValue(new Float(0.25)); + $outcome->setValue(new QtiFloat(0.25)); $this->assertFalse($outcome->isNull()); - $outcome->setValue(new Float(-1.2)); + $outcome->setValue(new QtiFloat(-1.2)); $this->assertFalse($outcome->isNull()); - $outcome->setValue(new Float(100.12)); + $outcome->setValue(new QtiFloat(100.12)); $this->assertFalse($outcome->isNull()); $outcome = new OutcomeVariable('var1', Cardinality::SINGLE, BaseType::BOOLEAN); $this->assertTrue($outcome->isNull()); - $outcome->setValue(new Boolean(true)); + $outcome->setValue(new QtiBoolean(true)); $this->assertFalse($outcome->isNull()); - $outcome->setValue(new Boolean(false)); + $outcome->setValue(new QtiBoolean(false)); $this->assertFalse($outcome->isNull()); $outcome = new OutcomeVariable('var1', Cardinality::MULTIPLE, BaseType::BOOLEAN); $this->assertTrue($outcome->isNull()); $value = $outcome->getValue(); - $value[] = new Boolean(true); + $value[] = new QtiBoolean(true); $this->assertFalse($outcome->isNull()); $outcome = new OutcomeVariable('var1', Cardinality::ORDERED, BaseType::STRING); $this->assertTrue($outcome->isNull()); $value = $outcome->getValue(); - $value[] = new String('string!'); + $value[] = new QtiString('string!'); $this->assertFalse($outcome->isNull()); $outcome = new OutcomeVariable('var1', Cardinality::RECORD); $this->assertTrue($outcome->isNull()); $value = $outcome->getValue(); - $value['point1'] = new Point(100, 200); + $value['point1'] = new QtiPoint(100, 200); $this->assertFalse($outcome->isNull()); } public function testClone() { - $var = new OutcomeVariable('var', Cardinality::SINGLE, BaseType::INTEGER, new Integer(25)); - $var->setDefaultValue(new Integer(1)); + $var = new OutcomeVariable('var', Cardinality::SINGLE, BaseType::INTEGER, new QtiInteger(25)); + $var->setDefaultValue(new QtiInteger(1)); // value and default value must be independant. $clone = clone $var; diff --git a/test/qtismtest/runtime/common/RecordContainerTest.php b/test/qtismtest/runtime/common/RecordContainerTest.php index fa0bf1f6e..48b64dccc 100644 --- a/test/qtismtest/runtime/common/RecordContainerTest.php +++ b/test/qtismtest/runtime/common/RecordContainerTest.php @@ -2,13 +2,13 @@ namespace qtismtest\runtime\common; use qtismtest\QtiSmTestCase; -use qtism\common\datatypes\String; -use qtism\common\datatypes\Integer; +use qtism\common\datatypes\QtiString; +use qtism\common\datatypes\QtiInteger; use qtism\common\enums\BaseType; use qtism\data\state\Value; use qtism\data\state\ValueCollection; use qtism\runtime\common\RecordContainer; -use qtism\common\datatypes\Point; +use qtism\common\datatypes\QtiPoint; use \DOMDocument; class RecordContainerTest extends QtiSmTestCase { @@ -17,41 +17,41 @@ public function testValid() { $record = new RecordContainer(); $this->assertInstanceOf('qtism\\runtime\\common\\RecordContainer', $record); - $record = new RecordContainer(array('key1' => new Integer(1), 'key2' => new String('a string'), 'key3' => new Point(10, 10))); + $record = new RecordContainer(array('key1' => new QtiInteger(1), 'key2' => new QtiString('a string'), 'key3' => new QtiPoint(10, 10))); $this->assertEquals(3, count($record)); $this->assertEquals($record['key1']->getValue(), 1); $this->assertEquals($record['key2']->getValue(), 'a string'); - $this->assertTrue($record['key3']->equals(new Point(10, 10))); - $this->assertEquals(1, $record->occurences(new Integer(1))); - $this->assertEquals(1, $record->occurences(new Point(10, 10))); + $this->assertTrue($record['key3']->equals(new QtiPoint(10, 10))); + $this->assertEquals(1, $record->occurences(new QtiInteger(1))); + $this->assertEquals(1, $record->occurences(new QtiPoint(10, 10))); } public function testEquals() { - $record1 = new RecordContainer(array('one' => new Integer(1), 'two' => new Integer(2))); - $record2 = new RecordContainer(array('two' => new Integer(2), 'one' => new Integer(1))); + $record1 = new RecordContainer(array('one' => new QtiInteger(1), 'two' => new QtiInteger(2))); + $record2 = new RecordContainer(array('two' => new QtiInteger(2), 'one' => new QtiInteger(1))); $this->assertTrue($record1->equals($record2)); $this->assertTrue($record2->equals($record1)); - $record3 = new RecordContainer(array('three' => new Integer(3), 'four' => new Integer(4))); + $record3 = new RecordContainer(array('three' => new QtiInteger(3), 'four' => new QtiInteger(4))); $this->assertFalse($record1->equals($record3)); $this->assertFalse($record3->equals($record1)); } public function testInvalidInstantiationOne() { $this->setExpectedException('\\InvalidArgumentException'); - $record = new RecordContainer(array(new Integer(1), new Integer(2), new Integer(3))); + $record = new RecordContainer(array(new QtiInteger(1), new QtiInteger(2), new QtiInteger(3))); } public function testInvalidUseOne() { $this->setExpectedException('\\RuntimeException'); $record = new RecordContainer(); - $record[] = new String('string'); + $record[] = new QtiString('string'); } public function testInvalidUseTwo() { $this->setExpectedException('\\RuntimeException'); $record = new RecordContainer(); - $record[111] = new String('string'); + $record[111] = new QtiString('string'); } public function testInvalidUseThree() { diff --git a/test/qtismtest/runtime/common/ResponseVariableTest.php b/test/qtismtest/runtime/common/ResponseVariableTest.php index 5bfe6acbf..e8a8a2c2d 100644 --- a/test/qtismtest/runtime/common/ResponseVariableTest.php +++ b/test/qtismtest/runtime/common/ResponseVariableTest.php @@ -1,10 +1,10 @@ assertInstanceOf('qtism\\data\\state\\Mapping', $mapping); $mapEntries = $mapping->getMapEntries(); $this->assertEquals(3, count($mapEntries)); - $this->assertInstanceOf('qtism\\common\\datatypes\\Pair', $mapEntries[0]->getMapKey()); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiPair', $mapEntries[0]->getMapKey()); $areaMapping = $responseVariable->getAreaMapping(); $this->assertInstanceOf('qtism\\data\\state\\AreaMapping', $areaMapping); $areaMapEntries = $areaMapping->getAreaMapEntries(); $this->assertEquals(3, count($areaMapEntries)); - $this->assertInstanceOf('qtism\\common\\datatypes\\Coords', $areaMapEntries[0]->getCoords()); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiCoords', $areaMapEntries[0]->getCoords()); $this->assertTrue($responseVariable->hasCorrectResponse()); $correctResponse = $responseVariable->getCorrectResponse(); $this->assertInstanceOf('qtism\\runtime\\common\\OrderedContainer', $correctResponse); $this->assertEquals(2, count($correctResponse)); - $this->assertTrue($correctResponse[0]->equals(new Pair('A', 'B'))); - $this->assertTrue($correctResponse[1]->equals(new Pair('E', 'F'))); + $this->assertTrue($correctResponse[0]->equals(new QtiPair('A', 'B'))); + $this->assertTrue($correctResponse[1]->equals(new QtiPair('E', 'F'))); - $responseVariable->setValue(new OrderedContainer(BaseType::PAIR, array(new Pair('A', 'B'), new Pair('E', 'F')))); + $responseVariable->setValue(new OrderedContainer(BaseType::PAIR, array(new QtiPair('A', 'B'), new QtiPair('E', 'F')))); $this->assertTrue($responseVariable->isCorrect()); - $responseVariable->setValue(new OrderedContainer(BaseType::PAIR, array(new Pair('E', 'F'), new Pair('A', 'B')))); + $responseVariable->setValue(new OrderedContainer(BaseType::PAIR, array(new QtiPair('E', 'F'), new QtiPair('A', 'B')))); $this->assertFalse($responseVariable->isCorrect()); // If I reinitialize the value, we must find a NULL container into this variable. @@ -89,19 +89,19 @@ public function testCreateFromVariableDeclarationExtended() { $responseVariable->applyDefaultValue(); $this->assertInstanceOf('qtism\\runtime\\common\\OrderedContainer', $responseVariable->getValue()); $this->assertEquals(3, count($responseVariable->getValue())); - $this->assertTrue($responseVariable->getValue()->equals(new OrderedContainer(BaseType::PAIR, array(new Pair('A', 'B'), new Pair('C', 'D'), new Pair('E', 'F'))))); + $this->assertTrue($responseVariable->getValue()->equals(new OrderedContainer(BaseType::PAIR, array(new QtiPair('A', 'B'), new QtiPair('C', 'D'), new QtiPair('E', 'F'))))); } public function testIsCorrectWithNullCorrectResponse() { - $responseVariable = new ResponseVariable('MYVAR', Cardinality::SINGLE, BaseType::INTEGER, new Integer(25)); + $responseVariable = new ResponseVariable('MYVAR', Cardinality::SINGLE, BaseType::INTEGER, new QtiInteger(25)); $this->assertFalse($responseVariable->isCorrect()); } public function testClone() { // value, default value and correct response must be independent after cloning. - $responseVariable = new ResponseVariable('MYVAR', Cardinality::SINGLE, BaseType::INTEGER, new Integer(25)); - $responseVariable->setDefaultValue(new Integer(1)); - $responseVariable->setCorrectResponse(new Integer(1337)); + $responseVariable = new ResponseVariable('MYVAR', Cardinality::SINGLE, BaseType::INTEGER, new QtiInteger(25)); + $responseVariable->setDefaultValue(new QtiInteger(1)); + $responseVariable->setCorrectResponse(new QtiInteger(1337)); $clone = clone $responseVariable; $this->assertNotSame($responseVariable->getValue(), $clone->getValue()); diff --git a/test/qtismtest/runtime/common/RuntimeUtilsTest.php b/test/qtismtest/runtime/common/RuntimeUtilsTest.php index aa864e502..3870a0c87 100644 --- a/test/qtismtest/runtime/common/RuntimeUtilsTest.php +++ b/test/qtismtest/runtime/common/RuntimeUtilsTest.php @@ -2,17 +2,17 @@ namespace qtismtest\runtime\common; use qtismtest\QtiSmTestCase; -use qtism\common\datatypes\Boolean; -use qtism\common\datatypes\Float; -use qtism\common\datatypes\Integer; -use qtism\common\datatypes\String; +use qtism\common\datatypes\QtiBoolean; +use qtism\common\datatypes\QtiFloat; +use qtism\common\datatypes\QtiInteger; +use qtism\common\datatypes\QtiString; use qtism\common\Comparable; use qtism\common\collections\Container; -use qtism\common\datatypes\DirectedPair; -use qtism\common\datatypes\Pair; -use qtism\common\datatypes\Point; +use qtism\common\datatypes\QtiDirectedPair; +use qtism\common\datatypes\QtiPair; +use qtism\common\datatypes\QtiPoint; use qtism\runtime\common\OrderedContainer; -use qtism\common\datatypes\Duration; +use qtism\common\datatypes\QtiDuration; use qtism\common\enums\BaseType; use qtism\common\enums\Cardinality; use qtism\runtime\common\MultipleContainer; @@ -71,19 +71,19 @@ public function inferBaseTypeProvider() { $returnValue = array(); $returnValue[] = array(new RecordContainer(), false); - $returnValue[] = array(new RecordContainer(array('a' => new Integer(1), 'b' => new Integer(2))), false); + $returnValue[] = array(new RecordContainer(array('a' => new QtiInteger(1), 'b' => new QtiInteger(2))), false); $returnValue[] = array(null, false); - $returnValue[] = array(new String(''), BaseType::STRING); - $returnValue[] = array(new String('String!'), BaseType::STRING); - $returnValue[] = array(new Boolean(false), BaseType::BOOLEAN); - $returnValue[] = array(new Integer(0), BaseType::INTEGER); - $returnValue[] = array(new Float(0.0), BaseType::FLOAT); + $returnValue[] = array(new QtiString(''), BaseType::STRING); + $returnValue[] = array(new QtiString('String!'), BaseType::STRING); + $returnValue[] = array(new QtiBoolean(false), BaseType::BOOLEAN); + $returnValue[] = array(new QtiInteger(0), BaseType::INTEGER); + $returnValue[] = array(new QtiFloat(0.0), BaseType::FLOAT); $returnValue[] = array(new MultipleContainer(BaseType::DURATION), BaseType::DURATION); $returnValue[] = array(new OrderedContainer(BaseType::BOOLEAN), BaseType::BOOLEAN); - $returnValue[] = array(new Duration('P1D'), BaseType::DURATION); - $returnValue[] = array(new Point(1, 1), BaseType::POINT); - $returnValue[] = array(new Pair('A', 'B'), BaseType::PAIR); - $returnValue[] = array(new DirectedPair('A', 'B'), BaseType::DIRECTED_PAIR); + $returnValue[] = array(new QtiDuration('P1D'), BaseType::DURATION); + $returnValue[] = array(new QtiPoint(1, 1), BaseType::POINT); + $returnValue[] = array(new QtiPair('A', 'B'), BaseType::PAIR); + $returnValue[] = array(new QtiDirectedPair('A', 'B'), BaseType::DIRECTED_PAIR); $returnValue[] = array(new \StdClass(), false); $returnValue[] = array(new Container(), false); @@ -98,15 +98,15 @@ public function inferCardinalityProvider() { $returnValue[] = array(new OrderedContainer(BaseType::DURATION), Cardinality::ORDERED); $returnValue[] = array(new \stdClass(), false); $returnValue[] = array(null, false); - $returnValue[] = array(new String(''), Cardinality::SINGLE); - $returnValue[] = array(new String('String!'), Cardinality::SINGLE); - $returnValue[] = array(new Integer(0), Cardinality::SINGLE); - $returnValue[] = array(new Float(0.0), Cardinality::SINGLE); - $returnValue[] = array(new Boolean(false), Cardinality::SINGLE); - $returnValue[] = array(new Point(1, 1), Cardinality::SINGLE); - $returnValue[] = array(new Pair('A', 'B'), Cardinality::SINGLE); - $returnValue[] = array(new DirectedPair('A', 'B'), Cardinality::SINGLE); - $returnValue[] = array(new Duration('P1D'), Cardinality::SINGLE); + $returnValue[] = array(new QtiString(''), Cardinality::SINGLE); + $returnValue[] = array(new QtiString('String!'), Cardinality::SINGLE); + $returnValue[] = array(new QtiInteger(0), Cardinality::SINGLE); + $returnValue[] = array(new QtiFloat(0.0), Cardinality::SINGLE); + $returnValue[] = array(new QtiBoolean(false), Cardinality::SINGLE); + $returnValue[] = array(new QtiPoint(1, 1), Cardinality::SINGLE); + $returnValue[] = array(new QtiPair('A', 'B'), Cardinality::SINGLE); + $returnValue[] = array(new QtiDirectedPair('A', 'B'), Cardinality::SINGLE); + $returnValue[] = array(new QtiDuration('P1D'), Cardinality::SINGLE); return $returnValue; } @@ -141,11 +141,11 @@ public function isValidVariableIdentifierProvider() { public function isNullDataProvider() { return array( - array(new Boolean(true), false), - array(new MultipleContainer(BaseType::INTEGER, array(new Integer(10), new Integer(20))), false), - array(new String('G-string!'), false), + array(new QtiBoolean(true), false), + array(new MultipleContainer(BaseType::INTEGER, array(new QtiInteger(10), new QtiInteger(20))), false), + array(new QtiString('G-string!'), false), array(null, true), - array(new String(''), true), + array(new QtiString(''), true), array(new MultipleContainer(BaseType::INTEGER), true), array(new OrderedContainer(BaseType::INTEGER), true), array(new RecordContainer(), true) @@ -154,10 +154,10 @@ public function isNullDataProvider() { public function equalsProvider() { return array( - array(new Boolean(true), null, false), + array(new QtiBoolean(true), null, false), array(null, null, true), - array(new MultipleContainer(BaseType::INTEGER, array(new Integer(10))), new MultipleContainer(BaseType::INTEGER, array(new Integer(10))), true), - array(new MultipleContainer(BaseType::INTEGER, array(new Integer(10))), new MultipleContainer(BaseType::INTEGER, array(new Integer(100))), false) + array(new MultipleContainer(BaseType::INTEGER, array(new QtiInteger(10))), new MultipleContainer(BaseType::INTEGER, array(new QtiInteger(10))), true), + array(new MultipleContainer(BaseType::INTEGER, array(new QtiInteger(10))), new MultipleContainer(BaseType::INTEGER, array(new QtiInteger(100))), false) ); } } \ No newline at end of file diff --git a/test/qtismtest/runtime/common/StateTest.php b/test/qtismtest/runtime/common/StateTest.php index 531eefadc..033056ff8 100644 --- a/test/qtismtest/runtime/common/StateTest.php +++ b/test/qtismtest/runtime/common/StateTest.php @@ -2,8 +2,8 @@ namespace qtismtest\runtime\common; use qtismtest\QtiSmTestCase; -use qtism\common\datatypes\Boolean; -use qtism\common\datatypes\Integer; +use qtism\common\datatypes\QtiBoolean; +use qtism\common\datatypes\QtiInteger; use qtism\data\state\ResponseDeclaration; use qtism\runtime\common\State; use qtism\runtime\common\ResponseVariable; @@ -76,10 +76,10 @@ public function testGetAllVariables() { $state = new State(); $this->assertEquals(0, count($state->getAllVariables())); - $state->setVariable(new ResponseVariable('RESPONSE1', Cardinality::SINGLE, BaseType::INTEGER, new Integer(25))); + $state->setVariable(new ResponseVariable('RESPONSE1', Cardinality::SINGLE, BaseType::INTEGER, new QtiInteger(25))); $this->assertEquals(1, count($state->getAllVariables())); - $state->setVariable(new OutcomeVariable('SCORE1', Cardinality::SINGLE, BaseType::BOOLEAN, new Boolean(true))); + $state->setVariable(new OutcomeVariable('SCORE1', Cardinality::SINGLE, BaseType::BOOLEAN, new QtiBoolean(true))); $this->assertEquals(2, count($state->getAllVariables())); unset($state['RESPONSE1']); diff --git a/test/qtismtest/runtime/expressions/BaseValueProcessorTest.php b/test/qtismtest/runtime/expressions/BaseValueProcessorTest.php index 1128c323f..a74e2c82d 100644 --- a/test/qtismtest/runtime/expressions/BaseValueProcessorTest.php +++ b/test/qtismtest/runtime/expressions/BaseValueProcessorTest.php @@ -3,7 +3,7 @@ use qtismtest\QtiSmTestCase; use qtism\runtime\expressions\BaseValueProcessor; -use qtism\common\datatypes\Point; +use qtism\common\datatypes\QtiPoint; class BaseValueProcessorTest extends QtiSmTestCase { @@ -14,6 +14,6 @@ public function testBaseValue() { $baseValue = $this->createComponentFromXml('150 130'); $baseValueProcessor->setExpression($baseValue); - $this->assertTrue($baseValueProcessor->process()->equals(new Point(150, 130))); + $this->assertTrue($baseValueProcessor->process()->equals(new QtiPoint(150, 130))); } } \ No newline at end of file diff --git a/test/qtismtest/runtime/expressions/CorrectProcessorTest.php b/test/qtismtest/runtime/expressions/CorrectProcessorTest.php index 3fb4bcbd4..96e0f8732 100644 --- a/test/qtismtest/runtime/expressions/CorrectProcessorTest.php +++ b/test/qtismtest/runtime/expressions/CorrectProcessorTest.php @@ -5,7 +5,7 @@ use qtism\runtime\common\OutcomeVariable; use qtism\runtime\common\State; use qtism\runtime\common\ResponseVariable; -use qtism\common\datatypes\DirectedPair; +use qtism\common\datatypes\QtiDirectedPair; use qtism\common\enums\BaseType; use qtism\runtime\common\MultipleContainer; use qtism\runtime\expressions\CorrectProcessor; @@ -28,8 +28,8 @@ public function testMultipleCardinality() { $processor->setState(new State(array($variable))); $comparable = new MultipleContainer(BaseType::DIRECTED_PAIR); - $comparable[] = new DirectedPair('A', 'B'); - $comparable[] = new DirectedPair('C', 'D'); + $comparable[] = new QtiDirectedPair('A', 'B'); + $comparable[] = new QtiDirectedPair('C', 'D'); $result = $processor->process(); $this->assertInstanceOf('qtism\\runtime\\common\\MultipleContainer', $result); @@ -52,7 +52,7 @@ public function testSingleCardinality() { $processor->setState(new State(array($variable))); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Integer', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiInteger', $result); $this->assertEquals(20, $result->getValue()); } diff --git a/test/qtismtest/runtime/expressions/DefaultProcessorTest.php b/test/qtismtest/runtime/expressions/DefaultProcessorTest.php index 77abfb8d4..4878503b0 100644 --- a/test/qtismtest/runtime/expressions/DefaultProcessorTest.php +++ b/test/qtismtest/runtime/expressions/DefaultProcessorTest.php @@ -2,7 +2,7 @@ namespace qtismtest\runtime\expressions; use qtismtest\QtiSmTestCase; -use qtism\common\datatypes\Duration; +use qtism\common\datatypes\QtiDuration; use qtism\common\enums\BaseType; use qtism\runtime\common\OrderedContainer; use qtism\runtime\common\State; @@ -29,9 +29,9 @@ public function testMultipleCardinality() { $processor->setState(new State(array($variable))); $comparable = new OrderedContainer(BaseType::DURATION); - $comparable[] = new Duration('P2D'); - $comparable[] = new Duration('P3D'); - $comparable[] = new Duration('P4D'); + $comparable[] = new QtiDuration('P2D'); + $comparable[] = new QtiDuration('P3D'); + $comparable[] = new QtiDuration('P4D'); $this->assertTrue($comparable->equals($processor->process())); } @@ -49,7 +49,7 @@ public function testSingleCardinality() { $processor->setState(new State(array($variable))); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Boolean', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiBoolean', $result); $this->assertFalse($result->getValue()); } diff --git a/test/qtismtest/runtime/expressions/ExpressionEngineTest.php b/test/qtismtest/runtime/expressions/ExpressionEngineTest.php index 7322e61c1..95543535a 100644 --- a/test/qtismtest/runtime/expressions/ExpressionEngineTest.php +++ b/test/qtismtest/runtime/expressions/ExpressionEngineTest.php @@ -10,7 +10,7 @@ public function testExpressionEngineBaseValue() { $expression = $this->createComponentFromXml('P2D'); $engine = new ExpressionEngine($expression); $result = $engine->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Duration', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiDuration', $result); $this->assertEquals(2, $result->getDays()); } @@ -30,7 +30,7 @@ public function testExpressionEngineSum() { $engine = new ExpressionEngine($expression); $result = $engine->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $result); $this->assertEquals(60.0, $result->getValue()); } } \ No newline at end of file diff --git a/test/qtismtest/runtime/expressions/MapResponsePointProcessorTest.php b/test/qtismtest/runtime/expressions/MapResponsePointProcessorTest.php index 6d9893700..7c80a0e97 100644 --- a/test/qtismtest/runtime/expressions/MapResponsePointProcessorTest.php +++ b/test/qtismtest/runtime/expressions/MapResponsePointProcessorTest.php @@ -6,7 +6,7 @@ use qtismtest\QtiSmTestCase; use qtism\common\enums\BaseType; use qtism\runtime\common\MultipleContainer; -use qtism\common\datatypes\Point; +use qtism\common\datatypes\QtiPoint; use qtism\runtime\common\OutcomeVariable; use qtism\runtime\common\State; use qtism\runtime\common\ResponseVariable; @@ -26,7 +26,7 @@ public function testSingleCardinality() { '); $variable = ResponseVariable::createFromDataModel($variableDeclaration); - $variable->setValue(new Point(1, 1)); // in rect, poly + $variable->setValue(new QtiPoint(1, 1)); // in rect, poly $processor = new MapResponsePointProcessor($expr); $state = new State(array($variable)); @@ -34,22 +34,22 @@ public function testSingleCardinality() { $processor->setState($state); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $result); $this->assertEquals(3.0, $result->getValue()); - $state['response1'] = new Point(3, 3); // in rect, circle, poly + $state['response1'] = new QtiPoint(3, 3); // in rect, circle, poly $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $result); $this->assertEquals(6, $result->getValue()); - $state['response1'] = new Point(19, 9); // in rect + $state['response1'] = new QtiPoint(19, 9); // in rect $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $result); $this->assertEquals(1, $result->getValue()); - $state['response1'] = new Point(25, 25); // outside everything. + $state['response1'] = new QtiPoint(25, 25); // outside everything. $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $result); $this->assertEquals(666.666, $result->getValue()); } @@ -66,8 +66,8 @@ public function testMultipleCardinality() { '); $variable = ResponseVariable::createFromDataModel($variableDeclaration); $points = new MultipleContainer(BaseType::POINT); - $points[] = new Point(1, 1); // in rect, poly - $points[] = new Point(3, 3); // in rect, circle, poly + $points[] = new QtiPoint(1, 1); // in rect, poly + $points[] = new QtiPoint(3, 3); // in rect, circle, poly $variable->setValue($points); // because 1, 1 falls in 2 times in rect and poly, it is added to the total @@ -78,17 +78,17 @@ public function testMultipleCardinality() { $processor->setState($state); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $result); $this->assertEquals(6, $result->getValue()); // Nothing matches... defaultValue returned. $points = new MultipleContainer(BaseType::POINT); - $points[] = new Point(-1, -1); - $points[] = new Point(21, 20); + $points[] = new QtiPoint(-1, -1); + $points[] = new QtiPoint(21, 20); $state['response1'] = $points; $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $result); $this->assertEquals(666.666, $result->getValue()); } @@ -112,7 +112,7 @@ public function testNoVariableValue() { $processor = new MapResponsePointProcessor($expr); $processor->setState(new State(array($variable))); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $result); $this->assertEquals(0.0, $result->getValue()); } @@ -129,7 +129,7 @@ public function testDefaultValue() { $processor = new MapResponsePointProcessor($expr); $processor->setState(new State(array($variable))); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $result); $this->assertEquals(2.0, $result->getValue()); } @@ -188,11 +188,11 @@ public function testLowerBoundOverflow() { '); $variable = ResponseVariable::createFromDataModel($variableDeclaration); $processor = new MapResponsePointProcessor($expr); - $variable->setValue(new Point(3, 3)); // inside everything. + $variable->setValue(new QtiPoint(3, 3)); // inside everything. $processor->setState(new State(array($variable))); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $result); $this->assertEquals(1, $result->getValue()); } @@ -208,11 +208,11 @@ public function testUpperBoundOverflow() { '); $variable = ResponseVariable::createFromDataModel($variableDeclaration); $processor = new MapResponsePointProcessor($expr); - $variable->setValue(new Point(3, 3)); // inside everything. + $variable->setValue(new QtiPoint(3, 3)); // inside everything. $processor->setState(new State(array($variable))); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $result); $this->assertEquals(5, $result->getValue()); } diff --git a/test/qtismtest/runtime/expressions/MapResponseProcessorTest.php b/test/qtismtest/runtime/expressions/MapResponseProcessorTest.php index 272fcdb2c..e31b02a40 100644 --- a/test/qtismtest/runtime/expressions/MapResponseProcessorTest.php +++ b/test/qtismtest/runtime/expressions/MapResponseProcessorTest.php @@ -2,8 +2,8 @@ namespace qtismtest\runtime\expressions; use qtismtest\QtiSmTestCase; -use qtism\common\datatypes\Identifier; -use qtism\common\datatypes\Integer; +use qtism\common\datatypes\QtiIdentifier; +use qtism\common\datatypes\QtiInteger; use qtism\data\expressions\MapResponse; use qtism\runtime\common\RecordContainer; use qtism\runtime\common\OutcomeVariable; @@ -11,7 +11,7 @@ use qtism\runtime\common\ResponseVariable; use qtism\runtime\common\State; use qtism\runtime\expressions\MapResponseProcessor; -use qtism\common\datatypes\Pair; +use qtism\common\datatypes\QtiPair; use qtism\runtime\common\MultipleContainer; class MapResponseProcessorTest extends QtiSmTestCase { @@ -34,23 +34,23 @@ public function testSimple() { $mapResponseProcessor->setState($state); $result = $mapResponseProcessor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $result); // The variable has no value so the default mapping value is returned. $this->assertEquals(0, $result->getValue()); - $state['response1'] = new Integer(0); + $state['response1'] = new QtiInteger(0); $result = $mapResponseProcessor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $result); $this->assertEquals(1, $result->getValue()); - $state['response1'] = new Integer(1); + $state['response1'] = new QtiInteger(1); $result = $mapResponseProcessor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $result); $this->assertEquals(2, $result->getValue()); - $state['response1'] = new Integer(240); + $state['response1'] = new QtiInteger(240); $result = $mapResponseProcessor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $result); $this->assertEquals(0, $result->getValue()); } @@ -73,23 +73,23 @@ public function testMultipleComplexTyping() { // No value could be tried to be matched. $result = $mapResponseProcessor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $result); $this->assertEquals(0.0, $result->getValue()); - $state['response1'] = new MultipleContainer(BaseType::PAIR, array(new Pair('A', 'B'))); + $state['response1'] = new MultipleContainer(BaseType::PAIR, array(new QtiPair('A', 'B'))); $result = $mapResponseProcessor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $result); $this->assertEquals(1.5, $result->getValue()); - $state['response1'][] = new Pair('C', 'D'); + $state['response1'][] = new QtiPair('C', 'D'); $result = $mapResponseProcessor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $result); $this->assertEquals(4, $result->getValue()); // mapEntries must be taken into account only once, as per QTI 2.1 spec. - $state['response1'][] = new Pair('C', 'D'); + $state['response1'][] = new QtiPair('C', 'D'); $result = $mapResponseProcessor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $result); $this->assertEquals(4, $result->getValue()); // 2.5 taken into account only once! } @@ -106,7 +106,7 @@ public function testIndentifier() { '); $variable = ResponseVariable::createFromDataModel($variableDeclaration); - $variable->setValue(new Identifier('Choice_3')); + $variable->setValue(new QtiIdentifier('Choice_3')); $mapResponseExpr = $this->createComponentFromXml(''); $mapResponseProcessor = new MapResponseProcessor($mapResponseExpr); $mapResponseProcessor->setState(new State(array($variable))); @@ -168,17 +168,17 @@ public function testMultipleCardinalityIdentifierToFloat() { $this->assertTrue($responseVariable->isNull()); $result = $mapResponseProcessor->process(); $this->assertEquals(0.0, $result->getValue()); - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $result); // RESPONSE is NULL. $responseVariable->setValue(null); $result = $mapResponseProcessor->process(); $this->assertEquals(0.0, $result->getValue()); - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $result); // RESPONSE is Choice 6, Choice 8. // Note that Choice 8 has not mapping, the mapping's default value (0) must be then used. - $state['RESPONSE'] = new MultipleContainer(BaseType::IDENTIFIER, array(new Identifier('Choice6'), new Identifier('Choice8'))); + $state['RESPONSE'] = new MultipleContainer(BaseType::IDENTIFIER, array(new QtiIdentifier('Choice6'), new QtiIdentifier('Choice8'))); $result = $mapResponseProcessor->process(); $this->assertEquals(20.0, $result->getValue()); @@ -187,14 +187,14 @@ public function testMultipleCardinalityIdentifierToFloat() { $mapping->setDefaultValue(-1.0); $responseVariable = ResponseVariable::createFromDataModel($responseDeclaration); $state->setVariable($responseVariable); - $state['RESPONSE'] = new MultipleContainer(BaseType::IDENTIFIER, array(new Identifier('Choice6'), new Identifier('Choice8'))); + $state['RESPONSE'] = new MultipleContainer(BaseType::IDENTIFIER, array(new QtiIdentifier('Choice6'), new QtiIdentifier('Choice8'))); $result = $mapResponseProcessor->process(); $this->assertEquals(19.0, $result->getValue()); // Response is 'choice7', and 'identifierX'. choice7 is in lower case but its // associated entry is case insensitive. It must be then matched. // 'identifierX' will not be matched at all, the mapping's default value (still -1) will be used. - $state['RESPONSE'] = new MultipleContainer(BaseType::IDENTIFIER, array(new Identifier('choice7'), new Identifier('identifierX'))); + $state['RESPONSE'] = new MultipleContainer(BaseType::IDENTIFIER, array(new QtiIdentifier('choice7'), new QtiIdentifier('identifierX'))); $result = $mapResponseProcessor->process(); $this->assertEquals(-21.0, $result->getValue()); diff --git a/test/qtismtest/runtime/expressions/MathConstantProcessorTest.php b/test/qtismtest/runtime/expressions/MathConstantProcessorTest.php index ce55ae86d..1fdc1efd6 100644 --- a/test/qtismtest/runtime/expressions/MathConstantProcessorTest.php +++ b/test/qtismtest/runtime/expressions/MathConstantProcessorTest.php @@ -11,13 +11,13 @@ public function testSimple() { $mathConstantProcessor = new MathConstantProcessor($mathConstantExpr); $result = $mathConstantProcessor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $result); $this->assertEquals(M_E, $result->getValue()); $mathConstantExpr = $this->createComponentFromXml(''); $mathConstantProcessor->setExpression($mathConstantExpr); $result = $mathConstantProcessor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $result); $this->assertEquals(M_PI, $result->getValue()); } } \ No newline at end of file diff --git a/test/qtismtest/runtime/expressions/NumberCorrectProcessorTest.php b/test/qtismtest/runtime/expressions/NumberCorrectProcessorTest.php index 53a4b1db7..177c22888 100644 --- a/test/qtismtest/runtime/expressions/NumberCorrectProcessorTest.php +++ b/test/qtismtest/runtime/expressions/NumberCorrectProcessorTest.php @@ -2,10 +2,10 @@ namespace qtismtest\runtime\expressions; use qtismtest\QtiSmItemSubsetTestCase; -use qtism\common\datatypes\Identifier; -use qtism\common\datatypes\Point; -use qtism\common\datatypes\DirectedPair; -use qtism\common\datatypes\Pair; +use qtism\common\datatypes\QtiIdentifier; +use qtism\common\datatypes\QtiPoint; +use qtism\common\datatypes\QtiDirectedPair; +use qtism\common\datatypes\QtiPair; use qtism\runtime\common\MultipleContainer; use qtism\common\enums\BaseType; use qtism\common\enums\Cardinality; @@ -35,7 +35,7 @@ public function testNumberCorrect() { $responses = new State(); // Correct! - $responses->setVariable(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('ChoiceA'))); + $responses->setVariable(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('ChoiceA'))); $session->endAttempt($responses); $processor->setExpression($overallCorrect); $this->assertEquals(1, $processor->process()->getValue()); @@ -47,7 +47,7 @@ public function testNumberCorrect() { $responses->reset(); $session->beginAttempt(); // Incorrect! - $responses->setVariable(new ResponseVariable('RESPONSE', Cardinality::MULTIPLE, BaseType::PAIR, new MultipleContainer(BaseType::PAIR, array(new Pair('A', 'P'), new Pair('D', 'L'))))); + $responses->setVariable(new ResponseVariable('RESPONSE', Cardinality::MULTIPLE, BaseType::PAIR, new MultipleContainer(BaseType::PAIR, array(new QtiPair('A', 'P'), new QtiPair('D', 'L'))))); $session->endAttempt($responses); $processor->setExpression($overallCorrect); $this->assertEquals(1, $processor->process()->getValue()); @@ -67,7 +67,7 @@ public function testNumberCorrect() { // Correct! $responses->reset(); $session->beginAttempt(); - $responses->setVariable(new ResponseVariable('RESPONSE', Cardinality::MULTIPLE, BaseType::DIRECTED_PAIR, new MultipleContainer(BaseType::DIRECTED_PAIR, array(new DirectedPair('W', 'G1'), new DirectedPair('Su', 'G2'))))); + $responses->setVariable(new ResponseVariable('RESPONSE', Cardinality::MULTIPLE, BaseType::DIRECTED_PAIR, new MultipleContainer(BaseType::DIRECTED_PAIR, array(new QtiDirectedPair('W', 'G1'), new QtiDirectedPair('Su', 'G2'))))); $session->endAttempt($responses); $this->assertEquals(2, $processor->process()->getValue()); $session->moveNext(); @@ -83,7 +83,7 @@ public function testNumberCorrect() { // Correct! $responses->reset(); $session->beginAttempt(); - $responses->setVariable(new ResponseVariable('answer', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('A'))); + $responses->setVariable(new ResponseVariable('answer', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('A'))); $session->endAttempt($responses); $this->assertEquals(3, $processor->process()->getValue()); $session->moveNext(); @@ -92,7 +92,7 @@ public function testNumberCorrect() { // Incorrect $responses->reset(); $session->beginAttempt(); - $responses->setVariable(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::POINT, new Point(100, 100))); + $responses->setVariable(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::POINT, new QtiPoint(100, 100))); $session->endAttempt($responses); $this->assertEquals(1, $session['Q07.1.SCORE']->getValue()); $this->assertEquals(3, $processor->process()->getValue()); @@ -102,7 +102,7 @@ public function testNumberCorrect() { // Incorrect! $responses->reset(); $session->beginAttempt(); - $responses->setVariable(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::POINT, new Point(10, 10))); + $responses->setVariable(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::POINT, new QtiPoint(10, 10))); $session->endAttempt($responses); $this->assertEquals(0, $session['Q07.2.SCORE']->getValue()); $this->assertEquals(3, $processor->process()->getValue()); @@ -112,7 +112,7 @@ public function testNumberCorrect() { // Correct! $responses->reset(); $session->beginAttempt(); - $responses->setVariable(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::POINT, new Point(102, 113))); + $responses->setVariable(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::POINT, new QtiPoint(102, 113))); $session->endAttempt($responses); $this->assertEquals(1, $session['Q07.3.SCORE']->getValue()); $this->assertEquals(4, $processor->process()->getValue()); diff --git a/test/qtismtest/runtime/expressions/NumberIncorrectProcessorTest.php b/test/qtismtest/runtime/expressions/NumberIncorrectProcessorTest.php index 5b0a6ec9d..b2240c1a8 100644 --- a/test/qtismtest/runtime/expressions/NumberIncorrectProcessorTest.php +++ b/test/qtismtest/runtime/expressions/NumberIncorrectProcessorTest.php @@ -2,10 +2,10 @@ namespace qtismtest\runtime\expressions; use qtismtest\QtiSmItemSubsetTestCase; -use qtism\common\datatypes\Identifier; -use qtism\common\datatypes\Point; -use qtism\common\datatypes\DirectedPair; -use qtism\common\datatypes\Pair; +use qtism\common\datatypes\QtiIdentifier; +use qtism\common\datatypes\QtiPoint; +use qtism\common\datatypes\QtiDirectedPair; +use qtism\common\datatypes\QtiPair; use qtism\runtime\common\MultipleContainer; use qtism\common\enums\BaseType; use qtism\common\enums\Cardinality; @@ -34,7 +34,7 @@ public function testNumberIncorrect() { $session->beginAttempt(); $responses = new State(); // Correct! - $responses->setVariable(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('ChoiceA'))); + $responses->setVariable(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('ChoiceA'))); $session->endAttempt($responses); $processor->setExpression($overallCorrect); $this->assertEquals(0, $processor->process()->getValue()); @@ -46,7 +46,7 @@ public function testNumberIncorrect() { $responses->reset(); $session->beginAttempt(); // Incorrect! - $responses->setVariable(new ResponseVariable('RESPONSE', Cardinality::MULTIPLE, BaseType::PAIR, new MultipleContainer(BaseType::PAIR, array(new Pair('A', 'P'), new Pair('D', 'L'))))); + $responses->setVariable(new ResponseVariable('RESPONSE', Cardinality::MULTIPLE, BaseType::PAIR, new MultipleContainer(BaseType::PAIR, array(new QtiPair('A', 'P'), new QtiPair('D', 'L'))))); $session->endAttempt($responses); $processor->setExpression($overallCorrect); $this->assertEquals(1, $processor->process()->getValue()); @@ -66,7 +66,7 @@ public function testNumberIncorrect() { // Correct! $responses->reset(); $session->beginAttempt(); - $responses->setVariable(new ResponseVariable('RESPONSE', Cardinality::MULTIPLE, BaseType::DIRECTED_PAIR, new MultipleContainer(BaseType::DIRECTED_PAIR, array(new DirectedPair('W', 'G1'), new DirectedPair('Su', 'G2'))))); + $responses->setVariable(new ResponseVariable('RESPONSE', Cardinality::MULTIPLE, BaseType::DIRECTED_PAIR, new MultipleContainer(BaseType::DIRECTED_PAIR, array(new QtiDirectedPair('W', 'G1'), new QtiDirectedPair('Su', 'G2'))))); $session->endAttempt($responses); $this->assertEquals(2, $processor->process()->getValue()); $session->moveNext(); @@ -82,7 +82,7 @@ public function testNumberIncorrect() { // Correct! $responses->reset(); $session->beginAttempt(); - $responses->setVariable(new ResponseVariable('answer', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('A'))); + $responses->setVariable(new ResponseVariable('answer', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('A'))); $session->endAttempt($responses); $this->assertEquals(3, $processor->process()->getValue()); $session->moveNext(); @@ -91,7 +91,7 @@ public function testNumberIncorrect() { // Incorrect $responses->reset(); $session->beginAttempt(); - $responses->setVariable(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::POINT, new Point(100, 100))); + $responses->setVariable(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::POINT, new QtiPoint(100, 100))); $session->endAttempt($responses); $this->assertEquals(4, $processor->process()->getValue()); $session->moveNext(); @@ -100,7 +100,7 @@ public function testNumberIncorrect() { // Incorrect! $responses->reset(); $session->beginAttempt(); - $responses->setVariable(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::POINT, new Point(10, 10))); + $responses->setVariable(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::POINT, new QtiPoint(10, 10))); $session->endAttempt($responses); $this->assertEquals(5, $processor->process()->getValue()); $session->moveNext(); @@ -109,7 +109,7 @@ public function testNumberIncorrect() { // Correct! $responses->reset(); $session->beginAttempt(); - $responses->setVariable(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::POINT, new Point(102, 113))); + $responses->setVariable(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::POINT, new QtiPoint(102, 113))); $session->endAttempt($responses); $this->assertEquals(5, $processor->process()->getValue()); $session->moveNext(); diff --git a/test/qtismtest/runtime/expressions/NumberRespondedProcessorTest.php b/test/qtismtest/runtime/expressions/NumberRespondedProcessorTest.php index 5aa72fae5..9f817e147 100644 --- a/test/qtismtest/runtime/expressions/NumberRespondedProcessorTest.php +++ b/test/qtismtest/runtime/expressions/NumberRespondedProcessorTest.php @@ -2,10 +2,10 @@ namespace qtismtest\runtime\expressions; use qtismtest\QtiSmItemSubsetTestCase; -use qtism\common\datatypes\Identifier; -use qtism\common\datatypes\Point; -use qtism\common\datatypes\DirectedPair; -use qtism\common\datatypes\Pair; +use qtism\common\datatypes\QtiIdentifier; +use qtism\common\datatypes\QtiPoint; +use qtism\common\datatypes\QtiDirectedPair; +use qtism\common\datatypes\QtiPair; use qtism\runtime\common\MultipleContainer; use qtism\common\enums\BaseType; use qtism\common\enums\Cardinality; @@ -34,7 +34,7 @@ public function testNumberResponded() { $session->beginAttempt(); $responses = new State(); // Correct! - $responses->setVariable(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('ChoiceA'))); + $responses->setVariable(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('ChoiceA'))); $session->endAttempt($responses); $processor->setExpression($overallResponded); $this->assertEquals(1, $processor->process()->getValue()); @@ -45,7 +45,7 @@ public function testNumberResponded() { // Q02 $responses->reset(); $session->beginAttempt(); - $responses->setVariable(new ResponseVariable('RESPONSE', Cardinality::MULTIPLE, BaseType::PAIR, new MultipleContainer(BaseType::PAIR, array(new Pair('A', 'P'), new Pair('D', 'L'))))); + $responses->setVariable(new ResponseVariable('RESPONSE', Cardinality::MULTIPLE, BaseType::PAIR, new MultipleContainer(BaseType::PAIR, array(new QtiPair('A', 'P'), new QtiPair('D', 'L'))))); $session->endAttempt($responses); $this->assertEquals(3, $session['Q02.SCORE']->getValue()); // just for fun... $processor->setExpression($overallResponded); @@ -64,7 +64,7 @@ public function testNumberResponded() { // Q04 $responses->reset(); $session->beginAttempt(); - $responses->setVariable(new ResponseVariable('RESPONSE', Cardinality::MULTIPLE, BaseType::DIRECTED_PAIR, new MultipleContainer(BaseType::DIRECTED_PAIR, array(new DirectedPair('W', 'G1'), new DirectedPair('Su', 'G2'))))); + $responses->setVariable(new ResponseVariable('RESPONSE', Cardinality::MULTIPLE, BaseType::DIRECTED_PAIR, new MultipleContainer(BaseType::DIRECTED_PAIR, array(new QtiDirectedPair('W', 'G1'), new QtiDirectedPair('Su', 'G2'))))); $session->endAttempt($responses); $this->assertEquals(3, $session['Q04.SCORE']->getValue()); $this->assertEquals(3, $processor->process()->getValue()); @@ -79,7 +79,7 @@ public function testNumberResponded() { // Q06 $responses->reset(); $session->beginAttempt(); - $responses->setVariable(new ResponseVariable('answer', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('A'))); + $responses->setVariable(new ResponseVariable('answer', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('A'))); $session->endAttempt($responses); $this->assertEquals(4, $processor->process()->getValue()); $session->moveNext(); @@ -87,7 +87,7 @@ public function testNumberResponded() { // Q07.1 $responses->reset(); $session->beginAttempt(); - $responses->setVariable(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::POINT, new Point(100, 100))); + $responses->setVariable(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::POINT, new QtiPoint(100, 100))); $session->endAttempt($responses); $this->assertEquals(1, $session['Q07.1.SCORE']->getValue()); $this->assertEquals(5, $processor->process()->getValue()); @@ -96,7 +96,7 @@ public function testNumberResponded() { // Q07.2 $responses->reset(); $session->beginAttempt(); - $responses->setVariable(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::POINT, new Point(10, 10))); + $responses->setVariable(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::POINT, new QtiPoint(10, 10))); $session->endAttempt($responses); $this->assertEquals(0, $session['Q07.2.SCORE']->getValue()); $this->assertEquals(6, $processor->process()->getValue()); @@ -105,7 +105,7 @@ public function testNumberResponded() { // Q07.3 $responses->reset(); $session->beginAttempt(); - $responses->setVariable(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::POINT, new Point(102, 113))); + $responses->setVariable(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::POINT, new QtiPoint(102, 113))); $session->endAttempt($responses); $this->assertEquals(1, $session['Q07.3.SCORE']->getValue()); $this->assertEquals(7, $processor->process()->getValue()); diff --git a/test/qtismtest/runtime/expressions/OutcomeMaximumProcessorTest.php b/test/qtismtest/runtime/expressions/OutcomeMaximumProcessorTest.php index d5ad8710e..b4393db50 100644 --- a/test/qtismtest/runtime/expressions/OutcomeMaximumProcessorTest.php +++ b/test/qtismtest/runtime/expressions/OutcomeMaximumProcessorTest.php @@ -2,7 +2,7 @@ namespace qtismtest\runtime\expressions; use qtismtest\QtiSmItemSubsetTestCase; -use qtism\common\datatypes\Float; +use qtism\common\datatypes\QtiFloat; use qtism\runtime\common\MultipleContainer; use qtism\common\enums\BaseType; use qtism\common\collections\IdentifierCollection; @@ -39,13 +39,13 @@ public function outcomeMaximumProvider() { return array( array(self::getOutcomeMaximum('SCORE'), null), // NULL values involved, the expression returns NULL systematically. array(self::getOutcomeMaximum('SCOREX'), null), // No variable at all matches. - array(self::getOutcomeMaximum('SCORE', '', '', new IdentifierCollection(array('maximum'))), new MultipleContainer(BaseType::FLOAT, array(new Float(2.5), new Float(1.5)))), - array(self::getOutcomeMaximum('SCORE', 'W0X', '', new IdentifierCollection(array('maximum'))), new MultipleContainer(BaseType::FLOAT, array(new Float(2.5), new Float(1.5)))), // Weight not found then not applied. - array(self::getOutcomeMaximum('SCORE', 'W01', '', new IdentifierCollection(array('maximum'))), new MultipleContainer(BaseType::FLOAT, array(new Float(5.0), new Float(3.0)))), - array(self::getOutcomeMaximum('SCORE', '', 'S01', new IdentifierCollection(array('maximum'))), new MultipleContainer(BaseType::FLOAT, array(new Float(2.5)))), - array(self::getOutcomeMaximum('SCORE', '', 'S02', new IdentifierCollection(array('maximum'))), new MultipleContainer(BaseType::FLOAT, array(new Float(1.5)))), - array(self::getOutcomeMaximum('SCORE', 'W01', 'S01', new IdentifierCollection(array('maximum'))), new MultipleContainer(BaseType::FLOAT, array(new Float(5.0)))), - array(self::getOutcomeMaximum('SCORE', 'W01', 'S02', new IdentifierCollection(array('maximum'))), new MultipleContainer(BaseType::FLOAT, array(new Float(3.0)))) + array(self::getOutcomeMaximum('SCORE', '', '', new IdentifierCollection(array('maximum'))), new MultipleContainer(BaseType::FLOAT, array(new QtiFloat(2.5), new QtiFloat(1.5)))), + array(self::getOutcomeMaximum('SCORE', 'W0X', '', new IdentifierCollection(array('maximum'))), new MultipleContainer(BaseType::FLOAT, array(new QtiFloat(2.5), new QtiFloat(1.5)))), // Weight not found then not applied. + array(self::getOutcomeMaximum('SCORE', 'W01', '', new IdentifierCollection(array('maximum'))), new MultipleContainer(BaseType::FLOAT, array(new QtiFloat(5.0), new QtiFloat(3.0)))), + array(self::getOutcomeMaximum('SCORE', '', 'S01', new IdentifierCollection(array('maximum'))), new MultipleContainer(BaseType::FLOAT, array(new QtiFloat(2.5)))), + array(self::getOutcomeMaximum('SCORE', '', 'S02', new IdentifierCollection(array('maximum'))), new MultipleContainer(BaseType::FLOAT, array(new QtiFloat(1.5)))), + array(self::getOutcomeMaximum('SCORE', 'W01', 'S01', new IdentifierCollection(array('maximum'))), new MultipleContainer(BaseType::FLOAT, array(new QtiFloat(5.0)))), + array(self::getOutcomeMaximum('SCORE', 'W01', 'S02', new IdentifierCollection(array('maximum'))), new MultipleContainer(BaseType::FLOAT, array(new QtiFloat(3.0)))) ); } diff --git a/test/qtismtest/runtime/expressions/OutcomeMinimumProcessorTest.php b/test/qtismtest/runtime/expressions/OutcomeMinimumProcessorTest.php index 41faab263..f6a7769a2 100644 --- a/test/qtismtest/runtime/expressions/OutcomeMinimumProcessorTest.php +++ b/test/qtismtest/runtime/expressions/OutcomeMinimumProcessorTest.php @@ -2,7 +2,7 @@ namespace qtismtest\runtime\expressions; use qtismtest\QtiSmItemSubsetTestCase; -use qtism\common\datatypes\Float; +use qtism\common\datatypes\QtiFloat; use qtism\runtime\common\MultipleContainer; use qtism\common\enums\BaseType; use qtism\common\collections\IdentifierCollection; @@ -37,12 +37,12 @@ public function testOutcomeMaximum(OutcomeMinimum $expression, $expectedResult) public function outcomeMinimumProvider() { return array( - array(self::getOutcomeMinimum('SCORE'), new MultipleContainer(BaseType::FLOAT, array(new Float(-2.0), new Float(0.5), new Float(1.0), new Float(1.0), new Float(1.0), new Float(1.0)))), - array(self::getOutcomeMinimum('SCORE', '', '', new IdentifierCollection(array('minimum'))), new MultipleContainer(BaseType::FLOAT, array(new Float(-2.0), new Float(0.5), new Float(1.0), new Float(1.0), new Float(1.0), new Float(1.0)))), - array(self::getOutcomeMinimum('SCORE', 'W01', '', new IdentifierCollection(array('minimum'))), new MultipleContainer(BaseType::FLOAT, array(new Float(-4.0), new Float(1.0), new Float(2.0), new Float(2.0), new Float(2.0), new Float(2.0)))), - array(self::getOutcomeMinimum('SCORE', 'W01', '', new IdentifierCollection(array('minimum', 'maximum'))), new MultipleContainer(BaseType::FLOAT, array(new Float(-4.0), new Float(1.0), new Float(2.0), new Float(2.0), new Float(2.0), new Float(2.0)))), - array(self::getOutcomeMinimum('SCORE', 'W01'), new MultipleContainer(BaseType::FLOAT, array(new Float(-4.0), new Float(1.0), new Float(2.0), new Float(2.0), new Float(2.0), new Float(2.0)))), - array(self::getOutcomeMinimum('SCORE', 'W02', '', new IdentifierCollection(array('minimum'))), new MultipleContainer(BaseType::FLOAT, array(new Float(-2.0), new Float(0.5), new Float(1.0), new Float(1.0), new Float(1.0), new Float(1.0)))), // Weight not found + array(self::getOutcomeMinimum('SCORE'), new MultipleContainer(BaseType::FLOAT, array(new QtiFloat(-2.0), new QtiFloat(0.5), new QtiFloat(1.0), new QtiFloat(1.0), new QtiFloat(1.0), new QtiFloat(1.0)))), + array(self::getOutcomeMinimum('SCORE', '', '', new IdentifierCollection(array('minimum'))), new MultipleContainer(BaseType::FLOAT, array(new QtiFloat(-2.0), new QtiFloat(0.5), new QtiFloat(1.0), new QtiFloat(1.0), new QtiFloat(1.0), new QtiFloat(1.0)))), + array(self::getOutcomeMinimum('SCORE', 'W01', '', new IdentifierCollection(array('minimum'))), new MultipleContainer(BaseType::FLOAT, array(new QtiFloat(-4.0), new QtiFloat(1.0), new QtiFloat(2.0), new QtiFloat(2.0), new QtiFloat(2.0), new QtiFloat(2.0)))), + array(self::getOutcomeMinimum('SCORE', 'W01', '', new IdentifierCollection(array('minimum', 'maximum'))), new MultipleContainer(BaseType::FLOAT, array(new QtiFloat(-4.0), new QtiFloat(1.0), new QtiFloat(2.0), new QtiFloat(2.0), new QtiFloat(2.0), new QtiFloat(2.0)))), + array(self::getOutcomeMinimum('SCORE', 'W01'), new MultipleContainer(BaseType::FLOAT, array(new QtiFloat(-4.0), new QtiFloat(1.0), new QtiFloat(2.0), new QtiFloat(2.0), new QtiFloat(2.0), new QtiFloat(2.0)))), + array(self::getOutcomeMinimum('SCORE', 'W02', '', new IdentifierCollection(array('minimum'))), new MultipleContainer(BaseType::FLOAT, array(new QtiFloat(-2.0), new QtiFloat(0.5), new QtiFloat(1.0), new QtiFloat(1.0), new QtiFloat(1.0), new QtiFloat(1.0)))), // Weight not found ); } diff --git a/test/qtismtest/runtime/expressions/RandomFloatProcessorTest.php b/test/qtismtest/runtime/expressions/RandomFloatProcessorTest.php index 3f0758877..7099ae721 100644 --- a/test/qtismtest/runtime/expressions/RandomFloatProcessorTest.php +++ b/test/qtismtest/runtime/expressions/RandomFloatProcessorTest.php @@ -10,21 +10,21 @@ public function testSimple() { $expression = $this->createComponentFromXml(''); $processor = new RandomFloatProcessor($expression); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $result); $this->assertLessThanOrEqual(100.34, $result->getValue()); $this->assertGreaterThanOrEqual(0, $result->getValue()); $expression = $this->createComponentFromXml(''); $processor->setExpression($expression); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $result); $this->assertGreaterThanOrEqual(-2000, $result->getValue()); $this->assertLessThanOrEqual(-1000, $result->getValue()); $expression = $this->createComponentFromXml(''); $processor->setExpression($expression); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $result); $this->assertGreaterThanOrEqual(100, $result->getValue()); $this->assertLessThanOrEqual(2430.6666, $result->getValue()); } diff --git a/test/qtismtest/runtime/expressions/RandomIntegerProcessorTest.php b/test/qtismtest/runtime/expressions/RandomIntegerProcessorTest.php index 4343fd0a1..64fd1afe1 100644 --- a/test/qtismtest/runtime/expressions/RandomIntegerProcessorTest.php +++ b/test/qtismtest/runtime/expressions/RandomIntegerProcessorTest.php @@ -12,21 +12,21 @@ public function testSimple() { $randomIntegerProcessor = new RandomIntegerProcessor($randomIntegerExpr); $result = $randomIntegerProcessor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Integer', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiInteger', $result); $this->assertGreaterThanOrEqual(0, $result->getValue()); $this->assertLessThanOrEqual(100, $result->getValue()); $randomIntegerExpr = $this->createComponentFromXml(''); $randomIntegerProcessor->setExpression($randomIntegerExpr); $result = $randomIntegerProcessor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Integer', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiInteger', $result); $this->assertGreaterThanOrEqual(-100, $result->getValue()); $this->assertLessThanOrEqual(100, $result->getValue()); $randomIntegerExpr = $this->createComponentFromXml(''); $randomIntegerProcessor->setExpression($randomIntegerExpr); $result = $randomIntegerProcessor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Integer', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiInteger', $result); $this->assertGreaterThanOrEqual(-20, $result->getValue()); $this->assertLessThanOrEqual(23, $result->getValue()); $this->assertEquals(0, $result->getValue() % 4); diff --git a/test/qtismtest/runtime/expressions/TestVariablesProcessorTest.php b/test/qtismtest/runtime/expressions/TestVariablesProcessorTest.php index d4681870a..f25869745 100644 --- a/test/qtismtest/runtime/expressions/TestVariablesProcessorTest.php +++ b/test/qtismtest/runtime/expressions/TestVariablesProcessorTest.php @@ -2,11 +2,11 @@ namespace qtismtest\runtime\expressions; use qtismtest\QtiSmItemSubsetTestCase; -use qtism\common\datatypes\Identifier; -use qtism\common\datatypes\Float; -use qtism\common\datatypes\Point; -use qtism\common\datatypes\DirectedPair; -use qtism\common\datatypes\Pair; +use qtism\common\datatypes\QtiIdentifier; +use qtism\common\datatypes\QtiFloat; +use qtism\common\datatypes\QtiPoint; +use qtism\common\datatypes\QtiDirectedPair; +use qtism\common\datatypes\QtiPair; use qtism\common\enums\Cardinality; use qtism\runtime\common\ResponseVariable; use qtism\runtime\common\State; @@ -29,73 +29,73 @@ public function testTestVariables(TestVariables $expression, $expectedResult) { // S01.Q01 - set a correct response 'ChoiceA', scoring = 1.0 $session->beginAttempt(); - $responses = new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('ChoiceA')))); + $responses = new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('ChoiceA')))); $session->endAttempt($responses); - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $session['Q01.scoring']); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $session['Q01.scoring']); $this->assertEquals(1.0, $session['Q01.scoring']->getValue()); $session->moveNext(); // S01.Q02 - set an incorrect response but close to the correct one ['A P', 'D L'], SCORE = 3 $session->beginAttempt(); - $responses = new State(array(new ResponseVariable('RESPONSE', Cardinality::MULTIPLE, BaseType::PAIR, new MultipleContainer(BaseType::PAIR, array(new Pair('A', 'P'), new Pair('D', 'L')))))); + $responses = new State(array(new ResponseVariable('RESPONSE', Cardinality::MULTIPLE, BaseType::PAIR, new MultipleContainer(BaseType::PAIR, array(new QtiPair('A', 'P'), new QtiPair('D', 'L')))))); $session->endAttempt($responses); - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $session['Q02.SCORE']); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $session['Q02.SCORE']); $this->assertEquals(3.0, $session['Q02.SCORE']->getValue()); $session->moveNext(); // S01.Q03 - set a correct response ['H', '0'], SCORE = 2 $session->beginAttempt(); - $responses = new State(array(new ResponseVariable('RESPONSE', Cardinality::MULTIPLE, BaseType::IDENTIFIER, new MultipleContainer(BaseType::IDENTIFIER, array(new Identifier('H'), new Identifier('O')))))); + $responses = new State(array(new ResponseVariable('RESPONSE', Cardinality::MULTIPLE, BaseType::IDENTIFIER, new MultipleContainer(BaseType::IDENTIFIER, array(new QtiIdentifier('H'), new QtiIdentifier('O')))))); $session->endAttempt($responses); - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $session['Q03.SCORE']); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $session['Q03.SCORE']); $this->assertEquals(2.0, $session['Q03.SCORE']->getValue()); $session->moveNext(); // S02.Q04 - set an incorrect response ['W Sp', 'G2 Su'], SCORE = 0 $session->beginAttempt(); - $responses = new State(array(new ResponseVariable('RESPONSE', Cardinality::MULTIPLE, BaseType::DIRECTED_PAIR, new MultipleContainer(BaseType::DIRECTED_PAIR, array(new DirectedPair('W', 'Sp'), new DirectedPair('G2', 'Su')))))); + $responses = new State(array(new ResponseVariable('RESPONSE', Cardinality::MULTIPLE, BaseType::DIRECTED_PAIR, new MultipleContainer(BaseType::DIRECTED_PAIR, array(new QtiDirectedPair('W', 'Sp'), new QtiDirectedPair('G2', 'Su')))))); $session->endAttempt($responses); - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $session['Q04.SCORE']); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $session['Q04.SCORE']); $this->assertEquals(0.0, $session['Q04.SCORE']->getValue()); $session->moveNext(); // S02.Q05 - set an incorrect response ['C B', 'C D', 'B D'], SCORE = 1 (max = 2) $session->beginAttempt(); - $responses = new State(array(new ResponseVariable('RESPONSE', Cardinality::MULTIPLE, BaseType::PAIR, new MultipleContainer(BaseType::PAIR, array(new Pair('C', 'B'), new Pair('C', 'D'), new Pair('B', 'D')))))); + $responses = new State(array(new ResponseVariable('RESPONSE', Cardinality::MULTIPLE, BaseType::PAIR, new MultipleContainer(BaseType::PAIR, array(new QtiPair('C', 'B'), new QtiPair('C', 'D'), new QtiPair('B', 'D')))))); $session->endAttempt($responses); - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $session['Q05.SCORE']); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $session['Q05.SCORE']); $this->assertEquals(1.0, $session['Q05.SCORE']->getValue()); $session->moveNext(); // S02.Q06 - set an correct response 'A', mySc0r3 = 1 $session->beginAttempt(); - $responses = new State(array(new ResponseVariable('answer', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('A')))); + $responses = new State(array(new ResponseVariable('answer', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('A')))); $session->endAttempt($responses); - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $session['Q06.mySc0r3']); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $session['Q06.mySc0r3']); $this->assertEquals(1.0, $session['Q06.mySc0r3']->getValue()); $session->moveNext(); // S03.Q07.1 - set an incorrect but in shape response '105 105', SCORE = 1 $session->beginAttempt(); - $responses = new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::POINT, new Point(105, 105)))); + $responses = new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::POINT, new QtiPoint(105, 105)))); $session->endAttempt($responses); - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $session['Q07.1.SCORE']); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $session['Q07.1.SCORE']); $this->assertEquals(1.0, $session['Q07.1.SCORE']->getValue()); $session->moveNext(); // S03.Q07.2 - set a perfectly correct response '102 113', SCORE = 1 $session->beginAttempt(); - $responses = new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::POINT, new Point(102, 113)))); + $responses = new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::POINT, new QtiPoint(102, 113)))); $session->endAttempt($responses); - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $session['Q07.2.SCORE']); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $session['Q07.2.SCORE']); $this->assertEquals(1.0, $session['Q07.2.SCORE']->getValue()); $session->moveNext(); // S03.Q07.3 - set an absolutely incorrect response '13 37', SCORE = 0 $session->beginAttempt(); - $responses = new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::POINT, new Point(13, 37)))); + $responses = new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::POINT, new QtiPoint(13, 37)))); $session->endAttempt($responses); - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $session['Q07.3.SCORE']); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $session['Q07.3.SCORE']); $this->assertEquals(0.0, $session['Q07.3.SCORE']->getValue()); $session->moveNext(); @@ -110,28 +110,28 @@ public function testTestVariables(TestVariables $expression, $expectedResult) { public function testVariablesProvider() { return array( - array(self::getTestVariables('SCORE'), new MultipleContainer(BaseType::FLOAT, array(new Float(1.0), new Float(3.0), new Float(2.0), new Float(0.0), new Float(1.0), new Float(1.0), new Float(1.0), new Float(1.0), new Float(0.0)))), + array(self::getTestVariables('SCORE'), new MultipleContainer(BaseType::FLOAT, array(new QtiFloat(1.0), new QtiFloat(3.0), new QtiFloat(2.0), new QtiFloat(0.0), new QtiFloat(1.0), new QtiFloat(1.0), new QtiFloat(1.0), new QtiFloat(1.0), new QtiFloat(0.0)))), array(self::getTestVariables('scoring'), new MultipleContainer(BaseType::FLOAT)), - array(self::getTestVariables('SCORE', -1, '', 'S01'), new MultipleContainer(BaseType::FLOAT, array(new Float(1.0), new Float(3.0), new Float(2.0)))), - array(self::getTestVariables('SCORE', -1, '', 'S02'), new MultipleContainer(BaseType::FLOAT, array(new Float(0.0), new Float(1.0), new Float(1.0)))), - array(self::getTestVariables('SCORE', -1, '', 'S03'), new MultipleContainer(BaseType::FLOAT, array(new Float(1.0), new Float(1.0), new Float(0.0)))), - array(self::getTestVariables('SCORE', -1, 'W01'), new MultipleContainer(BaseType::FLOAT, array(new Float(2.0), new Float(6.0), new Float(4.0), new Float(0.0), new Float(2.0), new Float(2.0), new Float(2.0), new Float(2.0), new Float(0.0)))), - array(self::getTestVariables('SCORE', -1, 'W01', 'S01'), new MultipleContainer(BaseType::FLOAT, array(new Float(2.0), new Float(6.0), new Float(4.0)))), - array(self::getTestVariables('SCORE', -1, 'W01', 'S02'), new MultipleContainer(BaseType::FLOAT, array(new Float(0.0), new Float(2.0), new Float(2.0)))), - array(self::getTestVariables('SCORE', -1, 'W01', 'S03'), new MultipleContainer(BaseType::FLOAT, array(new Float(2.0), new Float(2.0), new Float(0.0)))), - array(self::getTestVariables('SCORE', -1, 'W0X'), new MultipleContainer(BaseType::FLOAT, array(new Float(1.0), new Float(3.0), new Float(2.0), new Float(0.0), new Float(1.0), new Float(1.0), new Float(1.0), new Float(1.0), new Float(0.0)))), // Weight not found, no weight applied - array(self::getTestVariables('SCORE', -1, 'W0X', 'S01'), new MultipleContainer(BaseType::FLOAT, array(new Float(1.0), new Float(3.0), new Float(2.0)))), // same as previous - array(self::getTestVariables('SCORE', -1, 'W0X', 'S02'), new MultipleContainer(BaseType::FLOAT, array(new Float(0.0), new Float(1.0), new Float(1.0)))), // same as previous - array(self::getTestVariables('SCORE', -1, 'W0X', 'S03'), new MultipleContainer(BaseType::FLOAT, array(new Float(1.0), new Float(1.0), new Float(0.0)))), // same as previous - array(self::getTestVariables('SCORE', BaseType::FLOAT), new MultipleContainer(BaseType::FLOAT, array(new Float(1.0), new Float(3.0), new Float(2.0), new Float(0.0), new Float(1.0), new Float(1.0), new Float(1.0), new Float(1.0), new Float(0.0)))), + array(self::getTestVariables('SCORE', -1, '', 'S01'), new MultipleContainer(BaseType::FLOAT, array(new QtiFloat(1.0), new QtiFloat(3.0), new QtiFloat(2.0)))), + array(self::getTestVariables('SCORE', -1, '', 'S02'), new MultipleContainer(BaseType::FLOAT, array(new QtiFloat(0.0), new QtiFloat(1.0), new QtiFloat(1.0)))), + array(self::getTestVariables('SCORE', -1, '', 'S03'), new MultipleContainer(BaseType::FLOAT, array(new QtiFloat(1.0), new QtiFloat(1.0), new QtiFloat(0.0)))), + array(self::getTestVariables('SCORE', -1, 'W01'), new MultipleContainer(BaseType::FLOAT, array(new QtiFloat(2.0), new QtiFloat(6.0), new QtiFloat(4.0), new QtiFloat(0.0), new QtiFloat(2.0), new QtiFloat(2.0), new QtiFloat(2.0), new QtiFloat(2.0), new QtiFloat(0.0)))), + array(self::getTestVariables('SCORE', -1, 'W01', 'S01'), new MultipleContainer(BaseType::FLOAT, array(new QtiFloat(2.0), new QtiFloat(6.0), new QtiFloat(4.0)))), + array(self::getTestVariables('SCORE', -1, 'W01', 'S02'), new MultipleContainer(BaseType::FLOAT, array(new QtiFloat(0.0), new QtiFloat(2.0), new QtiFloat(2.0)))), + array(self::getTestVariables('SCORE', -1, 'W01', 'S03'), new MultipleContainer(BaseType::FLOAT, array(new QtiFloat(2.0), new QtiFloat(2.0), new QtiFloat(0.0)))), + array(self::getTestVariables('SCORE', -1, 'W0X'), new MultipleContainer(BaseType::FLOAT, array(new QtiFloat(1.0), new QtiFloat(3.0), new QtiFloat(2.0), new QtiFloat(0.0), new QtiFloat(1.0), new QtiFloat(1.0), new QtiFloat(1.0), new QtiFloat(1.0), new QtiFloat(0.0)))), // Weight not found, no weight applied + array(self::getTestVariables('SCORE', -1, 'W0X', 'S01'), new MultipleContainer(BaseType::FLOAT, array(new QtiFloat(1.0), new QtiFloat(3.0), new QtiFloat(2.0)))), // same as previous + array(self::getTestVariables('SCORE', -1, 'W0X', 'S02'), new MultipleContainer(BaseType::FLOAT, array(new QtiFloat(0.0), new QtiFloat(1.0), new QtiFloat(1.0)))), // same as previous + array(self::getTestVariables('SCORE', -1, 'W0X', 'S03'), new MultipleContainer(BaseType::FLOAT, array(new QtiFloat(1.0), new QtiFloat(1.0), new QtiFloat(0.0)))), // same as previous + array(self::getTestVariables('SCORE', BaseType::FLOAT), new MultipleContainer(BaseType::FLOAT, array(new QtiFloat(1.0), new QtiFloat(3.0), new QtiFloat(2.0), new QtiFloat(0.0), new QtiFloat(1.0), new QtiFloat(1.0), new QtiFloat(1.0), new QtiFloat(1.0), new QtiFloat(0.0)))), array(self::getTestVariables('SCORE', BaseType::INTEGER), new MultipleContainer(BaseType::FLOAT, array())), - array(self::getTestVariables('SCORE', BaseType::FLOAT, '', '', new IdentifierCollection(array('mathematics'))), new MultipleContainer(BaseType::FLOAT, array(new Float(1.0), new Float(2.0), new Float(1.0)))), - array(self::getTestVariables('SCORE', BaseType::FLOAT, '', '', null, new IdentifierCollection(array('mathematics', 'minimum'))), new MultipleContainer(BaseType::FLOAT, array(new Float(3.0), new Float(0.0)))), - array(self::getTestVariables('SCORE', -1, 'W01', 'S01', null, new IdentifierCollection(array('mathematics', 'minimum'))), new MultipleContainer(BaseType::FLOAT, array(new Float(6.0)))), + array(self::getTestVariables('SCORE', BaseType::FLOAT, '', '', new IdentifierCollection(array('mathematics'))), new MultipleContainer(BaseType::FLOAT, array(new QtiFloat(1.0), new QtiFloat(2.0), new QtiFloat(1.0)))), + array(self::getTestVariables('SCORE', BaseType::FLOAT, '', '', null, new IdentifierCollection(array('mathematics', 'minimum'))), new MultipleContainer(BaseType::FLOAT, array(new QtiFloat(3.0), new QtiFloat(0.0)))), + array(self::getTestVariables('SCORE', -1, 'W01', 'S01', null, new IdentifierCollection(array('mathematics', 'minimum'))), new MultipleContainer(BaseType::FLOAT, array(new QtiFloat(6.0)))), array(self::getTestVariables('RESPONSE'), new MultipleContainer(BaseType::FLOAT)), - array(self::getTestVariables('RESPONSE', BaseType::IDENTIFIER), new MultipleContainer(BaseType::IDENTIFIER, array(new Identifier('ChoiceA'), new Identifier('A')))), // Do not forget it only matches if Cardinality = SINGLE - array(self::getTestVariables('RESPONSE', BaseType::IDENTIFIER, 'W01'), new MultipleContainer(BaseType::IDENTIFIER, array(new Identifier('ChoiceA'), new Identifier('A')))), // Weight only applies if baseType is ommited or FLOAT. - array(self::getTestVariables('RESPONSE', BaseType::IDENTIFIER, 'W01', 'S01'), new MultipleContainer(BaseType::IDENTIFIER, array(new Identifier('ChoiceA')))), // Weight only applies if baseType is ommited or FLOAT. + array(self::getTestVariables('RESPONSE', BaseType::IDENTIFIER), new MultipleContainer(BaseType::IDENTIFIER, array(new QtiIdentifier('ChoiceA'), new QtiIdentifier('A')))), // Do not forget it only matches if Cardinality = SINGLE + array(self::getTestVariables('RESPONSE', BaseType::IDENTIFIER, 'W01'), new MultipleContainer(BaseType::IDENTIFIER, array(new QtiIdentifier('ChoiceA'), new QtiIdentifier('A')))), // Weight only applies if baseType is ommited or FLOAT. + array(self::getTestVariables('RESPONSE', BaseType::IDENTIFIER, 'W01', 'S01'), new MultipleContainer(BaseType::IDENTIFIER, array(new QtiIdentifier('ChoiceA')))), // Weight only applies if baseType is ommited or FLOAT. ); } diff --git a/test/qtismtest/runtime/expressions/VariableProcessorTest.php b/test/qtismtest/runtime/expressions/VariableProcessorTest.php index ac6b478f2..316c3d11e 100644 --- a/test/qtismtest/runtime/expressions/VariableProcessorTest.php +++ b/test/qtismtest/runtime/expressions/VariableProcessorTest.php @@ -2,9 +2,9 @@ namespace qtismtest\runtime\expressions; use qtismtest\QtiSmTestCase; -use qtism\common\datatypes\Identifier; -use qtism\common\datatypes\Float; -use qtism\common\datatypes\Integer; +use qtism\common\datatypes\QtiIdentifier; +use qtism\common\datatypes\QtiFloat; +use qtism\common\datatypes\QtiInteger; use qtism\runtime\tests\SessionManager; use qtism\runtime\common\ResponseVariable; use qtism\runtime\tests\AssessmentItemSession; @@ -35,7 +35,7 @@ public function testSimple() { $variableExpr = $this->createComponentFromXml(''); // single cardinality test. - $var1 = new OutcomeVariable('var1', Cardinality::SINGLE, BaseType::INTEGER, new Integer(1337)); + $var1 = new OutcomeVariable('var1', Cardinality::SINGLE, BaseType::INTEGER, new QtiInteger(1337)); $state = new State(array($var1)); $this->assertInstanceOf('qtism\\runtime\\common\\OutcomeVariable', $state->getVariable('var1')); @@ -44,11 +44,11 @@ public function testSimple() { $variableProcessor->setState($state); // State is populated with var1. $result = $variableProcessor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Integer', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiInteger', $result); $this->assertEquals(1337, $result->getValue()); // multiple cardinality test. - $val = new OrderedContainer(BaseType::INTEGER, array(new Integer(10), new Integer(12))); + $val = new OrderedContainer(BaseType::INTEGER, array(new QtiInteger(10), new QtiInteger(12))); $var2 = new OutcomeVariable('var2', Cardinality::ORDERED, BaseType::INTEGER, $val); $state->setVariable($var2); $variableExpr = $this->createComponentFromXml(''); @@ -78,7 +78,7 @@ public function testWeighted() { $assessmentTestSession = $sessionManager->createAssessmentTestSession($assessmentTest); $assessmentTestSession->beginTestSession(); - $assessmentTestSession['Q01.var1'] = new Integer(1337); + $assessmentTestSession['Q01.var1'] = new QtiInteger(1337); $variableExpr = $this->createComponentFromXml(''); $variableProcessor = new VariableProcessor($variableExpr); @@ -86,7 +86,7 @@ public function testWeighted() { // -- single cardinality test. $result = $variableProcessor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $result); $this->assertEquals(1470.7, $result->getValue()); // The value in the state must be intact. $this->assertEquals(1337, $assessmentTestSession['Q01.var1']->getValue()); @@ -98,7 +98,7 @@ public function testWeighted() { $this->assertEquals(1337, $result->getValue()); // -- multiple cardinality test. - $assessmentTestSession['Q01.var2'] = new MultipleContainer(BaseType::FLOAT, array(new Float(10.1), new Float(12.1))); + $assessmentTestSession['Q01.var2'] = new MultipleContainer(BaseType::FLOAT, array(new QtiFloat(10.1), new QtiFloat(12.1))); $variableExpr = $this->createComponentFromXml(''); $variableProcessor->setExpression($variableExpr); $result = $variableProcessor->process(); @@ -140,7 +140,7 @@ public function testMultipleOccurences() { // Q01.1 $session->beginAttempt(); - $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('ChoiceA'))))); + $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('ChoiceA'))))); $variableProcessor->setExpression($variableExpr); $result = $variableProcessor->process(); @@ -153,13 +153,13 @@ public function testMultipleOccurences() { $variableProcessor->setExpression($occurenceVariableExpression); $result = $variableProcessor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $result); $this->assertEquals(1.0, $result->getValue()); $session->moveNext(); // Q01.2 $session->beginAttempt(); - $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('ChoiceB'))))); + $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('ChoiceB'))))); $variableProcessor->setExpression($variableExpr); $result = $variableProcessor->process(); @@ -168,13 +168,13 @@ public function testMultipleOccurences() { // $occurenceVariableExpression still targets Q01.1 $variableProcessor->setExpression($occurenceVariableExpression); $result = $variableProcessor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $result); $this->assertEquals(1.0, $result->getValue()); // $occurenceVariableExpression now targets Q01.2 $occurenceVariableExpression->setIdentifier('Q01.2.SCORE'); $result = $variableProcessor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $result); $this->assertEquals(0.0, $result->getValue()); } } \ No newline at end of file diff --git a/test/qtismtest/runtime/expressions/operators/AndProcessorTest.php b/test/qtismtest/runtime/expressions/operators/AndProcessorTest.php index 6a4586335..dbd07684a 100644 --- a/test/qtismtest/runtime/expressions/operators/AndProcessorTest.php +++ b/test/qtismtest/runtime/expressions/operators/AndProcessorTest.php @@ -2,15 +2,15 @@ namespace qtismtest\runtime\expressions\operators; use qtismtest\QtiSmTestCase; -use qtism\common\datatypes\Point; +use qtism\common\datatypes\QtiPoint; use qtism\runtime\expressions\operators\AndProcessor; use qtism\runtime\expressions\operators\OperandsCollection; use qtism\common\enums\BaseType; use qtism\runtime\common\MultipleContainer; use qtism\runtime\common\RecordContainer; -use qtism\common\datatypes\Boolean; -use qtism\common\datatypes\Float; -use qtism\common\datatypes\String; +use qtism\common\datatypes\QtiBoolean; +use qtism\common\datatypes\QtiFloat; +use qtism\common\datatypes\QtiString; class AndProcessorTest extends QtiSmTestCase { @@ -24,7 +24,7 @@ public function testNotEnoughOperands () { public function testWrongBaseType() { $expression = $this->createFakeExpression(); - $operands = new OperandsCollection(array(new Point(1, 2))); + $operands = new OperandsCollection(array(new QtiPoint(1, 2))); $processor = new AndProcessor($expression, $operands); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $result = $processor->process(); @@ -32,7 +32,7 @@ public function testWrongBaseType() { public function testWrongCardinalityOne() { $expression = $this->createFakeExpression(); - $operands = new OperandsCollection(array(new RecordContainer(array('a' => new String('string!'))))); + $operands = new OperandsCollection(array(new RecordContainer(array('a' => new QtiString('string!'))))); $processor = new AndProcessor($expression, $operands); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $result = $processor->process(); @@ -40,7 +40,7 @@ public function testWrongCardinalityOne() { public function testWrongCardinalityTwo() { $expression = $this->createFakeExpression(); - $operands = new OperandsCollection(array(new MultipleContainer(BaseType::FLOAT, array(new Float(25.0))))); + $operands = new OperandsCollection(array(new MultipleContainer(BaseType::FLOAT, array(new QtiFloat(25.0))))); $processor = new AndProcessor($expression, $operands); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $result = $processor->process(); @@ -57,7 +57,7 @@ public function testNullOperands() { $this->assertSame(null, $result); // Two NULL values, 'null' && new RecordContainer(). - $operands = new OperandsCollection(array(new Boolean(true), new Boolean(false), new Boolean(true), null, new RecordContainer())); + $operands = new OperandsCollection(array(new QtiBoolean(true), new QtiBoolean(false), new QtiBoolean(true), null, new RecordContainer())); $processor->setOperands($operands); $result = $processor->process(); $this->assertSame(null, $result); @@ -65,31 +65,31 @@ public function testNullOperands() { public function testTrue() { $expression = $this->createFakeExpression(); - $operands = new OperandsCollection(array(new Boolean(true))); + $operands = new OperandsCollection(array(new QtiBoolean(true))); $processor = new AndProcessor($expression, $operands); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Boolean', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiBoolean', $result); $this->assertSame(true, $result->getValue()); - $operands = new OperandsCollection(array(new Boolean(true), new Boolean(true), new Boolean(true))); + $operands = new OperandsCollection(array(new QtiBoolean(true), new QtiBoolean(true), new QtiBoolean(true))); $processor->setOperands($operands); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Boolean', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiBoolean', $result); $this->assertSame(true, $result->getValue()); } public function testFalse() { $expression = $this->createFakeExpression(); - $operands = new OperandsCollection(array(new Boolean(false))); + $operands = new OperandsCollection(array(new QtiBoolean(false))); $processor = new AndProcessor($expression, $operands); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Boolean', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiBoolean', $result); $this->assertSame(false, $result->getValue()); - $operands = new OperandsCollection(array(new Boolean(false), new Boolean(true), new Boolean(false))); + $operands = new OperandsCollection(array(new QtiBoolean(false), new QtiBoolean(true), new QtiBoolean(false))); $processor->setOperands($operands); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Boolean', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiBoolean', $result); $this->assertSame(false, $result->getValue()); } diff --git a/test/qtismtest/runtime/expressions/operators/AnyNProcessorTest.php b/test/qtismtest/runtime/expressions/operators/AnyNProcessorTest.php index 013031302..ba73d0188 100644 --- a/test/qtismtest/runtime/expressions/operators/AnyNProcessorTest.php +++ b/test/qtismtest/runtime/expressions/operators/AnyNProcessorTest.php @@ -2,14 +2,14 @@ namespace qtismtest\runtime\expressions\operators; use qtismtest\QtiSmTestCase; -use qtism\common\datatypes\Float; -use qtism\common\datatypes\Integer; -use qtism\common\datatypes\String; +use qtism\common\datatypes\QtiFloat; +use qtism\common\datatypes\QtiInteger; +use qtism\common\datatypes\QtiString; use qtism\runtime\common\State; use qtism\common\enums\Cardinality; -use qtism\common\datatypes\Boolean; +use qtism\common\datatypes\QtiBoolean; use qtism\runtime\common\OutcomeVariable; -use qtism\common\datatypes\Point; +use qtism\common\datatypes\QtiPoint; use qtism\common\enums\BaseType; use qtism\runtime\common\MultipleContainer; use qtism\runtime\expressions\operators\AnyNProcessor; @@ -51,7 +51,7 @@ public function testWrongCardinality() { public function testWrongBaseTypeOne() { $expression = $this->createFakeExpression(2, 3); - $operands = new OperandsCollection(array(new String('String'))); + $operands = new OperandsCollection(array(new QtiString('String'))); $processor = new AnyNProcessor($expression, $operands); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $result = $processor->process(); @@ -59,7 +59,7 @@ public function testWrongBaseTypeOne() { public function testWrongBaseTypeTwo() { $expression = $this->createFakeExpression(2, 3); - $operands = new OperandsCollection(array(new Point(1, 2))); + $operands = new OperandsCollection(array(new QtiPoint(1, 2))); $processor = new AnyNProcessor($expression, $operands); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $result = $processor->process(); @@ -74,8 +74,8 @@ public function testNotEnoughOperands() { public function testWithMinFromVariableReference() { $expression = $this->createFakeExpression('var1', 4); - $var1 = new OutcomeVariable('var1', Cardinality::SINGLE, BaseType::INTEGER, new Integer(3)); - $operands = new OperandsCollection(array(new Boolean(true), new Boolean(false), new Boolean(false), null)); + $var1 = new OutcomeVariable('var1', Cardinality::SINGLE, BaseType::INTEGER, new QtiInteger(3)); + $operands = new OperandsCollection(array(new QtiBoolean(true), new QtiBoolean(false), new QtiBoolean(false), null)); $state = new State(); $state->setVariable($var1); $processor = new AnyNProcessor($expression, $operands); @@ -86,8 +86,8 @@ public function testWithMinFromVariableReference() { public function testWithMaxFromVariableReference() { $expression = $this->createFakeExpression(3, 'var1'); - $var1 = new OutcomeVariable('var1', Cardinality::SINGLE, BaseType::INTEGER, new Integer(4)); - $operands = new OperandsCollection(array(new Boolean(true), new Boolean(true), new Boolean(true), null)); + $var1 = new OutcomeVariable('var1', Cardinality::SINGLE, BaseType::INTEGER, new QtiInteger(4)); + $operands = new OperandsCollection(array(new QtiBoolean(true), new QtiBoolean(true), new QtiBoolean(true), null)); $state = new State(); $state->setVariable($var1); $processor = new AnyNProcessor($expression, $operands); @@ -98,7 +98,7 @@ public function testWithMaxFromVariableReference() { public function testMinCannotBeResolved() { $expression = $this->createFakeExpression('min', 4); - $operands = new OperandsCollection(array(new Boolean(true), new Boolean(true), new Boolean(true), null)); + $operands = new OperandsCollection(array(new QtiBoolean(true), new QtiBoolean(true), new QtiBoolean(true), null)); $processor = new AnyNProcessor($expression, $operands); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $result = $processor->process(); @@ -106,7 +106,7 @@ public function testMinCannotBeResolved() { public function testMaxCannotBeResolved() { $expression = $this->createFakeExpression(3, 'max'); - $operands = new OperandsCollection(array(new Boolean(true), new Boolean(true), new Boolean(true), null)); + $operands = new OperandsCollection(array(new QtiBoolean(true), new QtiBoolean(true), new QtiBoolean(true), null)); $processor = new AnyNProcessor($expression, $operands); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $result = $processor->process(); @@ -114,8 +114,8 @@ public function testMaxCannotBeResolved() { public function testMinReferenceWrongBaseType() { $expression = $this->createFakeExpression('min', 4); - $min = new OutcomeVariable('min', Cardinality::SINGLE, BaseType::FLOAT, new Float(2.3)); - $operands = new OperandsCollection(array(new Boolean(true), new Boolean(true), new Boolean(true), null)); + $min = new OutcomeVariable('min', Cardinality::SINGLE, BaseType::FLOAT, new QtiFloat(2.3)); + $operands = new OperandsCollection(array(new QtiBoolean(true), new QtiBoolean(true), new QtiBoolean(true), null)); $state = new State(); $state->setVariable($min); $processor = new AnyNProcessor($expression, $operands); @@ -126,8 +126,8 @@ public function testMinReferenceWrongBaseType() { public function testMaxReferenceWrongBaseType() { $expression = $this->createFakeExpression(3, 'max'); - $max = new OutcomeVariable('max', Cardinality::SINGLE, BaseType::FLOAT, new Float(4.5356)); - $operands = new OperandsCollection(array(new Boolean(true), new Boolean(true), new Boolean(true), null)); + $max = new OutcomeVariable('max', Cardinality::SINGLE, BaseType::FLOAT, new QtiFloat(4.5356)); + $operands = new OperandsCollection(array(new QtiBoolean(true), new QtiBoolean(true), new QtiBoolean(true), null)); $state = new State(); $state->setVariable($max); $processor = new AnyNProcessor($expression, $operands); @@ -149,27 +149,27 @@ public function createFakeExpression($min, $max) { public function anyNProvider() { $returnValue = array(); - $returnValue[] = array(3, 5, array(new Boolean(true), new Boolean(true), new Boolean(true)), true); - $returnValue[] = array(3, 5, array(new Boolean(true), new Boolean(true), new Boolean(true), new Boolean(true)), true); - $returnValue[] = array(3, 5, array(new Boolean(true), new Boolean(true), new Boolean(true), new Boolean(true), new Boolean(true)), true); - $returnValue[] = array(3, 5, array(new Boolean(true), new Boolean(true), new Boolean(true), new Boolean(true), new Boolean(true), new Boolean(true)), false); - $returnValue[] = array(3, 5, array(new Boolean(true)), false); - $returnValue[] = array(3, 5, array(new Boolean(false), new Boolean(true), new Boolean(false), new Boolean(true), new Boolean(true)), true); - $returnValue[] = array(3, 5, array(new Boolean(true), new Boolean(false), new Boolean(true), new Boolean(false)), false); - $returnValue[] = array(3, 5, array(new Boolean(false)), false); - $returnValue[] = array(3, 5, array(new Boolean(false), new Boolean(false), new Boolean(false), null), false); - $returnValue[] = array(3, 5, array(new Boolean(false), new Boolean(false), null, null), false); - $returnValue[] = array(3, 5, array(new Boolean(false), new Boolean(false), null, null), false); - $returnValue[] = array(3, 5, array(new Boolean(false), new Boolean(false), null, null, null), null); - $returnValue[] = array(3, 5, array(new Boolean(false), new Boolean(false), new Boolean(true), null, new Boolean(true)), null); + $returnValue[] = array(3, 5, array(new QtiBoolean(true), new QtiBoolean(true), new QtiBoolean(true)), true); + $returnValue[] = array(3, 5, array(new QtiBoolean(true), new QtiBoolean(true), new QtiBoolean(true), new QtiBoolean(true)), true); + $returnValue[] = array(3, 5, array(new QtiBoolean(true), new QtiBoolean(true), new QtiBoolean(true), new QtiBoolean(true), new QtiBoolean(true)), true); + $returnValue[] = array(3, 5, array(new QtiBoolean(true), new QtiBoolean(true), new QtiBoolean(true), new QtiBoolean(true), new QtiBoolean(true), new QtiBoolean(true)), false); + $returnValue[] = array(3, 5, array(new QtiBoolean(true)), false); + $returnValue[] = array(3, 5, array(new QtiBoolean(false), new QtiBoolean(true), new QtiBoolean(false), new QtiBoolean(true), new QtiBoolean(true)), true); + $returnValue[] = array(3, 5, array(new QtiBoolean(true), new QtiBoolean(false), new QtiBoolean(true), new QtiBoolean(false)), false); + $returnValue[] = array(3, 5, array(new QtiBoolean(false)), false); + $returnValue[] = array(3, 5, array(new QtiBoolean(false), new QtiBoolean(false), new QtiBoolean(false), null), false); + $returnValue[] = array(3, 5, array(new QtiBoolean(false), new QtiBoolean(false), null, null), false); + $returnValue[] = array(3, 5, array(new QtiBoolean(false), new QtiBoolean(false), null, null), false); + $returnValue[] = array(3, 5, array(new QtiBoolean(false), new QtiBoolean(false), null, null, null), null); + $returnValue[] = array(3, 5, array(new QtiBoolean(false), new QtiBoolean(false), new QtiBoolean(true), null, new QtiBoolean(true)), null); $returnValue[] = array(3, 5, array(null, null, null, null), null); $returnValue[] = array(3, 5, array(null), false); - $returnValue[] = array(0, 0, array(new Boolean(true)), false); + $returnValue[] = array(0, 0, array(new QtiBoolean(true)), false); // From IMS Spec - $returnValue[] = array(3, 4, array(new Boolean(true), new Boolean(true), new Boolean(false), null), null); - $returnValue[] = array(3, 4, array(new Boolean(true), new Boolean(false), new Boolean(false), null), false); - $returnValue[] = array(3, 4, array(new Boolean(true), new Boolean(true), new Boolean(true), null), true); + $returnValue[] = array(3, 4, array(new QtiBoolean(true), new QtiBoolean(true), new QtiBoolean(false), null), null); + $returnValue[] = array(3, 4, array(new QtiBoolean(true), new QtiBoolean(false), new QtiBoolean(false), null), false); + $returnValue[] = array(3, 4, array(new QtiBoolean(true), new QtiBoolean(true), new QtiBoolean(true), null), true); return $returnValue; } diff --git a/test/qtismtest/runtime/expressions/operators/ContainerSizeProcessorTest.php b/test/qtismtest/runtime/expressions/operators/ContainerSizeProcessorTest.php index b373dc5d8..4b6ef1612 100644 --- a/test/qtismtest/runtime/expressions/operators/ContainerSizeProcessorTest.php +++ b/test/qtismtest/runtime/expressions/operators/ContainerSizeProcessorTest.php @@ -2,13 +2,13 @@ namespace qtismtest\runtime\expressions\operators; use qtismtest\QtiSmTestCase; -use qtism\common\datatypes\String; -use qtism\common\datatypes\Float; -use qtism\common\datatypes\Integer; +use qtism\common\datatypes\QtiString; +use qtism\common\datatypes\QtiFloat; +use qtism\common\datatypes\QtiInteger; use qtism\runtime\expressions\operators\ContainerSizeProcessor; use qtism\data\expressions\operators\ContainerSize; use qtism\runtime\expressions\operators\OperandsCollection; -use qtism\common\datatypes\Point; +use qtism\common\datatypes\QtiPoint; use qtism\runtime\common\RecordContainer; use qtism\common\enums\BaseType; use qtism\runtime\common\MultipleContainer; @@ -25,8 +25,8 @@ public function testNotEnoughOperands() { public function testTooMuchOperands() { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); - $operands[] = new MultipleContainer(BaseType::INTEGER, array(new Integer(25))); - $operands[] = new MultipleContainer(BaseType::INTEGER, array(new Integer(26))); + $operands[] = new MultipleContainer(BaseType::INTEGER, array(new QtiInteger(25))); + $operands[] = new MultipleContainer(BaseType::INTEGER, array(new QtiInteger(26))); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $processor = new ContainerSizeProcessor($expression, $operands); } @@ -36,19 +36,19 @@ public function testNull() { $operands = new OperandsCollection(array(null)); $processor = new ContainerSizeProcessor($expression, $operands); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Integer', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiInteger', $result); $this->assertSame(0, $result->getValue()); $operands = new OperandsCollection(array(new MultipleContainer(BaseType::INTEGER))); $processor->setOperands($operands); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Integer', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiInteger', $result); $this->assertSame(0, $result->getValue()); } public function testWrongCardinalityOne() { $expression = $this->createFakeExpression(); - $operands = new OperandsCollection(array(new Integer(25))); + $operands = new OperandsCollection(array(new QtiInteger(25))); $processor = new ContainerSizeProcessor($expression, $operands); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $result = $processor->process(); @@ -56,7 +56,7 @@ public function testWrongCardinalityOne() { public function testWrongCardinalityTwo() { $expression = $this->createFakeExpression(); - $operands = new OperandsCollection(array(new RecordContainer(array('1' => new Float(1.0), '2' => new Integer(2))))); + $operands = new OperandsCollection(array(new RecordContainer(array('1' => new QtiFloat(1.0), '2' => new QtiInteger(2))))); $processor = new ContainerSizeProcessor($expression, $operands); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $result = $processor->process(); @@ -65,15 +65,15 @@ public function testWrongCardinalityTwo() { public function testSize() { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); - $operands[] = new MultipleContainer(BaseType::STRING, array(new String('String!'))); + $operands[] = new MultipleContainer(BaseType::STRING, array(new QtiString('String!'))); $processor = new ContainerSizeProcessor($expression, $operands); $result = $processor->process(); $this->assertEquals(1, $result->getValue()); $operands->reset(); - $operands[] = new MultipleContainer(BaseType::POINT, array(new Point(1, 2), new Point(2, 3), new Point(3, 4))); + $operands[] = new MultipleContainer(BaseType::POINT, array(new QtiPoint(1, 2), new QtiPoint(2, 3), new QtiPoint(3, 4))); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Integer', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiInteger', $result); $this->assertEquals(3, $result->getValue()); } diff --git a/test/qtismtest/runtime/expressions/operators/ContainsProcessorTest.php b/test/qtismtest/runtime/expressions/operators/ContainsProcessorTest.php index c2503144e..8ba7a459f 100644 --- a/test/qtismtest/runtime/expressions/operators/ContainsProcessorTest.php +++ b/test/qtismtest/runtime/expressions/operators/ContainsProcessorTest.php @@ -2,12 +2,12 @@ namespace qtismtest\runtime\expressions\operators; use qtismtest\QtiSmTestCase; -use qtism\common\datatypes\Identifier; -use qtism\common\datatypes\Float; -use qtism\common\datatypes\Integer; -use qtism\common\datatypes\String; +use qtism\common\datatypes\QtiIdentifier; +use qtism\common\datatypes\QtiFloat; +use qtism\common\datatypes\QtiInteger; +use qtism\common\datatypes\QtiString; use qtism\runtime\common\RecordContainer; -use qtism\common\datatypes\Point; +use qtism\common\datatypes\QtiPoint; use qtism\common\enums\BaseType; use qtism\runtime\common\OrderedContainer; use qtism\runtime\common\MultipleContainer; @@ -21,27 +21,27 @@ public function testPrimitiveOrderedTrailing() { // For ordered containers [A,B,C] contains [B,C] $operands = new OperandsCollection(); - $operands[] = new OrderedContainer(BaseType::STRING, array(new String('A'), new String('B'), new String('C'))); - $operands[] = new OrderedContainer(BaseType::STRING, array(new String('B'), new String('C'))); + $operands[] = new OrderedContainer(BaseType::STRING, array(new QtiString('A'), new QtiString('B'), new QtiString('C'))); + $operands[] = new OrderedContainer(BaseType::STRING, array(new QtiString('B'), new QtiString('C'))); $processor = new ContainsProcessor($expression, $operands); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Boolean', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiBoolean', $result); $this->assertTrue($result->getValue()); // [A,B,C] does not contain [C,B] $operands->reset(); - $operands[] = new OrderedContainer(BaseType::STRING, array(new String('A'), new String('B'), new String('C'))); - $operands[] = new OrderedContainer(BaseType::STRING, array(new String('C'), new String('B'))); + $operands[] = new OrderedContainer(BaseType::STRING, array(new QtiString('A'), new QtiString('B'), new QtiString('C'))); + $operands[] = new OrderedContainer(BaseType::STRING, array(new QtiString('C'), new QtiString('B'))); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Boolean', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiBoolean', $result); $this->assertFalse($result->getValue()); // [A,B,C] does not contain [E,F] $operands->reset(); - $operands[] = new OrderedContainer(BaseType::STRING, array(new String('A'), new String('B'), new String('C'))); - $operands[] = new OrderedContainer(BaseType::STRING, array(new String('E'), new String('F'))); + $operands[] = new OrderedContainer(BaseType::STRING, array(new QtiString('A'), new QtiString('B'), new QtiString('C'))); + $operands[] = new OrderedContainer(BaseType::STRING, array(new QtiString('E'), new QtiString('F'))); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Boolean', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiBoolean', $result); $this->assertFalse($result->getValue()); } @@ -50,19 +50,19 @@ public function testPrimitiveOrderedLeading() { // For ordered containers [A,B,C] contains [A,B] $operands = new OperandsCollection(); - $operands[] = new OrderedContainer(BaseType::STRING, array(new String('A'), new String('B'), new String('C'))); - $operands[] = new OrderedContainer(BaseType::STRING, array(new String('A'), new String('B'))); + $operands[] = new OrderedContainer(BaseType::STRING, array(new QtiString('A'), new QtiString('B'), new QtiString('C'))); + $operands[] = new OrderedContainer(BaseType::STRING, array(new QtiString('A'), new QtiString('B'))); $processor = new ContainsProcessor($expression, $operands); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Boolean', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiBoolean', $result); $this->assertTrue($result->getValue()); // [A,B,C] does not contain [B,A] $operands->reset(); - $operands[] = new OrderedContainer(BaseType::STRING, array(new String('A'), new String('B'), new String('C'))); - $operands[] = new OrderedContainer(BaseType::STRING, array(new String('B'), new String('A'))); + $operands[] = new OrderedContainer(BaseType::STRING, array(new QtiString('A'), new QtiString('B'), new QtiString('C'))); + $operands[] = new OrderedContainer(BaseType::STRING, array(new QtiString('B'), new QtiString('A'))); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Boolean', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiBoolean', $result); $this->assertFalse($result->getValue()); } @@ -71,27 +71,27 @@ public function testPrimitiveOrderedInBetween() { // For ordered containers [A,B,C,D] contains [B] $operands = new OperandsCollection(); - $operands[] = new OrderedContainer(BaseType::STRING, array(new String('A'), new String('B'), new String('C'), new String('D'))); - $operands[] = new OrderedContainer(BaseType::STRING, array(new String('B'))); + $operands[] = new OrderedContainer(BaseType::STRING, array(new QtiString('A'), new QtiString('B'), new QtiString('C'), new QtiString('D'))); + $operands[] = new OrderedContainer(BaseType::STRING, array(new QtiString('B'))); $processor = new ContainsProcessor($expression, $operands); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Boolean', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiBoolean', $result); $this->assertTrue($result->getValue()); // [A,B,C,D] does not contain [E] $operands->reset(); - $operands[] = new OrderedContainer(BaseType::STRING, array(new String('A'), new String('B'), new String('C'), new String('D'))); - $operands[] = new OrderedContainer(BaseType::STRING, array(new String('E'))); + $operands[] = new OrderedContainer(BaseType::STRING, array(new QtiString('A'), new QtiString('B'), new QtiString('C'), new QtiString('D'))); + $operands[] = new OrderedContainer(BaseType::STRING, array(new QtiString('E'))); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Boolean', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiBoolean', $result); $this->assertFalse($result->getValue()); // [A,B,C,D] contains [B,C] $operands->reset(); - $operands[] = new OrderedContainer(BaseType::STRING, array(new String('A'), new String('B'), new String('C'), new String('D'))); - $operands[] = new OrderedContainer(BaseType::STRING, array(new String('B'), new String('C'))); + $operands[] = new OrderedContainer(BaseType::STRING, array(new QtiString('A'), new QtiString('B'), new QtiString('C'), new QtiString('D'))); + $operands[] = new OrderedContainer(BaseType::STRING, array(new QtiString('B'), new QtiString('C'))); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Boolean', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiBoolean', $result); $this->assertTrue($result->getValue()); } @@ -100,27 +100,27 @@ public function testPrimitiveMultipleTrailing() { // For multiple containers [A,B,C] contains [B,C] $operands = new OperandsCollection(); - $operands[] = new MultipleContainer(BaseType::STRING, array(new String('A'), new String('B'), new String('C'))); - $operands[] = new MultipleContainer(BaseType::STRING, array(new String('B'), new String('C'))); + $operands[] = new MultipleContainer(BaseType::STRING, array(new QtiString('A'), new QtiString('B'), new QtiString('C'))); + $operands[] = new MultipleContainer(BaseType::STRING, array(new QtiString('B'), new QtiString('C'))); $processor = new ContainsProcessor($expression, $operands); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Boolean', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiBoolean', $result); $this->assertTrue($result->getValue()); // [A,B,C] contains [C,B] $operands->reset(); - $operands[] = new MultipleContainer(BaseType::STRING, array(new String('A'), new String('B'), new String('C'))); - $operands[] = new MultipleContainer(BaseType::STRING, array(new String('C'), new String('B'))); + $operands[] = new MultipleContainer(BaseType::STRING, array(new QtiString('A'), new QtiString('B'), new QtiString('C'))); + $operands[] = new MultipleContainer(BaseType::STRING, array(new QtiString('C'), new QtiString('B'))); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Boolean', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiBoolean', $result); $this->assertTrue($result->getValue()); // [A,B,C] does not contain [E,F] $operands->reset(); - $operands[] = new MultipleContainer(BaseType::STRING, array(new String('A'), new String('B'), new String('C'))); - $operands[] = new MultipleContainer(BaseType::STRING, array(new String('E'), new String('F'))); + $operands[] = new MultipleContainer(BaseType::STRING, array(new QtiString('A'), new QtiString('B'), new QtiString('C'))); + $operands[] = new MultipleContainer(BaseType::STRING, array(new QtiString('E'), new QtiString('F'))); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Boolean', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiBoolean', $result); $this->assertFalse($result->getValue()); } @@ -129,19 +129,19 @@ public function testPrimitiveMultipleLeading() { // For ordered containers [A,B,C] contains [A,B] $operands = new OperandsCollection(); - $operands[] = new MultipleContainer(BaseType::STRING, array(new String('A'), new String('B'), new String('C'))); - $operands[] = new MultipleContainer(BaseType::STRING, array(new String('A'), new String('B'))); + $operands[] = new MultipleContainer(BaseType::STRING, array(new QtiString('A'), new QtiString('B'), new QtiString('C'))); + $operands[] = new MultipleContainer(BaseType::STRING, array(new QtiString('A'), new QtiString('B'))); $processor = new ContainsProcessor($expression, $operands); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Boolean', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiBoolean', $result); $this->assertTrue($result->getValue()); // [A,B,C] contains [B,A] $operands->reset(); - $operands[] = new MultipleContainer(BaseType::STRING, array(new String('A'), new String('B'), new String('C'))); - $operands[] = new MultipleContainer(BaseType::STRING, array(new String('B'), new String('A'))); + $operands[] = new MultipleContainer(BaseType::STRING, array(new QtiString('A'), new QtiString('B'), new QtiString('C'))); + $operands[] = new MultipleContainer(BaseType::STRING, array(new QtiString('B'), new QtiString('A'))); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Boolean', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiBoolean', $result); $this->assertTrue($result->getValue()); } @@ -150,27 +150,27 @@ public function testPrimitiveMultipleInBetween() { // For ordered containers [A,B,C,D] contains [B] $operands = new OperandsCollection(); - $operands[] = new MultipleContainer(BaseType::STRING, array(new String('A'), new String('B'), new String('C'), new String('D'))); - $operands[] = new MultipleContainer(BaseType::STRING, array(new String('B'))); + $operands[] = new MultipleContainer(BaseType::STRING, array(new QtiString('A'), new QtiString('B'), new QtiString('C'), new QtiString('D'))); + $operands[] = new MultipleContainer(BaseType::STRING, array(new QtiString('B'))); $processor = new ContainsProcessor($expression, $operands); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Boolean', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiBoolean', $result); $this->assertTrue($result->getValue()); // [A,B,C,D] does not contain [E] $operands->reset(); - $operands[] = new MultipleContainer(BaseType::STRING, array(new String('A'), new String('B'), new String('C'), new String('D'))); - $operands[] = new MultipleContainer(BaseType::STRING, array(new String('E'))); + $operands[] = new MultipleContainer(BaseType::STRING, array(new QtiString('A'), new QtiString('B'), new QtiString('C'), new QtiString('D'))); + $operands[] = new MultipleContainer(BaseType::STRING, array(new QtiString('E'))); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Boolean', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiBoolean', $result); $this->assertFalse($result->getValue()); // [A,B,C,D] contains [A,D] $operands->reset(); - $operands[] = new MultipleContainer(BaseType::STRING, array(new String('A'), new String('B'), new String('C'), new String('D'))); - $operands[] = new MultipleContainer(BaseType::STRING, array(new String('A'), new String('D'))); + $operands[] = new MultipleContainer(BaseType::STRING, array(new QtiString('A'), new QtiString('B'), new QtiString('C'), new QtiString('D'))); + $operands[] = new MultipleContainer(BaseType::STRING, array(new QtiString('A'), new QtiString('D'))); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Boolean', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiBoolean', $result); $this->assertTrue($result->getValue()); } @@ -179,27 +179,27 @@ public function testComplexOrderedTrailing() { // For ordered containers [A,B,C] contains [B,C] $operands = new OperandsCollection(); - $operands[] = new OrderedContainer(BaseType::POINT, array(new Point(1, 2), new Point(3, 4), new Point(5, 6))); - $operands[] = new OrderedContainer(BaseType::POINT, array(new Point(3, 4), new Point(5, 6))); + $operands[] = new OrderedContainer(BaseType::POINT, array(new QtiPoint(1, 2), new QtiPoint(3, 4), new QtiPoint(5, 6))); + $operands[] = new OrderedContainer(BaseType::POINT, array(new QtiPoint(3, 4), new QtiPoint(5, 6))); $processor = new ContainsProcessor($expression, $operands); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Boolean', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiBoolean', $result); $this->assertTrue($result->getValue()); // [A,B,C] does not contain [C,B] $operands->reset(); - $operands[] = new OrderedContainer(BaseType::POINT, array(new Point(1, 2), new Point(3, 4), new Point(5, 6))); - $operands[] = new OrderedContainer(BaseType::POINT, array(new Point(5, 6), new Point(3, 4))); + $operands[] = new OrderedContainer(BaseType::POINT, array(new QtiPoint(1, 2), new QtiPoint(3, 4), new QtiPoint(5, 6))); + $operands[] = new OrderedContainer(BaseType::POINT, array(new QtiPoint(5, 6), new QtiPoint(3, 4))); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Boolean', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiBoolean', $result); $this->assertFalse($result->getValue()); // [A,B,C] does not contain [E,F] $operands->reset(); - $operands[] = new OrderedContainer(BaseType::POINT, array(new Point(1, 2), new Point(3, 4), new Point(5, 6))); - $operands[] = new OrderedContainer(BaseType::POINT, array(new Point(7, 8), new Point(9, 10))); + $operands[] = new OrderedContainer(BaseType::POINT, array(new QtiPoint(1, 2), new QtiPoint(3, 4), new QtiPoint(5, 6))); + $operands[] = new OrderedContainer(BaseType::POINT, array(new QtiPoint(7, 8), new QtiPoint(9, 10))); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Boolean', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiBoolean', $result); $this->assertFalse($result->getValue()); } @@ -208,19 +208,19 @@ public function testComplexOrderedLeading() { // For ordered containers [A,B,C] contains [A,B] $operands = new OperandsCollection(); - $operands[] = new OrderedContainer(BaseType::POINT, array(new Point(1, 2), new Point(3, 4), new Point(5, 6))); - $operands[] = new OrderedContainer(BaseType::POINT, array(new Point(1, 2), new Point(3, 4))); + $operands[] = new OrderedContainer(BaseType::POINT, array(new QtiPoint(1, 2), new QtiPoint(3, 4), new QtiPoint(5, 6))); + $operands[] = new OrderedContainer(BaseType::POINT, array(new QtiPoint(1, 2), new QtiPoint(3, 4))); $processor = new ContainsProcessor($expression, $operands); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Boolean', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiBoolean', $result); $this->assertTrue($result->getValue()); // [A,B,C] does not contain [B,A] $operands->reset(); - $operands[] = new OrderedContainer(BaseType::POINT, array(new Point(1, 2), new Point(3, 4), new Point(5, 6))); - $operands[] = new OrderedContainer(BaseType::POINT, array(new Point(3, 4), new Point(1, 2))); + $operands[] = new OrderedContainer(BaseType::POINT, array(new QtiPoint(1, 2), new QtiPoint(3, 4), new QtiPoint(5, 6))); + $operands[] = new OrderedContainer(BaseType::POINT, array(new QtiPoint(3, 4), new QtiPoint(1, 2))); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Boolean', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiBoolean', $result); $this->assertFalse($result->getValue()); } @@ -229,27 +229,27 @@ public function testComplexOrderedInBetween() { // For ordered containers [A,B,C,D] contains [B] $operands = new OperandsCollection(); - $operands[] = new OrderedContainer(BaseType::POINT, array(new Point(1, 2), new Point(3, 4), new Point(5, 6), new Point(7, 8))); - $operands[] = new OrderedContainer(BaseType::POINT, array(new Point(3, 4))); + $operands[] = new OrderedContainer(BaseType::POINT, array(new QtiPoint(1, 2), new QtiPoint(3, 4), new QtiPoint(5, 6), new QtiPoint(7, 8))); + $operands[] = new OrderedContainer(BaseType::POINT, array(new QtiPoint(3, 4))); $processor = new ContainsProcessor($expression, $operands); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Boolean', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiBoolean', $result); $this->assertTrue($result->getValue()); // [A,B,C,D] does not contain [E] $operands->reset(); - $operands[] = new OrderedContainer(BaseType::POINT, array(new Point(1, 2), new Point(3, 4), new Point(5, 6), new Point(7, 8))); - $operands[] = new OrderedContainer(BaseType::POINT, array(new Point(9, 10))); + $operands[] = new OrderedContainer(BaseType::POINT, array(new QtiPoint(1, 2), new QtiPoint(3, 4), new QtiPoint(5, 6), new QtiPoint(7, 8))); + $operands[] = new OrderedContainer(BaseType::POINT, array(new QtiPoint(9, 10))); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Boolean', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiBoolean', $result); $this->assertFalse($result->getValue()); // [A,B,C,D] contains [B,C] $operands->reset(); - $operands[] = new OrderedContainer(BaseType::POINT, array(new Point(1, 2), new Point(3, 4), new Point(5, 6), new Point(7, 8))); - $operands[] = new OrderedContainer(BaseType::POINT, array(new Point(3, 4), new Point(5, 6))); + $operands[] = new OrderedContainer(BaseType::POINT, array(new QtiPoint(1, 2), new QtiPoint(3, 4), new QtiPoint(5, 6), new QtiPoint(7, 8))); + $operands[] = new OrderedContainer(BaseType::POINT, array(new QtiPoint(3, 4), new QtiPoint(5, 6))); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Boolean', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiBoolean', $result); $this->assertTrue($result->getValue()); } @@ -258,27 +258,27 @@ public function testComplexMultipleTrailing() { // For multiple containers [A,B,C] contains [B,C] $operands = new OperandsCollection(); - $operands[] = new MultipleContainer(BaseType::POINT, array(new Point(1, 2), new Point(3, 4), new Point(5, 6))); - $operands[] = new MultipleContainer(BaseType::POINT, array(new Point(3, 4), new Point(5, 6))); + $operands[] = new MultipleContainer(BaseType::POINT, array(new QtiPoint(1, 2), new QtiPoint(3, 4), new QtiPoint(5, 6))); + $operands[] = new MultipleContainer(BaseType::POINT, array(new QtiPoint(3, 4), new QtiPoint(5, 6))); $processor = new ContainsProcessor($expression, $operands); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Boolean', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiBoolean', $result); $this->assertTrue($result->getValue()); // [A,B,C] contains [C,B] $operands->reset(); - $operands[] = new MultipleContainer(BaseType::POINT, array(new Point(1, 2), new Point(3, 4), new Point(5, 6))); - $operands[] = new MultipleContainer(BaseType::POINT, array(new Point(5, 6), new Point(3, 4))); + $operands[] = new MultipleContainer(BaseType::POINT, array(new QtiPoint(1, 2), new QtiPoint(3, 4), new QtiPoint(5, 6))); + $operands[] = new MultipleContainer(BaseType::POINT, array(new QtiPoint(5, 6), new QtiPoint(3, 4))); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Boolean', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiBoolean', $result); $this->assertTrue($result->getValue()); // [A,B,C] does not contain [E,F] $operands->reset(); - $operands[] = new MultipleContainer(BaseType::POINT, array(new Point(1, 2), new Point(3, 4), new Point(5, 6))); - $operands[] = new MultipleContainer(BaseType::POINT, array(new Point(9, 10), new Point(11, 12))); + $operands[] = new MultipleContainer(BaseType::POINT, array(new QtiPoint(1, 2), new QtiPoint(3, 4), new QtiPoint(5, 6))); + $operands[] = new MultipleContainer(BaseType::POINT, array(new QtiPoint(9, 10), new QtiPoint(11, 12))); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Boolean', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiBoolean', $result); $this->assertFalse($result->getValue()); } @@ -287,27 +287,27 @@ public function testComplexMultipleLeading() { // For ordered containers [A,B,C] contains [A,B] $operands = new OperandsCollection(); - $operands[] = new MultipleContainer(BaseType::POINT, array(new Point(1, 2), new Point(3, 4), new Point(5, 6))); - $operands[] = new MultipleContainer(BaseType::POINT, array(new Point(1, 2), new Point(3, 4))); + $operands[] = new MultipleContainer(BaseType::POINT, array(new QtiPoint(1, 2), new QtiPoint(3, 4), new QtiPoint(5, 6))); + $operands[] = new MultipleContainer(BaseType::POINT, array(new QtiPoint(1, 2), new QtiPoint(3, 4))); $processor = new ContainsProcessor($expression, $operands); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Boolean', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiBoolean', $result); $this->assertTrue($result->getValue()); // [A,B,C] contains [B,A] $operands->reset(); - $operands[] = new MultipleContainer(BaseType::POINT, array(new Point(1, 2), new Point(3, 4), new Point(5, 6))); - $operands[] = new MultipleContainer(BaseType::POINT, array(new Point(3, 4), new Point(1, 2))); + $operands[] = new MultipleContainer(BaseType::POINT, array(new QtiPoint(1, 2), new QtiPoint(3, 4), new QtiPoint(5, 6))); + $operands[] = new MultipleContainer(BaseType::POINT, array(new QtiPoint(3, 4), new QtiPoint(1, 2))); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Boolean', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiBoolean', $result); $this->assertTrue($result->getValue()); // [A,B,C] does not contain [B,D] $operands->reset(); - $operands[] = new MultipleContainer(BaseType::POINT, array(new Point(1, 2), new Point(3, 4), new Point(5, 6))); - $operands[] = new MultipleContainer(BaseType::POINT, array(new Point(3, 4), new Point(7, 8))); + $operands[] = new MultipleContainer(BaseType::POINT, array(new QtiPoint(1, 2), new QtiPoint(3, 4), new QtiPoint(5, 6))); + $operands[] = new MultipleContainer(BaseType::POINT, array(new QtiPoint(3, 4), new QtiPoint(7, 8))); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Boolean', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiBoolean', $result); $this->assertFalse($result->getValue()); } @@ -316,27 +316,27 @@ public function testComplexMultipleInBetween() { // For ordered containers [A,B,C,D] contains [B] $operands = new OperandsCollection(); - $operands[] = new MultipleContainer(BaseType::POINT, array(new Point(1, 2), new Point(3, 4), new Point(5, 6), new Point(7, 8))); - $operands[] = new MultipleContainer(BaseType::POINT, array(new Point(3, 4))); + $operands[] = new MultipleContainer(BaseType::POINT, array(new QtiPoint(1, 2), new QtiPoint(3, 4), new QtiPoint(5, 6), new QtiPoint(7, 8))); + $operands[] = new MultipleContainer(BaseType::POINT, array(new QtiPoint(3, 4))); $processor = new ContainsProcessor($expression, $operands); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Boolean', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiBoolean', $result); $this->assertTrue($result->getValue()); // [A,B,C,D] does not contain [E] $operands->reset(); - $operands[] = new MultipleContainer(BaseType::POINT, array(new Point(1, 2), new Point(3, 4), new Point(5, 6), new Point(7, 8))); - $operands[] = new MultipleContainer(BaseType::POINT, array(new Point(9, 10))); + $operands[] = new MultipleContainer(BaseType::POINT, array(new QtiPoint(1, 2), new QtiPoint(3, 4), new QtiPoint(5, 6), new QtiPoint(7, 8))); + $operands[] = new MultipleContainer(BaseType::POINT, array(new QtiPoint(9, 10))); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Boolean', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiBoolean', $result); $this->assertFalse($result->getValue()); // [A,B,C,D] contains [A,D] $operands->reset(); - $operands[] = new MultipleContainer(BaseType::POINT, array(new Point(1, 2), new Point(3, 4), new Point(5, 6), new Point(7, 8))); - $operands[] = new MultipleContainer(BaseType::POINT, array(new Point(1, 2), new Point(7, 8))); + $operands[] = new MultipleContainer(BaseType::POINT, array(new QtiPoint(1, 2), new QtiPoint(3, 4), new QtiPoint(5, 6), new QtiPoint(7, 8))); + $operands[] = new MultipleContainer(BaseType::POINT, array(new QtiPoint(1, 2), new QtiPoint(7, 8))); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Boolean', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiBoolean', $result); $this->assertTrue($result->getValue()); } @@ -344,8 +344,8 @@ public function testMultipleOccurences() { $expression = $this->createFakeExpression(); $operands = new OperandsCollection( array( - new MultipleContainer(BaseType::IDENTIFIER, array(new Identifier('no'), new Identifier('yes'), new Identifier('yes'), new Identifier('no'))), - new MultipleContainer(BaseType::IDENTIFIER, array(new Identifier('yes'), new Identifier('yes'))) + new MultipleContainer(BaseType::IDENTIFIER, array(new QtiIdentifier('no'), new QtiIdentifier('yes'), new QtiIdentifier('yes'), new QtiIdentifier('no'))), + new MultipleContainer(BaseType::IDENTIFIER, array(new QtiIdentifier('yes'), new QtiIdentifier('yes'))) ) ); $processor = new ContainsProcessor($expression, $operands); @@ -355,12 +355,12 @@ public function testMultipleOccurences() { public function testNull() { $expression = $this->createFakeExpression(); - $operands = new OperandsCollection(array(null, new MultipleContainer(BaseType::INTEGER, array(new Integer(25))))); + $operands = new OperandsCollection(array(null, new MultipleContainer(BaseType::INTEGER, array(new QtiInteger(25))))); $processor = new ContainsProcessor($expression, $operands); $result = $processor->process(); $this->assertSame(null, $result); - $operands = new OperandsCollection(array(new MultipleContainer(BaseType::INTEGER), new MultipleContainer(BaseType::INTEGER, array(new Integer(25))))); + $operands = new OperandsCollection(array(new MultipleContainer(BaseType::INTEGER), new MultipleContainer(BaseType::INTEGER, array(new QtiInteger(25))))); $processor->setOperands($operands); $result = $processor->process(); $this->assertSame(null, $result); @@ -369,8 +369,8 @@ public function testNull() { public function testNotSameBaseTypeOne() { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); - $operands[] = new MultipleContainer(BaseType::STRING, array(new String('identifier3'), new String('identifier4'), null, new String('identifier2'))); - $operands[] = new MultipleContainer(BaseType::IDENTIFIER, array(new Identifier('identifier3'), new Identifier('identifier2'))); + $operands[] = new MultipleContainer(BaseType::STRING, array(new QtiString('identifier3'), new QtiString('identifier4'), null, new QtiString('identifier2'))); + $operands[] = new MultipleContainer(BaseType::IDENTIFIER, array(new QtiIdentifier('identifier3'), new QtiIdentifier('identifier2'))); $processor = new ContainsProcessor($expression, $operands); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $processor->process(); @@ -379,8 +379,8 @@ public function testNotSameBaseTypeOne() { public function testNotSameBaseTypeTwo() { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); - $operands[] = new MultipleContainer(BaseType::INTEGER, array(new Integer(25))); - $operands[] = new MultipleContainer(BaseType::FLOAT, array(new Float(25.0))); + $operands[] = new MultipleContainer(BaseType::INTEGER, array(new QtiInteger(25))); + $operands[] = new MultipleContainer(BaseType::FLOAT, array(new QtiFloat(25.0))); $processor = new ContainsProcessor($expression, $operands); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $result = $processor->process(); @@ -389,8 +389,8 @@ public function testNotSameBaseTypeTwo() { public function testNotSameCardinality() { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); - $operands[] = new MultipleContainer(BaseType::INTEGER, array(new Integer(25))); - $operands[] = new OrderedContainer(BaseType::INTEGER, array(new Integer(25))); + $operands[] = new MultipleContainer(BaseType::INTEGER, array(new QtiInteger(25))); + $operands[] = new OrderedContainer(BaseType::INTEGER, array(new QtiInteger(25))); $processor = new ContainsProcessor($expression, $operands); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $result = $processor->process(); @@ -399,8 +399,8 @@ public function testNotSameCardinality() { public function testWrongCardinality() { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); - $operands[] = new OrderedContainer(BaseType::INTEGER, array(new Integer(25))); - $operands[] = new RecordContainer(array('1' => new Integer(1), '2' => new Integer(2))); + $operands[] = new OrderedContainer(BaseType::INTEGER, array(new QtiInteger(25))); + $operands[] = new RecordContainer(array('1' => new QtiInteger(1), '2' => new QtiInteger(2))); $processor = new ContainsProcessor($expression, $operands); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $result = $processor->process(); @@ -408,7 +408,7 @@ public function testWrongCardinality() { public function testNotEnoughOperands() { $expression = $this->createFakeExpression(); - $operands = new OperandsCollection(array(new MultipleContainer(BaseType::POINT, array(new Point(1, 2))))); + $operands = new OperandsCollection(array(new MultipleContainer(BaseType::POINT, array(new QtiPoint(1, 2))))); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $processor = new ContainsProcessor($expression, $operands); } @@ -416,9 +416,9 @@ public function testNotEnoughOperands() { public function testTooMuchOperands() { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); - $operands[] = new OrderedContainer(BaseType::INTEGER, array(new Integer(25))); - $operands[] = new OrderedContainer(BaseType::INTEGER, array(new Integer(25))); - $operands[] = new OrderedContainer(BaseType::INTEGER, array(new Integer(25))); + $operands[] = new OrderedContainer(BaseType::INTEGER, array(new QtiInteger(25))); + $operands[] = new OrderedContainer(BaseType::INTEGER, array(new QtiInteger(25))); + $operands[] = new OrderedContainer(BaseType::INTEGER, array(new QtiInteger(25))); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $processor = new ContainsProcessor($expression, $operands); } diff --git a/test/qtismtest/runtime/expressions/operators/DeleteProcessorTest.php b/test/qtismtest/runtime/expressions/operators/DeleteProcessorTest.php index 3d49731e6..b07440454 100644 --- a/test/qtismtest/runtime/expressions/operators/DeleteProcessorTest.php +++ b/test/qtismtest/runtime/expressions/operators/DeleteProcessorTest.php @@ -2,9 +2,9 @@ namespace qtismtest\runtime\expressions\operators; use qtismtest\QtiSmTestCase; -use qtism\common\datatypes\Float; -use qtism\common\datatypes\Integer; -use qtism\common\datatypes\Point; +use qtism\common\datatypes\QtiFloat; +use qtism\common\datatypes\QtiInteger; +use qtism\common\datatypes\QtiPoint; use qtism\runtime\expressions\operators\DeleteProcessor; use qtism\runtime\expressions\operators\OperandsCollection; use qtism\common\enums\BaseType; @@ -17,35 +17,35 @@ class DeleteProcessorTest extends QtiSmTestCase { public function testMultiple() { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); - $operands[] = new Integer(10); - $operands[] = new MultipleContainer(BaseType::INTEGER, array(new Integer(0), new Integer(10), new Integer(20), new Integer(30))); + $operands[] = new QtiInteger(10); + $operands[] = new MultipleContainer(BaseType::INTEGER, array(new QtiInteger(0), new QtiInteger(10), new QtiInteger(20), new QtiInteger(30))); $processor = new DeleteProcessor($expression, $operands); $result = $processor->process(); $this->assertInstanceOf('qtism\\runtime\\common\\MultipleContainer', $result); $this->assertEquals(3, count($result)); - $this->assertTrue($result->contains(new Integer(0))); - $this->assertTrue($result->contains(new Integer(20))); - $this->assertTrue($result->contains(new Integer(30))); - $this->assertFalse($result->contains(new Integer(10))); + $this->assertTrue($result->contains(new QtiInteger(0))); + $this->assertTrue($result->contains(new QtiInteger(20))); + $this->assertTrue($result->contains(new QtiInteger(30))); + $this->assertFalse($result->contains(new QtiInteger(10))); // Check that ALL the occurences of the first sub-expression are removed. $operands->reset(); - $operands[] = new Integer(10); - $operands[] = new MultipleContainer(BaseType::INTEGER, array(new Integer(0), new Integer(10), new Integer(20), new Integer(10), new Integer(10), new Integer(30))); + $operands[] = new QtiInteger(10); + $operands[] = new MultipleContainer(BaseType::INTEGER, array(new QtiInteger(0), new QtiInteger(10), new QtiInteger(20), new QtiInteger(10), new QtiInteger(10), new QtiInteger(30))); $result = $processor->process(); $this->assertInstanceOf('qtism\\runtime\\common\\MultipleContainer', $result); $this->assertEquals(3, count($result)); - $this->assertTrue($result->contains(new Integer(0))); - $this->assertTrue($result->contains(new Integer(20))); - $this->assertTrue($result->contains(new Integer(30))); - $this->assertFalse($result->contains(new Integer(10))); + $this->assertTrue($result->contains(new QtiInteger(0))); + $this->assertTrue($result->contains(new QtiInteger(20))); + $this->assertTrue($result->contains(new QtiInteger(30))); + $this->assertFalse($result->contains(new QtiInteger(10))); } public function testMultipleNotMatch() { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); - $operands[] = new Integer(60); - $operands[] = new MultipleContainer(BaseType::INTEGER, array(new Integer(0), new Integer(10), new Integer(20), new Integer(30))); + $operands[] = new QtiInteger(60); + $operands[] = new MultipleContainer(BaseType::INTEGER, array(new QtiInteger(0), new QtiInteger(10), new QtiInteger(20), new QtiInteger(30))); $processor = new DeleteProcessor($expression, $operands); $result = $processor->process(); $this->assertTrue($operands[1]->equals($result)); @@ -54,8 +54,8 @@ public function testMultipleNotMatch() { public function testEverythingRemoved() { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); - $operands[] = new Integer(60); - $operands[] = new MultipleContainer(BaseType::INTEGER, array(new Integer(60), new Integer(60), new Integer(60), new Integer(60))); + $operands[] = new QtiInteger(60); + $operands[] = new MultipleContainer(BaseType::INTEGER, array(new QtiInteger(60), new QtiInteger(60), new QtiInteger(60), new QtiInteger(60))); $processor = new DeleteProcessor($expression, $operands); $result = $processor->process(); $this->assertInstanceOf('qtism\\runtime\\common\\MultipleContainer', $result); @@ -65,39 +65,39 @@ public function testEverythingRemoved() { public function testOrdered() { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); - $operands[] = new Point(2, 4); - $operands[] = new OrderedContainer(BaseType::POINT, array(new Point(1, 2), new Point(2, 4), new Point(3, 4))); + $operands[] = new QtiPoint(2, 4); + $operands[] = new OrderedContainer(BaseType::POINT, array(new QtiPoint(1, 2), new QtiPoint(2, 4), new QtiPoint(3, 4))); $processor = new DeleteProcessor($expression, $operands); $result = $processor->process(); $this->assertInstanceOf('qtism\\runtime\\common\\OrderedContainer', $result); $this->assertEquals(2, count($result)); - $this->assertTrue($result->contains(new Point(1, 2))); - $this->assertTrue($result->contains(new Point(3, 4))); - $this->assertFalse($result->contains(new Point(2, 4))); + $this->assertTrue($result->contains(new QtiPoint(1, 2))); + $this->assertTrue($result->contains(new QtiPoint(3, 4))); + $this->assertFalse($result->contains(new QtiPoint(2, 4))); // Check that ALL the occurences of the first sub-expression are removed. $operands->reset(); - $operands[] = new Point(2, 4); - $operands[] = new OrderedContainer(BaseType::POINT, array(new Point(1, 2), new Point(2, 4), new Point(2, 4), new Point(3, 4))); + $operands[] = new QtiPoint(2, 4); + $operands[] = new OrderedContainer(BaseType::POINT, array(new QtiPoint(1, 2), new QtiPoint(2, 4), new QtiPoint(2, 4), new QtiPoint(3, 4))); $result = $processor->process(); $this->assertInstanceOf('qtism\\runtime\\common\\OrderedContainer', $result); $this->assertEquals(2, count($result)); - $this->assertTrue($result->contains(new Point(1, 2))); - $this->assertTrue($result->contains(new Point(3, 4))); - $this->assertFalse($result->contains(new Point(2, 4))); + $this->assertTrue($result->contains(new QtiPoint(1, 2))); + $this->assertTrue($result->contains(new QtiPoint(3, 4))); + $this->assertFalse($result->contains(new QtiPoint(2, 4))); } public function testNull() { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); $operands[] = null; - $operands[] = new MultipleContainer(BaseType::INTEGER, array(new Integer(0), new Integer(10), new Integer(20), new Integer(30))); + $operands[] = new MultipleContainer(BaseType::INTEGER, array(new QtiInteger(0), new QtiInteger(10), new QtiInteger(20), new QtiInteger(30))); $processor = new DeleteProcessor($expression, $operands); $result = $processor->process(); $this->assertSame(null, $result); $operands->reset(); - $operands[] = new Integer(10); + $operands[] = new QtiInteger(10); $operands[] = new MultipleContainer(BaseType::INTEGER); $result = $processor->process(); $this->assertSame(null, $result); @@ -106,8 +106,8 @@ public function testNull() { public function testDifferentBaseType() { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); - $operands[] = new Float(10.1); - $operands[] = new MultipleContainer(BaseType::INTEGER, array(new Integer(0), new Integer(10), new Integer(20), new Integer(30))); + $operands[] = new QtiFloat(10.1); + $operands[] = new MultipleContainer(BaseType::INTEGER, array(new QtiInteger(0), new QtiInteger(10), new QtiInteger(20), new QtiInteger(30))); $processor = new DeleteProcessor($expression, $operands); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $result = $processor->process(); @@ -116,8 +116,8 @@ public function testDifferentBaseType() { public function testWrongCardinalityOne() { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); - $operands[] = new MultipleContainer(BaseType::INTEGER, array(new Integer(0), new Integer(10), new Integer(20), new Integer(30))); - $operands[] = new MultipleContainer(BaseType::INTEGER, array(new Integer(0), new Integer(10), new Integer(20), new Integer(30))); + $operands[] = new MultipleContainer(BaseType::INTEGER, array(new QtiInteger(0), new QtiInteger(10), new QtiInteger(20), new QtiInteger(30))); + $operands[] = new MultipleContainer(BaseType::INTEGER, array(new QtiInteger(0), new QtiInteger(10), new QtiInteger(20), new QtiInteger(30))); $processor = new DeleteProcessor($expression, $operands); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $result = $processor->process(); @@ -126,8 +126,8 @@ public function testWrongCardinalityOne() { public function testWrongCardinalityTwo() { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); - $operands[] = new Integer(10); - $operands[] = new Integer(10); + $operands[] = new QtiInteger(10); + $operands[] = new QtiInteger(10); $processor = new DeleteProcessor($expression, $operands); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $result = $processor->process(); @@ -143,9 +143,9 @@ public function testNotEnoughOperands() { public function testTooMuchOperands() { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); - $operands[] = new Integer(10); - $operands[] = new MultipleContainer(BaseType::INTEGER, array(new Integer(10))); - $operands[] = new MultipleContainer(BaseType::INTEGER, array(new Integer(10))); + $operands[] = new QtiInteger(10); + $operands[] = new MultipleContainer(BaseType::INTEGER, array(new QtiInteger(10))); + $operands[] = new MultipleContainer(BaseType::INTEGER, array(new QtiInteger(10))); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $processor = new DeleteProcessor($expression, $operands); } diff --git a/test/qtismtest/runtime/expressions/operators/DivideProcessorTest.php b/test/qtismtest/runtime/expressions/operators/DivideProcessorTest.php index ecb9a3693..f954eb1bd 100644 --- a/test/qtismtest/runtime/expressions/operators/DivideProcessorTest.php +++ b/test/qtismtest/runtime/expressions/operators/DivideProcessorTest.php @@ -2,12 +2,12 @@ namespace qtismtest\runtime\expressions\operators; use qtismtest\QtiSmTestCase; -use qtism\common\datatypes\Boolean; -use qtism\common\datatypes\String; -use qtism\common\datatypes\Float; -use qtism\common\datatypes\Integer; +use qtism\common\datatypes\QtiBoolean; +use qtism\common\datatypes\QtiString; +use qtism\common\datatypes\QtiFloat; +use qtism\common\datatypes\QtiInteger; use qtism\runtime\common\RecordContainer; -use qtism\common\datatypes\Point; +use qtism\common\datatypes\QtiPoint; use qtism\runtime\expressions\operators\DivideProcessor; use qtism\runtime\expressions\operators\OperandsCollection; @@ -15,40 +15,40 @@ class DivideProcessorTest extends QtiSmTestCase { public function testDivide() { $expression = $this->createFakeExpression(); - $operands = new OperandsCollection(array(new Integer(1), new Integer(1))); + $operands = new OperandsCollection(array(new QtiInteger(1), new QtiInteger(1))); $processor = new DivideProcessor($expression, $operands); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $result); $this->assertEquals(1, $result->getValue()); - $operands = new OperandsCollection(array(new Integer(0), new Integer(2))); + $operands = new OperandsCollection(array(new QtiInteger(0), new QtiInteger(2))); $processor->setOperands($operands); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $result); $this->assertEquals(0, $result->getValue()); - $operands = new OperandsCollection(array(new Integer(-30), new Integer(5))); + $operands = new OperandsCollection(array(new QtiInteger(-30), new QtiInteger(5))); $processor->setOperands($operands); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $result); $this->assertEquals(-6, $result->getValue()); - $operands = new OperandsCollection(array(new Integer(30), new Integer(5))); + $operands = new OperandsCollection(array(new QtiInteger(30), new QtiInteger(5))); $processor->setOperands($operands); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $result); $this->assertEquals(6, $result->getValue()); - $operands = new OperandsCollection(array(new Integer(1), new Float(0.5))); + $operands = new OperandsCollection(array(new QtiInteger(1), new QtiFloat(0.5))); $processor->setOperands($operands); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $result); $this->assertEquals(2, $result->getValue()); } public function testDivisionByZero() { $expression = $this->createFakeExpression(); - $operands = new OperandsCollection(array(new Integer(1), new Integer(0))); + $operands = new OperandsCollection(array(new QtiInteger(1), new QtiInteger(0))); $processor = new DivideProcessor($expression, $operands); $result = $processor->process(); $this->assertSame(null, $result); @@ -56,22 +56,22 @@ public function testDivisionByZero() { public function testDivisionByInfinite() { $expression = $this->createFakeExpression(); - $operands = new OperandsCollection(array(new Integer(10), new Float(INF))); + $operands = new OperandsCollection(array(new QtiInteger(10), new QtiFloat(INF))); $processor = new DivideProcessor($expression, $operands); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $result); $this->assertEquals(0, $result->getValue()); - $operands = new OperandsCollection(array(new Integer(-1), new Float(INF))); + $operands = new OperandsCollection(array(new QtiInteger(-1), new QtiFloat(INF))); $processor->setOperands($operands); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $result); $this->assertEquals(-0, $result->getValue()); } public function testInfiniteDividedByInfinite() { $expression = $this->createFakeExpression(); - $operands = new OperandsCollection(array(new Float(INF), new Float(INF))); + $operands = new OperandsCollection(array(new QtiFloat(INF), new QtiFloat(INF))); $processor = new DivideProcessor($expression, $operands); $result = $processor->process(); $this->assertSame(null, $result); @@ -79,7 +79,7 @@ public function testInfiniteDividedByInfinite() { public function testWrongBaseTypeOne() { $expression = $this->createFakeExpression(); - $operands = new OperandsCollection(array(new String('string!'), new Boolean(true))); + $operands = new OperandsCollection(array(new QtiString('string!'), new QtiBoolean(true))); $processor = new DivideProcessor($expression, $operands); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $result = $processor->process(); @@ -87,7 +87,7 @@ public function testWrongBaseTypeOne() { public function testWrongBaseTypeTwo() { $expression = $this->createFakeExpression(); - $operands = new OperandsCollection(array(new Point(1, 2), new Boolean(true))); + $operands = new OperandsCollection(array(new QtiPoint(1, 2), new QtiBoolean(true))); $processor = new DivideProcessor($expression, $operands); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $result = $processor->process(); @@ -95,7 +95,7 @@ public function testWrongBaseTypeTwo() { public function testWrongCardinality() { $expression = $this->createFakeExpression(); - $operands = new OperandsCollection(array(new RecordContainer(array('A' => new Integer(1))), new Integer(10))); + $operands = new OperandsCollection(array(new RecordContainer(array('A' => new QtiInteger(1))), new QtiInteger(10))); $processor = new DivideProcessor($expression, $operands); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $result = $processor->process(); @@ -110,7 +110,7 @@ public function testNotEnoughOperands() { public function testTooMuchOperands() { $expression = $this->createFakeExpression(); - $operands = new OperandsCollection(array(new Integer(10), new Integer(11), new Integer(12))); + $operands = new OperandsCollection(array(new QtiInteger(10), new QtiInteger(11), new QtiInteger(12))); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $processor = new DivideProcessor($expression, $operands); } diff --git a/test/qtismtest/runtime/expressions/operators/DurationGTEProcessorTest.php b/test/qtismtest/runtime/expressions/operators/DurationGTEProcessorTest.php index ac126fc3d..06b5eb627 100644 --- a/test/qtismtest/runtime/expressions/operators/DurationGTEProcessorTest.php +++ b/test/qtismtest/runtime/expressions/operators/DurationGTEProcessorTest.php @@ -2,10 +2,10 @@ namespace qtismtest\runtime\expressions\operators; use qtismtest\QtiSmTestCase; -use qtism\common\datatypes\Integer; +use qtism\common\datatypes\QtiInteger; use qtism\common\enums\BaseType; use qtism\runtime\common\MultipleContainer; -use qtism\common\datatypes\Duration; +use qtism\common\datatypes\QtiDuration; use qtism\runtime\expressions\operators\DurationGTEProcessor; use qtism\runtime\expressions\operators\OperandsCollection; @@ -15,28 +15,28 @@ public function testDurationGTE() { // There is no need of intensive testing because // the main logic is contained in the Duration class. $expression = $this->createFakeExpression(); - $operands = new OperandsCollection(array(new Duration('P2D'), new Duration('P1D'))); + $operands = new OperandsCollection(array(new QtiDuration('P2D'), new QtiDuration('P1D'))); $processor = new DurationGTEProcessor($expression, $operands); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Boolean', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiBoolean', $result); $this->assertTrue($result->getValue()); - $operands = new OperandsCollection(array(new Duration('P1D'), new Duration('P2D'))); + $operands = new OperandsCollection(array(new QtiDuration('P1D'), new QtiDuration('P2D'))); $processor->setOperands($operands); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Boolean', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiBoolean', $result); $this->assertFalse($result->getValue()); - $operands = new OperandsCollection(array(new Duration('P1DT23M2S'), new Duration('P1DT23M2S'))); + $operands = new OperandsCollection(array(new QtiDuration('P1DT23M2S'), new QtiDuration('P1DT23M2S'))); $processor->setOperands($operands); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Boolean', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiBoolean', $result); $this->assertTrue($result->getValue()); } public function testNull() { $expression = $this->createFakeExpression(); - $operands = new OperandsCollection(array(new Duration('P1D'), null)); + $operands = new OperandsCollection(array(new QtiDuration('P1D'), null)); $processor = new DurationGTEProcessor($expression, $operands); $result = $processor->process(); $this->assertSame(null, $result); @@ -44,7 +44,7 @@ public function testNull() { public function testWrongBaseType() { $expression = $this->createFakeExpression(); - $operands = new OperandsCollection(array(new Duration('P1D'), new Integer(256))); + $operands = new OperandsCollection(array(new QtiDuration('P1D'), new QtiInteger(256))); $processor = new DurationGTEProcessor($expression, $operands); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $result = $processor->process(); @@ -52,7 +52,7 @@ public function testWrongBaseType() { public function testWrongCardinality() { $expression = $this->createFakeExpression(); - $operands = new OperandsCollection(array(new Duration('P1D'), new MultipleContainer(BaseType::DURATION, array(new Duration('P2D'))))); + $operands = new OperandsCollection(array(new QtiDuration('P1D'), new MultipleContainer(BaseType::DURATION, array(new QtiDuration('P2D'))))); $processor = new DurationGTEProcessor($expression, $operands); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $result = $processor->process(); @@ -67,7 +67,7 @@ public function testNotEnoughOperands() { public function testTooMuchOperands() { $expression = $this->createFakeExpression(); - $operands = new OperandsCollection(array(new Duration('P1D'), new Duration('P2D'), new Duration('P3D'))); + $operands = new OperandsCollection(array(new QtiDuration('P1D'), new QtiDuration('P2D'), new QtiDuration('P3D'))); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $processor = new DurationGTEProcessor($expression, $operands); } diff --git a/test/qtismtest/runtime/expressions/operators/DurationLTProcessorTest.php b/test/qtismtest/runtime/expressions/operators/DurationLTProcessorTest.php index 1189480da..269539395 100644 --- a/test/qtismtest/runtime/expressions/operators/DurationLTProcessorTest.php +++ b/test/qtismtest/runtime/expressions/operators/DurationLTProcessorTest.php @@ -2,10 +2,10 @@ namespace qtismtest\runtime\expressions\operators; use qtismtest\QtiSmTestCase; -use qtism\common\datatypes\Integer; +use qtism\common\datatypes\QtiInteger; use qtism\common\enums\BaseType; use qtism\runtime\common\MultipleContainer; -use qtism\common\datatypes\Duration; +use qtism\common\datatypes\QtiDuration; use qtism\runtime\expressions\operators\DurationLTProcessor; use qtism\runtime\expressions\operators\OperandsCollection; @@ -15,22 +15,22 @@ public function testDurationLT() { // There is no need of intensive testing because // the main logic is contained in the Duration class. $expression = $this->createFakeExpression(); - $operands = new OperandsCollection(array(new Duration('P1D'), new Duration('P2D'))); + $operands = new OperandsCollection(array(new QtiDuration('P1D'), new QtiDuration('P2D'))); $processor = new DurationLTProcessor($expression, $operands); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Boolean', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiBoolean', $result); $this->assertTrue($result->getValue()); - $operands = new OperandsCollection(array(new Duration('P2D'), new Duration('P1D'))); + $operands = new OperandsCollection(array(new QtiDuration('P2D'), new QtiDuration('P1D'))); $processor->setOperands($operands); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Boolean', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiBoolean', $result); $this->assertFalse($result->getValue()); } public function testNull() { $expression = $this->createFakeExpression(); - $operands = new OperandsCollection(array(new Duration('P1D'), null)); + $operands = new OperandsCollection(array(new QtiDuration('P1D'), null)); $processor = new DurationLTProcessor($expression, $operands); $result = $processor->process(); $this->assertSame(null, $result); @@ -38,7 +38,7 @@ public function testNull() { public function testWrongBaseType() { $expression = $this->createFakeExpression(); - $operands = new OperandsCollection(array(new Duration('P1D'), new Integer(256))); + $operands = new OperandsCollection(array(new QtiDuration('P1D'), new QtiInteger(256))); $processor = new DurationLTProcessor($expression, $operands); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $result = $processor->process(); @@ -46,7 +46,7 @@ public function testWrongBaseType() { public function testWrongCardinality() { $expression = $this->createFakeExpression(); - $operands = new OperandsCollection(array(new Duration('P1D'), new MultipleContainer(BaseType::DURATION, array(new Duration('P2D'))))); + $operands = new OperandsCollection(array(new QtiDuration('P1D'), new MultipleContainer(BaseType::DURATION, array(new QtiDuration('P2D'))))); $processor = new DurationLTProcessor($expression, $operands); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $result = $processor->process(); @@ -61,7 +61,7 @@ public function testNotEnoughOperands() { public function testTooMuchOperands() { $expression = $this->createFakeExpression(); - $operands = new OperandsCollection(array(new Duration('P1D'), new Duration('P2D'), new Duration('P3D'))); + $operands = new OperandsCollection(array(new QtiDuration('P1D'), new QtiDuration('P2D'), new QtiDuration('P3D'))); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $processor = new DurationLTProcessor($expression, $operands); } diff --git a/test/qtismtest/runtime/expressions/operators/EqualProcessorTest.php b/test/qtismtest/runtime/expressions/operators/EqualProcessorTest.php index 7971517fb..2422b7877 100644 --- a/test/qtismtest/runtime/expressions/operators/EqualProcessorTest.php +++ b/test/qtismtest/runtime/expressions/operators/EqualProcessorTest.php @@ -2,9 +2,9 @@ namespace qtismtest\runtime\expressions\operators; use qtismtest\QtiSmTestCase; -use qtism\common\datatypes\String; -use qtism\common\datatypes\Float; -use qtism\common\datatypes\Integer; +use qtism\common\datatypes\QtiString; +use qtism\common\datatypes\QtiFloat; +use qtism\common\datatypes\QtiInteger; use qtism\common\enums\BaseType; use qtism\common\enums\Cardinality; use qtism\runtime\common\OutcomeVariable; @@ -18,152 +18,152 @@ class EqualProcessorTest extends QtiSmTestCase { public function testExact() { $expression = $this->createFakeExpression(ToleranceMode::EXACT); - $operands = new OperandsCollection(array(new Integer(10), new Integer(10))); + $operands = new OperandsCollection(array(new QtiInteger(10), new QtiInteger(10))); $processor = new EqualProcessor($expression, $operands); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Boolean', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiBoolean', $result); $this->assertTrue($result->getValue()); - $operands = new OperandsCollection(array(new Integer(0), new Integer(1))); + $operands = new OperandsCollection(array(new QtiInteger(0), new QtiInteger(1))); $processor->setOperands($operands); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Boolean', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiBoolean', $result); $this->assertFalse($result->getValue()); - $operands = new OperandsCollection(array(new Integer(10), new Float(10.0))); + $operands = new OperandsCollection(array(new QtiInteger(10), new QtiFloat(10.0))); $processor->setOperands($operands); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Boolean', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiBoolean', $result); $this->assertTrue($result->getValue()); - $operands = new OperandsCollection(array(new Integer(10), new Float(10.1))); + $operands = new OperandsCollection(array(new QtiInteger(10), new QtiFloat(10.1))); $processor->setOperands($operands); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Boolean', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiBoolean', $result); $this->assertFalse($result->getValue()); } public function testRelative() { // Only one tolerance attribute. $expression = $this->createFakeExpression(ToleranceMode::RELATIVE, array(90)); - $operands = new OperandsCollection(array(new Integer(10), new Integer(10))); + $operands = new OperandsCollection(array(new QtiInteger(10), new QtiInteger(10))); $processor = new EqualProcessor($expression, $operands); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Boolean', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiBoolean', $result); $this->assertTrue($result->getValue()); // -- lowerBound = 1; upperBound = 19 - $operands = new OperandsCollection(array(new Integer(10), new Integer(19))); + $operands = new OperandsCollection(array(new QtiInteger(10), new QtiInteger(19))); $processor->setOperands($operands); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Boolean', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiBoolean', $result); $this->assertTrue($result->getValue()); - $operands = new OperandsCollection(array(new Integer(10), new Float(19.1))); + $operands = new OperandsCollection(array(new QtiInteger(10), new QtiFloat(19.1))); $processor->setOperands($operands); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Boolean', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiBoolean', $result); $this->assertFalse($result->getValue()); - $operands = new OperandsCollection(array(new Integer(10), new Integer(20))); + $operands = new OperandsCollection(array(new QtiInteger(10), new QtiInteger(20))); $processor->setOperands($operands); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Boolean', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiBoolean', $result); $this->assertFalse($result->getValue()); - $operands = new OperandsCollection(array(new Integer(10), new Integer(0))); + $operands = new OperandsCollection(array(new QtiInteger(10), new QtiInteger(0))); $processor->setOperands($operands); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Boolean', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiBoolean', $result); $this->assertFalse($result->getValue()); // -- do not include upper bound. $expression = $this->createFakeExpression(ToleranceMode::RELATIVE, array(90), true, false); $processor->setExpression($expression); - $operands = new OperandsCollection(array(new Integer(10), new Integer(1))); + $operands = new OperandsCollection(array(new QtiInteger(10), new QtiInteger(1))); $processor->setOperands($operands); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Boolean', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiBoolean', $result); $this->assertTrue($result->getValue()); - $operands = new OperandsCollection(array(new Integer(10), new Integer(19))); + $operands = new OperandsCollection(array(new QtiInteger(10), new QtiInteger(19))); $processor->setOperands($operands); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Boolean', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiBoolean', $result); $this->assertFalse($result->getValue()); // do not include lower bound. $expression = $this->createFakeExpression(ToleranceMode::RELATIVE, array(90), false, false); $processor->setExpression($expression); - $operands = new OperandsCollection(array(new Float(10.0), new Float(0.9999))); + $operands = new OperandsCollection(array(new QtiFloat(10.0), new QtiFloat(0.9999))); $processor->setOperands($operands); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Boolean', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiBoolean', $result); $this->assertFalse($result->getValue()); } public function testAbsolute() { $expression = $this->createFakeExpression(ToleranceMode::ABSOLUTE, array(0.1, 0.2)); - $operands = new OperandsCollection(array(new Integer(10), new Float(9.9))); + $operands = new OperandsCollection(array(new QtiInteger(10), new QtiFloat(9.9))); $processor = new EqualProcessor($expression, $operands); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Boolean', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiBoolean', $result); $this->assertTrue($result->getValue()); - $operands = new OperandsCollection(array(new Integer(10), new Float(10.2))); + $operands = new OperandsCollection(array(new QtiInteger(10), new QtiFloat(10.2))); $processor->setOperands($operands); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Boolean', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiBoolean', $result); $this->assertTrue($result->getValue()); - $operands = new OperandsCollection(array(new Integer(10), new Float(9.8))); + $operands = new OperandsCollection(array(new QtiInteger(10), new QtiFloat(9.8))); $processor->setOperands($operands); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Boolean', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiBoolean', $result); $this->assertFalse($result->getValue()); - $operands = new OperandsCollection(array(new Integer(10), new Float(10.3))); + $operands = new OperandsCollection(array(new QtiInteger(10), new QtiFloat(10.3))); $processor->setOperands($operands); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Boolean', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiBoolean', $result); $this->assertFalse($result->getValue()); } public function testWithVariableRef() { $expression = $this->createFakeExpression(ToleranceMode::ABSOLUTE, array('t0', 't1')); - $operands = new OperandsCollection(array(new Integer(10), new Float(9.9))); + $operands = new OperandsCollection(array(new QtiInteger(10), new QtiFloat(9.9))); $processor = new EqualProcessor($expression, $operands); $state = new State(); - $state->setVariable(new OutcomeVariable('t0', Cardinality::SINGLE, BaseType::FLOAT, new Float(0.1))); - $state->setVariable(new OutcomeVariable('t1', Cardinality::SINGLE, BaseType::FLOAT, new Float(0.1))); + $state->setVariable(new OutcomeVariable('t0', Cardinality::SINGLE, BaseType::FLOAT, new QtiFloat(0.1))); + $state->setVariable(new OutcomeVariable('t1', Cardinality::SINGLE, BaseType::FLOAT, new QtiFloat(0.1))); $processor->setState($state); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Boolean', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiBoolean', $result); $this->assertTrue($result->getValue()); - $operands = new OperandsCollection(array(new Integer(10), new Float(9.8))); + $operands = new OperandsCollection(array(new QtiInteger(10), new QtiFloat(9.8))); $processor->setOperands($operands); $result = $processor->process(); $this->assertFalse($result->getValue()); // only one t $expression = $this->createFakeExpression(ToleranceMode::ABSOLUTE, array('t0')); - $operands = new OperandsCollection(array(new Integer(10), new Integer(12))); + $operands = new OperandsCollection(array(new QtiInteger(10), new QtiInteger(12))); $processor = new EqualProcessor($expression, $operands); $state = new State(); - $state->setVariable(new OutcomeVariable('t0', Cardinality::SINGLE, BaseType::FLOAT, new Float(2.0))); + $state->setVariable(new OutcomeVariable('t0', Cardinality::SINGLE, BaseType::FLOAT, new QtiFloat(2.0))); $processor->setState($state); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Boolean', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiBoolean', $result); $this->assertTrue($result->getValue()); - $operands = new OperandsCollection(array(new Integer(10), new Integer(13))); + $operands = new OperandsCollection(array(new QtiInteger(10), new QtiInteger(13))); $processor->setOperands($operands); $result = $processor->process(); $this->assertFalse($result->getValue()); @@ -171,7 +171,7 @@ public function testWithVariableRef() { public function testNull() { $expression = $this->createFakeExpression(ToleranceMode::ABSOLUTE, array(0.1, 0.2)); - $operands = new OperandsCollection(array(new Integer(10), null)); + $operands = new OperandsCollection(array(new QtiInteger(10), null)); $processor = new EqualProcessor($expression, $operands); $result = $processor->process(); $this->assertSame(null, $result); @@ -179,7 +179,7 @@ public function testNull() { public function testNoVariableRef() { $expression = $this->createFakeExpression(ToleranceMode::ABSOLUTE, array('t0')); - $operands = new OperandsCollection(array(new Integer(10), new Float(9.9))); + $operands = new OperandsCollection(array(new QtiInteger(10), new QtiFloat(9.9))); $processor = new EqualProcessor($expression, $operands); $state = new State(); @@ -190,16 +190,16 @@ public function testNoVariableRef() { public function testNoSecondVariableRef() { $expression = $this->createFakeExpression(ToleranceMode::ABSOLUTE, array('t0', 't1')); - $operands = new OperandsCollection(array(new Integer(10), new Float(9.9))); + $operands = new OperandsCollection(array(new QtiInteger(10), new QtiFloat(9.9))); $processor = new EqualProcessor($expression, $operands); $state = new State(); - $state->setVariable(new OutcomeVariable('t0', Cardinality::SINGLE, BaseType::FLOAT, new Float(0.1))); + $state->setVariable(new OutcomeVariable('t0', Cardinality::SINGLE, BaseType::FLOAT, new QtiFloat(0.1))); $processor->setState($state); $result = $processor->process(); $this->assertTrue($result->getValue()); - $operands = new OperandsCollection(array(new Integer(10), new Float(9.8))); + $operands = new OperandsCollection(array(new QtiInteger(10), new QtiFloat(9.8))); $processor->setOperands($operands); $result = $processor->process(); $this->assertFalse($result->getValue()); @@ -207,7 +207,7 @@ public function testNoSecondVariableRef() { public function testWrongBaseType() { $expression = $this->createFakeExpression(ToleranceMode::ABSOLUTE, array(0.1, 0.2)); - $operands = new OperandsCollection(array(new Integer(10), new String('String!'))); + $operands = new OperandsCollection(array(new QtiInteger(10), new QtiString('String!'))); $processor = new EqualProcessor($expression, $operands); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $result = $processor->process(); @@ -215,7 +215,7 @@ public function testWrongBaseType() { public function testWrongCardinality() { $expression = $this->createFakeExpression(ToleranceMode::ABSOLUTE, array(0.1, 0.2)); - $operands = new OperandsCollection(array(new RecordContainer(array('A' => new Integer(1))), new Integer(10))); + $operands = new OperandsCollection(array(new RecordContainer(array('A' => new QtiInteger(1))), new QtiInteger(10))); $processor = new EqualProcessor($expression, $operands); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $result = $processor->process(); @@ -223,14 +223,14 @@ public function testWrongCardinality() { public function testNotEnoughOperands() { $expression = $this->createFakeExpression(ToleranceMode::ABSOLUTE, array(0.1, 0.2)); - $operands = new OperandsCollection(array(new Integer(10))); + $operands = new OperandsCollection(array(new QtiInteger(10))); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $processor = new EqualProcessor($expression, $operands); } public function testTooMuchOperands() { $expression = $this->createFakeExpression(ToleranceMode::ABSOLUTE, array(0.1, 0.2)); - $operands = new OperandsCollection(array(new Integer(10), new Integer(10), new Integer(10))); + $operands = new OperandsCollection(array(new QtiInteger(10), new QtiInteger(10), new QtiInteger(10))); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $processor = new EqualProcessor($expression, $operands); } diff --git a/test/qtismtest/runtime/expressions/operators/EqualRoundedProcessorTest.php b/test/qtismtest/runtime/expressions/operators/EqualRoundedProcessorTest.php index 01616c92e..549589b61 100644 --- a/test/qtismtest/runtime/expressions/operators/EqualRoundedProcessorTest.php +++ b/test/qtismtest/runtime/expressions/operators/EqualRoundedProcessorTest.php @@ -2,14 +2,14 @@ namespace qtismtest\runtime\expressions\operators; use qtismtest\QtiSmTestCase; -use qtism\common\datatypes\Integer; -use qtism\common\datatypes\Float; +use qtism\common\datatypes\QtiInteger; +use qtism\common\datatypes\QtiFloat; use qtism\common\enums\BaseType; use qtism\common\enums\Cardinality; use qtism\runtime\common\OutcomeVariable; use qtism\runtime\common\State; use qtism\runtime\common\RecordContainer; -use qtism\common\datatypes\Pair; +use qtism\common\datatypes\QtiPair; use qtism\data\expressions\operators\RoundingMode; use qtism\runtime\expressions\operators\EqualRoundedProcessor; use qtism\runtime\expressions\operators\OperandsCollection; @@ -18,12 +18,12 @@ class EqualRoundedProcessorTest extends QtiSmTestCase { public function testSignificantFigures() { $expression = $this->createFakeExpression(RoundingMode::SIGNIFICANT_FIGURES, 3); - $operands = new OperandsCollection(array(new Float(3.175), new Float(3.183))); + $operands = new OperandsCollection(array(new QtiFloat(3.175), new QtiFloat(3.183))); $processor = new EqualRoundedProcessor($expression, $operands); $result = $processor->process(); $this->assertSame(true, $result->getValue()); - $operands = new OperandsCollection(array(new Float(3.175), new Float(3.1749))); + $operands = new OperandsCollection(array(new QtiFloat(3.175), new QtiFloat(3.1749))); $processor->setOperands($operands); $result = $processor->process(); $this->assertSame(false, $result->getValue()); @@ -31,12 +31,12 @@ public function testSignificantFigures() { public function testDecimalPlaces() { $expression = $this->createFakeExpression(RoundingMode::DECIMAL_PLACES, 2); - $operands = new OperandsCollection(array(new Float(1.68572), new Float(1.69))); + $operands = new OperandsCollection(array(new QtiFloat(1.68572), new QtiFloat(1.69))); $processor = new EqualRoundedProcessor($expression, $operands); $result = $processor->process(); $this->assertSame(true, $result->getValue()); - $operands = new OperandsCollection(array(new Float(1.68572), new Float(1.68432))); + $operands = new OperandsCollection(array(new QtiFloat(1.68572), new QtiFloat(1.68432))); $processor->setOperands($operands); $result = $processor->process(); $this->assertSame(false, $result->getValue()); @@ -44,7 +44,7 @@ public function testDecimalPlaces() { public function testNull() { $expression = $this->createFakeExpression(RoundingMode::DECIMAL_PLACES, 2); - $operands = new OperandsCollection(array(new Float(1.68572), null)); + $operands = new OperandsCollection(array(new QtiFloat(1.68572), null)); $processor = new EqualRoundedProcessor($expression, $operands); $result = $processor->process(); $this->assertSame(null, $result); @@ -52,11 +52,11 @@ public function testNull() { public function testVariableRef() { $expression = $this->createFakeExpression(RoundingMode::SIGNIFICANT_FIGURES, 'var1'); - $operands = new OperandsCollection(array(new Float(3.175), new Float(3.183))); + $operands = new OperandsCollection(array(new QtiFloat(3.175), new QtiFloat(3.183))); $processor = new EqualRoundedProcessor($expression, $operands); $state = new State(); - $state->setVariable(new OutcomeVariable('var1', Cardinality::SINGLE, BaseType::INTEGER, new Integer(3))); + $state->setVariable(new OutcomeVariable('var1', Cardinality::SINGLE, BaseType::INTEGER, new QtiInteger(3))); $processor->setState($state); $result = $processor->process(); @@ -65,11 +65,11 @@ public function testVariableRef() { public function testUnknownVariableRef() { $expression = $this->createFakeExpression(RoundingMode::SIGNIFICANT_FIGURES, 'var1'); - $operands = new OperandsCollection(array(new Float(3.175), new Float(3.183))); + $operands = new OperandsCollection(array(new QtiFloat(3.175), new QtiFloat(3.183))); $processor = new EqualRoundedProcessor($expression, $operands); $state = new State(); - $state->setVariable(new OutcomeVariable('varX', Cardinality::SINGLE, BaseType::INTEGER, new Integer(3))); + $state->setVariable(new OutcomeVariable('varX', Cardinality::SINGLE, BaseType::INTEGER, new QtiInteger(3))); $processor->setState($state); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); @@ -79,7 +79,7 @@ public function testUnknownVariableRef() { public function testWrongBaseType() { $expression = $this->createFakeExpression(RoundingMode::DECIMAL_PLACES, 2); - $operands = new OperandsCollection(array(new Pair('A', 'B'), new Integer(3))); + $operands = new OperandsCollection(array(new QtiPair('A', 'B'), new QtiInteger(3))); $processor = new EqualRoundedProcessor($expression, $operands); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $result = $processor->process(); @@ -87,7 +87,7 @@ public function testWrongBaseType() { public function testWrongCardinality() { $expression = $this->createFakeExpression(RoundingMode::DECIMAL_PLACES, 2); - $operands = new OperandsCollection(array(new Integer(10), new RecordContainer(array('A' => new Integer(1337))))); + $operands = new OperandsCollection(array(new QtiInteger(10), new RecordContainer(array('A' => new QtiInteger(1337))))); $processor = new EqualRoundedProcessor($expression, $operands); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $result = $processor->process(); @@ -95,14 +95,14 @@ public function testWrongCardinality() { public function testNotEnoughOperands() { $expression = $this->createFakeExpression(RoundingMode::DECIMAL_PLACES, 2); - $operands = new OperandsCollection(array(new Integer(10))); + $operands = new OperandsCollection(array(new QtiInteger(10))); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $processor = new EqualRoundedProcessor($expression, $operands); } public function testTooMuchOperands() { $expression = $this->createFakeExpression(RoundingMode::DECIMAL_PLACES, 2); - $operands = new OperandsCollection(array(new Integer(10), new Integer(10), new Integer(10))); + $operands = new OperandsCollection(array(new QtiInteger(10), new QtiInteger(10), new QtiInteger(10))); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $processor = new EqualRoundedProcessor($expression, $operands); } diff --git a/test/qtismtest/runtime/expressions/operators/FieldValueProcessorTest.php b/test/qtismtest/runtime/expressions/operators/FieldValueProcessorTest.php index 12266c036..6f7990a85 100644 --- a/test/qtismtest/runtime/expressions/operators/FieldValueProcessorTest.php +++ b/test/qtismtest/runtime/expressions/operators/FieldValueProcessorTest.php @@ -2,10 +2,10 @@ namespace qtismtest\runtime\expressions\operators; use qtismtest\QtiSmTestCase; -use qtism\common\datatypes\Integer; +use qtism\common\datatypes\QtiInteger; use qtism\common\enums\BaseType; use qtism\runtime\common\MultipleContainer; -use qtism\common\datatypes\Point; +use qtism\common\datatypes\QtiPoint; use qtism\runtime\common\RecordContainer; use qtism\runtime\expressions\operators\FieldValueProcessor; use qtism\runtime\expressions\operators\OperandsCollection; @@ -53,7 +53,7 @@ public function testWrongCardinalityOne() { // primitive PHP. $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); - $operands[] = new Integer(10); + $operands[] = new QtiInteger(10); $processor = new FieldValueProcessor($expression, $operands); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $result = $processor->process(); @@ -63,7 +63,7 @@ public function testWrongCardinalityTwo() { // primitive QTI (Point, Duration, ...) $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); - $operands[] = new Point(1, 2); + $operands[] = new QtiPoint(1, 2); $processor = new FieldValueProcessor($expression, $operands); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $result = $processor->process(); @@ -72,7 +72,7 @@ public function testWrongCardinalityTwo() { public function testWrongCardinalityThree() { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); - $operands[] = new MultipleContainer(BaseType::POINT, array(new Point(1, 2))); + $operands[] = new MultipleContainer(BaseType::POINT, array(new QtiPoint(1, 2))); // Wrong container (Multiple, Ordered) $processor = new FieldValueProcessor($expression, $operands); @@ -84,7 +84,7 @@ public function testFieldValue() { $expression = $this->createFakeExpression('B'); $operands = new OperandsCollection(); - $operands[] = new RecordContainer(array('A' => new Integer(1), 'B' => new Integer(2), 'C' => new Integer(3))); + $operands[] = new RecordContainer(array('A' => new QtiInteger(1), 'B' => new QtiInteger(2), 'C' => new QtiInteger(3))); $processor = new FieldValueProcessor($expression, $operands); $result = $processor->process(); diff --git a/test/qtismtest/runtime/expressions/operators/GcdProcessorTest.php b/test/qtismtest/runtime/expressions/operators/GcdProcessorTest.php index 164f67692..91c67a253 100644 --- a/test/qtismtest/runtime/expressions/operators/GcdProcessorTest.php +++ b/test/qtismtest/runtime/expressions/operators/GcdProcessorTest.php @@ -2,8 +2,8 @@ namespace qtismtest\runtime\expressions\operators; use qtismtest\QtiSmTestCase; -use qtism\common\datatypes\Integer; -use qtism\common\datatypes\String; +use qtism\common\datatypes\QtiInteger; +use qtism\common\datatypes\QtiString; use qtism\runtime\common\RecordContainer; use qtism\runtime\expressions\operators\GcdProcessor; use qtism\runtime\expressions\operators\OperandsCollection; @@ -35,7 +35,7 @@ public function testNotEnoughOperands() { public function testWrongBaseType() { $expression = $this->createFakeExpression(); - $operands = new OperandsCollection(array(new MultipleContainer(BaseType::STRING, array(new String('String!'))), new Integer(10))); + $operands = new OperandsCollection(array(new MultipleContainer(BaseType::STRING, array(new QtiString('String!'))), new QtiInteger(10))); $processor = new GcdProcessor($expression, $operands); $this->setExpectedException('qtism\\runtime\\expressions\\operators\\OperatorProcessingException'); $result = $processor->process(); @@ -43,7 +43,7 @@ public function testWrongBaseType() { public function testWrongCardinality() { $expression = $this->createFakeExpression(); - $operands = new OperandsCollection(array(new Integer(10), new Integer(20), new RecordContainer(array('A' => new Integer(10))), new Integer(30))); + $operands = new OperandsCollection(array(new QtiInteger(10), new QtiInteger(20), new RecordContainer(array('A' => new QtiInteger(10))), new QtiInteger(30))); $processor = new GcdProcessor($expression, $operands); $this->setExpectedException('qtism\\runtime\\expressions\\operators\\OperatorProcessingException'); $result = $processor->process(); @@ -63,29 +63,29 @@ public function testGcdWithNullValues(array $operands) { public function gcdProvider() { return array( - array(array(new Integer(45), new Integer(60), new Integer(330)), 15), - array(array(new Integer(0), new Integer(45), new Integer(60), new Integer(0), new Integer(330), new Integer(15), new Integer(0)), 15), // gcd (0, 45, 60, 330, 15, 0) - array(array(new Integer(0)), 0), - array(array(new Integer(0), new Integer(0), new Integer(0)), 0), - array(array(new MultipleContainer(BaseType::INTEGER, array(new Integer(45), new Integer(60), new Integer(330)))), 15), // gcd(45, 60, 330) - array(array(new Integer(0), new OrderedContainer(BaseType::INTEGER, array(new Integer(0)))), 0), // gcd(0, 0, 0) - array(array(new MultipleContainer(BaseType::INTEGER, array(new Integer(45), new Integer(60), new Integer(0), new Integer(330)))), 15), // gcd(45, 60, 0, 330) - array(array(new MultipleContainer(BaseType::INTEGER, array(new Integer(45))), new OrderedContainer(BaseType::INTEGER, array(new Integer(60))), new MultipleContainer(BaseType::INTEGER, array(new Integer(330)))), 15), - array(array(new Integer(45)), 45), - array(array(new Integer(0), new Integer(45)), 45), - array(array(new Integer(45), new Integer(0)), 45), - array(array(new Integer(0), new Integer(45), new Integer(0)), 45) + array(array(new QtiInteger(45), new QtiInteger(60), new QtiInteger(330)), 15), + array(array(new QtiInteger(0), new QtiInteger(45), new QtiInteger(60), new QtiInteger(0), new QtiInteger(330), new QtiInteger(15), new QtiInteger(0)), 15), // gcd (0, 45, 60, 330, 15, 0) + array(array(new QtiInteger(0)), 0), + array(array(new QtiInteger(0), new QtiInteger(0), new QtiInteger(0)), 0), + array(array(new MultipleContainer(BaseType::INTEGER, array(new QtiInteger(45), new QtiInteger(60), new QtiInteger(330)))), 15), // gcd(45, 60, 330) + array(array(new QtiInteger(0), new OrderedContainer(BaseType::INTEGER, array(new QtiInteger(0)))), 0), // gcd(0, 0, 0) + array(array(new MultipleContainer(BaseType::INTEGER, array(new QtiInteger(45), new QtiInteger(60), new QtiInteger(0), new QtiInteger(330)))), 15), // gcd(45, 60, 0, 330) + array(array(new MultipleContainer(BaseType::INTEGER, array(new QtiInteger(45))), new OrderedContainer(BaseType::INTEGER, array(new QtiInteger(60))), new MultipleContainer(BaseType::INTEGER, array(new QtiInteger(330)))), 15), + array(array(new QtiInteger(45)), 45), + array(array(new QtiInteger(0), new QtiInteger(45)), 45), + array(array(new QtiInteger(45), new QtiInteger(0)), 45), + array(array(new QtiInteger(0), new QtiInteger(45), new QtiInteger(0)), 45) ); } public function gcdWithNullValuesProvider() { return array( - array(array(new Integer(45), null, new Integer(330))), - array(array(new String(''), new Integer(550), new Integer(330))), - array(array(new Integer(230), new OrderedContainer(BaseType::INTEGER), new Integer(25), new Integer(33))), + array(array(new QtiInteger(45), null, new QtiInteger(330))), + array(array(new QtiString(''), new QtiInteger(550), new QtiInteger(330))), + array(array(new QtiInteger(230), new OrderedContainer(BaseType::INTEGER), new QtiInteger(25), new QtiInteger(33))), array(array(new OrderedContainer(BaseType::INTEGER, array(null)))), array(array(new OrderedContainer(BaseType::INTEGER, array(null, null, null)))), - array(array(new OrderedContainer(BaseType::INTEGER, array(new Integer(25), new Integer(30))), new Integer(200), new MultipleContainer(BaseType::INTEGER, array(new Integer(25), null, new Integer(30))))) + array(array(new OrderedContainer(BaseType::INTEGER, array(new QtiInteger(25), new QtiInteger(30))), new QtiInteger(200), new MultipleContainer(BaseType::INTEGER, array(new QtiInteger(25), null, new QtiInteger(30))))) ); } diff --git a/test/qtismtest/runtime/expressions/operators/GtProcessorTest.php b/test/qtismtest/runtime/expressions/operators/GtProcessorTest.php index 8d2c58d14..f033a2340 100644 --- a/test/qtismtest/runtime/expressions/operators/GtProcessorTest.php +++ b/test/qtismtest/runtime/expressions/operators/GtProcessorTest.php @@ -2,11 +2,11 @@ namespace qtismtest\runtime\expressions\operators; use qtismtest\QtiSmTestCase; -use qtism\common\datatypes\Boolean; -use qtism\common\datatypes\Float; -use qtism\common\datatypes\Integer; +use qtism\common\datatypes\QtiBoolean; +use qtism\common\datatypes\QtiFloat; +use qtism\common\datatypes\QtiInteger; use qtism\runtime\common\RecordContainer; -use qtism\common\datatypes\Point; +use qtism\common\datatypes\QtiPoint; use qtism\runtime\expressions\operators\GtProcessor; use qtism\runtime\expressions\operators\OperandsCollection; @@ -15,32 +15,32 @@ class GtProcessorTest extends QtiSmTestCase { public function testGt() { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); - $operands[] = new Integer(1); - $operands[] = new Float(0.5); + $operands[] = new QtiInteger(1); + $operands[] = new QtiFloat(0.5); $processor = new GtProcessor($expression, $operands); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Boolean', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiBoolean', $result); $this->assertTrue($result->getValue()); $operands->reset(); - $operands[] = new Float(0.5); - $operands[] = new Integer(1); + $operands[] = new QtiFloat(0.5); + $operands[] = new QtiInteger(1); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Boolean', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiBoolean', $result); $this->assertFalse($result->getValue()); $operands->reset(); - $operands[] = new Integer(1); - $operands[] = new Integer(1); + $operands[] = new QtiInteger(1); + $operands[] = new QtiInteger(1); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Boolean', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiBoolean', $result); $this->assertFalse($result->getValue()); } public function testNull() { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); - $operands[] = new Integer(1); + $operands[] = new QtiInteger(1); $operands[] = null; $processor = new GtProcessor($expression, $operands); $result = $processor->process(); @@ -50,8 +50,8 @@ public function testNull() { public function testWrongBaseTypeOne() { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); - $operands[] = new Integer(1); - $operands[] = new Boolean(true); + $operands[] = new QtiInteger(1); + $operands[] = new QtiBoolean(true); $processor = new GtProcessor($expression, $operands); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $result = $processor->process(); @@ -60,8 +60,8 @@ public function testWrongBaseTypeOne() { public function testWrongBaseTypeTwo() { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); - $operands[] = new Point(1, 2); - $operands[] = new Integer(2); + $operands[] = new QtiPoint(1, 2); + $operands[] = new QtiInteger(2); $processor = new GtProcessor($expression, $operands); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $result = $processor->process(); @@ -70,8 +70,8 @@ public function testWrongBaseTypeTwo() { public function testWrongCardinality() { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); - $operands[] = new RecordContainer(array('A' => new Integer(1))); - $operands[] = new Integer(2); + $operands[] = new RecordContainer(array('A' => new QtiInteger(1))); + $operands[] = new QtiInteger(2); $processor = new GtProcessor($expression, $operands); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $result = $processor->process(); @@ -86,7 +86,7 @@ public function testNotEnoughOperands() { public function testTooMuchOperands() { $expression = $this->createFakeExpression(); - $operands = new OperandsCollection(array(new Integer(1), new Integer(2), new Integer(3))); + $operands = new OperandsCollection(array(new QtiInteger(1), new QtiInteger(2), new QtiInteger(3))); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $processor = new GtProcessor($expression, $operands); } diff --git a/test/qtismtest/runtime/expressions/operators/GteProcessorTest.php b/test/qtismtest/runtime/expressions/operators/GteProcessorTest.php index 10319b372..9c68e7ef3 100644 --- a/test/qtismtest/runtime/expressions/operators/GteProcessorTest.php +++ b/test/qtismtest/runtime/expressions/operators/GteProcessorTest.php @@ -2,11 +2,11 @@ namespace qtismtest\runtime\expressions\operators; use qtismtest\QtiSmTestCase; -use qtism\common\datatypes\Boolean; -use qtism\common\datatypes\Float; -use qtism\common\datatypes\Integer; +use qtism\common\datatypes\QtiBoolean; +use qtism\common\datatypes\QtiFloat; +use qtism\common\datatypes\QtiInteger; use qtism\runtime\common\RecordContainer; -use qtism\common\datatypes\Point; +use qtism\common\datatypes\QtiPoint; use qtism\runtime\expressions\operators\GteProcessor; use qtism\runtime\expressions\operators\OperandsCollection; @@ -15,32 +15,32 @@ class GteProcessorTest extends QtiSmTestCase { public function testGte() { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); - $operands[] = new Integer(1); - $operands[] = new Float(0.5); + $operands[] = new QtiInteger(1); + $operands[] = new QtiFloat(0.5); $processor = new GteProcessor($expression, $operands); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Boolean', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiBoolean', $result); $this->assertTrue($result->getValue()); $operands->reset(); - $operands[] = new Float(0.5); - $operands[] = new Integer(1); + $operands[] = new QtiFloat(0.5); + $operands[] = new QtiInteger(1); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Boolean', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiBoolean', $result); $this->assertFalse($result->getValue()); $operands->reset(); - $operands[] = new Integer(1); - $operands[] = new Integer(1); + $operands[] = new QtiInteger(1); + $operands[] = new QtiInteger(1); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Boolean', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiBoolean', $result); $this->assertTrue($result->getValue()); } public function testNull() { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); - $operands[] = new Integer(1); + $operands[] = new QtiInteger(1); $operands[] = null; $processor = new GteProcessor($expression, $operands); $result = $processor->process(); @@ -50,8 +50,8 @@ public function testNull() { public function testWrongBaseTypeOne() { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); - $operands[] = new Integer(1); - $operands[] = new Boolean(true); + $operands[] = new QtiInteger(1); + $operands[] = new QtiBoolean(true); $processor = new GteProcessor($expression, $operands); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $result = $processor->process(); @@ -60,8 +60,8 @@ public function testWrongBaseTypeOne() { public function testWrongBaseTypeTwo() { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); - $operands[] = new Point(1, 2); - $operands[] = new Integer(2); + $operands[] = new QtiPoint(1, 2); + $operands[] = new QtiInteger(2); $processor = new GteProcessor($expression, $operands); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $result = $processor->process(); @@ -70,8 +70,8 @@ public function testWrongBaseTypeTwo() { public function testWrongCardinality() { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); - $operands[] = new RecordContainer(array('A' => new Integer(1))); - $operands[] = new Integer(2); + $operands[] = new RecordContainer(array('A' => new QtiInteger(1))); + $operands[] = new QtiInteger(2); $processor = new GteProcessor($expression, $operands); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $result = $processor->process(); @@ -86,7 +86,7 @@ public function testNotEnoughOperands() { public function testTooMuchOperands() { $expression = $this->createFakeExpression(); - $operands = new OperandsCollection(array(new Integer(1), new Integer(2), new Integer(3))); + $operands = new OperandsCollection(array(new QtiInteger(1), new QtiInteger(2), new QtiInteger(3))); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $processor = new GteProcessor($expression, $operands); } diff --git a/test/qtismtest/runtime/expressions/operators/IndexProcessorTest.php b/test/qtismtest/runtime/expressions/operators/IndexProcessorTest.php index 3f1662187..84449ecd5 100644 --- a/test/qtismtest/runtime/expressions/operators/IndexProcessorTest.php +++ b/test/qtismtest/runtime/expressions/operators/IndexProcessorTest.php @@ -2,8 +2,8 @@ namespace qtismtest\runtime\expressions\operators; use qtismtest\QtiSmTestCase; -use qtism\common\datatypes\Integer; -use qtism\common\datatypes\Point; +use qtism\common\datatypes\QtiInteger; +use qtism\common\datatypes\QtiPoint; use qtism\common\enums\Cardinality; use qtism\runtime\common\OutcomeVariable; use qtism\runtime\common\State; @@ -19,50 +19,50 @@ public function testIndexNumeric() { // first trial at the trail of the collection. $expression = $this->createFakeExpression(1); $operands = new OperandsCollection(); - $operands[] = new OrderedContainer(BaseType::INTEGER, array(new Integer(1), new Integer(2), new Integer(3), new Integer(4), new Integer(5))); + $operands[] = new OrderedContainer(BaseType::INTEGER, array(new QtiInteger(1), new QtiInteger(2), new QtiInteger(3), new QtiInteger(4), new QtiInteger(5))); $processor = new IndexProcessor($expression, $operands); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Integer', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiInteger', $result); $this->assertEquals(1, $result->getValue()); // in the middle... $expression = $this->createFakeExpression(3); $processor->setExpression($expression); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Integer', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiInteger', $result); $this->assertEquals(3, $result->getValue()); // in the end... $expression = $this->createFakeExpression(5); $processor->setExpression($expression); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Integer', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiInteger', $result); $this->assertEquals(5, $result->getValue()); } public function testIndexVariableReference() { $expression = $this->createFakeExpression('variable1'); $operands = new OperandsCollection(); - $operands[] = new OrderedContainer(BaseType::INTEGER, array(new Integer(1), new Integer(2), new Integer(3), new Integer(4), new Integer(5))); + $operands[] = new OrderedContainer(BaseType::INTEGER, array(new QtiInteger(1), new QtiInteger(2), new QtiInteger(3), new QtiInteger(4), new QtiInteger(5))); $processor = new IndexProcessor($expression, $operands); $state = new State(); - $state->setVariable(new OutcomeVariable('variable1', Cardinality::SINGLE, BaseType::INTEGER, new Integer(3))); + $state->setVariable(new OutcomeVariable('variable1', Cardinality::SINGLE, BaseType::INTEGER, new QtiInteger(3))); $processor->setState($state); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Integer', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiInteger', $result); $this->assertEquals(3, $result->getValue()); } public function testIndexVariableReferenceNotFound() { $expression = $this->createFakeExpression('variable1'); $operands = new OperandsCollection(); - $operands[] = new OrderedContainer(BaseType::INTEGER, array(new Integer(1), new Integer(2), new Integer(3), new Integer(4), new Integer(5))); + $operands[] = new OrderedContainer(BaseType::INTEGER, array(new QtiInteger(1), new QtiInteger(2), new QtiInteger(3), new QtiInteger(4), new QtiInteger(5))); $processor = new IndexProcessor($expression, $operands); $state = new State(); - $state->setVariable(new OutcomeVariable('variableXXX', Cardinality::SINGLE, BaseType::INTEGER, new Integer(3))); + $state->setVariable(new OutcomeVariable('variableXXX', Cardinality::SINGLE, BaseType::INTEGER, new QtiInteger(3))); $processor->setState($state); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $result = $processor->process(); @@ -71,11 +71,11 @@ public function testIndexVariableReferenceNotFound() { public function testVariableReferenceNotInteger() { $expression = $this->createFakeExpression('variable1'); $operands = new OperandsCollection(); - $operands[] = new OrderedContainer(BaseType::INTEGER, array(new Integer(1), new Integer(2), new Integer(3), new Integer(4), new Integer(5))); + $operands[] = new OrderedContainer(BaseType::INTEGER, array(new QtiInteger(1), new QtiInteger(2), new QtiInteger(3), new QtiInteger(4), new QtiInteger(5))); $processor = new IndexProcessor($expression, $operands); $state = new State(); - $state->setVariable(new OutcomeVariable('variable1', Cardinality::SINGLE, BaseType::POINT, new Point(1, 2))); + $state->setVariable(new OutcomeVariable('variable1', Cardinality::SINGLE, BaseType::POINT, new QtiPoint(1, 2))); $processor->setState($state); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $result = $processor->process(); @@ -85,7 +85,7 @@ public function testOutOfRangeOne() { // 1. non-zero integer $expression = $this->createFakeExpression(-3); $operands = new OperandsCollection(); - $operands[] = new OrderedContainer(BaseType::INTEGER, array(new Integer(1), new Integer(2), new Integer(3), new Integer(4), new Integer(5))); + $operands[] = new OrderedContainer(BaseType::INTEGER, array(new QtiInteger(1), new QtiInteger(2), new QtiInteger(3), new QtiInteger(4), new QtiInteger(5))); $processor = new IndexProcessor($expression, $operands); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $result = $processor->process(); @@ -95,7 +95,7 @@ public function testOutOfRangeTwo() { // 2. out of range $expression = $this->createFakeExpression(1000); $operands = new OperandsCollection(); - $operands[] = new OrderedContainer(BaseType::INTEGER, array(new Integer(1), new Integer(2), new Integer(3), new Integer(4), new Integer(5))); + $operands[] = new OrderedContainer(BaseType::INTEGER, array(new QtiInteger(1), new QtiInteger(2), new QtiInteger(3), new QtiInteger(4), new QtiInteger(5))); $processor = new IndexProcessor($expression, $operands); $result = $processor->process(); $this->assertSame(null, $result); @@ -104,7 +104,7 @@ public function testOutOfRangeTwo() { public function testWrongCardinality() { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); - $operands[] = new MultipleContainer(BaseType::INTEGER, array(new Integer(1), new Integer(2), new Integer(3), new Integer(4), new Integer(5))); + $operands[] = new MultipleContainer(BaseType::INTEGER, array(new QtiInteger(1), new QtiInteger(2), new QtiInteger(3), new QtiInteger(4), new QtiInteger(5))); $processor = new IndexProcessor($expression, $operands); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $result = $processor->process(); @@ -129,8 +129,8 @@ public function testNotEnoughOperands() { public function testTooMuchOperands() { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); - $operands[] = new OrderedContainer(BaseType::INTEGER, array(new Integer(1), new Integer(2), new Integer(3), new Integer(4), new Integer(5))); - $operands[] = new OrderedContainer(BaseType::INTEGER, array(new Integer(1), new Integer(2), new Integer(3), new Integer(4), new Integer(5))); + $operands[] = new OrderedContainer(BaseType::INTEGER, array(new QtiInteger(1), new QtiInteger(2), new QtiInteger(3), new QtiInteger(4), new QtiInteger(5))); + $operands[] = new OrderedContainer(BaseType::INTEGER, array(new QtiInteger(1), new QtiInteger(2), new QtiInteger(3), new QtiInteger(4), new QtiInteger(5))); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $processor = new IndexProcessor($expression, $operands); } diff --git a/test/qtismtest/runtime/expressions/operators/InsideProcessorTest.php b/test/qtismtest/runtime/expressions/operators/InsideProcessorTest.php index 753083c3e..195be263d 100644 --- a/test/qtismtest/runtime/expressions/operators/InsideProcessorTest.php +++ b/test/qtismtest/runtime/expressions/operators/InsideProcessorTest.php @@ -2,83 +2,83 @@ namespace qtismtest\runtime\expressions\operators; use qtismtest\QtiSmTestCase; -use qtism\common\datatypes\Integer; +use qtism\common\datatypes\QtiInteger; use qtism\common\enums\BaseType; use qtism\runtime\common\MultipleContainer; -use qtism\common\datatypes\Duration; -use qtism\common\datatypes\Shape; -use qtism\common\datatypes\Coords; -use qtism\common\datatypes\Point; +use qtism\common\datatypes\QtiDuration; +use qtism\common\datatypes\QtiShape; +use qtism\common\datatypes\QtiCoords; +use qtism\common\datatypes\QtiPoint; use qtism\runtime\expressions\operators\InsideProcessor; use qtism\runtime\expressions\operators\OperandsCollection; class InsideProcessorTest extends QtiSmTestCase { public function testRect() { - $coords = new Coords(Shape::RECT, array(0, 0, 5, 3)); - $point = new Point(0, 0); // 0, 0 is inside. + $coords = new QtiCoords(QtiShape::RECT, array(0, 0, 5, 3)); + $point = new QtiPoint(0, 0); // 0, 0 is inside. $expression = $this->createFakeExpression($point, $coords); $operands = new OperandsCollection(array($point)); $processor = new InsideProcessor($expression, $operands); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Boolean', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiBoolean', $result); $this->assertTrue($result->getValue()); - $point = new Point(-1, -1); // -1, -1 is outside. + $point = new QtiPoint(-1, -1); // -1, -1 is outside. $operands = new OperandsCollection(array($point)); $expression = $this->createFakeExpression($point, $coords); $processor->setExpression($expression); $processor->setOperands($operands); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Boolean', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiBoolean', $result); $this->assertFalse($result->getValue()); } public function testPoly() { - $coords = new Coords(Shape::POLY, array(0, 8, 7, 4, 2, 2, 8, -4, -2, 1)); - $point = new Point(0, 8); // 0, 8 is inside. + $coords = new QtiCoords(QtiShape::POLY, array(0, 8, 7, 4, 2, 2, 8, -4, -2, 1)); + $point = new QtiPoint(0, 8); // 0, 8 is inside. $expression = $this->createFakeExpression($point, $coords); $operands = new OperandsCollection(array($point)); $processor = new InsideProcessor($expression, $operands); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Boolean', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiBoolean', $result); $this->assertTrue($result->getValue()); - $point = new Point(10, 9); // 10, 9 is outside. + $point = new QtiPoint(10, 9); // 10, 9 is outside. $operands = new OperandsCollection(array($point)); $expression = $this->createFakeExpression($point, $coords); $processor->setExpression($expression); $processor->setOperands($operands); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Boolean', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiBoolean', $result); $this->assertFalse($result->getValue()); } public function testCircle() { - $coords = new Coords(Shape::CIRCLE, array(5, 5, 5)); - $point = new Point(3, 3); // 3,3 is inside + $coords = new QtiCoords(QtiShape::CIRCLE, array(5, 5, 5)); + $point = new QtiPoint(3, 3); // 3,3 is inside $expression = $this->createFakeExpression($point, $coords); $operands = new OperandsCollection(array($point)); $processor = new InsideProcessor($expression, $operands); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Boolean', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiBoolean', $result); $this->assertTrue($result->getValue()); - $point = new Point(1, 1); // 1,1 is outside + $point = new QtiPoint(1, 1); // 1,1 is outside $operands = new OperandsCollection(array($point)); $expression = $this->createFakeExpression($point, $coords); $processor->setExpression($expression); $processor->setOperands($operands); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Boolean', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiBoolean', $result); $this->assertFalse($result->getValue()); } public function testNull() { - $coords = new Coords(Shape::RECT, array(0, 0, 5, 3)); + $coords = new QtiCoords(QtiShape::RECT, array(0, 0, 5, 3)); $point = null; $expression = $this->createFakeExpression($point, $coords); $operands = new OperandsCollection(array($point)); @@ -88,8 +88,8 @@ public function testNull() { } public function testWrongBaseTypeOne() { - $coords = new Coords(Shape::RECT, array(0, 0, 5, 3)); - $point = new Duration('P1D'); + $coords = new QtiCoords(QtiShape::RECT, array(0, 0, 5, 3)); + $point = new QtiDuration('P1D'); $expression = $this->createFakeExpression($point, $coords); $operands = new OperandsCollection(array($point)); $processor = new InsideProcessor($expression, $operands); @@ -98,8 +98,8 @@ public function testWrongBaseTypeOne() { } public function testWrongBaseTypeTwo() { - $coords = new Coords(Shape::RECT, array(0, 0, 5, 3)); - $point = new Integer(10); + $coords = new QtiCoords(QtiShape::RECT, array(0, 0, 5, 3)); + $point = new QtiInteger(10); $expression = $this->createFakeExpression($point, $coords); $operands = new OperandsCollection(array($point)); $processor = new InsideProcessor($expression, $operands); @@ -108,8 +108,8 @@ public function testWrongBaseTypeTwo() { } public function testWrongCardinality() { - $coords = new Coords(Shape::RECT, array(0, 0, 5, 3)); - $point = new MultipleContainer(BaseType::POINT, array(new Point(1, 2))); + $coords = new QtiCoords(QtiShape::RECT, array(0, 0, 5, 3)); + $point = new MultipleContainer(BaseType::POINT, array(new QtiPoint(1, 2))); $expression = $this->createFakeExpression($point, $coords); $operands = new OperandsCollection(array($point)); $processor = new InsideProcessor($expression, $operands); @@ -118,8 +118,8 @@ public function testWrongCardinality() { } public function testNotEnoughOperands() { - $coords = new Coords(Shape::RECT, array(0, 0, 5, 3)); - $point = new Point(1, 2); + $coords = new QtiCoords(QtiShape::RECT, array(0, 0, 5, 3)); + $point = new QtiPoint(1, 2); $expression = $this->createFakeExpression($point, $coords); $operands = new OperandsCollection(); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); @@ -127,20 +127,20 @@ public function testNotEnoughOperands() { } public function testTooMuchOperands() { - $coords = new Coords(Shape::RECT, array(0, 0, 5, 3)); - $point = new Point(1, 2); + $coords = new QtiCoords(QtiShape::RECT, array(0, 0, 5, 3)); + $point = new QtiPoint(1, 2); $expression = $this->createFakeExpression($point, $coords); - $operands = new OperandsCollection(array(new Point(1, 2), new Point(2, 3))); + $operands = new OperandsCollection(array(new QtiPoint(1, 2), new QtiPoint(2, 3))); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $processor = new InsideProcessor($expression, $operands); } - public function createFakeExpression($point = null, Coords $coords = null) { - $point = (is_null($point) || !$point instanceof Point) ? new Point(2, 2) : $point; - $coords = (is_null($coords)) ? new Coords(Shape::RECT, array(0, 0, 5, 3)) : $coords; + public function createFakeExpression($point = null, QtiCoords $coords = null) { + $point = (is_null($point) || !$point instanceof QtiPoint) ? new QtiPoint(2, 2) : $point; + $coords = (is_null($coords)) ? new QtiCoords(QtiShape::RECT, array(0, 0, 5, 3)) : $coords; return $this->createComponentFromXml(' - + ' . $point . ' '); diff --git a/test/qtismtest/runtime/expressions/operators/IntegerDivideProcessorTest.php b/test/qtismtest/runtime/expressions/operators/IntegerDivideProcessorTest.php index 0593c1d38..d6172bfce 100644 --- a/test/qtismtest/runtime/expressions/operators/IntegerDivideProcessorTest.php +++ b/test/qtismtest/runtime/expressions/operators/IntegerDivideProcessorTest.php @@ -2,9 +2,9 @@ namespace qtismtest\runtime\expressions\operators; use qtismtest\QtiSmTestCase; -use qtism\common\datatypes\String; -use qtism\common\datatypes\Integer; -use qtism\common\datatypes\Duration; +use qtism\common\datatypes\QtiString; +use qtism\common\datatypes\QtiInteger; +use qtism\common\datatypes\QtiDuration; use qtism\common\enums\BaseType; use qtism\runtime\common\MultipleContainer; use qtism\runtime\expressions\operators\IntegerDivideProcessor; @@ -14,22 +14,22 @@ class IntegerDivideProcessorTest extends QtiSmTestCase { public function testIntegerDivide() { $expression = $this->createFakeExpression(); - $operands = new OperandsCollection(array(new Integer(10), new Integer(5))); + $operands = new OperandsCollection(array(new QtiInteger(10), new QtiInteger(5))); $processor = new IntegerDivideProcessor($expression, $operands); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Integer', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiInteger', $result); $this->assertEquals(2, $result->getValue()); - $operands = new OperandsCollection(array(new Integer(49), new Integer(-5))); + $operands = new OperandsCollection(array(new QtiInteger(49), new QtiInteger(-5))); $processor->setOperands($operands); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Integer', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiInteger', $result); $this->assertEquals(-10, $result->getValue()); } public function testNull() { $expression = $this->createFakeExpression(); - $operands = new OperandsCollection(array(null, new Integer(5))); + $operands = new OperandsCollection(array(null, new QtiInteger(5))); $processor = new IntegerDivideProcessor($expression, $operands); $result = $processor->process(); $this->assertSame(null, $result); @@ -37,7 +37,7 @@ public function testNull() { public function testDivisionByZero() { $expression = $this->createFakeExpression(); - $operands = new OperandsCollection(array(new Integer(50), new Integer(0))); + $operands = new OperandsCollection(array(new QtiInteger(50), new QtiInteger(0))); $processor = new IntegerDivideProcessor($expression, $operands); $result = $processor->process(); $this->assertSame(null, $result); @@ -45,7 +45,7 @@ public function testDivisionByZero() { public function testWrongCardinality() { $expression = $this->createFakeExpression(); - $operands = new OperandsCollection(array(new MultipleContainer(BaseType::INTEGER, array(new Integer(10))), new Integer(5))); + $operands = new OperandsCollection(array(new MultipleContainer(BaseType::INTEGER, array(new QtiInteger(10))), new QtiInteger(5))); $processor = new IntegerDivideProcessor($expression, $operands); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $result = $processor->process(); @@ -53,7 +53,7 @@ public function testWrongCardinality() { public function testWrongBaseTypeOne() { $expression = $this->createFakeExpression(); - $operands = new OperandsCollection(array(new String('ping!'), new Integer(5))); + $operands = new OperandsCollection(array(new QtiString('ping!'), new QtiInteger(5))); $processor = new IntegerDivideProcessor($expression, $operands); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $result = $processor->process(); @@ -61,7 +61,7 @@ public function testWrongBaseTypeOne() { public function testWrongBaseTypeTwo() { $expression = $this->createFakeExpression(); - $operands = new OperandsCollection(array(new Integer(5), new Duration('P1D'))); + $operands = new OperandsCollection(array(new QtiInteger(5), new QtiDuration('P1D'))); $processor = new IntegerDivideProcessor($expression, $operands); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $result = $processor->process(); @@ -69,14 +69,14 @@ public function testWrongBaseTypeTwo() { public function testNotEnoughOperands() { $expression = $this->createFakeExpression(); - $operands = new OperandsCollection(array(new Integer(5))); + $operands = new OperandsCollection(array(new QtiInteger(5))); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $processor = new IntegerDivideProcessor($expression, $operands); } public function testTooMuchOperands() { $expression = $this->createFakeExpression(); - $operands = new OperandsCollection(array(new Integer(5), new Integer(5), new Integer(5))); + $operands = new OperandsCollection(array(new QtiInteger(5), new QtiInteger(5), new QtiInteger(5))); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $processor = new IntegerDivideProcessor($expression, $operands); } diff --git a/test/qtismtest/runtime/expressions/operators/IntegerModulusProcessorTest.php b/test/qtismtest/runtime/expressions/operators/IntegerModulusProcessorTest.php index 771111a4a..e3cdd14b2 100644 --- a/test/qtismtest/runtime/expressions/operators/IntegerModulusProcessorTest.php +++ b/test/qtismtest/runtime/expressions/operators/IntegerModulusProcessorTest.php @@ -2,9 +2,9 @@ namespace qtismtest\runtime\expressions\operators; use qtismtest\QtiSmTestCase; -use qtism\common\datatypes\Integer; -use qtism\common\datatypes\String; -use qtism\common\datatypes\Duration; +use qtism\common\datatypes\QtiInteger; +use qtism\common\datatypes\QtiString; +use qtism\common\datatypes\QtiDuration; use qtism\common\enums\BaseType; use qtism\runtime\common\MultipleContainer; use qtism\runtime\expressions\operators\IntegerModulusProcessor; @@ -14,28 +14,28 @@ class IntegerModulusProcessorTest extends QtiSmTestCase { public function testIntegerModulus() { $expression = $this->createFakeExpression(); - $operands = new OperandsCollection(array(new Integer(10), new Integer(5))); + $operands = new OperandsCollection(array(new QtiInteger(10), new QtiInteger(5))); $processor = new IntegerModulusProcessor($expression, $operands); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Integer', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiInteger', $result); $this->assertEquals(0, $result->getValue()); - $operands = new OperandsCollection(array(new Integer(49), new Integer(-5))); + $operands = new OperandsCollection(array(new QtiInteger(49), new QtiInteger(-5))); $processor->setOperands($operands); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Integer', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiInteger', $result); $this->assertEquals(4, $result->getValue()); - $operands = new OperandsCollection(array(new Integer(36), new Integer(7))); + $operands = new OperandsCollection(array(new QtiInteger(36), new QtiInteger(7))); $processor->setOperands($operands); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Integer', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiInteger', $result); $this->assertEquals(1, $result->getValue()); } public function testNull() { $expression = $this->createFakeExpression(); - $operands = new OperandsCollection(array(null, new Integer(5))); + $operands = new OperandsCollection(array(null, new QtiInteger(5))); $processor = new IntegerModulusProcessor($expression, $operands); $result = $processor->process(); $this->assertSame(null, $result); @@ -43,7 +43,7 @@ public function testNull() { public function testModulusByZero() { $expression = $this->createFakeExpression(); - $operands = new OperandsCollection(array(new Integer(50), new Integer(0))); + $operands = new OperandsCollection(array(new QtiInteger(50), new QtiInteger(0))); $processor = new IntegerModulusProcessor($expression, $operands); $result = $processor->process(); $this->assertSame(null, $result); @@ -51,7 +51,7 @@ public function testModulusByZero() { public function testWrongCardinality() { $expression = $this->createFakeExpression(); - $operands = new OperandsCollection(array(new MultipleContainer(BaseType::INTEGER, array(new Integer(10))), new Integer(5))); + $operands = new OperandsCollection(array(new MultipleContainer(BaseType::INTEGER, array(new QtiInteger(10))), new QtiInteger(5))); $processor = new IntegerModulusProcessor($expression, $operands); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $result = $processor->process(); @@ -59,7 +59,7 @@ public function testWrongCardinality() { public function testWrongBaseTypeOne() { $expression = $this->createFakeExpression(); - $operands = new OperandsCollection(array(new String('ping!'), new Integer(5))); + $operands = new OperandsCollection(array(new QtiString('ping!'), new QtiInteger(5))); $processor = new IntegerModulusProcessor($expression, $operands); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $result = $processor->process(); @@ -67,7 +67,7 @@ public function testWrongBaseTypeOne() { public function testWrongBaseTypeTwo() { $expression = $this->createFakeExpression(); - $operands = new OperandsCollection(array(new Integer(5), new Duration('P1D'))); + $operands = new OperandsCollection(array(new QtiInteger(5), new QtiDuration('P1D'))); $processor = new IntegerModulusProcessor($expression, $operands); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $result = $processor->process(); @@ -75,14 +75,14 @@ public function testWrongBaseTypeTwo() { public function testNotEnoughOperands() { $expression = $this->createFakeExpression(); - $operands = new OperandsCollection(array(new Integer(5))); + $operands = new OperandsCollection(array(new QtiInteger(5))); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $processor = new IntegerModulusProcessor($expression, $operands); } public function testTooMuchOperands() { $expression = $this->createFakeExpression(); - $operands = new OperandsCollection(array(new Integer(5), new Integer(5), new Integer(5))); + $operands = new OperandsCollection(array(new QtiInteger(5), new QtiInteger(5), new QtiInteger(5))); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $processor = new IntegerModulusProcessor($expression, $operands); } diff --git a/test/qtismtest/runtime/expressions/operators/IntegerToFloatTest.php b/test/qtismtest/runtime/expressions/operators/IntegerToFloatTest.php index 3c5aba05b..c535e7bc2 100644 --- a/test/qtismtest/runtime/expressions/operators/IntegerToFloatTest.php +++ b/test/qtismtest/runtime/expressions/operators/IntegerToFloatTest.php @@ -2,10 +2,10 @@ namespace qtismtest\runtime\expressions\operators; use qtismtest\QtiSmTestCase; -use qtism\common\datatypes\String; -use qtism\common\datatypes\Float; -use qtism\common\datatypes\Integer; -use qtism\common\datatypes\Point; +use qtism\common\datatypes\QtiString; +use qtism\common\datatypes\QtiFloat; +use qtism\common\datatypes\QtiInteger; +use qtism\common\datatypes\QtiPoint; use qtism\common\enums\BaseType; use qtism\runtime\common\MultipleContainer; use qtism\runtime\expressions\operators\IntegerToFloatProcessor; @@ -16,29 +16,29 @@ class IntegerToFloatProcessorTest extends QtiSmTestCase { public function testIntegerToFloat() { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); - $operands[] = new Integer(10); + $operands[] = new QtiInteger(10); $processor = new IntegerToFloatProcessor($expression, $operands); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $result); $this->assertEquals(10.0, $result->getValue()); $operands->reset(); - $operands[] = new Integer(-10); + $operands[] = new QtiInteger(-10); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $result); $this->assertEquals(-10.0, $result->getValue()); $operands->reset(); - $operands[] = new Integer(0); + $operands[] = new QtiInteger(0); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $result); $this->assertEquals(0.0, $result->getValue()); $operands->reset(); - $operands[] = new Integer(-0); + $operands[] = new QtiInteger(-0); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $result); $this->assertEquals(-0.0, $result->getValue()); } @@ -55,7 +55,7 @@ public function testNullOne() { public function testNullTwo() { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); - $operands[] = new String(''); + $operands[] = new QtiString(''); $processor = new IntegerToFloatProcessor($expression, $operands); $result = $processor->process(); @@ -65,7 +65,7 @@ public function testNullTwo() { public function testWrongCardinality() { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); - $operands[] = new MultipleContainer(BaseType::INTEGER, array(new Integer(1), new Integer(2), new Integer(3))); + $operands[] = new MultipleContainer(BaseType::INTEGER, array(new QtiInteger(1), new QtiInteger(2), new QtiInteger(3))); $processor = new IntegerToFloatProcessor($expression, $operands); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); @@ -75,7 +75,7 @@ public function testWrongCardinality() { public function testWrongBaseTypeOne() { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); - $operands[] = new String('String!'); + $operands[] = new QtiString('String!'); $processor = new IntegerToFloatProcessor($expression, $operands); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); @@ -85,7 +85,7 @@ public function testWrongBaseTypeOne() { public function testWrongBaseTypeTwo() { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); - $operands[] = new Point(1, 2); + $operands[] = new QtiPoint(1, 2); $processor = new IntegerToFloatProcessor($expression, $operands); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); @@ -102,8 +102,8 @@ public function testNotEnoughOperands() { public function testTooMuchOperands() { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); - $operands[] = new Integer(10); - $operands[] = new Integer(-10); + $operands[] = new QtiInteger(10); + $operands[] = new QtiInteger(-10); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $processor = new IntegerToFloatProcessor($expression, $operands); } diff --git a/test/qtismtest/runtime/expressions/operators/IsNullProcessorTest.php b/test/qtismtest/runtime/expressions/operators/IsNullProcessorTest.php index 9aa9fa6f4..53d2b427a 100644 --- a/test/qtismtest/runtime/expressions/operators/IsNullProcessorTest.php +++ b/test/qtismtest/runtime/expressions/operators/IsNullProcessorTest.php @@ -2,11 +2,11 @@ namespace qtismtest\runtime\expressions\operators; use qtismtest\QtiSmTestCase; -use qtism\common\datatypes\Float; -use qtism\common\datatypes\Boolean; -use qtism\common\datatypes\Integer; -use qtism\common\datatypes\String; -use qtism\common\datatypes\Point; +use qtism\common\datatypes\QtiFloat; +use qtism\common\datatypes\QtiBoolean; +use qtism\common\datatypes\QtiInteger; +use qtism\common\datatypes\QtiString; +use qtism\common\datatypes\QtiPoint; use qtism\runtime\common\RecordContainer; use qtism\runtime\common\OrderedContainer; use qtism\common\enums\BaseType; @@ -18,7 +18,7 @@ class IsNullProcessorTest extends QtiSmTestCase { public function testWithEmptyString() { $operands = new OperandsCollection(); - $operands[] = new String(''); + $operands[] = new QtiString(''); $expression = $this->getFakeExpression(); $processor = new IsNullProcessor($expression, $operands); @@ -53,33 +53,33 @@ public function testEmptyContainers() { public function testNotEmpty() { $expression = $this->getFakeExpression(); - $operands = new OperandsCollection(array(new Integer(0))); + $operands = new OperandsCollection(array(new QtiInteger(0))); $processor = new IsNullProcessor($expression, $operands); $this->assertFalse($processor->process()->getValue()); $operands->reset(); - $operands[] = new Boolean(false); + $operands[] = new QtiBoolean(false); $this->assertFalse($processor->process()->getValue()); $operands->reset(); - $operands[] = new Integer(-1); + $operands[] = new QtiInteger(-1); $this->assertFalse($processor->process()->getValue()); $operands->reset(); - $operands[] = new Point(1, 2); + $operands[] = new QtiPoint(1, 2); $this->assertFalse($processor->process()->getValue()); $operands->reset(); - $operands[] = new MultipleContainer(BaseType::INTEGER, array(new Integer(25))); + $operands[] = new MultipleContainer(BaseType::INTEGER, array(new QtiInteger(25))); $this->assertFalse($processor->process()->getValue()); $operands->reset(); - $operands[] = new OrderedContainer(BaseType::POINT, array(new Point(3, 4), new Point(5, 6))); + $operands[] = new OrderedContainer(BaseType::POINT, array(new QtiPoint(3, 4), new QtiPoint(5, 6))); $this->assertFalse($processor->process()->getValue()); $operands->reset(); - $operands[] = new RecordContainer(array('a' => new Boolean(true), 'b' => null, 'c' => new Point(1, 2), 'd' => new Integer(24), 'e' => new Float(23.3))); + $operands[] = new RecordContainer(array('a' => new QtiBoolean(true), 'b' => null, 'c' => new QtiPoint(1, 2), 'd' => new QtiInteger(24), 'e' => new QtiFloat(23.3))); $this->assertFalse($processor->process()->getValue()); } @@ -95,7 +95,7 @@ public function testLessThanNeededOperands() { public function testMoreThanNeededOperands() { $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); - $operands = new OperandsCollection(array(new Integer(25), null)); + $operands = new OperandsCollection(array(new QtiInteger(25), null)); $expression = $this->getFakeExpression(); $processor = new IsNullProcessor($expression, $operands); $result = $processor->process(); diff --git a/test/qtismtest/runtime/expressions/operators/LcmProcessorTest.php b/test/qtismtest/runtime/expressions/operators/LcmProcessorTest.php index 4c5008f70..9484ecdf3 100644 --- a/test/qtismtest/runtime/expressions/operators/LcmProcessorTest.php +++ b/test/qtismtest/runtime/expressions/operators/LcmProcessorTest.php @@ -2,8 +2,8 @@ namespace qtismtest\runtime\expressions\operators; use qtismtest\QtiSmTestCase; -use qtism\common\datatypes\String; -use qtism\common\datatypes\Integer; +use qtism\common\datatypes\QtiString; +use qtism\common\datatypes\QtiInteger; use qtism\runtime\common\RecordContainer; use qtism\runtime\expressions\operators\LcmProcessor; use qtism\runtime\expressions\operators\OperandsCollection; @@ -35,7 +35,7 @@ public function testNotEnoughOperands() { public function testWrongBaseType() { $expression = $this->createFakeExpression(); - $operands = new OperandsCollection(array(new MultipleContainer(BaseType::STRING, array(new String('String!'))), new Integer(10))); + $operands = new OperandsCollection(array(new MultipleContainer(BaseType::STRING, array(new QtiString('String!'))), new QtiInteger(10))); $processor = new LcmProcessor($expression, $operands); $this->setExpectedException('qtism\\runtime\\expressions\\operators\\OperatorProcessingException'); $result = $processor->process(); @@ -43,7 +43,7 @@ public function testWrongBaseType() { public function testWrongCardinality() { $expression = $this->createFakeExpression(); - $operands = new OperandsCollection(array(new Integer(10), new Integer(20), new RecordContainer(array('A' => new Integer(10))), new Integer(30))); + $operands = new OperandsCollection(array(new QtiInteger(10), new QtiInteger(20), new RecordContainer(array('A' => new QtiInteger(10))), new QtiInteger(30))); $processor = new LcmProcessor($expression, $operands); $this->setExpectedException('qtism\\runtime\\expressions\\operators\\OperatorProcessingException'); $result = $processor->process(); @@ -63,29 +63,29 @@ public function testGcdWithNullValues(array $operands) { public function lcmProvider() { return array( - array(array(new Integer(0)), 0), - array(array(new Integer(0), new MultipleContainer(BaseType::INTEGER, array(new Integer(0)))), 0), - array(array(new Integer(0), new Integer(0)), 0), - array(array(new Integer(330), new Integer(0)), 0), - array(array(new Integer(0), new Integer(330)), 0), - array(array(new Integer(330), new Integer(0), new Integer(15)), 0), - array(array(new Integer(330), new Integer(65), new Integer(15)), 4290), - array(array(new Integer(-10), new Integer(-5)), 10), - array(array(new Integer(330)), 330), - array(array(new Integer(330), new MultipleContainer(BaseType::INTEGER, array(new Integer(65))), new Integer(15)), 4290), - array(array(new OrderedContainer(BaseType::INTEGER, array(new Integer(330))), new MultipleContainer(BaseType::INTEGER, array(new Integer(65))), new MultipleContainer(BaseType::INTEGER, array(new Integer(15)))), 4290), - array(array(new OrderedContainer(BaseType::INTEGER, array(new Integer(330), new Integer(65))), new MultipleContainer(BaseType::INTEGER, array(new Integer(65)))), 4290), + array(array(new QtiInteger(0)), 0), + array(array(new QtiInteger(0), new MultipleContainer(BaseType::INTEGER, array(new QtiInteger(0)))), 0), + array(array(new QtiInteger(0), new QtiInteger(0)), 0), + array(array(new QtiInteger(330), new QtiInteger(0)), 0), + array(array(new QtiInteger(0), new QtiInteger(330)), 0), + array(array(new QtiInteger(330), new QtiInteger(0), new QtiInteger(15)), 0), + array(array(new QtiInteger(330), new QtiInteger(65), new QtiInteger(15)), 4290), + array(array(new QtiInteger(-10), new QtiInteger(-5)), 10), + array(array(new QtiInteger(330)), 330), + array(array(new QtiInteger(330), new MultipleContainer(BaseType::INTEGER, array(new QtiInteger(65))), new QtiInteger(15)), 4290), + array(array(new OrderedContainer(BaseType::INTEGER, array(new QtiInteger(330))), new MultipleContainer(BaseType::INTEGER, array(new QtiInteger(65))), new MultipleContainer(BaseType::INTEGER, array(new QtiInteger(15)))), 4290), + array(array(new OrderedContainer(BaseType::INTEGER, array(new QtiInteger(330), new QtiInteger(65))), new MultipleContainer(BaseType::INTEGER, array(new QtiInteger(65)))), 4290), ); } public function lcmWithNullValuesProvider() { return array( array(array(null)), - array(array(null, new Integer(10))), - array(array(new Integer(10), null)), - array(array(new Integer(10), null, new Integer(10))), - array(array(new Integer(10), new MultipleContainer(BaseType::INTEGER))), - array(array(new OrderedContainer(BaseType::INTEGER, array(new Integer(10), null)))) + array(array(null, new QtiInteger(10))), + array(array(new QtiInteger(10), null)), + array(array(new QtiInteger(10), null, new QtiInteger(10))), + array(array(new QtiInteger(10), new MultipleContainer(BaseType::INTEGER))), + array(array(new OrderedContainer(BaseType::INTEGER, array(new QtiInteger(10), null)))) ); } diff --git a/test/qtismtest/runtime/expressions/operators/LtProcessorTest.php b/test/qtismtest/runtime/expressions/operators/LtProcessorTest.php index 852656abb..f86cf6bc1 100644 --- a/test/qtismtest/runtime/expressions/operators/LtProcessorTest.php +++ b/test/qtismtest/runtime/expressions/operators/LtProcessorTest.php @@ -2,11 +2,11 @@ namespace qtismtest\runtime\expressions\operators; use qtismtest\QtiSmTestCase; -use qtism\common\datatypes\Boolean; -use qtism\common\datatypes\Integer; -use qtism\common\datatypes\Float; +use qtism\common\datatypes\QtiBoolean; +use qtism\common\datatypes\QtiInteger; +use qtism\common\datatypes\QtiFloat; use qtism\runtime\common\RecordContainer; -use qtism\common\datatypes\Point; +use qtism\common\datatypes\QtiPoint; use qtism\runtime\expressions\operators\LtProcessor; use qtism\runtime\expressions\operators\OperandsCollection; @@ -15,32 +15,32 @@ class LtProcessorTest extends QtiSmTestCase { public function testLt() { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); - $operands[] = new Float(0.5); - $operands[] = new Integer(1); + $operands[] = new QtiFloat(0.5); + $operands[] = new QtiInteger(1); $processor = new LtProcessor($expression, $operands); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Boolean', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiBoolean', $result); $this->assertTrue($result->getValue()); $operands->reset(); - $operands[] = new Integer(1); - $operands[] = new Float(0.5); + $operands[] = new QtiInteger(1); + $operands[] = new QtiFloat(0.5); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Boolean', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiBoolean', $result); $this->assertFalse($result->getValue()); $operands->reset(); - $operands[] = new Integer(1); - $operands[] = new Integer(1); + $operands[] = new QtiInteger(1); + $operands[] = new QtiInteger(1); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Boolean', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiBoolean', $result); $this->assertFalse($result->getValue()); } public function testNull() { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); - $operands[] = new Integer(1); + $operands[] = new QtiInteger(1); $operands[] = null; $processor = new LtProcessor($expression, $operands); $result = $processor->process(); @@ -50,8 +50,8 @@ public function testNull() { public function testWrongBaseTypeOne() { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); - $operands[] = new Integer(1); - $operands[] = new Boolean(true); + $operands[] = new QtiInteger(1); + $operands[] = new QtiBoolean(true); $processor = new LtProcessor($expression, $operands); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $result = $processor->process(); @@ -60,8 +60,8 @@ public function testWrongBaseTypeOne() { public function testWrongBaseTypeTwo() { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); - $operands[] = new Point(1, 2); - $operands[] = new Integer(2); + $operands[] = new QtiPoint(1, 2); + $operands[] = new QtiInteger(2); $processor = new LtProcessor($expression, $operands); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $result = $processor->process(); @@ -70,8 +70,8 @@ public function testWrongBaseTypeTwo() { public function testWrongCardinality() { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); - $operands[] = new RecordContainer(array('A' => new Integer(1))); - $operands[] = new Integer(2); + $operands[] = new RecordContainer(array('A' => new QtiInteger(1))); + $operands[] = new QtiInteger(2); $processor = new LtProcessor($expression, $operands); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $result = $processor->process(); @@ -86,7 +86,7 @@ public function testNotEnoughOperands() { public function testTooMuchOperands() { $expression = $this->createFakeExpression(); - $operands = new OperandsCollection(array(new Integer(1), new Integer(2), new Integer(3))); + $operands = new OperandsCollection(array(new QtiInteger(1), new QtiInteger(2), new QtiInteger(3))); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $processor = new LtProcessor($expression, $operands); } diff --git a/test/qtismtest/runtime/expressions/operators/LteProcessorTest.php b/test/qtismtest/runtime/expressions/operators/LteProcessorTest.php index 686a6e8b2..3ae6db2a4 100644 --- a/test/qtismtest/runtime/expressions/operators/LteProcessorTest.php +++ b/test/qtismtest/runtime/expressions/operators/LteProcessorTest.php @@ -2,11 +2,11 @@ namespace qtismtest\runtime\expressions\operators; use qtismtest\QtiSmTestCase; -use qtism\common\datatypes\Boolean; -use qtism\common\datatypes\Integer; -use qtism\common\datatypes\Float; +use qtism\common\datatypes\QtiBoolean; +use qtism\common\datatypes\QtiInteger; +use qtism\common\datatypes\QtiFloat; use qtism\runtime\common\RecordContainer; -use qtism\common\datatypes\Point; +use qtism\common\datatypes\QtiPoint; use qtism\runtime\expressions\operators\LteProcessor; use qtism\runtime\expressions\operators\OperandsCollection; @@ -15,32 +15,32 @@ class LteProcessorTest extends QtiSmTestCase { public function testLte() { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); - $operands[] = new Float(0.5); - $operands[] = new Integer(1); + $operands[] = new QtiFloat(0.5); + $operands[] = new QtiInteger(1); $processor = new LteProcessor($expression, $operands); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Boolean', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiBoolean', $result); $this->assertTrue($result->getValue()); $operands->reset(); - $operands[] = new Integer(1); - $operands[] = new Float(0.5); + $operands[] = new QtiInteger(1); + $operands[] = new QtiFloat(0.5); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Boolean', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiBoolean', $result); $this->assertFalse($result->getValue()); $operands->reset(); - $operands[] = new Integer(1); - $operands[] = new Integer(1); + $operands[] = new QtiInteger(1); + $operands[] = new QtiInteger(1); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Boolean', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiBoolean', $result); $this->assertTrue($result->getValue()); } public function testNull() { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); - $operands[] = new Integer(1); + $operands[] = new QtiInteger(1); $operands[] = null; $processor = new LteProcessor($expression, $operands); $result = $processor->process(); @@ -50,8 +50,8 @@ public function testNull() { public function testWrongBaseTypeOne() { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); - $operands[] = new Integer(1); - $operands[] = new Boolean(true); + $operands[] = new QtiInteger(1); + $operands[] = new QtiBoolean(true); $processor = new LteProcessor($expression, $operands); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $result = $processor->process(); @@ -60,8 +60,8 @@ public function testWrongBaseTypeOne() { public function testWrongBaseTypeTwo() { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); - $operands[] = new Point(1, 2); - $operands[] = new Integer(2); + $operands[] = new QtiPoint(1, 2); + $operands[] = new QtiInteger(2); $processor = new LteProcessor($expression, $operands); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $result = $processor->process(); @@ -70,8 +70,8 @@ public function testWrongBaseTypeTwo() { public function testWrongCardinality() { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); - $operands[] = new RecordContainer(array('A' => new Integer(1))); - $operands[] = new Integer(2); + $operands[] = new RecordContainer(array('A' => new QtiInteger(1))); + $operands[] = new QtiInteger(2); $processor = new LteProcessor($expression, $operands); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $result = $processor->process(); @@ -86,7 +86,7 @@ public function testNotEnoughOperands() { public function testTooMuchOperands() { $expression = $this->createFakeExpression(); - $operands = new OperandsCollection(array(new Integer(1), new Integer(2), new Integer(3))); + $operands = new OperandsCollection(array(new QtiInteger(1), new QtiInteger(2), new QtiInteger(3))); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $processor = new LteProcessor($expression, $operands); } diff --git a/test/qtismtest/runtime/expressions/operators/MatchProcessorTest.php b/test/qtismtest/runtime/expressions/operators/MatchProcessorTest.php index 54a609e12..f4663f6d7 100644 --- a/test/qtismtest/runtime/expressions/operators/MatchProcessorTest.php +++ b/test/qtismtest/runtime/expressions/operators/MatchProcessorTest.php @@ -4,11 +4,11 @@ use qtismtest\QtiSmTestCase; use qtism\common\datatypes\files\FileSystemFileManager; use qtism\common\datatypes\files\FileSystemFile; -use qtism\common\datatypes\Float; -use qtism\common\datatypes\IntOrIdentifier; -use qtism\common\datatypes\Identifier; -use qtism\common\datatypes\String; -use qtism\common\datatypes\Integer; +use qtism\common\datatypes\QtiFloat; +use qtism\common\datatypes\QtiIntOrIdentifier; +use qtism\common\datatypes\QtiIdentifier; +use qtism\common\datatypes\QtiString; +use qtism\common\datatypes\QtiInteger; use qtism\common\enums\BaseType; use qtism\runtime\common\MultipleContainer; use qtism\runtime\common\OrderedContainer; @@ -20,11 +20,11 @@ class MatchProcessorTest extends QtiSmTestCase { public function testScalar() { $expression = $this->createFakeExpression(); - $operands = new OperandsCollection(array(new Integer(10), new Integer(10))); + $operands = new OperandsCollection(array(new QtiInteger(10), new QtiInteger(10))); $processor = new MatchProcessor($expression, $operands); $this->assertTrue($processor->process()->getValue() === true); - $operands = new OperandsCollection(array(new Integer(10), new Integer(11))); + $operands = new OperandsCollection(array(new QtiInteger(10), new QtiInteger(11))); $processor->setOperands($operands); $this->assertFalse($processor->process()->getValue() === true); } @@ -32,15 +32,15 @@ public function testScalar() { public function testContainer() { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); - $operands[] = new MultipleContainer(BaseType::INTEGER, array(new Integer(5), new Integer(4), new Integer(3), new Integer(2), new Integer(1))); - $operands[] = new MultipleContainer(BaseType::INTEGER, array(new Integer(1), new Integer(2), new Integer(3), new Integer(4), new Integer(5))); + $operands[] = new MultipleContainer(BaseType::INTEGER, array(new QtiInteger(5), new QtiInteger(4), new QtiInteger(3), new QtiInteger(2), new QtiInteger(1))); + $operands[] = new MultipleContainer(BaseType::INTEGER, array(new QtiInteger(1), new QtiInteger(2), new QtiInteger(3), new QtiInteger(4), new QtiInteger(5))); $processor = new MatchProcessor($expression, $operands); $this->assertTrue($processor->process()->getValue() === true); $operands = new OperandsCollection(); - $operands[] = new MultipleContainer(BaseType::INTEGER, array(new Integer(5), new Integer(4), new Integer(3), new Integer(2), new Integer(1))); - $operands[] = new MultipleContainer(BaseType::INTEGER, array(new Integer(1), new Integer(6), new Integer(7), new Integer(8), new Integer(5))); + $operands[] = new MultipleContainer(BaseType::INTEGER, array(new QtiInteger(5), new QtiInteger(4), new QtiInteger(3), new QtiInteger(2), new QtiInteger(1))); + $operands[] = new MultipleContainer(BaseType::INTEGER, array(new QtiInteger(1), new QtiInteger(6), new QtiInteger(7), new QtiInteger(8), new QtiInteger(5))); $processor->setOperands($operands); $this->assertFalse($processor->process()->getValue() === true); } @@ -75,8 +75,8 @@ public function testFile() { public function testWrongBaseType() { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); - $operands[] = new MultipleContainer(BaseType::IDENTIFIER, array(new Identifier('txt1'), new Identifier('txt2'))); - $operands[] = new MultipleContainer(BaseType::STRING, array(new String('txt1'), new String('txt2'))); + $operands[] = new MultipleContainer(BaseType::IDENTIFIER, array(new QtiIdentifier('txt1'), new QtiIdentifier('txt2'))); + $operands[] = new MultipleContainer(BaseType::STRING, array(new QtiString('txt1'), new QtiString('txt2'))); $processor = new MatchProcessor($expression, $operands); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $processor->process(); @@ -85,8 +85,8 @@ public function testWrongBaseType() { public function testWrongBaseTypeCompliance() { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); - $operands[] = new MultipleContainer(BaseType::INT_OR_IDENTIFIER, array(new IntOrIdentifier('txt1'), new IntOrIdentifier('txt2'))); - $operands[] = new MultipleContainer(BaseType::STRING, array(new String('txt1'), new String('txt2'))); + $operands[] = new MultipleContainer(BaseType::INT_OR_IDENTIFIER, array(new QtiIntOrIdentifier('txt1'), new QtiIntOrIdentifier('txt2'))); + $operands[] = new MultipleContainer(BaseType::STRING, array(new QtiString('txt1'), new QtiString('txt2'))); $processor = new MatchProcessor($expression, $operands); // Unfortunately, INT_OR_IDENTIFIER cannot be considered as compliant with STRING. @@ -97,8 +97,8 @@ public function testWrongBaseTypeCompliance() { public function testDifferentBaseTypesScalar() { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); - $operands[] = new Integer(15); - $operands[] = new String('String!'); + $operands[] = new QtiInteger(15); + $operands[] = new QtiString('String!'); $processor = new MatchProcessor($expression, $operands); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $result = $processor->process(); @@ -107,8 +107,8 @@ public function testDifferentBaseTypesScalar() { public function testDifferentBaseTypesContainer() { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); - $operands[] = new MultipleContainer(BaseType::INTEGER, array(new Integer(10), new Integer(20), new Integer(30), new Integer(40))); - $operands[] = new MultipleContainer(BaseType::FLOAT, array(new Float(10.0), new Float(20.0), new Float(30.0), new Float(40.0))); + $operands[] = new MultipleContainer(BaseType::INTEGER, array(new QtiInteger(10), new QtiInteger(20), new QtiInteger(30), new QtiInteger(40))); + $operands[] = new MultipleContainer(BaseType::FLOAT, array(new QtiFloat(10.0), new QtiFloat(20.0), new QtiFloat(30.0), new QtiFloat(40.0))); $processor = new MatchProcessor($expression, $operands); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $result = $processor->process(); @@ -117,8 +117,8 @@ public function testDifferentBaseTypesContainer() { public function testDifferentBaseTypesMixed() { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); - $operands[] = new String('String!'); - $operands[] = new OrderedContainer(BaseType::FLOAT, array(new Float(10.0), new Float(20.0))); + $operands[] = new QtiString('String!'); + $operands[] = new OrderedContainer(BaseType::FLOAT, array(new QtiFloat(10.0), new QtiFloat(20.0))); $processor = new MatchProcessor($expression, $operands); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $result = $processor->process(); @@ -127,8 +127,8 @@ public function testDifferentBaseTypesMixed() { public function testDifferentCardinalitiesOne() { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); - $operands[] = new String('String!'); - $operands[] = new MultipleContainer(BaseType::STRING, array(new String('String!'))); + $operands[] = new QtiString('String!'); + $operands[] = new MultipleContainer(BaseType::STRING, array(new QtiString('String!'))); $processor = new MatchProcessor($expression, $operands); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $result = $processor->process(); @@ -137,8 +137,8 @@ public function testDifferentCardinalitiesOne() { public function testDifferentCardinalitiesTwo() { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); - $operands[] = new OrderedContainer(BaseType::STRING, array(new String('String!'))); - $operands[] = new MultipleContainer(BaseType::STRING, array(new String('String!'))); + $operands[] = new OrderedContainer(BaseType::STRING, array(new QtiString('String!'))); + $operands[] = new MultipleContainer(BaseType::STRING, array(new QtiString('String!'))); $processor = new MatchProcessor($expression, $operands); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $result = $processor->process(); @@ -147,8 +147,8 @@ public function testDifferentCardinalitiesTwo() { public function testDifferentCardinalitiesThree() { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); - $operands[] = new OrderedContainer(BaseType::STRING, array(new String('String!'))); - $operands[] = new RecordContainer(array('entry1' => new String('String!'))); + $operands[] = new OrderedContainer(BaseType::STRING, array(new QtiString('String!'))); + $operands[] = new RecordContainer(array('entry1' => new QtiString('String!'))); $processor = new MatchProcessor($expression, $operands); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $result = $processor->process(); @@ -156,21 +156,21 @@ public function testDifferentCardinalitiesThree() { public function testNotEnoughOperands() { $expression = $this->createFakeExpression(); - $operands = new OperandsCollection(array(new Integer(15))); + $operands = new OperandsCollection(array(new QtiInteger(15))); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $processor = new MatchProcessor($expression, $operands); } public function testTooMuchOperands() { $expression = $this->createFakeExpression(); - $operands = new OperandsCollection(array(new Integer(25), new Integer(25), new Integer(25))); + $operands = new OperandsCollection(array(new QtiInteger(25), new QtiInteger(25), new QtiInteger(25))); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $processor = new MatchProcessor($expression, $operands); } public function testNullScalar() { $expression = $this->createFakeExpression(); - $operands = new OperandsCollection(array(new Float(15.0), null)); + $operands = new OperandsCollection(array(new QtiFloat(15.0), null)); $processor = new MatchProcessor($expression, $operands); $this->assertSame(null, $processor->process()); } @@ -178,7 +178,7 @@ public function testNullScalar() { public function testNullContainer() { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); - $operands[] = new MultipleContainer(BaseType::INTEGER, array(new Integer(10), new Integer(20))); + $operands[] = new MultipleContainer(BaseType::INTEGER, array(new QtiInteger(10), new QtiInteger(20))); $operands[] = new MultipleContainer(BaseType::INTEGER); $processor = new MatchProcessor($expression, $operands); $this->assertSame(null, $processor->process()); diff --git a/test/qtismtest/runtime/expressions/operators/MathOperatorProcessorTest.php b/test/qtismtest/runtime/expressions/operators/MathOperatorProcessorTest.php index 4dbb18355..1ce7f0a16 100644 --- a/test/qtismtest/runtime/expressions/operators/MathOperatorProcessorTest.php +++ b/test/qtismtest/runtime/expressions/operators/MathOperatorProcessorTest.php @@ -4,8 +4,8 @@ use qtismtest\QtiSmTestCase; use qtism\data\expressions\operators\MathFunctions; use qtism\runtime\expressions\operators\MathOperatorProcessor; -use qtism\common\datatypes\Integer; -use qtism\common\datatypes\Float; +use qtism\common\datatypes\QtiInteger; +use qtism\common\datatypes\QtiFloat; use qtism\runtime\expressions\operators\OperandsCollection; class MathOperatorProcessorTest extends QtiSmTestCase { @@ -22,7 +22,7 @@ public function testSin($operand, $expected) { $processor = new MathOperatorProcessor($expression, $operands); $result = $processor->process(); $this->assertEqualsRounded($expected, $result); - $this->assertTrue(!$result instanceof Integer); + $this->assertTrue(!$result instanceof QtiInteger); } /** @@ -37,7 +37,7 @@ public function testCos($operand, $expected) { $processor = new MathOperatorProcessor($expression, $operands); $result = $processor->process(); $this->assertEqualsRounded($expected, $result); - $this->assertTrue(!$result instanceof Integer);; + $this->assertTrue(!$result instanceof QtiInteger);; } /** @@ -52,7 +52,7 @@ public function testTan($operand, $expected) { $processor = new MathOperatorProcessor($expression, $operands); $result = $processor->process(); $this->assertEqualsRounded($expected, $result); - $this->assertTrue(!$result instanceof Integer); + $this->assertTrue(!$result instanceof QtiInteger); } /** @@ -67,7 +67,7 @@ public function testSec($operand, $expected) { $processor = new MathOperatorProcessor($expression, $operands); $result = $processor->process(); $this->assertEqualsRounded($expected, $result); - $this->assertTrue(!$result instanceof Integer); + $this->assertTrue(!$result instanceof QtiInteger); } /** @@ -82,7 +82,7 @@ public function testCsc($operand, $expected) { $processor = new MathOperatorProcessor($expression, $operands); $result = $processor->process(); $this->assertEqualsRounded($expected, $result); - $this->assertTrue(!$result instanceof Integer); + $this->assertTrue(!$result instanceof QtiInteger); } /** @@ -97,7 +97,7 @@ public function testCot($operand, $expected) { $processor = new MathOperatorProcessor($expression, $operands); $result = $processor->process(); $this->assertEqualsRounded($expected, $result); - $this->assertTrue(!$result instanceof Integer); + $this->assertTrue(!$result instanceof QtiInteger); } /** @@ -112,7 +112,7 @@ public function testAsin($operand, $expected) { $processor = new MathOperatorProcessor($expression, $operands); $result = $processor->process(); $this->assertEqualsRounded($expected, $result); - $this->assertTrue(!$result instanceof Integer); + $this->assertTrue(!$result instanceof QtiInteger); } /** @@ -128,7 +128,7 @@ public function testAtan2($operand1, $operand2, $expected) { $processor = new MathOperatorProcessor($expression, $operands); $result = $processor->process(); $this->assertEqualsRounded($expected, $result); - $this->assertTrue(!$result instanceof Integer); + $this->assertTrue(!$result instanceof QtiInteger); } /** @@ -143,7 +143,7 @@ public function testAsec($operand, $expected) { $processor = new MathOperatorProcessor($expression, $operands); $result = $processor->process(); $this->assertEqualsRounded($expected, $result); - $this->assertTrue(!$result instanceof Integer); + $this->assertTrue(!$result instanceof QtiInteger); } /** @@ -158,7 +158,7 @@ public function testAcsc($operand, $expected) { $processor = new MathOperatorProcessor($expression, $operands); $result = $processor->process(); $this->assertEqualsRounded($expected, $result); - $this->assertTrue(!$result instanceof Integer); + $this->assertTrue(!$result instanceof QtiInteger); } /** @@ -173,7 +173,7 @@ public function testAcot($operand, $expected) { $processor = new MathOperatorProcessor($expression, $operands); $result = $processor->process(); $this->assertEqualsRounded($expected, $result); - $this->assertTrue(!$result instanceof Integer); + $this->assertTrue(!$result instanceof QtiInteger); } /** @@ -188,7 +188,7 @@ public function testLog($operand, $expected) { $processor = new MathOperatorProcessor($expression, $operands); $result = $processor->process(); $this->assertEqualsRounded($expected, $result); - $this->assertTrue(!$result instanceof Integer); + $this->assertTrue(!$result instanceof QtiInteger); } /** @@ -203,7 +203,7 @@ public function testLn($operand, $expected) { $processor = new MathOperatorProcessor($expression, $operands); $result = $processor->process(); $this->assertEqualsRounded($expected, $result); - $this->assertTrue(!$result instanceof Integer); + $this->assertTrue(!$result instanceof QtiInteger); } /** @@ -218,7 +218,7 @@ public function testSinh($operand, $expected) { $processor = new MathOperatorProcessor($expression, $operands); $result = $processor->process(); $this->assertEqualsRounded($expected, $result); - $this->assertTrue(!$result instanceof Integer); + $this->assertTrue(!$result instanceof QtiInteger); } /** @@ -233,7 +233,7 @@ public function testCosh($operand, $expected) { $processor = new MathOperatorProcessor($expression, $operands); $result = $processor->process(); $this->assertEqualsRounded($expected, $result); - $this->assertTrue(!$result instanceof Integer); + $this->assertTrue(!$result instanceof QtiInteger); } /** @@ -248,7 +248,7 @@ public function testTanh($operand, $expected) { $processor = new MathOperatorProcessor($expression, $operands); $result = $processor->process(); $this->assertEqualsRounded($expected, $result); - $this->assertTrue(!$result instanceof Integer); + $this->assertTrue(!$result instanceof QtiInteger); } /** @@ -263,7 +263,7 @@ public function testSech($operand, $expected) { $processor = new MathOperatorProcessor($expression, $operands); $result = $processor->process(); $this->assertEqualsRounded($expected, $result); - $this->assertTrue(!$result instanceof Integer); + $this->assertTrue(!$result instanceof QtiInteger); } /** @@ -278,7 +278,7 @@ public function testCsch($operand, $expected) { $processor = new MathOperatorProcessor($expression, $operands); $result = $processor->process(); $this->assertEqualsRounded($expected, $result); - $this->assertTrue(!$result instanceof Integer); + $this->assertTrue(!$result instanceof QtiInteger); } /** @@ -293,7 +293,7 @@ public function testCoth($operand, $expected) { $processor = new MathOperatorProcessor($expression, $operands); $result = $processor->process(); $this->assertEqualsRounded($expected, $result); - $this->assertTrue(!$result instanceof Integer); + $this->assertTrue(!$result instanceof QtiInteger); } /** @@ -308,7 +308,7 @@ public function testAbs($operand, $expected) { $processor = new MathOperatorProcessor($expression, $operands); $result = $processor->process(); $this->assertEqualsRounded($expected, $result); - $this->assertTrue(!$result instanceof Integer); + $this->assertTrue(!$result instanceof QtiInteger); } /** @@ -323,7 +323,7 @@ public function testExp($operand, $expected) { $processor = new MathOperatorProcessor($expression, $operands); $result = $processor->process(); $this->assertEqualsRounded($expected, $result); - $this->assertTrue(!$result instanceof Integer); + $this->assertTrue(!$result instanceof QtiInteger); } /** @@ -338,7 +338,7 @@ public function testSignum($operand, $expected) { $processor = new MathOperatorProcessor($expression, $operands); $result = $processor->process(); $this->assertEqualsRounded($expected, $result); - $this->assertTrue(!$result instanceof Float); + $this->assertTrue(!$result instanceof QtiFloat); } /** @@ -381,7 +381,7 @@ public function testToDegrees($operand, $expected) { $processor = new MathOperatorProcessor($expression, $operands); $result = $processor->process(); $this->assertEqualsRounded($expected, $result); - $this->assertTrue(!$result instanceof Integer); + $this->assertTrue(!$result instanceof QtiInteger); } /** @@ -396,7 +396,7 @@ public function testToRadians($operand, $expected) { $processor = new MathOperatorProcessor($expression, $operands); $result = $processor->process(); $this->assertEqualsRounded($expected, $result); - $this->assertTrue(!$result instanceof Integer); + $this->assertTrue(!$result instanceof QtiInteger); } protected function assertEqualsRounded($expected, $value) { @@ -418,275 +418,275 @@ protected function assertEqualsRounded($expected, $value) { public function sinProvider() { return array( - array(new Float(1.5708), 1), - array(new Float(INF), null), // falls outside the domain. + array(new QtiFloat(1.5708), 1), + array(new QtiFloat(INF), null), // falls outside the domain. ); } public function cosProvider() { return array( - array(new Integer(25), 0.99120281), - array(new Float(INF), null), // falls outside the domain. + array(new QtiInteger(25), 0.99120281), + array(new QtiFloat(INF), null), // falls outside the domain. ); } public function tanProvider() { return array( - array(new Float(2.65), -0.53543566), - array(new Float(INF), null) + array(new QtiFloat(2.65), -0.53543566), + array(new QtiFloat(INF), null) ); } public function secProvider() { return array( - array(new Float(deg2rad(85)), 11.4737) + array(new QtiFloat(deg2rad(85)), 11.4737) ); } public function cscProvider() { return array( - array(new Float(deg2rad(31.67)), 1.904667) + array(new QtiFloat(deg2rad(31.67)), 1.904667) ); } public function cotProvider() { return array( - array(new Float(2.09), -0.571505) + array(new QtiFloat(2.09), -0.571505) ); } public function asinProvider() { return array( - array(new Integer(2), null), - array(new Integer(1), 1.570796), - array(new Float(1.1), null) + array(new QtiInteger(2), null), + array(new QtiInteger(1), 1.570796), + array(new QtiFloat(1.1), null) ); } public function atan2Provider() { $data = array( - array(new Float(NAN), new Integer(10), null), - array(new Integer(+0), new Integer(25), 0), - array(new Integer(25), new Float(+INF), 0), - array(new Integer(-0), new Integer(25), 0), - array(new Integer(-25), new Float(+INF), 0), - array(new Integer(+0), new Integer(-25), M_PI), - array(new Integer(25), new Float(-INF), M_PI), + array(new QtiFloat(NAN), new QtiInteger(10), null), + array(new QtiInteger(+0), new QtiInteger(25), 0), + array(new QtiInteger(25), new QtiFloat(+INF), 0), + array(new QtiInteger(-0), new QtiInteger(25), 0), + array(new QtiInteger(-25), new QtiFloat(+INF), 0), + array(new QtiInteger(+0), new QtiInteger(-25), M_PI), + array(new QtiInteger(25), new QtiFloat(-INF), M_PI), //array(-0, -19, -M_PI), Cannot be tested, because no valid way to express negative zero in PHP. - array(new Integer(-25), new Float(-INF), -M_PI), - array(new Integer(25), new Integer(-0), M_PI_2), - array(new Float(INF), new Integer(25), M_PI_2), - array(new Integer(-10), new Integer(+0), -M_PI_2), - array(new Float(-INF), new Integer(14), -M_PI_2), + array(new QtiInteger(-25), new QtiFloat(-INF), -M_PI), + array(new QtiInteger(25), new QtiInteger(-0), M_PI_2), + array(new QtiFloat(INF), new QtiInteger(25), M_PI_2), + array(new QtiInteger(-10), new QtiInteger(+0), -M_PI_2), + array(new QtiFloat(-INF), new QtiInteger(14), -M_PI_2), ); //Sometimes atan2 with both INF arguments returns NAN. I have no idea why it happens (PHP 5.6.13, win10). if (!is_nan(atan2(INF, INF))) { - $data[] = array(new Float(INF), new Float(INF), M_PI_4); - $data[] = array(new Float(INF), new Float(-INF), 3 * M_PI_4); - $data[] = array(new Float(-INF), new Float(INF), -M_PI_4); - $data[] = array(new Float(-INF), new Float(-INF), -3 * M_PI_4); + $data[] = array(new QtiFloat(INF), new QtiFloat(INF), M_PI_4); + $data[] = array(new QtiFloat(INF), new QtiFloat(-INF), 3 * M_PI_4); + $data[] = array(new QtiFloat(-INF), new QtiFloat(INF), -M_PI_4); + $data[] = array(new QtiFloat(-INF), new QtiFloat(-INF), -3 * M_PI_4); } return $data; } public function asecProvider() { return array( - array(new Integer(-5), 1.7721), - array(new Integer(0), null), - array(new Float(0.45), null), - array(new Float(-0.45), null) + array(new QtiInteger(-5), 1.7721), + array(new QtiInteger(0), null), + array(new QtiFloat(0.45), null), + array(new QtiFloat(-0.45), null) ); } public function acscProvider() { return array( - array(new Integer(-5), -0.20135), - array(new Integer(0), null), - array(new Float(-0.45), null) + array(new QtiInteger(-5), -0.20135), + array(new QtiInteger(0), null), + array(new QtiFloat(-0.45), null) ); } public function acotProvider() { return array( - array(new Integer(-5), -0.197396), - array(new Integer(-0), M_PI_2) + array(new QtiInteger(-5), -0.197396), + array(new QtiInteger(-0), M_PI_2) ); } public function sinhProvider() { return array( - array(new Integer(5), 74.203210578), - array(new Integer(-5), -74.203210578), - array(new Integer(0), 0), - array(new Float(INF), INF), - array(new Float(-INF), -INF) + array(new QtiInteger(5), 74.203210578), + array(new QtiInteger(-5), -74.203210578), + array(new QtiInteger(0), 0), + array(new QtiFloat(INF), INF), + array(new QtiFloat(-INF), -INF) ); } public function coshProvider() { return array( - array(new Integer(0), 1), - array(new Integer(1), 1.543080), - array(new Float(NAN), null), + array(new QtiInteger(0), 1), + array(new QtiInteger(1), 1.543080), + array(new QtiFloat(NAN), null), array(null, null), - array(new Float(INF), INF), - array(new Float(-INF), INF) + array(new QtiFloat(INF), INF), + array(new QtiFloat(-INF), INF) ); } public function tanhProvider() { return array( - array(new Integer(0), 0), - array(new Integer(1), 0.761594155956), - array(new Float(-1.5), -0.905148253645), - array(new Float(INF), 1), - array(new Float(-INF), -1) + array(new QtiInteger(0), 0), + array(new QtiInteger(1), 0.761594155956), + array(new QtiFloat(-1.5), -0.905148253645), + array(new QtiFloat(INF), 1), + array(new QtiFloat(-INF), -1) ); } public function sechProvider() { return array( - array(new Float(NAN), null), - array(new Float(INF), 0), - array(new Float(-INF), 0), - array(new Integer(0), null), - array(new Integer(-0), null), - array(new Integer(1), 0.64805) + array(new QtiFloat(NAN), null), + array(new QtiFloat(INF), 0), + array(new QtiFloat(-INF), 0), + array(new QtiInteger(0), null), + array(new QtiInteger(-0), null), + array(new QtiInteger(1), 0.64805) ); } public function cschProvider() { return array( - array(new Float(NAN), null), - array(new Float(INF), 0), - array(new Float(-INF), 0), - array(new Integer(0), null), - array(new Integer(-0), null), - array(new Integer(1), 0.850918) + array(new QtiFloat(NAN), null), + array(new QtiFloat(INF), 0), + array(new QtiFloat(-INF), 0), + array(new QtiInteger(0), null), + array(new QtiInteger(-0), null), + array(new QtiInteger(1), 0.850918) ); } public function cothProvider() { return array( - array(new Float(NAN), null), - array(new Float(INF), 0), - array(new Float(-INF), 0), - array(new Integer(0), null), - array(new Integer(-0), null), - array(new Integer(1), 1.31304), - array(new Float(-2.1), -1.03045) + array(new QtiFloat(NAN), null), + array(new QtiFloat(INF), 0), + array(new QtiFloat(-INF), 0), + array(new QtiInteger(0), null), + array(new QtiInteger(-0), null), + array(new QtiInteger(1), 1.31304), + array(new QtiFloat(-2.1), -1.03045) ); } public function logProvider() { return array( - array(new Float(-0.5), null), - array(new Float(INF), INF), - array(new Integer(0), -INF), - array(new Integer(112), 2.049218) + array(new QtiFloat(-0.5), null), + array(new QtiFloat(INF), INF), + array(new QtiInteger(0), -INF), + array(new QtiInteger(112), 2.049218) ); } public function lnProvider() { return array( - array(new Float(-0.5), null), - array(new Float(INF), INF), - array(new Integer(0), -INF), - array(new Integer(10), 2.30258) + array(new QtiFloat(-0.5), null), + array(new QtiFloat(INF), INF), + array(new QtiInteger(0), -INF), + array(new QtiInteger(10), 2.30258) ); } public function expProvider() { return array( - array(new Float(NAN), null), + array(new QtiFloat(NAN), null), array(null, null), - array(new Float(INF), INF) , - array(new Float(-INF), 0), - array(new Integer(3), 20.08554), - array(new Integer(-3), 0.04979) + array(new QtiFloat(INF), INF) , + array(new QtiFloat(-INF), 0), + array(new QtiInteger(3), 20.08554), + array(new QtiInteger(-3), 0.04979) ); } public function absProvider() { return array( - array(new Integer(0), 0), - array(new Integer(-0), 0), - array(new Float(INF), INF), - array(new Float(-INF), INF), - array(new Float(NAN), null), - array(new Float(25.3), 25.3), - array(new Integer(24), 24), - array(new Float(-25.3), 25.3), - array(new Integer(-24), 24), + array(new QtiInteger(0), 0), + array(new QtiInteger(-0), 0), + array(new QtiFloat(INF), INF), + array(new QtiFloat(-INF), INF), + array(new QtiFloat(NAN), null), + array(new QtiFloat(25.3), 25.3), + array(new QtiInteger(24), 24), + array(new QtiFloat(-25.3), 25.3), + array(new QtiInteger(-24), 24), array(null, null) ); } public function signumProvider() { return array( - array(new Integer(0), 0) , - array(new Integer(-0), 0), - array(new Float(0.1), 1), - array(new Integer(25), 1), - array(new Float(-0.1), -1), - array(new Integer(-25), -1), + array(new QtiInteger(0), 0) , + array(new QtiInteger(-0), 0), + array(new QtiFloat(0.1), 1), + array(new QtiInteger(25), 1), + array(new QtiFloat(-0.1), -1), + array(new QtiInteger(-25), -1), array(null, null), - array(new Float(NAN), null) + array(new QtiFloat(NAN), null) ); } public function floorProvider() { return array( - array(new Integer(10), 10), - array(new Integer(-10), -10), - array(new Float(4.3), 4), - array(new Float(9.999), 9), - array(new Float(-3.14), -4), + array(new QtiInteger(10), 10), + array(new QtiInteger(-10), -10), + array(new QtiFloat(4.3), 4), + array(new QtiFloat(9.999), 9), + array(new QtiFloat(-3.14), -4), array(null, null), - array(new Float(NAN), null), - array(new Float(INF), INF), - array(new Float(-INF), -INF) + array(new QtiFloat(NAN), null), + array(new QtiFloat(INF), INF), + array(new QtiFloat(-INF), -INF) ); } public function ceilProvider() { return array( - array(new Integer(10), 10), - array(new Integer(-10), -10), - array(new Float(4.3), 5), - array(new Float(9.999), 10), - array(new Float(-3.14), -3), + array(new QtiInteger(10), 10), + array(new QtiInteger(-10), -10), + array(new QtiFloat(4.3), 5), + array(new QtiFloat(9.999), 10), + array(new QtiFloat(-3.14), -3), array(null, null), - array(new Float(NAN), null), - array(new Float(INF), INF), - array(new Float(-INF), -INF) + array(new QtiFloat(NAN), null), + array(new QtiFloat(INF), INF), + array(new QtiFloat(-INF), -INF) ); } public function toDegreesProvider() { return array( - array(new Float(NAN), null), - array(new Float(INF), INF), - array(new Float(-INF), -INF), + array(new QtiFloat(NAN), null), + array(new QtiFloat(INF), INF), + array(new QtiFloat(-INF), -INF), array(null, null), - array(new Float(2.1), 120.321), - array(new Float(-2.1), -120.321), - array(new Integer(0), 0.0) + array(new QtiFloat(2.1), 120.321), + array(new QtiFloat(-2.1), -120.321), + array(new QtiInteger(0), 0.0) ); } public function toRadiansProvider() { return array( - array(new Float(NAN), null), - array(new Float(INF), INF) , - array(new Float(-INF), -INF), + array(new QtiFloat(NAN), null), + array(new QtiFloat(INF), INF) , + array(new QtiFloat(-INF), -INF), array(null, null), - array(new Integer(0), 0.0), - array(new Integer(90), 1.571), - array(new Integer(180), 3.142), - array(new Integer(270), 4.712), - array(new Integer(360), 6.283) + array(new QtiInteger(0), 0.0), + array(new QtiInteger(90), 1.571), + array(new QtiInteger(180), 3.142), + array(new QtiInteger(270), 4.712), + array(new QtiInteger(360), 6.283) ); } diff --git a/test/qtismtest/runtime/expressions/operators/MaxProcessorTest.php b/test/qtismtest/runtime/expressions/operators/MaxProcessorTest.php index fda88d90d..8e25252d8 100644 --- a/test/qtismtest/runtime/expressions/operators/MaxProcessorTest.php +++ b/test/qtismtest/runtime/expressions/operators/MaxProcessorTest.php @@ -2,9 +2,9 @@ namespace qtismtest\runtime\expressions\operators; use qtismtest\QtiSmTestCase; -use qtism\common\datatypes\Float; -use qtism\common\datatypes\String; -use qtism\common\datatypes\Integer; +use qtism\common\datatypes\QtiFloat; +use qtism\common\datatypes\QtiString; +use qtism\common\datatypes\QtiInteger; use qtism\runtime\common\OrderedContainer; use qtism\runtime\common\RecordContainer; use qtism\common\enums\BaseType; @@ -19,9 +19,9 @@ public function testWrongBaseType() { // If any of the sub-expressions is NULL, the result is NULL. $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); - $operands[] = new Integer(-10); - $operands[] = new String('String'); - $operands[] = new MultipleContainer(BaseType::FLOAT, array(new Float(10.0))); + $operands[] = new QtiInteger(-10); + $operands[] = new QtiString('String'); + $operands[] = new MultipleContainer(BaseType::FLOAT, array(new QtiFloat(10.0))); $processor = new MaxProcessor($expression, $operands); $result = $processor->process(); $this->assertSame(null, $result); @@ -30,14 +30,14 @@ public function testWrongBaseType() { public function testWrongCardinality() { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); - $operands[] = new Float(-245.30); + $operands[] = new QtiFloat(-245.30); $rec = new RecordContainer(); // will be at a first glance considered as NULL. $operands[] = $rec; $processor = new MaxProcessor($expression, $operands); $result = $processor->process(); $this->assertSame(null, $result); - $rec['A'] = new Integer(1); + $rec['A'] = new QtiInteger(1); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $result = $processor->process(); } @@ -45,9 +45,9 @@ public function testWrongCardinality() { public function testNull() { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); - $operands[] = new Integer(10); + $operands[] = new QtiInteger(10); $operands[] = new OrderedContainer(BaseType::FLOAT); // null - $operands[] = new Float(-0.5); + $operands[] = new QtiFloat(-0.5); $processor = new MaxProcessor($expression, $operands); $result = $processor->process(); $this->assertSame(null, $result); @@ -62,36 +62,36 @@ public function testAllIntegers() { // As per QTI spec, // if all sub-expressions are of integer type, a single integer (ndlr: is returned). $expression = $this->createFakeExpression(); - $operands = new OperandsCollection(array(new Integer(-20), new Integer(-10), new Integer(0), new Integer(10), new Integer(20))); + $operands = new OperandsCollection(array(new QtiInteger(-20), new QtiInteger(-10), new QtiInteger(0), new QtiInteger(10), new QtiInteger(20))); $processor = new MaxProcessor($expression, $operands); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Integer', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiInteger', $result); $this->assertEquals(20, $result->getValue()); $operands = new OperandsCollection(); - $operands[] = new Integer(10002); - $operands[] = new MultipleContainer(BaseType::INTEGER, array(new Integer(4566), new Integer(8400), new Integer(2094))); - $operands[] = new Integer(100002); + $operands[] = new QtiInteger(10002); + $operands[] = new MultipleContainer(BaseType::INTEGER, array(new QtiInteger(4566), new QtiInteger(8400), new QtiInteger(2094))); + $operands[] = new QtiInteger(100002); $processor->setOperands($operands); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Integer', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiInteger', $result); $this->assertEquals(100002, $result->getValue()); } public function testMixed() { $expression = $this->createFakeExpression(); - $operands = new OperandsCollection(array(new Integer(10), new Float(26.4), new Integer(-4), new Float(25.3))); + $operands = new OperandsCollection(array(new QtiInteger(10), new QtiFloat(26.4), new QtiInteger(-4), new QtiFloat(25.3))); $processor = new MaxProcessor($expression, $operands); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $result); $this->assertEquals(26.4, $result->getValue()); $operands->reset(); - $operands[] = new OrderedContainer(BaseType::INTEGER, array(new Integer(2), new Integer(3), new Integer(1), new Integer(4), new Integer(5))); - $operands[] = new Float(2.4); - $operands[] = new MultipleContainer(BaseType::FLOAT, array(new Float(245.4), new Float(1337.1337))); + $operands[] = new OrderedContainer(BaseType::INTEGER, array(new QtiInteger(2), new QtiInteger(3), new QtiInteger(1), new QtiInteger(4), new QtiInteger(5))); + $operands[] = new QtiFloat(2.4); + $operands[] = new MultipleContainer(BaseType::FLOAT, array(new QtiFloat(245.4), new QtiFloat(1337.1337))); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $result); $this->assertEquals(1337.1337, $result->getValue()); } diff --git a/test/qtismtest/runtime/expressions/operators/MemberProcessorTest.php b/test/qtismtest/runtime/expressions/operators/MemberProcessorTest.php index 6d429a458..274bc6148 100644 --- a/test/qtismtest/runtime/expressions/operators/MemberProcessorTest.php +++ b/test/qtismtest/runtime/expressions/operators/MemberProcessorTest.php @@ -2,12 +2,12 @@ namespace qtismtest\runtime\expressions\operators; use qtismtest\QtiSmTestCase; -use qtism\common\datatypes\Identifier; -use qtism\common\datatypes\String; -use qtism\common\datatypes\Integer; -use qtism\common\datatypes\Float; -use qtism\common\datatypes\Pair; -use qtism\common\datatypes\Point; +use qtism\common\datatypes\QtiIdentifier; +use qtism\common\datatypes\QtiString; +use qtism\common\datatypes\QtiInteger; +use qtism\common\datatypes\QtiFloat; +use qtism\common\datatypes\QtiPair; +use qtism\common\datatypes\QtiPoint; use qtism\common\enums\BaseType; use qtism\runtime\common\MultipleContainer; use qtism\runtime\common\OrderedContainer; @@ -19,34 +19,34 @@ class MemberProcessorTest extends QtiSmTestCase { public function testMultiple() { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); - $operands[] = new Float(10.1); - $mult = new MultipleContainer(BaseType::FLOAT, array(new Float(1.1), new Float(2.1), new Float(3.1))); + $operands[] = new QtiFloat(10.1); + $mult = new MultipleContainer(BaseType::FLOAT, array(new QtiFloat(1.1), new QtiFloat(2.1), new QtiFloat(3.1))); $operands[] = $mult; $processor = new MemberProcessor($expression, $operands); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Boolean', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiBoolean', $result); $this->assertEquals(false, $result->getValue()); - $mult[] = new Float(10.1); + $mult[] = new QtiFloat(10.1); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Boolean', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiBoolean', $result); $this->assertEquals(true, $result->getValue()); } public function testOrdered() { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); - $operands[] = new Pair('A', 'B'); - $ordered = new OrderedContainer(BaseType::PAIR, array(new Pair('B', 'C'))); + $operands[] = new QtiPair('A', 'B'); + $ordered = new OrderedContainer(BaseType::PAIR, array(new QtiPair('B', 'C'))); $operands[] = $ordered; $processor = new MemberProcessor($expression, $operands); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Boolean', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiBoolean', $result); $this->assertEquals(false, $result->getValue()); - $ordered[] = new Pair('A', 'B'); + $ordered[] = new QtiPair('A', 'B'); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Boolean', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiBoolean', $result); $this->assertEquals(true, $result->getValue()); } @@ -55,7 +55,7 @@ public function testNull() { $operands = new OperandsCollection(); // second operand is null. - $operands[] = new Integer(10); + $operands[] = new QtiInteger(10); $operands[] = new OrderedContainer(BaseType::INTEGER); $processor = new MemberProcessor($expression, $operands); $result = $processor->process(); @@ -64,7 +64,7 @@ public function testNull() { // fist operand is null. $operands->reset(); $operands[] = null; - $operands[] = new MultipleContainer(BaseType::INTEGER, array(new Integer(10))); + $operands[] = new MultipleContainer(BaseType::INTEGER, array(new QtiInteger(10))); $result = $processor->process(); $this->assertSame(null, $result); } @@ -72,8 +72,8 @@ public function testNull() { public function testDifferentBaseTypeOne() { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); - $operands[] = new String('String1'); - $operands[] = new OrderedContainer(BaseType::IDENTIFIER, array(new Identifier('String2'), new Identifier('String1'), null)); + $operands[] = new QtiString('String1'); + $operands[] = new OrderedContainer(BaseType::IDENTIFIER, array(new QtiIdentifier('String2'), new QtiIdentifier('String1'), null)); $processor = new MemberProcessor($expression, $operands); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); @@ -83,8 +83,8 @@ public function testDifferentBaseTypeOne() { public function testDifferentBaseTypeTwo() { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); - $operands[] = new Pair('A', 'B'); - $operands[] = new MultipleContainer(BaseType::POINT, array(new Point(1, 2))); + $operands[] = new QtiPair('A', 'B'); + $operands[] = new MultipleContainer(BaseType::POINT, array(new QtiPoint(1, 2))); $processor = new MemberProcessor($expression, $operands); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $result = $processor->process(); @@ -93,8 +93,8 @@ public function testDifferentBaseTypeTwo() { public function testWrongCardinalityOne() { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); - $operands[] = new MultipleContainer(BaseType::POINT, array(new Point(13, 37))); - $operands[] = new MultipleContainer(BaseType::POINT, array(new Point(1, 2))); + $operands[] = new MultipleContainer(BaseType::POINT, array(new QtiPoint(13, 37))); + $operands[] = new MultipleContainer(BaseType::POINT, array(new QtiPoint(1, 2))); $processor = new MemberProcessor($expression, $operands); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $result = $processor->process(); @@ -103,8 +103,8 @@ public function testWrongCardinalityOne() { public function testWrongCardinalityTwo() { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); - $operands[] = new Point(13, 37); - $operands[] = new Point(13, 38); + $operands[] = new QtiPoint(13, 37); + $operands[] = new QtiPoint(13, 38); $processor = new MemberProcessor($expression, $operands); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $result = $processor->process(); @@ -113,7 +113,7 @@ public function testWrongCardinalityTwo() { public function testNotEnoughOperands() { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); - $operands[] = new Point(13, 37); + $operands[] = new QtiPoint(13, 37); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $processor = new MemberProcessor($expression, $operands); } @@ -121,9 +121,9 @@ public function testNotEnoughOperands() { public function testTooMuchOperands() { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); - $operands[] = new Point(13, 37); - $operands[] = new MultipleContainer(BaseType::POINT, array(new Point(1, 2))); - $operands[] = new MultipleContainer(BaseType::POINT, array(new Point(3, 4))); + $operands[] = new QtiPoint(13, 37); + $operands[] = new MultipleContainer(BaseType::POINT, array(new QtiPoint(1, 2))); + $operands[] = new MultipleContainer(BaseType::POINT, array(new QtiPoint(3, 4))); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $processor = new MemberProcessor($expression, $operands); } diff --git a/test/qtismtest/runtime/expressions/operators/MinProcessorTest.php b/test/qtismtest/runtime/expressions/operators/MinProcessorTest.php index ceb3f726e..b5166011a 100644 --- a/test/qtismtest/runtime/expressions/operators/MinProcessorTest.php +++ b/test/qtismtest/runtime/expressions/operators/MinProcessorTest.php @@ -2,9 +2,9 @@ namespace qtismtest\runtime\expressions\operators; use qtismtest\QtiSmTestCase; -use qtism\common\datatypes\Float; -use qtism\common\datatypes\String; -use qtism\common\datatypes\Integer; +use qtism\common\datatypes\QtiFloat; +use qtism\common\datatypes\QtiString; +use qtism\common\datatypes\QtiInteger; use qtism\runtime\common\OrderedContainer; use qtism\runtime\common\RecordContainer; use qtism\common\enums\BaseType; @@ -19,9 +19,9 @@ public function testWrongBaseType() { // If any of the sub-expressions is NULL, the result is NULL. $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); - $operands[] = new Integer(-10); - $operands[] = new String('String'); - $operands[] = new MultipleContainer(BaseType::FLOAT, array(new Float(10.0))); + $operands[] = new QtiInteger(-10); + $operands[] = new QtiString('String'); + $operands[] = new MultipleContainer(BaseType::FLOAT, array(new QtiFloat(10.0))); $processor = new MinProcessor($expression, $operands); $result = $processor->process(); $this->assertSame(null, $result); @@ -30,14 +30,14 @@ public function testWrongBaseType() { public function testWrongCardinality() { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); - $operands[] = new Float(-245.30); + $operands[] = new QtiFloat(-245.30); $rec = new RecordContainer(); // will be at a first glance considered as NULL. $operands[] = $rec; $processor = new MinProcessor($expression, $operands); $result = $processor->process(); $this->assertSame(null, $result); - $rec['A'] = new Integer(1); + $rec['A'] = new QtiInteger(1); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $result = $processor->process(); } @@ -45,9 +45,9 @@ public function testWrongCardinality() { public function testNull() { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); - $operands[] = new Integer(10); + $operands[] = new QtiInteger(10); $operands[] = new OrderedContainer(BaseType::FLOAT); // null - $operands[] = new Float(-0.5); + $operands[] = new QtiFloat(-0.5); $processor = new MinProcessor($expression, $operands); $result = $processor->process(); $this->assertSame(null, $result); @@ -62,36 +62,36 @@ public function testAllIntegers() { // As per QTI spec, // if all sub-expressions are of integer type, a single integer (ndlr: is returned). $expression = $this->createFakeExpression(); - $operands = new OperandsCollection(array(new Integer(-20), new Integer(-10), new Integer(0), new Integer(10), new Integer(20))); + $operands = new OperandsCollection(array(new QtiInteger(-20), new QtiInteger(-10), new QtiInteger(0), new QtiInteger(10), new QtiInteger(20))); $processor = new MinProcessor($expression, $operands); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Integer', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiInteger', $result); $this->assertEquals(-20, $result->getValue()); $operands = new OperandsCollection(); - $operands[] = new Integer(10002); - $operands[] = new MultipleContainer(BaseType::INTEGER, array(new Integer(4566), new Integer(8400), new Integer(2094))); - $operands[] = new Integer(100002); + $operands[] = new QtiInteger(10002); + $operands[] = new MultipleContainer(BaseType::INTEGER, array(new QtiInteger(4566), new QtiInteger(8400), new QtiInteger(2094))); + $operands[] = new QtiInteger(100002); $processor->setOperands($operands); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Integer', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiInteger', $result); $this->assertEquals(2094, $result->getValue()); } public function testMixed() { $expression = $this->createFakeExpression(); - $operands = new OperandsCollection(array(new Integer(10), new Float(26.4), new Integer(-4), new Float(25.3))); + $operands = new OperandsCollection(array(new QtiInteger(10), new QtiFloat(26.4), new QtiInteger(-4), new QtiFloat(25.3))); $processor = new MinProcessor($expression, $operands); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $result); $this->assertEquals(-4.0, $result->getValue()); $operands->reset(); - $operands[] = new OrderedContainer(BaseType::INTEGER, array(new Integer(2), new Integer(3), new Integer(1), new Integer(4), new Integer(5))); - $operands[] = new Float(2.4); - $operands[] = new MultipleContainer(BaseType::FLOAT, array(new Float(245.4), new Float(1337.1337))); + $operands[] = new OrderedContainer(BaseType::INTEGER, array(new QtiInteger(2), new QtiInteger(3), new QtiInteger(1), new QtiInteger(4), new QtiInteger(5))); + $operands[] = new QtiFloat(2.4); + $operands[] = new MultipleContainer(BaseType::FLOAT, array(new QtiFloat(245.4), new QtiFloat(1337.1337))); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $result); $this->assertEquals(1.0, $result->getValue()); } diff --git a/test/qtismtest/runtime/expressions/operators/MultipleProcessorTest.php b/test/qtismtest/runtime/expressions/operators/MultipleProcessorTest.php index 98189faec..4f78f993e 100644 --- a/test/qtismtest/runtime/expressions/operators/MultipleProcessorTest.php +++ b/test/qtismtest/runtime/expressions/operators/MultipleProcessorTest.php @@ -2,17 +2,17 @@ namespace qtismtest\runtime\expressions\operators; use qtismtest\QtiSmTestCase; -use qtism\common\datatypes\Identifier; -use qtism\common\datatypes\String; -use qtism\common\datatypes\Integer; +use qtism\common\datatypes\QtiIdentifier; +use qtism\common\datatypes\QtiString; +use qtism\common\datatypes\QtiInteger; use qtism\runtime\expressions\operators\MultipleProcessor; use qtism\runtime\expressions\operators\OperandsCollection; use qtism\common\enums\BaseType; use qtism\runtime\common\OrderedContainer; use qtism\runtime\common\RecordContainer; use qtism\runtime\common\MultipleContainer; -use qtism\common\datatypes\Duration; -use qtism\common\datatypes\Point; +use qtism\common\datatypes\QtiDuration; +use qtism\common\datatypes\QtiPoint; class MultipleProcessorTest extends QtiSmTestCase { @@ -30,7 +30,7 @@ public function testNull() { $result = $processor->process(); $this->assertSame(null, $result); - $operands = new OperandsCollection(array(null, new Integer(25), new MultipleContainer(BaseType::INTEGER))); + $operands = new OperandsCollection(array(null, new QtiInteger(25), new MultipleContainer(BaseType::INTEGER))); $processor->setOperands($operands); $result = $processor->process(); $this->assertInstanceOf('qtism\\runtime\\common\\MultipleContainer', $result); @@ -38,7 +38,7 @@ public function testNull() { $this->assertEquals(BaseType::INTEGER, $result->getBaseType()); $this->assertEquals(25, $result[0]->getValue()); - $operands = new OperandsCollection(array(null, new Integer(25), new MultipleContainer(BaseType::INTEGER, array(new Integer(26))))); + $operands = new OperandsCollection(array(null, new QtiInteger(25), new MultipleContainer(BaseType::INTEGER, array(new QtiInteger(26))))); $processor->setOperands($operands); $result = $processor->process(); $this->assertInstanceOf('qtism\\runtime\\common\\MultipleContainer', $result); @@ -47,7 +47,7 @@ public function testNull() { $this->assertEquals(25, $result[0]->getValue()); $this->assertEquals(26, $result[1]->getValue()); - $operands = new OperandsCollection(array(new MultipleContainer(BaseType::INTEGER), new Integer(25), new MultipleContainer(BaseType::INTEGER, array(new Integer(26))))); + $operands = new OperandsCollection(array(new MultipleContainer(BaseType::INTEGER), new QtiInteger(25), new MultipleContainer(BaseType::INTEGER, array(new QtiInteger(26))))); $processor->setOperands($operands); $result = $processor->process(); $this->assertInstanceOf('qtism\\runtime\\common\\MultipleContainer', $result); @@ -65,9 +65,9 @@ public function testNull() { public function testScalar() { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); - $operands[] = new String('String1'); - $operands[] = new String('String2'); - $operands[] = new String('String3'); + $operands[] = new QtiString('String1'); + $operands[] = new QtiString('String2'); + $operands[] = new QtiString('String3'); $processor = new MultipleProcessor($expression, $operands); $result = $processor->process(); @@ -77,7 +77,7 @@ public function testScalar() { $this->assertEquals('String2', $result[1]->getValue()); $this->assertEquals('String3', $result[2]->getValue()); - $operands = new OperandsCollection(array(new String('String!'))); + $operands = new OperandsCollection(array(new QtiString('String!'))); $processor->setOperands($operands); $result = $processor->process(); $this->assertInstanceOf('qtism\\runtime\\common\\MultipleContainer', $result); @@ -87,38 +87,38 @@ public function testScalar() { public function testContainer() { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); - $operands[] = new MultipleContainer(BaseType::POINT, array(new Point(1, 2), new Point(2, 3))); + $operands[] = new MultipleContainer(BaseType::POINT, array(new QtiPoint(1, 2), new QtiPoint(2, 3))); $operands[] = new MultipleContainer(BaseType::POINT); - $operands[] = new MultipleContainer(BaseType::POINT, array(new Point(3, 4))); + $operands[] = new MultipleContainer(BaseType::POINT, array(new QtiPoint(3, 4))); $processor = new MultipleProcessor($expression, $operands); $result = $processor->process(); $this->assertInstanceOf('qtism\\runtime\\common\\MultipleContainer', $result); $this->assertEquals(3, count($result)); - $this->assertTrue($result[0]->equals(new Point(1, 2))); - $this->assertTrue($result[1]->equals(new Point(2, 3))); - $this->assertTrue($result[2]->equals(new Point(3, 4))); + $this->assertTrue($result[0]->equals(new QtiPoint(1, 2))); + $this->assertTrue($result[1]->equals(new QtiPoint(2, 3))); + $this->assertTrue($result[2]->equals(new QtiPoint(3, 4))); } public function testMixed() { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); - $operands[] = new Point(1, 2); + $operands[] = new QtiPoint(1, 2); $operands[] = null; - $operands[] = new MultipleContainer(BaseType::POINT, array(new Point(3, 4))); + $operands[] = new MultipleContainer(BaseType::POINT, array(new QtiPoint(3, 4))); $processor = new MultipleProcessor($expression, $operands); $result = $processor->process(); $this->assertInstanceOf('qtism\\runtime\\common\\MultipleContainer', $result); $this->assertEquals(2, count($result)); - $this->assertTrue($result[0]->equals(new Point(1, 2))); - $this->assertTrue($result[1]->equals(new Point(3, 4))); + $this->assertTrue($result[0]->equals(new QtiPoint(1, 2))); + $this->assertTrue($result[1]->equals(new QtiPoint(3, 4))); } public function testWrongBaseTypeOne() { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); - $operands[] = new MultipleContainer(BaseType::IDENTIFIER, array(new Identifier('identifier1'), new Identifier('identifier2'))); - $operands[] = new Identifier('identifier3'); - $operands[] = new MultipleContainer(BaseType::STRING, array(new String('string1'), new String('string2'))); + $operands[] = new MultipleContainer(BaseType::IDENTIFIER, array(new QtiIdentifier('identifier1'), new QtiIdentifier('identifier2'))); + $operands[] = new QtiIdentifier('identifier3'); + $operands[] = new MultipleContainer(BaseType::STRING, array(new QtiString('string1'), new QtiString('string2'))); $operands[] = null; $processor = new MultipleProcessor($expression, $operands); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); @@ -128,10 +128,10 @@ public function testWrongBaseTypeOne() { public function testWrongBaseType() { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); - $operands[] = new Point(1, 2); - $operands[] = new Duration('P2D'); + $operands[] = new QtiPoint(1, 2); + $operands[] = new QtiDuration('P2D'); $operands[] = null; - $operands[] = new Integer(10); + $operands[] = new QtiInteger(10); $processor = new MultipleProcessor($expression, $operands); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $result = $processor->process(); @@ -140,9 +140,9 @@ public function testWrongBaseType() { public function testWrongCardinality() { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); - $operands[] = new Integer(10); + $operands[] = new QtiInteger(10); $operands[] = null; - $operands[] = new MultipleContainer(BaseType::INTEGER, array(new Integer(10))); + $operands[] = new MultipleContainer(BaseType::INTEGER, array(new QtiInteger(10))); $processor = new MultipleProcessor($expression, $operands); $result = $processor->process(); diff --git a/test/qtismtest/runtime/expressions/operators/NotProcessorTest.php b/test/qtismtest/runtime/expressions/operators/NotProcessorTest.php index b94dedb2b..40bd9d831 100644 --- a/test/qtismtest/runtime/expressions/operators/NotProcessorTest.php +++ b/test/qtismtest/runtime/expressions/operators/NotProcessorTest.php @@ -2,11 +2,11 @@ namespace qtismtest\runtime\expressions\operators; use qtismtest\QtiSmTestCase; -use qtism\common\datatypes\Integer; -use qtism\common\datatypes\Boolean; +use qtism\common\datatypes\QtiInteger; +use qtism\common\datatypes\QtiBoolean; use qtism\runtime\expressions\operators\NotProcessor; use qtism\runtime\expressions\operators\OperandsCollection; -use qtism\common\datatypes\Point; +use qtism\common\datatypes\QtiPoint; use qtism\common\enums\BaseType; use qtism\runtime\common\MultipleContainer; @@ -21,14 +21,14 @@ public function testNotEnoughOperands () { public function testTooMuchOperands() { $expression = $this->createFakeExpression(); - $operands = new OperandsCollection(array(new Boolean(true), new Boolean(false))); + $operands = new OperandsCollection(array(new QtiBoolean(true), new QtiBoolean(false))); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $processor = new NotProcessor($expression, $operands); } public function testWrongCardinality() { $expression = $this->createFakeExpression(); - $operands = new OperandsCollection(array(new MultipleContainer(BaseType::POINT, array(new Point(1, 2))))); + $operands = new OperandsCollection(array(new MultipleContainer(BaseType::POINT, array(new QtiPoint(1, 2))))); $processor = new NotProcessor($expression, $operands); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $result = $processor->process(); @@ -36,7 +36,7 @@ public function testWrongCardinality() { public function testWrongBaseType() { $expression = $this->createFakeExpression(); - $operands = new OperandsCollection(array(new Integer(25))); + $operands = new OperandsCollection(array(new QtiInteger(25))); $processor = new NotProcessor($expression, $operands); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $result = $processor->process(); @@ -52,7 +52,7 @@ public function testNull() { public function testTrue() { $expression = $this->createFakeExpression(); - $operands = new OperandsCollection(array(new Boolean(false))); + $operands = new OperandsCollection(array(new QtiBoolean(false))); $processor = new NotProcessor($expression, $operands); $result = $processor->process(); $this->assertSame(true, $result->getValue()); @@ -60,10 +60,10 @@ public function testTrue() { public function testFalse() { $expression = $this->createFakeExpression(); - $operands = new OperandsCollection(array(new Boolean(true))); + $operands = new OperandsCollection(array(new QtiBoolean(true))); $processor = new NotProcessor($expression, $operands); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Boolean', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiBoolean', $result); $this->assertSame(false, $result->getValue()); } diff --git a/test/qtismtest/runtime/expressions/operators/OperandsCollectionTest.php b/test/qtismtest/runtime/expressions/operators/OperandsCollectionTest.php index 13334204e..9e0b15cf2 100644 --- a/test/qtismtest/runtime/expressions/operators/OperandsCollectionTest.php +++ b/test/qtismtest/runtime/expressions/operators/OperandsCollectionTest.php @@ -2,16 +2,16 @@ namespace qtismtest\runtime\expressions\operators; use qtismtest\QtiSmTestCase; -use qtism\common\datatypes\String; -use qtism\common\datatypes\Float; -use qtism\common\datatypes\Boolean; -use qtism\common\datatypes\Integer; -use qtism\common\datatypes\Point; +use qtism\common\datatypes\QtiString; +use qtism\common\datatypes\QtiFloat; +use qtism\common\datatypes\QtiBoolean; +use qtism\common\datatypes\QtiInteger; +use qtism\common\datatypes\QtiPoint; use qtism\common\enums\BaseType; use qtism\runtime\common\MultipleContainer; use qtism\runtime\common\OrderedContainer; use qtism\runtime\common\RecordContainer; -use qtism\common\datatypes\Duration; +use qtism\common\datatypes\QtiDuration; use qtism\runtime\expressions\operators\OperandsCollection; class OperandsCollectionProcessorTest extends QtiSmTestCase { @@ -43,14 +43,14 @@ public function testContainsNullEmpty() { public function testContainsNullFullSingleCardinality() { $operands = $this->getOperands(); - $operands[] = new Integer(15); + $operands[] = new QtiInteger(15); $this->assertFalse($operands->containsNull()); - $operands[] = new Boolean(true); - $operands[] = new Float(0.4); - $operands[] = new String('string'); - $operands[] = new Duration('P1D'); + $operands[] = new QtiBoolean(true); + $operands[] = new QtiFloat(0.4); + $operands[] = new QtiString('string'); + $operands[] = new QtiDuration('P1D'); $this->assertFalse($operands->containsNull()); $operands[] = null; @@ -63,19 +63,19 @@ public function testContainsNullMixed() { $this->assertTrue($operands->containsNull()); - $operands[0][] = new Float(15.3); + $operands[0][] = new QtiFloat(15.3); $this->assertFalse($operands->containsNull()); - $operands[] = new String(''); + $operands[] = new QtiString(''); $this->assertTrue($operands->containsNull()); - $operands[1] = new String('string!'); + $operands[1] = new QtiString('string!'); $this->assertFalse($operands->containsNull()); $operands[] = new RecordContainer(); $this->assertTrue($operands->containsNull()); - $operands[2]['date'] = new Duration('P2D'); + $operands[2]['date'] = new QtiDuration('P2D'); $this->assertFalse($operands->containsNull()); } @@ -83,16 +83,16 @@ public function testExclusivelyNumeric() { $operands = $this->getOperands(); $this->assertFalse($operands->exclusivelyNumeric()); - $operands[] = new Integer(14); - $operands[] = new Float(15.3); + $operands[] = new QtiInteger(14); + $operands[] = new QtiFloat(15.3); $this->assertTrue($operands->exclusivelyNumeric()); - $operands[] = new String(''); + $operands[] = new QtiString(''); $this->assertFalse($operands->exclusivelyNumeric()); unset($operands[2]); $this->assertTrue($operands->exclusivelyNumeric()); - $operands[] = new Point(1, 10); + $operands[] = new QtiPoint(1, 10); $this->assertFalse($operands->exclusivelyNumeric()); unset($operands[3]); $this->assertTrue($operands->exclusivelyNumeric()); @@ -100,13 +100,13 @@ public function testExclusivelyNumeric() { $mult = new MultipleContainer(BaseType::INTEGER); $operands[] = $mult; $this->assertFalse($operands->exclusivelyNumeric()); - $mult[] = new Integer(15); + $mult[] = new QtiInteger(15); $this->assertTrue($operands->exclusivelyNumeric()); $ord = new OrderedContainer(BaseType::FLOAT); $operands[] = $ord; $this->assertFalse($operands->exclusivelyNumeric()); - $ord[] = new Float(15.5); + $ord[] = new QtiFloat(15.5); $this->assertTrue($operands->exclusivelyNumeric()); $operands[] = new RecordContainer(); @@ -122,16 +122,16 @@ public function testExclusivelyInteger() { $operands = $this->getOperands(); $this->assertFalse($operands->exclusivelyInteger()); - $operands[] = new Integer(14); - $operands[] = new Integer(15); + $operands[] = new QtiInteger(14); + $operands[] = new QtiInteger(15); $this->assertTrue($operands->exclusivelyInteger()); - $operands[] = new String(''); + $operands[] = new QtiString(''); $this->assertFalse($operands->exclusivelyInteger()); unset($operands[2]); $this->assertTrue($operands->exclusivelyInteger()); - $operands[] = new Point(1, 10); + $operands[] = new QtiPoint(1, 10); $this->assertFalse($operands->exclusivelyInteger()); unset($operands[3]); $this->assertTrue($operands->exclusivelyInteger()); @@ -139,7 +139,7 @@ public function testExclusivelyInteger() { $mult = new MultipleContainer(BaseType::INTEGER); $operands[] = $mult; $this->assertFalse($operands->exclusivelyInteger()); - $mult[] = new Integer(15); + $mult[] = new QtiInteger(15); $this->assertTrue($operands->exclusivelyInteger()); $operands[] = new RecordContainer(); @@ -155,16 +155,16 @@ public function testExclusivelyPoint() { $operands = $this->getOperands(); $this->assertFalse($operands->exclusivelyPoint()); - $operands[] = new Point(1, 2); - $operands[] = new Point(3, 4); + $operands[] = new QtiPoint(1, 2); + $operands[] = new QtiPoint(3, 4); $this->assertTrue($operands->exclusivelyPoint()); - $operands[] = new String(''); + $operands[] = new QtiString(''); $this->assertFalse($operands->exclusivelyPoint()); unset($operands[2]); $this->assertTrue($operands->exclusivelyPoint()); - $operands[] = new Duration('P1D'); + $operands[] = new QtiDuration('P1D'); $this->assertFalse($operands->exclusivelyPoint()); unset($operands[3]); $this->assertTrue($operands->exclusivelyPoint()); @@ -172,7 +172,7 @@ public function testExclusivelyPoint() { $mult = new MultipleContainer(BaseType::POINT); $operands[] = $mult; $this->assertFalse($operands->exclusivelyPoint()); - $mult[] = new Point(1, 3); + $mult[] = new QtiPoint(1, 3); $this->assertTrue($operands->exclusivelyPoint()); $operands[] = new RecordContainer(); @@ -188,16 +188,16 @@ public function testExclusivelyDuration() { $operands = $this->getOperands(); $this->assertFalse($operands->exclusivelyDuration()); - $operands[] = new Duration('P1D'); - $operands[] = new Duration('P2D'); + $operands[] = new QtiDuration('P1D'); + $operands[] = new QtiDuration('P2D'); $this->assertTrue($operands->exclusivelyDuration()); - $operands[] = new Integer(10); + $operands[] = new QtiInteger(10); $this->assertFalse($operands->exclusivelyDuration()); unset($operands[2]); $this->assertTrue($operands->exclusivelyDuration()); - $operands[] = new Point(1, 2); + $operands[] = new QtiPoint(1, 2); $this->assertFalse($operands->exclusivelyDuration()); unset($operands[3]); $this->assertTrue($operands->exclusivelyDuration()); @@ -205,7 +205,7 @@ public function testExclusivelyDuration() { $mult = new MultipleContainer(BaseType::DURATION); $operands[] = $mult; $this->assertFalse($operands->exclusivelyDuration()); - $mult[] = new Duration('P1DT2S'); + $mult[] = new QtiDuration('P1DT2S'); $this->assertTrue($operands->exclusivelyDuration()); $operands[] = new RecordContainer(); @@ -224,28 +224,28 @@ public function testAnythingButRecord() { $operands[] = null; $this->assertTrue($operands->anythingButRecord()); - $operands[] = new Integer(10); + $operands[] = new QtiInteger(10); $this->assertTrue($operands->anythingButRecord()); - $operands[] = new Float(10.11); + $operands[] = new QtiFloat(10.11); $this->assertTrue($operands->anythingButRecord()); - $operands[] = new Point(1, 1); + $operands[] = new QtiPoint(1, 1); $this->assertTrue($operands->anythingButRecord()); - $operands[] = new String(''); + $operands[] = new QtiString(''); $this->assertTrue($operands->anythingButRecord()); - $operands[] = new String('string'); + $operands[] = new QtiString('string'); $this->assertTrue($operands->anythingButRecord()); - $operands[] = new Boolean(true); + $operands[] = new QtiBoolean(true); $this->assertTrue($operands->anythingButRecord()); - $operands[] = new MultipleContainer(BaseType::INTEGER, array(new Integer(10), new Integer(20))); + $operands[] = new MultipleContainer(BaseType::INTEGER, array(new QtiInteger(10), new QtiInteger(20))); $this->assertTrue($operands->anythingButRecord()); - $operands[] = new OrderedContainer(BaseType::BOOLEAN, array(new Boolean(true), new Boolean(false), new Boolean(true))); + $operands[] = new OrderedContainer(BaseType::BOOLEAN, array(new QtiBoolean(true), new QtiBoolean(false), new QtiBoolean(true))); $this->assertTrue($operands->anythingButRecord()); $operands[] = new RecordContainer(); @@ -267,7 +267,7 @@ public function testExclusivelyMultipleOrOrdered() { unset($operands[2]); $this->assertTrue($operands->exclusivelyMultipleOrOrdered()); - $operands[] = new Integer(15); + $operands[] = new QtiInteger(15); $this->assertFalse($operands->exclusivelyMultipleOrOrdered()); unset($operands[3]); $this->assertTrue($operands->exclusivelyMultipleOrOrdered()); @@ -278,12 +278,12 @@ public function testExclusivelyMultipleOrOrdered() { $this->assertTrue($operands->exclusivelyMultipleOrOrdered()); - $operands[] = new String(''); + $operands[] = new QtiString(''); $this->assertFalse($operands->exclusivelyMultipleOrOrdered()); unset($operands[5]); $this->assertTrue($operands->exclusivelyMultipleOrOrdered()); - $operands[] = new Boolean(false); + $operands[] = new QtiBoolean(false); $this->assertFalse($operands->exclusivelyMultipleOrOrdered()); unset($operands[6]); $this->assertTrue($operands->exclusivelyMultipleOrOrdered()); @@ -297,13 +297,13 @@ public function testExclusivelySingleOrOrdered() { $operands[] = new OrderedContainer(BaseType::INTEGER); $this->assertTrue($operands->exclusivelySingleOrOrdered()); - $operands[] = new Integer(10); + $operands[] = new QtiInteger(10); $this->assertTrue($operands->exclusivelySingleOrOrdered()); - $operands[] = new Boolean(false); + $operands[] = new QtiBoolean(false); $this->assertTrue($operands->exclusivelySingleOrOrdered()); - $operands[] = new Point(10, 20); + $operands[] = new QtiPoint(10, 20); $this->assertTrue($operands->exclusivelySingleOrOrdered()); $operands[] = new MultipleContainer(BaseType::INTEGER); @@ -318,13 +318,13 @@ public function testExclusivelySingleOrMultiple() { $operands[] = new MultipleContainer(BaseType::INTEGER); $this->assertTrue($operands->exclusivelySingleOrMultiple()); - $operands[] = new Integer(10); + $operands[] = new QtiInteger(10); $this->assertTrue($operands->exclusivelySingleOrMultiple()); - $operands[] = new Boolean(false); + $operands[] = new QtiBoolean(false); $this->assertTrue($operands->exclusivelySingleOrMultiple()); - $operands[] = new Point(10, 20); + $operands[] = new QtiPoint(10, 20); $this->assertTrue($operands->exclusivelySingleOrMultiple()); $operands[] = new OrderedContainer(BaseType::INTEGER); @@ -341,19 +341,19 @@ public function testSameBaseType() { $this->assertFalse($operands->sameBaseType()); // If any of the values is null, false. - $operands = new OperandsCollection(array(new MultipleContainer(BaseType::INTEGER), null, new Integer(15))); + $operands = new OperandsCollection(array(new MultipleContainer(BaseType::INTEGER), null, new QtiInteger(15))); $this->assertFalse($operands->sameBaseType()); // If any of the values is null (an empty container is considered null), false. - $operands = new OperandsCollection(array(new MultipleContainer(BaseType::INTEGER), new Integer(1), new Integer(15))); + $operands = new OperandsCollection(array(new MultipleContainer(BaseType::INTEGER), new QtiInteger(1), new QtiInteger(15))); $this->assertFalse($operands->sameBaseType()); // Non-null values, all integers. - $operands = new OperandsCollection(array(new MultipleContainer(BaseType::INTEGER, array(new Integer(15))), new Integer(1), new Integer(15))); + $operands = new OperandsCollection(array(new MultipleContainer(BaseType::INTEGER, array(new QtiInteger(15))), new QtiInteger(1), new QtiInteger(15))); $this->assertTrue($operands->sameBaseType()); // Non-null, exclusively records. - $operands = new OperandsCollection(array(new RecordContainer(array('a' => new Integer(15))), new RecordContainer(array('b' => new Integer(22))))); + $operands = new OperandsCollection(array(new RecordContainer(array('a' => new QtiInteger(15))), new RecordContainer(array('b' => new QtiInteger(22))))); $this->assertTrue($operands->sameBaseType()); // Exclusively records but considered to be null because they are empty. @@ -361,24 +361,24 @@ public function testSameBaseType() { $this->assertFalse($operands->sameBaseType()); // Test Exclusively boolean - $operands = new OperandsCollection(array(new Boolean(true), new Boolean(false))); + $operands = new OperandsCollection(array(new QtiBoolean(true), new QtiBoolean(false))); $this->assertTrue($operands->sameBaseType()); - $operands = new Operandscollection(array(new Boolean(false))); + $operands = new Operandscollection(array(new QtiBoolean(false))); $this->assertTrue($operands->sameBaseType()); // Test Exclusively int - $operands = new OperandsCollection(array(new Integer(10), new Integer(0))); + $operands = new OperandsCollection(array(new QtiInteger(10), new QtiInteger(0))); $this->assertTrue($operands->sameBaseType()); - $operands = new OperandsCollection(array(new Integer(0))); + $operands = new OperandsCollection(array(new QtiInteger(0))); $this->assertTrue($operands->sameBaseType()); - $operands = new OperandsCollection(array(new Integer(10), new OrderedContainer(BaseType::INTEGER, array(new Integer(10), new Integer(-1), new Integer(20))), new Integer(5))); + $operands = new OperandsCollection(array(new QtiInteger(10), new OrderedContainer(BaseType::INTEGER, array(new QtiInteger(10), new QtiInteger(-1), new QtiInteger(20))), new QtiInteger(5))); $this->assertTrue($operands->sameBaseType()); // - Misc - $operands = new Operandscollection(array(new Integer(0), new Integer(10), new Float(10.0))); + $operands = new Operandscollection(array(new QtiInteger(0), new QtiInteger(10), new QtiFloat(10.0))); $this->assertFalse($operands->sameBaseType()); } @@ -389,13 +389,13 @@ public function testSameCardinality() { $operands = new OperandsCollection(array(null)); $this->assertFalse($operands->sameCardinality()); - $operands = new OperandsCollection(array(null, new Integer(10), new Integer(10))); + $operands = new OperandsCollection(array(null, new QtiInteger(10), new QtiInteger(10))); $this->assertFalse($operands->sameCardinality()); - $operands = new OperandsCollection(array(new Integer(0), new Boolean(false), new Integer(16), new Boolean(true), new Point(1, 1))); + $operands = new OperandsCollection(array(new QtiInteger(0), new QtiBoolean(false), new QtiInteger(16), new QtiBoolean(true), new QtiPoint(1, 1))); $this->assertTrue($operands->sameCardinality()); - $operands = new OperandsCollection(array(new Integer(10), new Integer(20), new OrderedContainer(BaseType::INTEGER))); + $operands = new OperandsCollection(array(new QtiInteger(10), new QtiInteger(20), new OrderedContainer(BaseType::INTEGER))); $this->assertFalse($operands->sameCardinality()); } @@ -403,40 +403,40 @@ public function testExclusivelyBoolean() { $operands = new OperandsCollection(); $this->assertFalse($operands->exclusivelyBoolean()); - $operands[] = new Boolean(true); + $operands[] = new QtiBoolean(true); $this->assertTrue($operands->exclusivelyBoolean()); - $operands[] = new Boolean(false); + $operands[] = new QtiBoolean(false); $this->assertTrue($operands->exclusivelyBoolean()); $container = new MultipleContainer(BaseType::BOOLEAN); $operands[] = $container; $this->assertFalse($operands->exclusivelyBoolean()); - $container[] = new Boolean(false); + $container[] = new QtiBoolean(false); $this->assertTrue($operands->exclusivelyBoolean()); $operands = new OperandsCollection(); - $operands[] = new Boolean(true); + $operands[] = new QtiBoolean(true); $this->assertTrue($operands->exclusivelyBoolean()); $operands[] = null; $this->assertFalse($operands->exclusivelyBoolean()); $operands = new OperandsCollection(); - $operands[] = new OrderedContainer(BaseType::BOOLEAN, array(new Boolean(true), new Boolean(false), new Boolean(true))); + $operands[] = new OrderedContainer(BaseType::BOOLEAN, array(new QtiBoolean(true), new QtiBoolean(false), new QtiBoolean(true))); $this->assertTrue($operands->exclusivelyBoolean()); $operands[] = new MultipleContainer(BaseType::BOOLEAN); $this->assertFalse($operands->exclusivelyBoolean()); $operands = new OperandsCollection(); - $operands[] = new Boolean(true); - $operands[] = new Boolean(false); + $operands[] = new QtiBoolean(true); + $operands[] = new QtiBoolean(false); $this->assertTrue($operands->exclusivelyBoolean()); - $operands[] = new RecordContainer(array('b1' => new Boolean(true), 'b2' => new Boolean(false))); + $operands[] = new RecordContainer(array('b1' => new QtiBoolean(true), 'b2' => new QtiBoolean(false))); $operands = new OperandsCollection(); - $operands[] = new Boolean(true); - $operands[] = new MultipleContainer(BaseType::BOOLEAN, array(new Boolean(true))); + $operands[] = new QtiBoolean(true); + $operands[] = new MultipleContainer(BaseType::BOOLEAN, array(new QtiBoolean(true))); $this->assertTrue($operands->exclusivelyBoolean()); $operands[] = new RecordContainer(); $this->assertFalse($operands->exclusivelyBoolean()); @@ -450,7 +450,7 @@ public function testExclusivelyRecord() { $operands[] = $rec; $this->assertTrue($operands->exclusivelyRecord()); - $rec['A'] = new Integer(1); + $rec['A'] = new QtiInteger(1); $this->assertTrue($operands->exclusivelyRecord()); $operands[] = null; @@ -460,12 +460,12 @@ public function testExclusivelyRecord() { $operands[] = $rec; $this->assertTrue($operands->exclusivelyRecord()); - $operands[] = new Integer(10); + $operands[] = new QtiInteger(10); $this->assertFalse($operands->exclusivelyRecord()); $operands->reset(); $operands[] = $rec; - $operands[] = new String('String!'); + $operands[] = new QtiString('String!'); $this->assertFalse($operands->exclusivelyRecord()); } @@ -478,7 +478,7 @@ public function testExclusivelyOrdered() { $operands[] = $mult; $this->assertTrue($operands->exclusivelyOrdered()); - $mult[] = new Integer(-10); + $mult[] = new QtiInteger(-10); $this->assertTrue($operands->exclusivelyOrdered()); $operands[] = null; @@ -488,12 +488,12 @@ public function testExclusivelyOrdered() { $operands[] = $mult; $this->assertTrue($operands->exclusivelyOrdered()); - $operands[] = new Integer(10); + $operands[] = new QtiInteger(10); $this->assertFalse($operands->exclusivelyOrdered()); $operands->reset(); $operands[] = $mult; - $operands[] = new String('String!'); + $operands[] = new QtiString('String!'); $this->assertFalse($operands->exclusivelyOrdered()); $operands->reset(); diff --git a/test/qtismtest/runtime/expressions/operators/OperatorProcessorFactoryTest.php b/test/qtismtest/runtime/expressions/operators/OperatorProcessorFactoryTest.php index 2d2040832..7d02d8e50 100644 --- a/test/qtismtest/runtime/expressions/operators/OperatorProcessorFactoryTest.php +++ b/test/qtismtest/runtime/expressions/operators/OperatorProcessorFactoryTest.php @@ -4,8 +4,8 @@ use qtismtest\QtiSmTestCase; use qtism\common\enums\BaseType; use qtism\runtime\common\OrderedContainer; -use qtism\common\datatypes\String; -use qtism\common\datatypes\Integer; +use qtism\common\datatypes\QtiString; +use qtism\common\datatypes\QtiInteger; use qtism\runtime\expressions\operators\OperandsCollection; use qtism\runtime\expressions\operators\OperatorProcessorFactory; use qtism\data\expressions\operators\Operator; @@ -36,7 +36,7 @@ public function testCreateProcessor() { ); $factory = new OperatorProcessorFactory(); - $operands = new OperandsCollection(array(new Integer(2), new Integer(2))); + $operands = new OperandsCollection(array(new QtiInteger(2), new QtiInteger(2))); $processor = $factory->createProcessor($expression, $operands); $this->assertInstanceOf('qtism\\runtime\\expressions\\operators\\SumProcessor', $processor); $this->assertEquals('sum', $processor->getExpression()->getQtiClassName()); @@ -60,10 +60,10 @@ public function testCustomOperator() { ); $factory = new OperatorProcessorFactory(); - $operands = new OperandsCollection(array(new String('this-is-a-test'))); + $operands = new OperandsCollection(array(new QtiString('this-is-a-test'))); $processor = $factory->createProcessor($expression, $operands); $this->assertInstanceOf('org\\qtism\\test\\Explode', $processor); $this->assertEquals('customOperator', $processor->getExpression()->getQtiClassName()); - $this->assertTrue($processor->process()->equals(new OrderedContainer(BaseType::STRING, array(new String('this'), new String('is'), new String('a'), new String('test'))))); + $this->assertTrue($processor->process()->equals(new OrderedContainer(BaseType::STRING, array(new QtiString('this'), new QtiString('is'), new QtiString('a'), new QtiString('test'))))); } } \ No newline at end of file diff --git a/test/qtismtest/runtime/expressions/operators/OrProcessorTest.php b/test/qtismtest/runtime/expressions/operators/OrProcessorTest.php index 1ddfe7bab..392ba0007 100644 --- a/test/qtismtest/runtime/expressions/operators/OrProcessorTest.php +++ b/test/qtismtest/runtime/expressions/operators/OrProcessorTest.php @@ -2,10 +2,10 @@ namespace qtismtest\runtime\expressions\operators; use qtismtest\QtiSmTestCase; -use qtism\common\datatypes\Boolean; -use qtism\common\datatypes\Float; -use qtism\common\datatypes\String; -use qtism\common\datatypes\Point; +use qtism\common\datatypes\QtiBoolean; +use qtism\common\datatypes\QtiFloat; +use qtism\common\datatypes\QtiString; +use qtism\common\datatypes\QtiPoint; use qtism\runtime\expressions\operators\OrProcessor; use qtism\runtime\expressions\operators\OperandsCollection; use qtism\common\enums\BaseType; @@ -24,7 +24,7 @@ public function testNotEnoughOperands () { public function testWrongBaseType() { $expression = $this->createFakeExpression(); - $operands = new OperandsCollection(array(new Point(1, 2))); + $operands = new OperandsCollection(array(new QtiPoint(1, 2))); $processor = new OrProcessor($expression, $operands); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $result = $processor->process(); @@ -32,7 +32,7 @@ public function testWrongBaseType() { public function testWrongCardinalityOne() { $expression = $this->createFakeExpression(); - $operands = new OperandsCollection(array(new RecordContainer(array('a' => new String('string!'))))); + $operands = new OperandsCollection(array(new RecordContainer(array('a' => new QtiString('string!'))))); $processor = new OrProcessor($expression, $operands); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $result = $processor->process(); @@ -40,7 +40,7 @@ public function testWrongCardinalityOne() { public function testWrongCardinalityTwo() { $expression = $this->createFakeExpression(); - $operands = new OperandsCollection(array(new MultipleContainer(BaseType::FLOAT, array(new Float(25.0))))); + $operands = new OperandsCollection(array(new MultipleContainer(BaseType::FLOAT, array(new QtiFloat(25.0))))); $processor = new OrProcessor($expression, $operands); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $result = $processor->process(); @@ -51,18 +51,18 @@ public function testNullOperands() { // As per specs, If one or more sub-expressions are NULL and all the others // are false then the operator also results in NULL. - $operands = new OperandsCollection(array(new Boolean(false), null)); + $operands = new OperandsCollection(array(new QtiBoolean(false), null)); $processor = new OrProcessor($expression, $operands); $result = $processor->process(); $this->assertSame(null, $result); - $operands = new OperandsCollection(array(new Boolean(false), null, new Boolean(false))); + $operands = new OperandsCollection(array(new QtiBoolean(false), null, new QtiBoolean(false))); $processor->setOperands($operands); $result = $processor->process(); $this->assertSame(null, $result); // On the other hand... - $operands = new OperandsCollection(array(new Boolean(false), null, new Boolean(true))); + $operands = new OperandsCollection(array(new QtiBoolean(false), null, new QtiBoolean(true))); $processor->setOperands($operands); $result = $processor->process(); $this->assertTrue($result->getValue()); @@ -70,31 +70,31 @@ public function testNullOperands() { public function testTrue() { $expression = $this->createFakeExpression(); - $operands = new OperandsCollection(array(new Boolean(true))); + $operands = new OperandsCollection(array(new QtiBoolean(true))); $processor = new OrProcessor($expression, $operands); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Boolean', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiBoolean', $result); $this->assertSame(true, $result->getValue()); - $operands = new OperandsCollection(array(new Boolean(false), new Boolean(true), new Boolean(false))); + $operands = new OperandsCollection(array(new QtiBoolean(false), new QtiBoolean(true), new QtiBoolean(false))); $processor->setOperands($operands); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Boolean', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiBoolean', $result); $this->assertSame(true, $result->getValue()); } public function testFalse() { $expression = $this->createFakeExpression(); - $operands = new OperandsCollection(array(new Boolean(false))); + $operands = new OperandsCollection(array(new QtiBoolean(false))); $processor = new OrProcessor($expression, $operands); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Boolean', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiBoolean', $result); $this->assertSame(false, $result->getValue()); - $operands = new OperandsCollection(array(new Boolean(false), new Boolean(false), new Boolean(false))); + $operands = new OperandsCollection(array(new QtiBoolean(false), new QtiBoolean(false), new QtiBoolean(false))); $processor->setOperands($operands); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Boolean', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiBoolean', $result); $this->assertSame(false, $result->getValue()); } diff --git a/test/qtismtest/runtime/expressions/operators/OrderedProcessorTest.php b/test/qtismtest/runtime/expressions/operators/OrderedProcessorTest.php index ec3027aae..d7312f310 100644 --- a/test/qtismtest/runtime/expressions/operators/OrderedProcessorTest.php +++ b/test/qtismtest/runtime/expressions/operators/OrderedProcessorTest.php @@ -2,17 +2,17 @@ namespace qtismtest\runtime\expressions\operators; use qtismtest\QtiSmTestCase; -use qtism\common\datatypes\Identifier; -use qtism\common\datatypes\String; -use qtism\common\datatypes\Integer; +use qtism\common\datatypes\QtiIdentifier; +use qtism\common\datatypes\QtiString; +use qtism\common\datatypes\QtiInteger; use qtism\runtime\expressions\operators\OrderedProcessor; use qtism\runtime\expressions\operators\OperandsCollection; use qtism\common\enums\BaseType; use qtism\runtime\common\OrderedContainer; use qtism\runtime\common\RecordContainer; use qtism\runtime\common\MultipleContainer; -use qtism\common\datatypes\Duration; -use qtism\common\datatypes\Point; +use qtism\common\datatypes\QtiDuration; +use qtism\common\datatypes\QtiPoint; class OrderedProcessorTest extends QtiSmTestCase { @@ -30,7 +30,7 @@ public function testNull() { $result = $processor->process(); $this->assertSame(null, $result); - $operands = new OperandsCollection(array(null, new Integer(25), new OrderedContainer(BaseType::INTEGER))); + $operands = new OperandsCollection(array(null, new QtiInteger(25), new OrderedContainer(BaseType::INTEGER))); $processor->setOperands($operands); $result = $processor->process(); $this->assertInstanceOf('qtism\\runtime\\common\\OrderedContainer', $result); @@ -38,7 +38,7 @@ public function testNull() { $this->assertEquals(BaseType::INTEGER, $result->getBaseType()); $this->assertEquals(25, $result[0]->getValue()); - $operands = new OperandsCollection(array(null, new Integer(25), new OrderedContainer(BaseType::INTEGER, array(new Integer(26))))); + $operands = new OperandsCollection(array(null, new QtiInteger(25), new OrderedContainer(BaseType::INTEGER, array(new QtiInteger(26))))); $processor->setOperands($operands); $result = $processor->process(); $this->assertInstanceOf('qtism\\runtime\\common\\OrderedContainer', $result); @@ -47,7 +47,7 @@ public function testNull() { $this->assertEquals(25, $result[0]->getValue()); $this->assertEquals(26, $result[1]->getValue()); - $operands = new OperandsCollection(array(new OrderedContainer(BaseType::INTEGER), new Integer(25), new OrderedContainer(BaseType::INTEGER, array(new Integer(26))))); + $operands = new OperandsCollection(array(new OrderedContainer(BaseType::INTEGER), new QtiInteger(25), new OrderedContainer(BaseType::INTEGER, array(new QtiInteger(26))))); $processor->setOperands($operands); $result = $processor->process(); $this->assertInstanceOf('qtism\\runtime\\common\\OrderedContainer', $result); @@ -65,9 +65,9 @@ public function testNull() { public function testScalar() { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); - $operands[] = new String('String1'); - $operands[] = new String('String2'); - $operands[] = new String('String3'); + $operands[] = new QtiString('String1'); + $operands[] = new QtiString('String2'); + $operands[] = new QtiString('String3'); $processor = new OrderedProcessor($expression, $operands); $result = $processor->process(); @@ -77,7 +77,7 @@ public function testScalar() { $this->assertEquals('String2', $result[1]->getValue()); $this->assertEquals('String3', $result[2]->getValue()); - $operands = new OperandsCollection(array(new String('String!'))); + $operands = new OperandsCollection(array(new QtiString('String!'))); $processor->setOperands($operands); $result = $processor->process(); $this->assertInstanceOf('qtism\\runtime\\common\\OrderedContainer', $result); @@ -87,38 +87,38 @@ public function testScalar() { public function testContainer() { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); - $operands[] = new OrderedContainer(BaseType::POINT, array(new Point(1, 2), new Point(2, 3))); + $operands[] = new OrderedContainer(BaseType::POINT, array(new QtiPoint(1, 2), new QtiPoint(2, 3))); $operands[] = new OrderedContainer(BaseType::POINT); - $operands[] = new OrderedContainer(BaseType::POINT, array(new Point(3, 4))); + $operands[] = new OrderedContainer(BaseType::POINT, array(new QtiPoint(3, 4))); $processor = new OrderedProcessor($expression, $operands); $result = $processor->process(); $this->assertInstanceOf('qtism\\runtime\\common\\OrderedContainer', $result); $this->assertEquals(3, count($result)); - $this->assertTrue($result[0]->equals(new Point(1, 2))); - $this->assertTrue($result[1]->equals(new Point(2, 3))); - $this->assertTrue($result[2]->equals(new Point(3, 4))); + $this->assertTrue($result[0]->equals(new QtiPoint(1, 2))); + $this->assertTrue($result[1]->equals(new QtiPoint(2, 3))); + $this->assertTrue($result[2]->equals(new QtiPoint(3, 4))); } public function testMixed() { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); - $operands[] = new Point(1, 2); + $operands[] = new QtiPoint(1, 2); $operands[] = null; - $operands[] = new OrderedContainer(BaseType::POINT, array(new Point(3, 4))); + $operands[] = new OrderedContainer(BaseType::POINT, array(new QtiPoint(3, 4))); $processor = new OrderedProcessor($expression, $operands); $result = $processor->process(); $this->assertInstanceOf('qtism\\runtime\\common\\OrderedContainer', $result); $this->assertEquals(2, count($result)); - $this->assertTrue($result[0]->equals(new Point(1, 2))); - $this->assertTrue($result[1]->equals(new Point(3, 4))); + $this->assertTrue($result[0]->equals(new QtiPoint(1, 2))); + $this->assertTrue($result[1]->equals(new QtiPoint(3, 4))); } public function testWrongBaseTypeOne() { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); - $operands[] = new OrderedContainer(BaseType::IDENTIFIER, array(new Identifier('identifier1'), new Identifier('identifier2'))); - $operands[] = new Identifier('identifier3'); - $operands[] = new OrderedContainer(BaseType::STRING, array(new String('string1'), new String('string2'))); + $operands[] = new OrderedContainer(BaseType::IDENTIFIER, array(new QtiIdentifier('identifier1'), new QtiIdentifier('identifier2'))); + $operands[] = new QtiIdentifier('identifier3'); + $operands[] = new OrderedContainer(BaseType::STRING, array(new QtiString('string1'), new QtiString('string2'))); $operands[] = null; $processor = new OrderedProcessor($expression, $operands); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); @@ -128,10 +128,10 @@ public function testWrongBaseTypeOne() { public function testWrongBaseTypeTwo() { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); - $operands[] = new Point(1, 2); - $operands[] = new Duration('P2D'); + $operands[] = new QtiPoint(1, 2); + $operands[] = new QtiDuration('P2D'); $operands[] = null; - $operands[] = new Integer(10); + $operands[] = new QtiInteger(10); $processor = new OrderedProcessor($expression, $operands); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $result = $processor->process(); @@ -140,9 +140,9 @@ public function testWrongBaseTypeTwo() { public function testWrongCardinality() { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); - $operands[] = new Integer(10); + $operands[] = new QtiInteger(10); $operands[] = null; - $operands[] = new OrderedContainer(BaseType::INTEGER, array(new Integer(10))); + $operands[] = new OrderedContainer(BaseType::INTEGER, array(new QtiInteger(10))); $processor = new OrderedProcessor($expression, $operands); $result = $processor->process(); diff --git a/test/qtismtest/runtime/expressions/operators/PatternMatchProcessorTest.php b/test/qtismtest/runtime/expressions/operators/PatternMatchProcessorTest.php index 17a37df3f..3435bdb95 100644 --- a/test/qtismtest/runtime/expressions/operators/PatternMatchProcessorTest.php +++ b/test/qtismtest/runtime/expressions/operators/PatternMatchProcessorTest.php @@ -2,9 +2,9 @@ namespace qtismtest\runtime\expressions\operators; use qtismtest\QtiSmTestCase; -use qtism\common\datatypes\Float; -use qtism\common\datatypes\Integer; -use qtism\common\datatypes\String; +use qtism\common\datatypes\QtiFloat; +use qtism\common\datatypes\QtiInteger; +use qtism\common\datatypes\QtiString; use qtism\runtime\common\RecordContainer; use qtism\common\enums\BaseType; use qtism\runtime\common\OrderedContainer; @@ -50,14 +50,14 @@ public function testNotEnougOperands() { public function testTooMuchOperands() { $expression = $this->createFakeExpression('abc'); - $operands = new OperandsCollection(array(new String('string'), new String('string'))); + $operands = new OperandsCollection(array(new QtiString('string'), new QtiString('string'))); $this->setExpectedException('qtism\\runtime\\expressions\\operators\\OperatorProcessingException'); $processor = new PatternMatchProcessor($expression, $operands); } public function testWrongCardinality() { $expression = $this->createFakeExpression('abc'); - $operands = new OperandsCollection(array(new RecordContainer(array('A' => new Integer(1))))); + $operands = new OperandsCollection(array(new RecordContainer(array('A' => new QtiInteger(1))))); $processor = new PatternMatchProcessor($expression, $operands); $this->setExpectedException('qtism\\runtime\\expressions\\operators\\OperatorProcessingException'); $result = $processor->process(); @@ -65,7 +65,7 @@ public function testWrongCardinality() { public function testWrongBaseType() { $expression = $this->createFakeExpression('abc'); - $operands = new OperandsCollection(array(new Float(255.34))); + $operands = new OperandsCollection(array(new QtiFloat(255.34))); $processor = new PatternMatchProcessor($expression, $operands); $this->setExpectedException('qtism\\runtime\\expressions\\operators\\OperatorProcessingException'); $result = $processor->process(); @@ -73,7 +73,7 @@ public function testWrongBaseType() { public function testInternalError() { $expression = $this->createFakeExpression('['); - $operands = new OperandsCollection(array(new String('string!'))); + $operands = new OperandsCollection(array(new QtiString('string!'))); $processor = new PatternMatchProcessor($expression, $operands); try { $result = $processor->process(); @@ -87,23 +87,23 @@ public function testInternalError() { public function patternMatchProvider() { return array( - array(new String('string'), 'string', true), - array(new String('string'), 'stRing', false), - array(new String('string'), 'shell', false), - array(new String('stringString'), '.*', true), // in xml schema 2, dot matches white-spaces - array(new String('^String$'), 'String', false), // No carret nor dollar in xml schema 2 - array(new String('^String$'), '^String$', true), - array(new String('Str/ing'), 'Str/ing', true), - array(new String('Str^ing'), 'Str^ing', true), - array(new String('99'), '\d{1,2}', true), - array(new String('abc'), '\d{1,2}', false) + array(new QtiString('string'), 'string', true), + array(new QtiString('string'), 'stRing', false), + array(new QtiString('string'), 'shell', false), + array(new QtiString('stringString'), '.*', true), // in xml schema 2, dot matches white-spaces + array(new QtiString('^String$'), 'String', false), // No carret nor dollar in xml schema 2 + array(new QtiString('^String$'), '^String$', true), + array(new QtiString('Str/ing'), 'Str/ing', true), + array(new QtiString('Str^ing'), 'Str^ing', true), + array(new QtiString('99'), '\d{1,2}', true), + array(new QtiString('abc'), '\d{1,2}', false) ); } public function nullProvider() { return array( array(null, '\d{1,2}'), - array(new String(''), '\d{1,2}'), + array(new QtiString(''), '\d{1,2}'), array(new OrderedContainer(BaseType::STRING), '\d{1,2}') ); } diff --git a/test/qtismtest/runtime/expressions/operators/PowerProcessorTest.php b/test/qtismtest/runtime/expressions/operators/PowerProcessorTest.php index e3be6492e..8a7afa8e0 100644 --- a/test/qtismtest/runtime/expressions/operators/PowerProcessorTest.php +++ b/test/qtismtest/runtime/expressions/operators/PowerProcessorTest.php @@ -2,9 +2,9 @@ namespace qtismtest\runtime\expressions\operators; use qtismtest\QtiSmTestCase; -use qtism\common\datatypes\String; -use qtism\common\datatypes\Float; -use qtism\common\datatypes\Integer; +use qtism\common\datatypes\QtiString; +use qtism\common\datatypes\QtiFloat; +use qtism\common\datatypes\QtiInteger; use qtism\common\enums\BaseType; use qtism\runtime\common\MultipleContainer; use qtism\runtime\expressions\operators\PowerProcessor; @@ -14,51 +14,51 @@ class PowerProcessorTest extends QtiSmTestCase { public function testPowerNormal() { $expression = $this->createFakeExpression(); - $operands = new OperandsCollection(array(new Integer(0), new Integer(0))); + $operands = new OperandsCollection(array(new QtiInteger(0), new QtiInteger(0))); $processor = new PowerProcessor($expression, $operands); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $result); $this->assertEquals(1, $result->getValue()); $operands->reset(); - $operands[] = new Integer(256); - $operands[] = new Integer(0); + $operands[] = new QtiInteger(256); + $operands[] = new QtiInteger(0); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $result); $this->assertEquals(1, $result->getValue()); $operands->reset(); - $operands[] = new Integer(0); - $operands[] = new Integer(0); + $operands[] = new QtiInteger(0); + $operands[] = new QtiInteger(0); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $result); $this->assertEquals(1, $result->getValue()); $operands->reset(); - $operands[] = new Integer(0); - $operands[] = new Integer(2); + $operands[] = new QtiInteger(0); + $operands[] = new QtiInteger(2); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $result); $this->assertEquals(0, $result->getValue()); $operands->reset(); - $operands[] = new Integer(2); - $operands[] = new Integer(8); + $operands[] = new QtiInteger(2); + $operands[] = new QtiInteger(8); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $result); $this->assertEquals(256, $result->getValue()); $operands->reset(); - $operands[] = new Integer(20); - $operands[] = new Float(3.4); + $operands[] = new QtiInteger(20); + $operands[] = new QtiFloat(3.4); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $result); $this->assertEquals(26515, intval($result->getValue())); } public function testOverflow() { $expression = $this->createFakeExpression(); - $operands = new OperandsCollection(array(new Integer(2), new Integer(100000000))); + $operands = new OperandsCollection(array(new QtiInteger(2), new QtiInteger(100000000))); $processor = new PowerProcessor($expression, $operands); $result = $processor->process(); $this->assertSame(null, $result); @@ -66,7 +66,7 @@ public function testOverflow() { public function testUnderflow() { $expression = $this->createFakeExpression(); - $operands = new OperandsCollection(array(new Integer(-2), new Integer(333333333))); + $operands = new OperandsCollection(array(new QtiInteger(-2), new QtiInteger(333333333))); $processor = new PowerProcessor($expression, $operands); $result = $processor->process(); $this->assertSame(null, $result); @@ -74,7 +74,7 @@ public function testUnderflow() { public function testInfinite() { $expression = $this->createFakeExpression(); - $operands = new OperandsCollection(array(new Float(INF), new Float(INF))); + $operands = new OperandsCollection(array(new QtiFloat(INF), new QtiFloat(INF))); $processor = new PowerProcessor($expression, $operands); $result = $processor->process(); $this->assertTrue(is_infinite($result->getValue())); @@ -83,27 +83,27 @@ public function testInfinite() { public function testNull() { // exp as a float is NaN when negative base is used. $expression = $this->createFakeExpression(); - $operands = new OperandsCollection(array(new Integer(-20), new Float(3.4))); + $operands = new OperandsCollection(array(new QtiInteger(-20), new QtiFloat(3.4))); $processor = new PowerProcessor($expression, $operands); $result = $processor->process(); $this->assertSame(null, $result); $operands->reset(); - $operands[] = new Integer(1); + $operands[] = new QtiInteger(1); $operands[] = null; $result = $processor->process(); $this->assertSame(null, $result); $operands->reset(); $operands[] = new MultipleContainer(BaseType::FLOAT); - $operands[] = new Integer(2); + $operands[] = new QtiInteger(2); $result = $processor->process(); $this->assertSame(null, $result); } public function testWrongBaseType() { $expression = $this->createFakeExpression(); - $operands = new OperandsCollection(array(new Integer(-20), new String('String!'))); + $operands = new OperandsCollection(array(new QtiInteger(-20), new QtiString('String!'))); $processor = new PowerProcessor($expression, $operands); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $result = $processor->process(); @@ -111,7 +111,7 @@ public function testWrongBaseType() { public function testWrongCardinality() { $expression = $this->createFakeExpression(); - $operands = new OperandsCollection(array(new Integer(-20), new MultipleContainer(BaseType::INTEGER, array(new Integer(10))))); + $operands = new OperandsCollection(array(new QtiInteger(-20), new MultipleContainer(BaseType::INTEGER, array(new QtiInteger(10))))); $processor = new PowerProcessor($expression, $operands); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $result = $processor->process(); @@ -119,14 +119,14 @@ public function testWrongCardinality() { public function testNotEnoughOperands() { $expression = $this->createFakeExpression(); - $operands = new OperandsCollection(array(new Integer(-20))); + $operands = new OperandsCollection(array(new QtiInteger(-20))); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $processor = new PowerProcessor($expression, $operands); } public function testTooMuchOperands() { $expression = $this->createFakeExpression(); - $operands = new OperandsCollection(array(new Integer(-20), new Integer(20), new Integer(30))); + $operands = new OperandsCollection(array(new QtiInteger(-20), new QtiInteger(20), new QtiInteger(30))); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $processor = new PowerProcessor($expression, $operands); } diff --git a/test/qtismtest/runtime/expressions/operators/ProductProcessorTest.php b/test/qtismtest/runtime/expressions/operators/ProductProcessorTest.php index 189bff3a0..1c093a8d6 100644 --- a/test/qtismtest/runtime/expressions/operators/ProductProcessorTest.php +++ b/test/qtismtest/runtime/expressions/operators/ProductProcessorTest.php @@ -2,9 +2,9 @@ namespace qtismtest\runtime\expressions\operators; use qtismtest\QtiSmTestCase; -use qtism\common\datatypes\Boolean; -use qtism\common\datatypes\Float; -use qtism\common\datatypes\Integer; +use qtism\common\datatypes\QtiBoolean; +use qtism\common\datatypes\QtiFloat; +use qtism\common\datatypes\QtiInteger; use qtism\common\enums\BaseType; use qtism\runtime\common\MultipleContainer; use qtism\runtime\common\OrderedContainer; @@ -16,36 +16,36 @@ class ProductProcessorTest extends QtiSmTestCase { public function testSimple() { $product = $this->createFakeProductComponent(); - $operands = new OperandsCollection(array(new Integer(1), new Integer(1))); + $operands = new OperandsCollection(array(new QtiInteger(1), new QtiInteger(1))); $productProcessor = new ProductProcessor($product, $operands); $result = $productProcessor->process(); $this->assertInstanceOf('qtism\\runtime\\common\\Processable', $productProcessor); - $this->assertInstanceOf('qtism\\common\\datatypes\\Integer', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiInteger', $result); $this->assertEquals(1, $result->getValue()); } public function testNary() { $product = $this->createFakeProductComponent(); - $operands = new OperandsCollection(array(new Integer(24), new Integer(-4), new Integer(1))); + $operands = new OperandsCollection(array(new QtiInteger(24), new QtiInteger(-4), new QtiInteger(1))); $productProcessor = new ProductProcessor($product, $operands); $result = $productProcessor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Integer', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiInteger', $result); $this->assertEquals(-96, $result->getValue()); } public function testComplex() { $product = $this->createFakeProductComponent(); - $operands = new OperandsCollection(array(new Integer(-1), new Integer(1))); - $operands[] = new MultipleContainer(BaseType::FLOAT, array(new Float(2.1), new Float(4.3))); - $operands[] = new OrderedContainer(BaseType::INTEGER, array(new Integer(10), new Integer(15))); + $operands = new OperandsCollection(array(new QtiInteger(-1), new QtiInteger(1))); + $operands[] = new MultipleContainer(BaseType::FLOAT, array(new QtiFloat(2.1), new QtiFloat(4.3))); + $operands[] = new OrderedContainer(BaseType::INTEGER, array(new QtiInteger(10), new QtiInteger(15))); $productProcessor = new ProductProcessor($product, $operands); $result = $productProcessor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $result); $this->assertEquals(-1354.5, $result->getValue()); } @@ -54,7 +54,7 @@ public function testInvalidOperandsOne() { $this->setExpectedException('\\RuntimeException'); - $operands = new OperandsCollection(array(new Boolean(true), new Integer(14), new Integer(10))); + $operands = new OperandsCollection(array(new QtiBoolean(true), new QtiInteger(14), new QtiInteger(10))); $productProcessor = new ProductProcessor($product, $operands); $result = $productProcessor->process(); } @@ -62,7 +62,7 @@ public function testInvalidOperandsOne() { public function testInvalidOperandsTwo() { $product = $this->createFakeProductComponent(); $operands = new OperandsCollection(); - $operands[] = new MultipleContainer(BaseType::BOOLEAN, array(new Boolean(true), new Boolean(false))); + $operands[] = new MultipleContainer(BaseType::BOOLEAN, array(new QtiBoolean(true), new QtiBoolean(false))); $productProcessor = new ProductProcessor($product, $operands); $this->setExpectedException('\\RuntimeException'); @@ -71,7 +71,7 @@ public function testInvalidOperandsTwo() { public function testNullInvolved() { $product = $this->createFakeProductComponent(); - $operands = new OperandsCollection(array(new Integer(10), new Integer(10), null)); + $operands = new OperandsCollection(array(new QtiInteger(10), new QtiInteger(10), null)); $productProcessor = new ProductProcessor($product, $operands); $result = $productProcessor->process(); $this->assertTrue($result === null); diff --git a/test/qtismtest/runtime/expressions/operators/RandomProcessorTest.php b/test/qtismtest/runtime/expressions/operators/RandomProcessorTest.php index 94b0408db..ffe718dc7 100644 --- a/test/qtismtest/runtime/expressions/operators/RandomProcessorTest.php +++ b/test/qtismtest/runtime/expressions/operators/RandomProcessorTest.php @@ -2,12 +2,12 @@ namespace qtismtest\runtime\expressions\operators; use qtismtest\QtiSmTestCase; -use qtism\common\datatypes\Integer; -use qtism\common\datatypes\String; -use qtism\common\datatypes\Float; +use qtism\common\datatypes\QtiInteger; +use qtism\common\datatypes\QtiString; +use qtism\common\datatypes\QtiFloat; use qtism\runtime\common\RecordContainer; -use qtism\common\datatypes\Point; -use qtism\common\datatypes\Duration; +use qtism\common\datatypes\QtiPoint; +use qtism\common\datatypes\QtiDuration; use qtism\common\enums\BaseType; use qtism\runtime\common\MultipleContainer; use qtism\runtime\common\OrderedContainer; @@ -19,10 +19,10 @@ class RandomProcessorTest extends QtiSmTestCase { public function testPrimitiveMultiple() { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); - $operands[] = new MultipleContainer(BaseType::FLOAT, array(new Float(1.0), new Float(2.0), new Float(3.0))); + $operands[] = new MultipleContainer(BaseType::FLOAT, array(new QtiFloat(1.0), new QtiFloat(2.0), new QtiFloat(3.0))); $processor = new RandomProcessor($expression, $operands); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $result); $this->assertGreaterThanOrEqual(1.0, $result->getValue()); $this->assertLessThanOrEqual(3.0, $result->getValue()); } @@ -30,20 +30,20 @@ public function testPrimitiveMultiple() { public function testPrimitiveOrdered() { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); - $operands[] = new OrderedContainer(BaseType::STRING, array(new String('s1'), new String('s2'), new String('s3'))); + $operands[] = new OrderedContainer(BaseType::STRING, array(new QtiString('s1'), new QtiString('s2'), new QtiString('s3'))); $processor = new RandomProcessor($expression, $operands); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\String', $result); - $this->assertTrue($result->equals(new String('s1')) || $result->equals(new String('s2')) || $result->equals(new String('s3'))); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiString', $result); + $this->assertTrue($result->equals(new QtiString('s1')) || $result->equals(new QtiString('s2')) || $result->equals(new QtiString('s3'))); } public function testComplexMultiple() { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); - $operands[] = new MultipleContainer(BaseType::DURATION, array(new Duration('P1D'), new Duration('P2D'), new Duration('P3D'))); + $operands[] = new MultipleContainer(BaseType::DURATION, array(new QtiDuration('P1D'), new QtiDuration('P2D'), new QtiDuration('P3D'))); $processor = new RandomProcessor($expression, $operands); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Duration', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiDuration', $result); $this->assertGreaterThanOrEqual(1, $result->getDays()); $this->assertLessThanOrEqual(3, $result->getDays()); } @@ -51,10 +51,10 @@ public function testComplexMultiple() { public function testComplexOrdered() { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); - $operands[] = new OrderedContainer(BaseType::POINT, array(new Point(1, 1), new Point(2, 2), new Point(3, 3))); + $operands[] = new OrderedContainer(BaseType::POINT, array(new QtiPoint(1, 1), new QtiPoint(2, 2), new QtiPoint(3, 3))); $processor = new RandomProcessor($expression, $operands); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Point', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiPoint', $result); $this->assertGreaterThanOrEqual(1, $result->getX()); $this->assertLessThanOrEqual(3, $result->getY()); } @@ -62,10 +62,10 @@ public function testComplexOrdered() { public function testOnlyOneInContainer() { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); - $operands[] = new OrderedContainer(BaseType::POINT, array(new Point(22, 33))); + $operands[] = new OrderedContainer(BaseType::POINT, array(new QtiPoint(22, 33))); $processor = new RandomProcessor($expression, $operands); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Point', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiPoint', $result); $this->assertEquals(22, $result->getX()); $this->assertEquals(33, $result->getY()); } @@ -82,7 +82,7 @@ public function testNull() { public function testWrongCardinalityOne() { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); - $operands[] = new Integer(10); + $operands[] = new QtiInteger(10); $processor = new RandomProcessor($expression, $operands); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $result = $processor->process(); @@ -91,7 +91,7 @@ public function testWrongCardinalityOne() { public function testWrongCardinalityTwo() { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); - $operands[] = new RecordContainer(array('A' => new Integer(1))); + $operands[] = new RecordContainer(array('A' => new QtiInteger(1))); $processor = new RandomProcessor($expression, $operands); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $result = $processor->process(); diff --git a/test/qtismtest/runtime/expressions/operators/RepeatProcessorTest.php b/test/qtismtest/runtime/expressions/operators/RepeatProcessorTest.php index 275343a2b..f1da20834 100644 --- a/test/qtismtest/runtime/expressions/operators/RepeatProcessorTest.php +++ b/test/qtismtest/runtime/expressions/operators/RepeatProcessorTest.php @@ -2,13 +2,13 @@ namespace qtismtest\runtime\expressions\operators; use qtismtest\QtiSmTestCase; -use qtism\common\datatypes\Float; -use qtism\common\datatypes\Uri; -use qtism\common\datatypes\Identifier; -use qtism\common\datatypes\String; -use qtism\common\datatypes\Integer; +use qtism\common\datatypes\QtiFloat; +use qtism\common\datatypes\QtiUri; +use qtism\common\datatypes\QtiIdentifier; +use qtism\common\datatypes\QtiString; +use qtism\common\datatypes\QtiInteger; use qtism\runtime\common\MultipleContainer; -use qtism\common\datatypes\Point; +use qtism\common\datatypes\QtiPoint; use qtism\common\enums\BaseType; use qtism\runtime\common\OrderedContainer; use qtism\runtime\expressions\operators\RepeatProcessor; @@ -17,7 +17,7 @@ class RepeatProcessorTest extends QtiSmTestCase { public function testRepeatScalarOnly() { - $initialVal = array(new Integer(1), new Integer(2), new Integer(3)); + $initialVal = array(new QtiInteger(1), new QtiInteger(2), new QtiInteger(3)); $expression = $this->createFakeExpression(1); $operands = new OperandsCollection($initialVal); $processor = new RepeatProcessor($expression, $operands); @@ -32,28 +32,28 @@ public function testRepeatScalarOnly() { public function testOrderedOnly() { $expression = $this->createFakeExpression(2); - $ordered1 = new OrderedContainer(BaseType::INTEGER, array(new Integer(1), new Integer(2), new Integer(3))); - $ordered2 = new OrderedContainer(BaseType::INTEGER, array(new Integer(4))); + $ordered1 = new OrderedContainer(BaseType::INTEGER, array(new QtiInteger(1), new QtiInteger(2), new QtiInteger(3))); + $ordered2 = new OrderedContainer(BaseType::INTEGER, array(new QtiInteger(4))); $operands = new OperandsCollection(array($ordered1, $ordered2)); $processor = new RepeatProcessor($expression, $operands); $result = $processor->process(); - $comparison = new OrderedContainer(BaseType::INTEGER, array(new Integer(1), new Integer(2), new Integer(3), new Integer(4), new Integer(1), new Integer(2), new Integer(3), new Integer(4))); + $comparison = new OrderedContainer(BaseType::INTEGER, array(new QtiInteger(1), new QtiInteger(2), new QtiInteger(3), new QtiInteger(4), new QtiInteger(1), new QtiInteger(2), new QtiInteger(3), new QtiInteger(4))); $this->assertTrue($comparison->equals($result)); } public function testMixed() { $expression = $this->createFakeExpression(2); $operands = new OperandsCollection(); - $operands[] = new Point(0, 0); - $operands[] = new OrderedContainer(BaseType::POINT, array(new Point(1, 2), new Point(2, 3), new Point(3, 4))); - $operands[] = new Point(10, 10); - $operands[] = new OrderedContainer(BaseType::POINT, array(new Point(4, 5))); + $operands[] = new QtiPoint(0, 0); + $operands[] = new OrderedContainer(BaseType::POINT, array(new QtiPoint(1, 2), new QtiPoint(2, 3), new QtiPoint(3, 4))); + $operands[] = new QtiPoint(10, 10); + $operands[] = new OrderedContainer(BaseType::POINT, array(new QtiPoint(4, 5))); $processor = new RepeatProcessor($expression, $operands); $result = $processor->process(); - $comparison = new OrderedContainer(BaseType::POINT, array(new Point(0, 0), new Point(1, 2), new Point(2, 3), new Point(3, 4), new Point(10, 10), new Point(4, 5), new Point(0, 0), new Point(1, 2), new Point(2, 3), new Point(3, 4), new Point(10, 10), new Point(4, 5))); + $comparison = new OrderedContainer(BaseType::POINT, array(new QtiPoint(0, 0), new QtiPoint(1, 2), new QtiPoint(2, 3), new QtiPoint(3, 4), new QtiPoint(10, 10), new QtiPoint(4, 5), new QtiPoint(0, 0), new QtiPoint(1, 2), new QtiPoint(2, 3), new QtiPoint(3, 4), new QtiPoint(10, 10), new QtiPoint(4, 5))); $this->assertTrue($comparison->equals($result)); } @@ -66,11 +66,11 @@ public function testNull() { $this->assertSame(null, $result); // Any sub-expressions evaluating to NULL are ignored. - $operands = new OperandsCollection(array(null, new String('String1'), new OrderedContainer(BaseType::STRING, array(new String('String2'), null)), new String('String3'))); + $operands = new OperandsCollection(array(null, new QtiString('String1'), new OrderedContainer(BaseType::STRING, array(new QtiString('String2'), null)), new QtiString('String3'))); $processor->setOperands($operands); $result = $processor->process(); - $comparison = new OrderedContainer(BaseType::STRING, array(new String('String1'), new String('String2'), null, new String('String3'))); + $comparison = new OrderedContainer(BaseType::STRING, array(new QtiString('String1'), new QtiString('String2'), null, new QtiString('String3'))); $this->assertTrue($result->equals($comparison)); } @@ -78,9 +78,9 @@ public function testWrongBaseTypeOne() { $expression = $this->createFakeExpression(1); $operands = new OperandsCollection(); $operands[] = null; - $operands[] = new OrderedContainer(BaseType::IDENTIFIER, array(new Identifier('id1'), new Identifier('id2'))); - $operands[] = new OrderedContainer(BaseType::URI, array(new Uri('id3'), new Uri('id4'))); - $operands[] = new Uri('http://www.taotesting.com'); + $operands[] = new OrderedContainer(BaseType::IDENTIFIER, array(new QtiIdentifier('id1'), new QtiIdentifier('id2'))); + $operands[] = new OrderedContainer(BaseType::URI, array(new QtiUri('id3'), new QtiUri('id4'))); + $operands[] = new QtiUri('http://www.taotesting.com'); $operands[] = new OrderedContainer(BaseType::STRING); $processor = new RepeatProcessor($expression, $operands); @@ -90,7 +90,7 @@ public function testWrongBaseTypeOne() { public function testWrongCardinality() { $expression = $this->createFakeExpression(); - $operands = new OperandsCollection(array(new MultipleContainer(BaseType::INTEGER, array(new Integer(10))))); + $operands = new OperandsCollection(array(new MultipleContainer(BaseType::INTEGER, array(new QtiInteger(10))))); $processor = new RepeatProcessor($expression, $operands); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $result = $processor->process(); @@ -98,7 +98,7 @@ public function testWrongCardinality() { public function testWrongBaseTypeTwo() { $expression = $this->createFakeExpression(); - $operands = new OperandsCollection(array(new OrderedContainer(BaseType::INTEGER, array(new Integer(10))), new Float(10.3))); + $operands = new OperandsCollection(array(new OrderedContainer(BaseType::INTEGER, array(new QtiInteger(10))), new QtiFloat(10.3))); $processor = new RepeatProcessor($expression, $operands); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $result = $processor->process(); diff --git a/test/qtismtest/runtime/expressions/operators/RoundProcessorTest.php b/test/qtismtest/runtime/expressions/operators/RoundProcessorTest.php index 1b9a8faa9..7f917d9ea 100644 --- a/test/qtismtest/runtime/expressions/operators/RoundProcessorTest.php +++ b/test/qtismtest/runtime/expressions/operators/RoundProcessorTest.php @@ -2,10 +2,10 @@ namespace qtismtest\runtime\expressions\operators; use qtismtest\QtiSmTestCase; -use qtism\common\datatypes\Boolean; -use qtism\common\datatypes\Integer; -use qtism\common\datatypes\Float; -use qtism\common\datatypes\Duration; +use qtism\common\datatypes\QtiBoolean; +use qtism\common\datatypes\QtiInteger; +use qtism\common\datatypes\QtiFloat; +use qtism\common\datatypes\QtiDuration; use qtism\common\enums\BaseType; use qtism\runtime\common\OrderedContainer; use qtism\runtime\expressions\operators\RoundProcessor; @@ -16,65 +16,65 @@ class RoundProcessorTest extends QtiSmTestCase { public function testRound() { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); - $operands[] = new Float(6.8); + $operands[] = new QtiFloat(6.8); $processor = new RoundProcessor($expression, $operands); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Integer', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiInteger', $result); $this->assertEquals(7, $result->getValue()); $operands->reset(); - $operands[] = new Float(6.5); + $operands[] = new QtiFloat(6.5); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Integer', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiInteger', $result); $this->assertEquals(7, $result->getValue()); $operands->reset(); - $operands[] = new Float(6.49); + $operands[] = new QtiFloat(6.49); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Integer', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiInteger', $result); $this->assertEquals(6, $result->getValue()); $operands->reset(); - $operands[] = new Float(6.5); + $operands[] = new QtiFloat(6.5); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Integer', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiInteger', $result); $this->assertEquals(7, $result->getValue()); $operands->reset(); - $operands[] = new Float(-6.5); + $operands[] = new QtiFloat(-6.5); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Integer', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiInteger', $result); $this->assertEquals(-6, $result->getValue()); $operands->reset(); - $operands[] = new Float(-6.51); + $operands[] = new QtiFloat(-6.51); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Integer', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiInteger', $result); $this->assertEquals(-7, $result->getValue()); $operands->reset(); - $operands[] = new Float(-6.49); + $operands[] = new QtiFloat(-6.49); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Integer', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiInteger', $result); $this->assertEquals(-6, $result->getValue()); $operands->reset(); - $operands[] = new Integer(0); + $operands[] = new QtiInteger(0); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Integer', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiInteger', $result); $this->assertEquals(0, $result->getValue()); $operands->reset(); - $operands[] = new Float(-0.0); + $operands[] = new QtiFloat(-0.0); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Integer', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiInteger', $result); $this->assertEquals(0, $result->getValue()); $operands->reset(); - $operands[] = new Float(-0.5); + $operands[] = new QtiFloat(-0.5); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Integer', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiInteger', $result); $this->assertEquals(0, $result->getValue()); } @@ -90,7 +90,7 @@ public function testNull() { public function testWrongCardinality() { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); - $operands[] = new OrderedContainer(BaseType::FLOAT, array(new Float(1.1), new Float(2.2))); + $operands[] = new OrderedContainer(BaseType::FLOAT, array(new QtiFloat(1.1), new QtiFloat(2.2))); $processor = new RoundProcessor($expression, $operands); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $result = $processor->process(); @@ -99,7 +99,7 @@ public function testWrongCardinality() { public function testWrongBaseTypeOne() { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); - $operands[] = new Boolean(true); + $operands[] = new QtiBoolean(true); $processor = new RoundProcessor($expression, $operands); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $result = $processor->process(); @@ -108,7 +108,7 @@ public function testWrongBaseTypeOne() { public function testWrongBaseTypeTwo() { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); - $operands[] = new Duration('P1D'); + $operands[] = new QtiDuration('P1D'); $processor = new RoundProcessor($expression, $operands); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $result = $processor->process(); @@ -124,8 +124,8 @@ public function testNotEnoughOperands() { public function testTooMuchOperands() { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); - $operands[] = new Integer(10); - $operands[] = new Float(1.1); + $operands[] = new QtiInteger(10); + $operands[] = new QtiFloat(1.1); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $processor = new RoundProcessor($expression, $operands); } diff --git a/test/qtismtest/runtime/expressions/operators/RoundToProcessorTest.php b/test/qtismtest/runtime/expressions/operators/RoundToProcessorTest.php index e1fac1f56..8dbb2cd90 100644 --- a/test/qtismtest/runtime/expressions/operators/RoundToProcessorTest.php +++ b/test/qtismtest/runtime/expressions/operators/RoundToProcessorTest.php @@ -2,9 +2,9 @@ namespace qtismtest\runtime\expressions\operators; use qtismtest\QtiSmTestCase; -use qtism\common\datatypes\Boolean; -use qtism\common\datatypes\Float; -use qtism\common\datatypes\Integer; +use qtism\common\datatypes\QtiBoolean; +use qtism\common\datatypes\QtiFloat; +use qtism\common\datatypes\QtiInteger; use qtism\runtime\common\MultipleContainer; use qtism\common\enums\BaseType; use qtism\runtime\expressions\operators\OperandsCollection; @@ -20,40 +20,40 @@ public function testSignificantFigures() { '); $operands = new OperandsCollection(); - $operands[] = new Integer(1239451); + $operands[] = new QtiInteger(1239451); $processor = new RoundToProcessor($expr, $operands); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $result); $this->assertEquals(round(1240000), round($result->getValue())); - $operands[0] = new Float(12.1257); + $operands[0] = new QtiFloat(12.1257); $processor->setOperands($operands); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $result); $this->assertEquals(round(12.1, 1), round($result->getValue(), 1)); - $operands[0] = new Float(0.0681); + $operands[0] = new QtiFloat(0.0681); $processor->setOperands($operands); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $result); $this->assertEquals(round(0.0681, 4), round($result->getValue(), 4)); - $operands[0] = new Integer(5); + $operands[0] = new QtiInteger(5); $processor->setOperands($operands); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $result); $this->assertEquals(5, $result->getValue()); - $operands[0] = new Integer(0); + $operands[0] = new QtiInteger(0); $processor->setOperands($operands); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $result); $this->assertEquals(0, $result->getValue()); - $operands[0] = new Float(-12.1257); + $operands[0] = new QtiFloat(-12.1257); $processor->setOperands($operands); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $result); $this->assertEquals(round(-12.1, 1), round($result->getValue(), 1)); } @@ -65,42 +65,42 @@ public function testDecimalPlaces() { '); $operands = new OperandsCollection(); - $operands[] = new Float(3.4); + $operands[] = new QtiFloat(3.4); $processor = new RoundToProcessor($expr, $operands); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $result); $this->assertEquals(3, $result->getValue()); - $operands[0] = new Float(3.5); + $operands[0] = new QtiFloat(3.5); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $result); $this->assertEquals(4, $result->getValue()); - $operands[0] = new Float(3.6); + $operands[0] = new QtiFloat(3.6); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $result); $this->assertEquals(4, $result->getValue()); - $operands[0] = new Float(4.0); + $operands[0] = new QtiFloat(4.0); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $result); $this->assertEquals(4, $result->getValue()); $expr->setFigures(2); // We now go for 2 figures... - $operands[0] = new Float(1.95583); + $operands[0] = new QtiFloat(1.95583); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $result); $this->assertEquals(1.96, $result->getValue()); - $operands[0] = new Float(5.045); + $operands[0] = new QtiFloat(5.045); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $result); $this->assertEquals(5.05, $result->getValue()); $expr->setFigures(2); - $operands[0] = new Float(5.055); + $operands[0] = new QtiFloat(5.055); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $result); $this->assertEquals(5.06, $result->getValue()); } @@ -125,7 +125,7 @@ public function testTooMuchOperands() { 3.4 '); - $operands = new OperandsCollection(array(new Integer(4), new Integer(4))); + $operands = new OperandsCollection(array(new QtiInteger(4), new QtiInteger(4))); $processor = new RoundToProcessor($expr, $operands); $result = $processor->process(); } @@ -138,7 +138,7 @@ public function testWrongBaseType() { 3.4 '); - $operands = new OperandsCollection(array(new Boolean(true))); + $operands = new OperandsCollection(array(new QtiBoolean(true))); $processor = new RoundToProcessor($expr, $operands); $result = $processor->process(); } @@ -151,7 +151,7 @@ public function testWrongCardinality() { 3.4 '); - $operands = new OperandsCollection(array(new MultipleContainer(BaseType::INTEGER, array(new Integer(20), new Integer(30), new Integer(40))))); + $operands = new OperandsCollection(array(new MultipleContainer(BaseType::INTEGER, array(new QtiInteger(20), new QtiInteger(30), new QtiInteger(40))))); $processor = new RoundToProcessor($expr, $operands); $result = $processor->process(); } @@ -165,7 +165,7 @@ public function testWrongFiguresOne() { '); - $operands = new OperandsCollection(array(new Float(3.4))); + $operands = new OperandsCollection(array(new QtiFloat(3.4))); $processor = new RoundToProcessor($expr, $operands); $result = $processor->process(); } @@ -178,7 +178,7 @@ public function testWrongFiguresTwo() { 3.4 '); - $operands = new OperandsCollection(array(new Float(3.4))); + $operands = new OperandsCollection(array(new QtiFloat(3.4))); $processor = new RoundToProcessor($expr, $operands); $result = $processor->process(); } @@ -189,7 +189,7 @@ public function testNan() { 3.4 '); - $operands = new OperandsCollection(array(new Float(NAN))); + $operands = new OperandsCollection(array(new QtiFloat(NAN))); $processor = new RoundToProcessor($expr, $operands); $result = $processor->process(); $this->assertTrue(is_null($result)); @@ -201,13 +201,13 @@ public function testInfinity() { 3.4 '); - $operands = new OperandsCollection(array(new Float(INF))); + $operands = new OperandsCollection(array(new QtiFloat(INF))); $processor = new RoundToProcessor($expr, $operands); $result = $processor->process(); $this->assertTrue(is_infinite($result->getValue())); $this->assertTrue(INF === $result->getValue()); - $processor->setOperands(new OperandsCollection(array(new Float(-INF)))); + $processor->setOperands(new OperandsCollection(array(new QtiFloat(-INF)))); $result = $processor->process(); $this->assertTrue(is_infinite($result->getValue())); $this->assertTrue(-INF === $result->getValue()); diff --git a/test/qtismtest/runtime/expressions/operators/StatsOperatorProcessorTest.php b/test/qtismtest/runtime/expressions/operators/StatsOperatorProcessorTest.php index d0773ade7..fb256db6c 100644 --- a/test/qtismtest/runtime/expressions/operators/StatsOperatorProcessorTest.php +++ b/test/qtismtest/runtime/expressions/operators/StatsOperatorProcessorTest.php @@ -2,11 +2,11 @@ namespace qtismtest\runtime\expressions\operators; use qtismtest\QtiSmTestCase; -use qtism\common\datatypes\String; -use qtism\common\datatypes\Float; -use qtism\common\datatypes\Integer; +use qtism\common\datatypes\QtiString; +use qtism\common\datatypes\QtiFloat; +use qtism\common\datatypes\QtiInteger; use qtism\runtime\common\RecordContainer; -use qtism\common\datatypes\Point; +use qtism\common\datatypes\QtiPoint; use qtism\common\collections\Container; use qtism\data\expressions\operators\Statistics; use qtism\runtime\expressions\operators\StatsOperatorProcessor; @@ -132,7 +132,7 @@ public function testNotEnoughOperands() { public function testTooMuchOperands() { $expression = $this->createFakeExpression(Statistics::MEAN); - $operands = new OperandsCollection(array(new OrderedContainer(BaseType::INTEGER, array(new Integer(10))), new MultipleContainer(BaseType::FLOAT, array(new Float(10.0))))); + $operands = new OperandsCollection(array(new OrderedContainer(BaseType::INTEGER, array(new QtiInteger(10))), new MultipleContainer(BaseType::FLOAT, array(new QtiFloat(10.0))))); $this->setExpectedException('qtism\\runtime\\expressions\\operators\\OperatorProcessingException'); $processor = new StatsOperatorProcessor($expression, $operands); } @@ -142,66 +142,66 @@ protected function check($expected, $value) { $this->assertTrue($value === null); } else { - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $value); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $value); $this->assertSame(round($expected, 3), round($value->getValue(), 3)); } } public function meanProvider() { return array( - array(new OrderedContainer(BaseType::FLOAT, array(new Float(10.0), new Float(20.0), new Float(30.0))), 20.0), - array(new MultipleContainer(BaseType::INTEGER, array(new Integer(0))), 0.0), - array(new MultipleContainer(BaseType::FLOAT, array(new Float(10.0), null, new Float(23.3))), null), // contains a null value + array(new OrderedContainer(BaseType::FLOAT, array(new QtiFloat(10.0), new QtiFloat(20.0), new QtiFloat(30.0))), 20.0), + array(new MultipleContainer(BaseType::INTEGER, array(new QtiInteger(0))), 0.0), + array(new MultipleContainer(BaseType::FLOAT, array(new QtiFloat(10.0), null, new QtiFloat(23.3))), null), // contains a null value array(null, null) ); } public function sampleVarianceProvider() { return array( - array(new OrderedContainer(BaseType::FLOAT, array(new Float(10.0))), null), // fails because containerSize <= 1 - array(new MultipleContainer(BaseType::INTEGER, array(new Integer(600), new Integer(470), new Integer(170), new Integer(430), new Integer(300))), 27130), - array(new MultipleContainer(BaseType::FLOAT, array(new Float(10.0), null, new Float(23.3))), null), // contains a null value + array(new OrderedContainer(BaseType::FLOAT, array(new QtiFloat(10.0))), null), // fails because containerSize <= 1 + array(new MultipleContainer(BaseType::INTEGER, array(new QtiInteger(600), new QtiInteger(470), new QtiInteger(170), new QtiInteger(430), new QtiInteger(300))), 27130), + array(new MultipleContainer(BaseType::FLOAT, array(new QtiFloat(10.0), null, new QtiFloat(23.3))), null), // contains a null value array(null, null) ); } public function sampleSDProvider() { return array( - array(new OrderedContainer(BaseType::INTEGER, array(new Integer(10))), null), // containerSize <= 1 - array(new OrderedContainer(BaseType::INTEGER, array(new Integer(600), new Integer(470), new Integer(170), new Integer(430), new Integer(300))), 164.712), - array(new MultipleContainer(BaseType::FLOAT, array(new Float(10.0), null, new Float(23.3))), null), // contains a null value + array(new OrderedContainer(BaseType::INTEGER, array(new QtiInteger(10))), null), // containerSize <= 1 + array(new OrderedContainer(BaseType::INTEGER, array(new QtiInteger(600), new QtiInteger(470), new QtiInteger(170), new QtiInteger(430), new QtiInteger(300))), 164.712), + array(new MultipleContainer(BaseType::FLOAT, array(new QtiFloat(10.0), null, new QtiFloat(23.3))), null), // contains a null value array(null, null) ); } public function popVarianceProvider() { return array( - array(new OrderedContainer(BaseType::INTEGER, array(new Integer(10))), 0), // containerSize <= 1 but applied on a population -> OK. - array(new MultipleContainer(BaseType::INTEGER, array(new Integer(600), new Integer(470), new Integer(170), new Integer(430), new Integer(300))), 21704), - array(new MultipleContainer(BaseType::FLOAT, array(new Float(10.0), null, new Float(23.33333))), null), // contains a null value + array(new OrderedContainer(BaseType::INTEGER, array(new QtiInteger(10))), 0), // containerSize <= 1 but applied on a population -> OK. + array(new MultipleContainer(BaseType::INTEGER, array(new QtiInteger(600), new QtiInteger(470), new QtiInteger(170), new QtiInteger(430), new QtiInteger(300))), 21704), + array(new MultipleContainer(BaseType::FLOAT, array(new QtiFloat(10.0), null, new QtiFloat(23.33333))), null), // contains a null value ); } public function popSDProvider() { return array( - array(new OrderedContainer(BaseType::INTEGER, array(new Integer(10))), 0), // containerSize <= 1 but applied on population - array(new OrderedContainer(BaseType::FLOAT, array(new Float(600.0), new Float(470.0), new Float(170.0), new Float(430.0), new Float(300.0))), 147.323), - array(new MultipleContainer(BaseType::FLOAT, array(new Float(10.0), null, new Float(23.33333))), null), // contains a null value + array(new OrderedContainer(BaseType::INTEGER, array(new QtiInteger(10))), 0), // containerSize <= 1 but applied on population + array(new OrderedContainer(BaseType::FLOAT, array(new QtiFloat(600.0), new QtiFloat(470.0), new QtiFloat(170.0), new QtiFloat(430.0), new QtiFloat(300.0))), 147.323), + array(new MultipleContainer(BaseType::FLOAT, array(new QtiFloat(10.0), null, new QtiFloat(23.33333))), null), // contains a null value ); } public function wrongCardinalityProvider() { return array( - array(array(new Float(25.3))), - array(array(new Integer(-10))), - array(array(new RecordContainer(array('A' => new Integer(1))))), + array(array(new QtiFloat(25.3))), + array(array(new QtiInteger(-10))), + array(array(new RecordContainer(array('A' => new QtiInteger(1))))), ); } public function wrongBaseTypeProvider() { return array( - array(array(new MultipleContainer(BaseType::POINT, array(new Point(1, 2))))), - array(array(new OrderedContainer(BaseType::STRING, array(new String('String!'))))) + array(array(new MultipleContainer(BaseType::POINT, array(new QtiPoint(1, 2))))), + array(array(new OrderedContainer(BaseType::STRING, array(new QtiString('String!'))))) ); } diff --git a/test/qtismtest/runtime/expressions/operators/StringMatchProcessorTest.php b/test/qtismtest/runtime/expressions/operators/StringMatchProcessorTest.php index 6ef63c709..3f445d35f 100644 --- a/test/qtismtest/runtime/expressions/operators/StringMatchProcessorTest.php +++ b/test/qtismtest/runtime/expressions/operators/StringMatchProcessorTest.php @@ -2,8 +2,8 @@ namespace qtismtest\runtime\expressions\operators; use qtismtest\QtiSmTestCase; -use qtism\common\datatypes\Integer; -use qtism\common\datatypes\String; +use qtism\common\datatypes\QtiInteger; +use qtism\common\datatypes\QtiString; use qtism\common\enums\BaseType; use qtism\runtime\common\MultipleContainer; use qtism\runtime\expressions\operators\StringMatchProcessor; @@ -14,41 +14,41 @@ class StringMatchProcessorTest extends QtiSmTestCase { public function testStringMatch() { $expression = $this->createFakeExpression(); - $operands = new OperandsCollection(array(new String('one'), new String('one'))); + $operands = new OperandsCollection(array(new QtiString('one'), new QtiString('one'))); $processor = new StringMatchProcessor($expression, $operands); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Boolean', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiBoolean', $result); $this->assertSame(true, $result->getValue()); - $operands = new OperandsCollection(array(new String('one'), new String('oNe'))); + $operands = new OperandsCollection(array(new QtiString('one'), new QtiString('oNe'))); $processor->setOperands($operands); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Boolean', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiBoolean', $result); $this->assertSame(false, $result->getValue()); $processor->setExpression($this->createFakeExpression(false)); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Boolean', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiBoolean', $result); $this->assertSame(true, $result->getValue()); // Binary-safe? $processor->setExpression($this->createFakeExpression(true)); - $operands = new OperandsCollection(array(new String('它的工作原理'), new String('它的工作原理'))); + $operands = new OperandsCollection(array(new QtiString('它的工作原理'), new QtiString('它的工作原理'))); $processor->setOperands($operands); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Boolean', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiBoolean', $result); $this->assertSame(true, $result->getValue()); - $operands = new OperandsCollection(array(new String('它的工作原理'), new String('它的原理'))); + $operands = new OperandsCollection(array(new QtiString('它的工作原理'), new QtiString('它的原理'))); $processor->setOperands($operands); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Boolean', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiBoolean', $result); $this->assertSame(false, $result->getValue()); } public function testNull() { $expression = $this->createFakeExpression(); - $operands = new OperandsCollection(array(new String(''), null)); + $operands = new OperandsCollection(array(new QtiString(''), null)); $processor = new StringMatchProcessor($expression, $operands); $result = $processor->process(); $this->assertSame(null, $result); @@ -56,7 +56,7 @@ public function testNull() { public function testWrongCardinality() { $expression = $this->createFakeExpression(); - $operands = new OperandsCollection(array(new String('String!'), new MultipleContainer(BaseType::STRING, array(new String('String!'))))); + $operands = new OperandsCollection(array(new QtiString('String!'), new MultipleContainer(BaseType::STRING, array(new QtiString('String!'))))); $processor = new StringMatchProcessor($expression, $operands); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $result = $processor->process(); @@ -64,7 +64,7 @@ public function testWrongCardinality() { public function testWrongBaseType() { $expression = $this->createFakeExpression(); - $operands = new OperandsCollection(array(new String('String!'), new Integer(25))); + $operands = new OperandsCollection(array(new QtiString('String!'), new QtiInteger(25))); $processor = new StringMatchProcessor($expression, $operands); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $result = $processor->process(); @@ -72,14 +72,14 @@ public function testWrongBaseType() { public function testNotEnoughOperands() { $expression = $this->createFakeExpression(); - $operands = new OperandsCollection(array(new String('String!'))); + $operands = new OperandsCollection(array(new QtiString('String!'))); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $processor = new StringMatchProcessor($expression, $operands); } public function testTooMuchOperands() { $expression = $this->createFakeExpression(); - $operands = new OperandsCollection(array(new String('String!'), new String('String!'), new String('String!'))); + $operands = new OperandsCollection(array(new QtiString('String!'), new QtiString('String!'), new QtiString('String!'))); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $processor = new StringMatchProcessor($expression, $operands); } diff --git a/test/qtismtest/runtime/expressions/operators/SubstringProcessorTest.php b/test/qtismtest/runtime/expressions/operators/SubstringProcessorTest.php index c5a16fc19..7d1f4b1bc 100644 --- a/test/qtismtest/runtime/expressions/operators/SubstringProcessorTest.php +++ b/test/qtismtest/runtime/expressions/operators/SubstringProcessorTest.php @@ -2,8 +2,8 @@ namespace qtismtest\runtime\expressions\operators; use qtismtest\QtiSmTestCase; -use qtism\common\datatypes\Integer; -use qtism\common\datatypes\String; +use qtism\common\datatypes\QtiInteger; +use qtism\common\datatypes\QtiString; use qtism\common\enums\BaseType; use qtism\runtime\common\MultipleContainer; use qtism\runtime\expressions\operators\SubstringProcessor; @@ -14,80 +14,80 @@ class SubstringProcessorTest extends QtiSmTestCase { public function testCaseSensitive() { $expression = $this->createFakeExpression(true); $operands = new OperandsCollection(); - $operands[] = new String('hell'); - $operands[] = new String('Shell'); + $operands[] = new QtiString('hell'); + $operands[] = new QtiString('Shell'); $processor = new SubstringProcessor($expression, $operands); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Boolean', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiBoolean', $result); $this->assertTrue($result->getValue()); $operands->reset(); - $operands[] = new String('Hell'); - $operands[] = new String('Shell'); + $operands[] = new QtiString('Hell'); + $operands[] = new QtiString('Shell'); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Boolean', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiBoolean', $result); $this->assertFalse($result->getValue()); } public function testCaseInsensitive() { $expression = $this->createFakeExpression(false); $operands = new OperandsCollection(); - $operands[] = new String('hell'); - $operands[] = new String('Shell'); + $operands[] = new QtiString('hell'); + $operands[] = new QtiString('Shell'); $processor = new SubstringProcessor($expression, $operands); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Boolean', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiBoolean', $result); $this->assertTrue($result->getValue()); $operands->reset(); - $operands[] = new String('Hell'); - $operands[] = new String('Shell'); + $operands[] = new QtiString('Hell'); + $operands[] = new QtiString('Shell'); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Boolean', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiBoolean', $result); $this->assertTrue($result->getValue()); $operands->reset(); - $operands[] = new String('Hello world!'); - $operands[] = new String('Bye world!'); + $operands[] = new QtiString('Hello world!'); + $operands[] = new QtiString('Bye world!'); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Boolean', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiBoolean', $result); $this->assertFalse($result->getValue()); $operands->reset(); - $operands[] = new String('Hello World!'); - $operands[] = new String('hello world!'); + $operands[] = new QtiString('Hello World!'); + $operands[] = new QtiString('hello world!'); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Boolean', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiBoolean', $result); $this->assertTrue($result->getValue()); // Unicode ? x) $operands->reset(); - $operands[] = new String('界您'); - $operands[] = new String('世界您好!'); // Hello World! + $operands[] = new QtiString('界您'); + $operands[] = new QtiString('世界您好!'); // Hello World! $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Boolean', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiBoolean', $result); $this->assertTrue($result->getValue()); $operands->reset(); - $operands[] = new String('假'); // 'Fake' in traditional chinese - $operands[] = new String('世界您好!'); // Hello World! + $operands[] = new QtiString('假'); // 'Fake' in traditional chinese + $operands[] = new QtiString('世界您好!'); // Hello World! $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Boolean', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiBoolean', $result); $this->assertFalse($result->getValue()); } public function testNull() { $expression = $this->createFakeExpression(false); $operands = new OperandsCollection(); - $operands[] = new String('test'); + $operands[] = new QtiString('test'); $operands[] = null; $processor = new SubstringProcessor($expression, $operands); $result = $processor->process(); $this->assertSame(null, $result); $operands->reset(); - $operands[] = new String(''); // in QTI, empty string considered to be NULL. - $operands[] = new String('blah!'); + $operands[] = new QtiString(''); // in QTI, empty string considered to be NULL. + $operands[] = new QtiString('blah!'); $result = $processor->process(); $this->assertSame(null, $result); } @@ -95,8 +95,8 @@ public function testNull() { public function testWrongBaseType() { $expression = $this->createFakeExpression(false); $operands = new OperandsCollection(); - $operands[] = new String('10'); - $operands[] = new Integer(100); + $operands[] = new QtiString('10'); + $operands[] = new QtiInteger(100); $processor = new SubstringProcessor($expression, $operands); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $result = $processor->process(); @@ -105,8 +105,8 @@ public function testWrongBaseType() { public function testWrongCardinality() { $expression = $this->createFakeExpression(false); $operands = new OperandsCollection(); - $operands[] = new String('Wrong Cardinality'); - $operands[] = new MultipleContainer(BaseType::STRING, array(new String('Wrong'), new String('Cardinality'))); + $operands[] = new QtiString('Wrong Cardinality'); + $operands[] = new MultipleContainer(BaseType::STRING, array(new QtiString('Wrong'), new QtiString('Cardinality'))); $processor = new SubstringProcessor($expression, $operands); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $result = $processor->process(); @@ -114,14 +114,14 @@ public function testWrongCardinality() { public function testNotEnoughOperands() { $expression = $this->createFakeExpression(false); - $operands = new OperandsCollection(array(new String('only 1 operand'))); + $operands = new OperandsCollection(array(new QtiString('only 1 operand'))); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $processor = new SubstringProcessor($expression, $operands); } public function testTooMuchOperands() { $expression = $this->createFakeExpression(false); - $operands = new OperandsCollection(array(new String('exactly'), new String('three'), new String('operands'))); + $operands = new OperandsCollection(array(new QtiString('exactly'), new QtiString('three'), new QtiString('operands'))); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $processor = new SubstringProcessor($expression, $operands); } diff --git a/test/qtismtest/runtime/expressions/operators/SubtractProcessorTest.php b/test/qtismtest/runtime/expressions/operators/SubtractProcessorTest.php index d8023ece2..8a6d459c7 100644 --- a/test/qtismtest/runtime/expressions/operators/SubtractProcessorTest.php +++ b/test/qtismtest/runtime/expressions/operators/SubtractProcessorTest.php @@ -2,10 +2,10 @@ namespace qtismtest\runtime\expressions\operators; use qtismtest\QtiSmTestCase; -use qtism\common\datatypes\Float; -use qtism\common\datatypes\Integer; +use qtism\common\datatypes\QtiFloat; +use qtism\common\datatypes\QtiInteger; use qtism\common\enums\BaseType; -use qtism\common\datatypes\Point; +use qtism\common\datatypes\QtiPoint; use qtism\runtime\common\MultipleContainer; use qtism\runtime\expressions\operators\SubtractProcessor; use qtism\runtime\expressions\operators\OperandsCollection; @@ -14,22 +14,22 @@ class SubtractProcessorTest extends QtiSmTestCase { public function testSubtract() { $expression = $this->createFakeExpression(); - $operands = new OperandsCollection(array(new Integer(10), new Integer(256))); + $operands = new OperandsCollection(array(new QtiInteger(10), new QtiInteger(256))); $processor = new SubtractProcessor($expression, $operands); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Integer', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiInteger', $result); $this->assertEquals(-246, $result->getValue()); - $operands = new OperandsCollection(array(new Float(-5.0), new Integer(-10))); + $operands = new OperandsCollection(array(new QtiFloat(-5.0), new QtiInteger(-10))); $processor->setOperands($operands); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $result); $this->assertEquals(5, $result->getValue()); } public function testNull() { $expression = $this->createFakeExpression(); - $operands = new OperandsCollection(array(new Integer(10), null)); + $operands = new OperandsCollection(array(new QtiInteger(10), null)); $processor = new SubtractProcessor($expression, $operands); $result = $processor->process(); $this->assertSame(null, $result); @@ -42,7 +42,7 @@ public function testNull() { public function testWrongBaseType() { $expression = $this->createFakeExpression(); - $operands = new OperandsCollection(array(new Integer(10), new Point(1, 2))); + $operands = new OperandsCollection(array(new QtiInteger(10), new QtiPoint(1, 2))); $processor = new SubtractProcessor($expression, $operands); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $result = $processor->process(); @@ -50,7 +50,7 @@ public function testWrongBaseType() { public function testWrongCardinality() { $expression = $this->createFakeExpression(); - $operands = new OperandsCollection(array(new MultipleContainer(BaseType::INTEGER, array(new Integer(10))), new Integer(20))); + $operands = new OperandsCollection(array(new MultipleContainer(BaseType::INTEGER, array(new QtiInteger(10))), new QtiInteger(20))); $processor = new SubtractProcessor($expression, $operands); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $result = $processor->process(); @@ -65,7 +65,7 @@ public function testNotEnoughOperands() { public function testTooMuchOperands() { $expression = $this->createFakeExpression(); - $operands = new OperandsCollection(array(new Integer(10), new Integer(20), new Integer(30), new Integer(40))); + $operands = new OperandsCollection(array(new QtiInteger(10), new QtiInteger(20), new QtiInteger(30), new QtiInteger(40))); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $processor = new SubtractProcessor($expression, $operands); } diff --git a/test/qtismtest/runtime/expressions/operators/SumProcessorTest.php b/test/qtismtest/runtime/expressions/operators/SumProcessorTest.php index 1b7eca35e..a1992d0b2 100644 --- a/test/qtismtest/runtime/expressions/operators/SumProcessorTest.php +++ b/test/qtismtest/runtime/expressions/operators/SumProcessorTest.php @@ -2,9 +2,9 @@ namespace qtismtest\runtime\expressions\operators; use qtismtest\QtiSmTestCase; -use qtism\common\datatypes\Boolean; -use qtism\common\datatypes\Float; -use qtism\common\datatypes\Integer; +use qtism\common\datatypes\QtiBoolean; +use qtism\common\datatypes\QtiFloat; +use qtism\common\datatypes\QtiInteger; use qtism\common\enums\BaseType; use qtism\runtime\common\MultipleContainer; use qtism\runtime\common\OrderedContainer; @@ -16,47 +16,47 @@ class SumProcessorTest extends QtiSmTestCase { public function testSimple() { $sum = $this->createFakeSumComponent(); - $operands = new OperandsCollection(array(new Integer(1), new Integer(1))); + $operands = new OperandsCollection(array(new QtiInteger(1), new QtiInteger(1))); $sumProcessor = new SumProcessor($sum, $operands); $result = $sumProcessor->process(); $this->assertInstanceOf('qtism\\runtime\\common\\Processable', $sumProcessor); - $this->assertInstanceOf('qtism\\common\\datatypes\\Integer', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiInteger', $result); $this->assertEquals(2, $result->getValue()); } public function testNary() { $sum = $this->createFakeSumComponent(); - $operands = new OperandsCollection(array(new Integer(24), new Integer(-4), new Integer(0))); + $operands = new OperandsCollection(array(new QtiInteger(24), new QtiInteger(-4), new QtiInteger(0))); $sumProcessor = new SumProcessor($sum, $operands); $result = $sumProcessor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Integer', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiInteger', $result); $this->assertEquals(20, $result->getValue()); } public function testComplex() { $sum = $this->createFakeSumComponent(); - $operands = new OperandsCollection(array(new Integer(-1), new Integer(1))); - $operands[] = new MultipleContainer(BaseType::FLOAT, array(new Float(2.1), new Float(4.3))); - $operands[] = new OrderedContainer(BaseType::INTEGER, array(new Integer(10), new Integer(15))); + $operands = new OperandsCollection(array(new QtiInteger(-1), new QtiInteger(1))); + $operands[] = new MultipleContainer(BaseType::FLOAT, array(new QtiFloat(2.1), new QtiFloat(4.3))); + $operands[] = new OrderedContainer(BaseType::INTEGER, array(new QtiInteger(10), new QtiInteger(15))); $sumProcessor = new SumProcessor($sum, $operands); $result = $sumProcessor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $result); $this->assertEquals(31.4, $result->getValue()); } public function testZero() { $sum = $this->createFakeSumComponent(); - $operands = new OperandsCollection(array(new Integer(0), new Float(6.0))); + $operands = new OperandsCollection(array(new QtiInteger(0), new QtiFloat(6.0))); $sumProcessor = new SumProcessor($sum, $operands); $result = $sumProcessor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $result); $this->assertEquals(6.0, $result->getValue()); } @@ -65,7 +65,7 @@ public function testInvalidOperandsOne() { $this->setExpectedException('\\RuntimeException'); - $operands = new OperandsCollection(array(new Boolean(true), new Integer(14), new Integer(10))); + $operands = new OperandsCollection(array(new QtiBoolean(true), new QtiInteger(14), new QtiInteger(10))); $sumProcessor = new SumProcessor($sum, $operands); $result = $sumProcessor->process(); } @@ -73,7 +73,7 @@ public function testInvalidOperandsOne() { public function testInvalidOperandsTwo() { $sum = $this->createFakeSumComponent(); $operands = new OperandsCollection(); - $operands[] = new MultipleContainer(BaseType::BOOLEAN, array(new Boolean(true), new Boolean(false))); + $operands[] = new MultipleContainer(BaseType::BOOLEAN, array(new QtiBoolean(true), new QtiBoolean(false))); $sumProcessor = new SumProcessor($sum, $operands); $this->setExpectedException('\\RuntimeException'); @@ -82,7 +82,7 @@ public function testInvalidOperandsTwo() { public function testNullInvolved() { $sum = $this->createFakeSumComponent(); - $operands = new OperandsCollection(array(new Integer(10), new Integer(10), null)); + $operands = new OperandsCollection(array(new QtiInteger(10), new QtiInteger(10), null)); $sumProcessor = new SumProcessor($sum, $operands); $result = $sumProcessor->process(); $this->assertTrue($result === null); diff --git a/test/qtismtest/runtime/expressions/operators/TruncateProcessorTest.php b/test/qtismtest/runtime/expressions/operators/TruncateProcessorTest.php index 5c5009c36..607a52be2 100644 --- a/test/qtismtest/runtime/expressions/operators/TruncateProcessorTest.php +++ b/test/qtismtest/runtime/expressions/operators/TruncateProcessorTest.php @@ -2,10 +2,10 @@ namespace qtismtest\runtime\expressions\operators; use qtismtest\QtiSmTestCase; -use qtism\common\datatypes\Boolean; -use qtism\common\datatypes\Integer; -use qtism\common\datatypes\Float; -use qtism\common\datatypes\Duration; +use qtism\common\datatypes\QtiBoolean; +use qtism\common\datatypes\QtiInteger; +use qtism\common\datatypes\QtiFloat; +use qtism\common\datatypes\QtiDuration; use qtism\common\enums\BaseType; use qtism\runtime\common\OrderedContainer; use qtism\runtime\expressions\operators\TruncateProcessor; @@ -16,88 +16,88 @@ class TruncateProcessorTest extends QtiSmTestCase { public function testRound() { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); - $operands[] = new Float(6.8); + $operands[] = new QtiFloat(6.8); $processor = new TruncateProcessor($expression, $operands); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Integer', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiInteger', $result); $this->assertEquals(6, $result->getValue()); $operands->reset(); - $operands[] = new Float(6.5); + $operands[] = new QtiFloat(6.5); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Integer', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiInteger', $result); $this->assertEquals(6, $result->getValue()); $operands->reset(); - $operands[] = new Float(6.49); + $operands[] = new QtiFloat(6.49); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Integer', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiInteger', $result); $this->assertEquals(6, $result->getValue()); $operands->reset(); - $operands[] = new Float(-6.5); + $operands[] = new QtiFloat(-6.5); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Integer', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiInteger', $result); $this->assertEquals(-6, $result->getValue()); $operands->reset(); - $operands[] = new Float(-6.8); + $operands[] = new QtiFloat(-6.8); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Integer', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiInteger', $result); $this->assertEquals(-6, $result->getValue()); $operands->reset(); - $operands[] = new Float(-6.49); + $operands[] = new QtiFloat(-6.49); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Integer', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiInteger', $result); $this->assertEquals(-6, $result->getValue()); $operands->reset(); - $operands[] = new Integer(0); + $operands[] = new QtiInteger(0); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Integer', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiInteger', $result); $this->assertEquals(0, $result->getValue()); $operands->reset(); - $operands[] = new Float(-0.0); + $operands[] = new QtiFloat(-0.0); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Integer', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiInteger', $result); $this->assertEquals(0, $result->getValue()); $operands->reset(); - $operands[] = new Float(-0.5); + $operands[] = new QtiFloat(-0.5); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Integer', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiInteger', $result); $this->assertEquals(0, $result->getValue()); $operands->reset(); - $operands[] = new Float(-0.4); + $operands[] = new QtiFloat(-0.4); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Integer', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiInteger', $result); $this->assertEquals(0, $result->getValue()); $operands->reset(); - $operands[] = new Float(-0.6); + $operands[] = new QtiFloat(-0.6); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Integer', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiInteger', $result); $this->assertEquals(0, $result->getValue()); $operands->reset(); - $operands[] = new Float(NAN); + $operands[] = new QtiFloat(NAN); $result = $processor->process(); $this->assertSame(null, $result); $operands->reset(); - $operands[] = new Float(-INF); + $operands[] = new QtiFloat(-INF); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $result); $this->assertEquals(-INF, $result->getValue()); $operands->reset(); - $operands[] = new Float(INF); + $operands[] = new QtiFloat(INF); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $result); $this->assertEquals(INF, $result->getValue()); } @@ -113,7 +113,7 @@ public function testNull() { public function testWrongCardinality() { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); - $operands[] = new OrderedContainer(BaseType::FLOAT, array(new Float(1.1), new Float(2.2))); + $operands[] = new OrderedContainer(BaseType::FLOAT, array(new QtiFloat(1.1), new QtiFloat(2.2))); $processor = new TruncateProcessor($expression, $operands); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $result = $processor->process(); @@ -122,7 +122,7 @@ public function testWrongCardinality() { public function testWrongBaseTypeOne() { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); - $operands[] = new Boolean(true); + $operands[] = new QtiBoolean(true); $processor = new TruncateProcessor($expression, $operands); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $result = $processor->process(); @@ -131,7 +131,7 @@ public function testWrongBaseTypeOne() { public function testWrongBaseTypeTwo() { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); - $operands[] = new Duration('P1D'); + $operands[] = new QtiDuration('P1D'); $processor = new TruncateProcessor($expression, $operands); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $result = $processor->process(); @@ -147,8 +147,8 @@ public function testNotEnoughOperands() { public function testTooMuchOperands() { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); - $operands[] = new Integer(10); - $operands[] = new Float(1.1); + $operands[] = new QtiInteger(10); + $operands[] = new QtiFloat(1.1); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException'); $processor = new TruncateProcessor($expression, $operands); } diff --git a/test/qtismtest/runtime/expressions/operators/custom/ExplodeTest.php b/test/qtismtest/runtime/expressions/operators/custom/ExplodeTest.php index 7c941e8a1..0a5968668 100644 --- a/test/qtismtest/runtime/expressions/operators/custom/ExplodeTest.php +++ b/test/qtismtest/runtime/expressions/operators/custom/ExplodeTest.php @@ -5,9 +5,9 @@ use qtism\common\enums\BaseType; use qtism\runtime\common\MultipleContainer; use qtism\runtime\common\RecordContainer; -use qtism\common\datatypes\Point; -use qtism\common\datatypes\Integer; -use qtism\common\datatypes\String; +use qtism\common\datatypes\QtiPoint; +use qtism\common\datatypes\QtiInteger; +use qtism\common\datatypes\QtiString; use qtism\runtime\expressions\operators\OperatorProcessingException; use qtism\runtime\expressions\operators\custom\Explode; use qtism\runtime\expressions\operators\OperandsCollection; @@ -26,7 +26,7 @@ public function testNotEnoughOperandsOne() { public function testNotEnoughOperandsTwo() { $expression = $this->createFakeExpression(); - $operands = new OperandsCollection(array(new String('Hello-World!'))); + $operands = new OperandsCollection(array(new QtiString('Hello-World!'))); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException', "The 'qtism.runtime.expressions.operators.custom.Explode' custom operator takes 2 sub-expressions as parameters, 1 given.", OperatorProcessingException::NOT_ENOUGH_OPERANDS); @@ -36,7 +36,7 @@ public function testNotEnoughOperandsTwo() { public function testWrongBaseType() { $expression = $this->createFakeExpression(); - $operands = new OperandsCollection(array(new Integer(2), new Point(0, 0))); + $operands = new OperandsCollection(array(new QtiInteger(2), new QtiPoint(0, 0))); $processor = new Explode($expression, $operands); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException', "The 'qtism.runtime.expressions.operators.custom.Explode' custom operator only accepts operands with a string baseType.", @@ -46,7 +46,7 @@ public function testWrongBaseType() { public function testWrongCardinality() { $expression = $this->createFakeExpression(); - $operands = new OperandsCollection(array(new RecordContainer(array('a' => new String('String!'))), new String('Hey!'))); + $operands = new OperandsCollection(array(new RecordContainer(array('a' => new QtiString('String!'))), new QtiString('Hey!'))); $processor = new Explode($expression, $operands); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException', "The 'qtism.runtime.expressions.operators.custom.Explode' custom operator only accepts operands with single cardinality.", @@ -66,7 +66,7 @@ public function testNullOperands() { public function testExplodeOne() { $expression = $this->createFakeExpression(); - $operands = new OperandsCollection(array(new String('-'), new String('Hello-World-This-Is-Me'))); + $operands = new OperandsCollection(array(new QtiString('-'), new QtiString('Hello-World-This-Is-Me'))); $processor = new Explode($expression, $operands); $result = $processor->process(); @@ -78,7 +78,7 @@ public function testExplodeOne() { public function testExplodeTwo() { // Specific case, the delimiter is not found in the original string. $expression = $this->createFakeExpression(); - $operands = new OperandsCollection(array(new String('-'), new String('Hello World!'))); + $operands = new OperandsCollection(array(new QtiString('-'), new QtiString('Hello World!'))); $processor = new Explode($expression, $operands); $result = $processor->process(); @@ -89,7 +89,7 @@ public function testExplodeTwo() { public function testExplodeThree() { $expression = $this->createFakeExpression(); - $operands = new OperandsCollection(array(new String(' '), new String('Hello World!'))); + $operands = new OperandsCollection(array(new QtiString(' '), new QtiString('Hello World!'))); $processor = new Explode($expression, $operands); $result = $processor->process(); diff --git a/test/qtismtest/runtime/expressions/operators/custom/ImplodeTest.php b/test/qtismtest/runtime/expressions/operators/custom/ImplodeTest.php index 14ce5e18d..af8f9ea3d 100644 --- a/test/qtismtest/runtime/expressions/operators/custom/ImplodeTest.php +++ b/test/qtismtest/runtime/expressions/operators/custom/ImplodeTest.php @@ -2,14 +2,14 @@ namespace qtismtest\runtime\expressions\operators\custom; use qtismtest\QtiSmTestCase; -use qtism\common\datatypes\Point; -use qtism\common\datatypes\Integer; +use qtism\common\datatypes\QtiPoint; +use qtism\common\datatypes\QtiInteger; use qtism\runtime\common\OrderedContainer; use qtism\runtime\expressions\operators\OperatorProcessingException; use qtism\runtime\expressions\operators\custom\Implode; use qtism\common\enums\BaseType; use qtism\runtime\common\MultipleContainer; -use qtism\common\datatypes\String; +use qtism\common\datatypes\QtiString; use qtism\runtime\expressions\operators\OperandsCollection; class ImplodeProcessorTest extends QtiSmTestCase { @@ -26,7 +26,7 @@ public function testNotEnoughOperandsOne() { public function testNotEnoughOperandsTwo() { $expression = $this->createFakeExpression(); - $operands = new OperandsCollection(array(new String('Hello-World!'))); + $operands = new OperandsCollection(array(new QtiString('Hello-World!'))); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException', "The 'qtism.runtime.expressions.operators.custom.Implode' custom operator takes 2 sub-expressions as parameters, 1 given.", OperatorProcessingException::NOT_ENOUGH_OPERANDS); @@ -36,7 +36,7 @@ public function testNotEnoughOperandsTwo() { public function testWrongBaseType() { $expression = $this->createFakeExpression(); - $operands = new OperandsCollection(array(new Integer(2), new Point(0, 0))); + $operands = new OperandsCollection(array(new QtiInteger(2), new QtiPoint(0, 0))); $processor = new Implode($expression, $operands); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException', "The 'qtism.runtime.expressions.operators.custom.Implode' custom operator only accepts operands with a string baseType.", @@ -46,7 +46,7 @@ public function testWrongBaseType() { public function testWrongCardinalityOne() { $expression = $this->createFakeExpression(); - $operands = new OperandsCollection(array(new MultipleContainer(BaseType::STRING, array(new String('String!'))), new String('Hello World!'))); + $operands = new OperandsCollection(array(new MultipleContainer(BaseType::STRING, array(new QtiString('String!'))), new QtiString('Hello World!'))); $processor = new Implode($expression, $operands); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException', "The 'qtism.runtime.expressions.operators.custom.Implode' custom operator only accepts a first operand with single cardinality.", @@ -56,7 +56,7 @@ public function testWrongCardinalityOne() { public function testWrongCardinalityTwo() { $expression = $this->createFakeExpression(); - $operands = new OperandsCollection(array(new String('-'), new String('Hello-World!'))); + $operands = new OperandsCollection(array(new QtiString('-'), new QtiString('Hello-World!'))); $processor = new Implode($expression, $operands); $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException', "The 'qtism.runtime.expressions.operators.custom.Implode' custom operator only accepts a second operand with multiple or ordered cardinality.", @@ -67,7 +67,7 @@ public function testWrongCardinalityTwo() { public function testNullOperands() { $expression = $this->createFakeExpression(); - $operands = new OperandsCollection(array(new String(''), null)); + $operands = new OperandsCollection(array(new QtiString(''), null)); $processor = new Implode($expression, $operands); $result = $processor->process(); $this->assertSame(null, $result); @@ -75,11 +75,11 @@ public function testNullOperands() { public function testImplodeOne() { $expression = $this->createFakeExpression(); - $operands = new OperandsCollection(array(new String('-'), new MultipleContainer(BaseType::STRING, array(new String('Hello'), new String('World'))))); + $operands = new OperandsCollection(array(new QtiString('-'), new MultipleContainer(BaseType::STRING, array(new QtiString('Hello'), new QtiString('World'))))); $processor = new Implode($expression, $operands); $result = $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\String', $result); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiString', $result); $this->assertEquals('Hello-World', $result->getValue()); } diff --git a/test/qtismtest/runtime/expressions/operators/custom/org/qtism/test/Explode.php b/test/qtismtest/runtime/expressions/operators/custom/org/qtism/test/Explode.php index 4b9a92c5a..02b4eb931 100644 --- a/test/qtismtest/runtime/expressions/operators/custom/org/qtism/test/Explode.php +++ b/test/qtismtest/runtime/expressions/operators/custom/org/qtism/test/Explode.php @@ -3,7 +3,7 @@ use qtism\common\enums\BaseType; use qtism\runtime\common\OrderedContainer; -use qtism\common\datatypes\String; +use qtism\common\datatypes\QtiString; use qtism\runtime\expressions\operators\OperatorProcessingException; use qtism\runtime\expressions\operators\OperandsCollection; use qtism\runtime\expressions\operators\CustomOperatorProcessor; @@ -52,7 +52,7 @@ public function process() { $ordered = new OrderedContainer(BaseType::STRING); foreach ($strings as $str) { - $ordered[] = new String($str); + $ordered[] = new QtiString($str); } return $ordered; diff --git a/test/qtismtest/runtime/pci/json/JsonMarshallerTest.php b/test/qtismtest/runtime/pci/json/JsonMarshallerTest.php index cfd93bddd..8431f1e70 100644 --- a/test/qtismtest/runtime/pci/json/JsonMarshallerTest.php +++ b/test/qtismtest/runtime/pci/json/JsonMarshallerTest.php @@ -12,19 +12,19 @@ use qtism\runtime\common\OrderedContainer; use qtism\common\enums\BaseType; use qtism\runtime\common\MultipleContainer; -use qtism\common\datatypes\Duration; -use qtism\common\datatypes\DirectedPair; -use qtism\common\datatypes\Pair; -use qtism\common\datatypes\Point; -use qtism\common\datatypes\Uri; -use qtism\common\datatypes\IntOrIdentifier; -use qtism\common\datatypes\Identifier; -use qtism\common\datatypes\String; -use qtism\common\datatypes\Float; -use qtism\common\datatypes\Integer; +use qtism\common\datatypes\QtiDuration; +use qtism\common\datatypes\QtiDirectedPair; +use qtism\common\datatypes\QtiPair; +use qtism\common\datatypes\QtiPoint; +use qtism\common\datatypes\QtiUri; +use qtism\common\datatypes\QtiIntOrIdentifier; +use qtism\common\datatypes\QtiIdentifier; +use qtism\common\datatypes\QtiString; +use qtism\common\datatypes\QtiFloat; +use qtism\common\datatypes\QtiInteger; use qtism\common\datatypes\QtiDatatype; use qtism\runtime\pci\json\Marshaller; -use qtism\common\datatypes\Boolean; +use qtism\common\datatypes\QtiBoolean; class JsonMarshallerTest extends QtiSmTestCase { @@ -107,22 +107,22 @@ public function testMarshallInvalidInput($input) { public function testMarshallAsArray() { $marshaller = new Marshaller(); - $data = $marshaller->marshall(new Integer(12), Marshaller::MARSHALL_ARRAY); + $data = $marshaller->marshall(new QtiInteger(12), Marshaller::MARSHALL_ARRAY); $this->assertEquals(12, $data['base']['integer']); } public function marshallScalarProvider() { return array( - array(new Boolean(true), json_encode(array('base' => array('boolean' => true)))), - array(new Boolean(false), json_encode(array('base' => array('boolean' => false)))), - array(new Integer(1337), json_encode(array('base' => array('integer' => 1337)))), - array(new Float(1337.1337), json_encode(array('base' => array('float' => 1337.1337)))), - array(new String("String!"), json_encode(array('base' => array('string' => "String!")))), - array(new String(""), json_encode(array('base' => array('string' => "")))), - array(new Identifier("RESP_X32"), json_encode(array('base' => array('identifier' => "RESP_X32")))), - array(new IntOrIdentifier("RESP_X33"), json_encode(array('base' => array('intOrIdentifier' => "RESP_X33")))), - array(new IntOrIdentifier(1337), json_encode(array('base' => array('intOrIdentifier' => 1337)))), - array(new Uri('http://www.taotesting.com'), json_encode(array('base' => array('uri' => 'http://www.taotesting.com')))), + array(new QtiBoolean(true), json_encode(array('base' => array('boolean' => true)))), + array(new QtiBoolean(false), json_encode(array('base' => array('boolean' => false)))), + array(new QtiInteger(1337), json_encode(array('base' => array('integer' => 1337)))), + array(new QtiFloat(1337.1337), json_encode(array('base' => array('float' => 1337.1337)))), + array(new QtiString("String!"), json_encode(array('base' => array('string' => "String!")))), + array(new QtiString(""), json_encode(array('base' => array('string' => "")))), + array(new QtiIdentifier("RESP_X32"), json_encode(array('base' => array('identifier' => "RESP_X32")))), + array(new QtiIntOrIdentifier("RESP_X33"), json_encode(array('base' => array('intOrIdentifier' => "RESP_X33")))), + array(new QtiIntOrIdentifier(1337), json_encode(array('base' => array('intOrIdentifier' => 1337)))), + array(new QtiUri('http://www.taotesting.com'), json_encode(array('base' => array('uri' => 'http://www.taotesting.com')))), array(null, json_encode(array('base' => null))) ); } @@ -131,10 +131,10 @@ public function marshallComplexProvider() { $samples = self::samplesDir(); $returnValue = array(); - $returnValue[] = array(new Point(10, 20), json_encode(array('base' => array('point' => array(10, 20))))); - $returnValue[] = array(new Pair('A', 'B'), json_encode(array('base' => array('pair' => array('A', 'B'))))); - $returnValue[] = array(new DirectedPair('a', 'b'), json_encode(array('base' => array('directedPair' => array('a', 'b'))))); - $returnValue[] = array(new Duration('P3DT4H'), json_encode(array('base' => array('duration' => 'P3DT4H')))); + $returnValue[] = array(new QtiPoint(10, 20), json_encode(array('base' => array('point' => array(10, 20))))); + $returnValue[] = array(new QtiPair('A', 'B'), json_encode(array('base' => array('pair' => array('A', 'B'))))); + $returnValue[] = array(new QtiDirectedPair('a', 'b'), json_encode(array('base' => array('directedPair' => array('a', 'b'))))); + $returnValue[] = array(new QtiDuration('P3DT4H'), json_encode(array('base' => array('duration' => 'P3DT4H')))); $file = new FileSystemFile($samples . 'datatypes/file/text-plain_text_data.txt'); $returnValue[] = array($file, json_encode(array('base' => array('file' => array('mime' => $file->getMimeType(), 'data' => base64_encode($file->getData()), 'name' => 'text.txt'))))); @@ -154,12 +154,12 @@ public function marshallMultipleProvider() { $returnValue[] = array($container, $json); // bool multiple(true, false, true). - $container = new MultipleContainer(BaseType::BOOLEAN, array(new Boolean(true), new Boolean(false), new Boolean(true))); + $container = new MultipleContainer(BaseType::BOOLEAN, array(new QtiBoolean(true), new QtiBoolean(false), new QtiBoolean(true))); $json = json_encode(array('list' => array('boolean' => array(true, false, true)))); $returnValue[] = array($container, $json); // bool multiple(true, null, false). - $container = new MultipleContainer(BaseType::BOOLEAN, array(new Boolean(true), null, new Boolean(false))); + $container = new MultipleContainer(BaseType::BOOLEAN, array(new QtiBoolean(true), null, new QtiBoolean(false))); $json = json_encode(array('list' => array('boolean' => array(true, null, false)))); $returnValue[] = array($container, $json); @@ -169,52 +169,52 @@ public function marshallMultipleProvider() { $returnValue[] = array($container, $json); // integer multiple(2, 3, 5, 7, 11, 13). - $container = new MultipleContainer(BaseType::INTEGER, array(new Integer(2), new Integer(3), new Integer(5), new Integer(7), new Integer(11), new Integer(13))); + $container = new MultipleContainer(BaseType::INTEGER, array(new QtiInteger(2), new QtiInteger(3), new QtiInteger(5), new QtiInteger(7), new QtiInteger(11), new QtiInteger(13))); $json = json_encode(array('list' => array('integer' => array(2, 3, 5, 7, 11, 13)))); $returnValue[] = array($container, $json); // float multiple(3.1415926, 12.34, 98.76). - $container = new MultipleContainer(BaseType::FLOAT, array(new Float(3.1415926), new Float(12.34), new Float(98.76))); + $container = new MultipleContainer(BaseType::FLOAT, array(new QtiFloat(3.1415926), new QtiFloat(12.34), new QtiFloat(98.76))); $json = json_encode(array('list' => array('float' => array(3.1415926, 12.34, 98.76)))); $returnValue[] = array($container, $json); // string multiple("Another", "And Another"). - $container = new MultipleContainer(BaseType::STRING, array(new String("Another"), new String("And another"))); + $container = new MultipleContainer(BaseType::STRING, array(new QtiString("Another"), new QtiString("And another"))); $json = json_encode(array('list' => array('string' => array("Another", "And another")))); $returnValue[] = array($container, $json); // point multiple(point(123, 456), point(640, 480)). - $container = new MultipleContainer(BaseType::POINT, array(new Point(123, 456), new Point(640, 480))); + $container = new MultipleContainer(BaseType::POINT, array(new QtiPoint(123, 456), new QtiPoint(640, 480))); $json = json_encode(array('list' => array('point' => array(array(123, 456), array(640, 480))))); $returnValue[] = array($container, $json); // pair multiple(pair(A, B), pair(C, D)). - $container = new MultipleContainer(BaseType::PAIR, array(new Pair('A', 'B'), new Pair('D', 'C'))); + $container = new MultipleContainer(BaseType::PAIR, array(new QtiPair('A', 'B'), new QtiPair('D', 'C'))); $json = json_encode(array('list' => array('pair' => array(array('A', 'B'), array('D', 'C'))))); $returnValue[] = array($container, $json); // pair multiple(pair(A, B), pair(C, D)). - $container = new MultipleContainer(BaseType::DIRECTED_PAIR, array(new DirectedPair('A', 'B'), new DirectedPair('D', 'C'))); + $container = new MultipleContainer(BaseType::DIRECTED_PAIR, array(new QtiDirectedPair('A', 'B'), new QtiDirectedPair('D', 'C'))); $json = json_encode(array('list' => array('directedPair' => array(array('A', 'B'), array('D', 'C'))))); $returnValue[] = array($container, $json); // duration multiple("P3Y67M", "P4Y"). - $container = new MultipleContainer(BaseType::DURATION, array(new Duration('P3Y7M'), new Duration('P4Y'))); + $container = new MultipleContainer(BaseType::DURATION, array(new QtiDuration('P3Y7M'), new QtiDuration('P4Y'))); $json = json_encode(array('list' => array('duration' => array('P3Y7M', 'P4Y')))); $returnValue[] = array($container, $json); // uri multiple("file:///aFile.txt", "file:///abc.txt"). - $container = new MultipleContainer(BaseType::URI, array(new Uri('file:///aFile.txt'), new Uri('file:///abc.txt'))); + $container = new MultipleContainer(BaseType::URI, array(new QtiUri('file:///aFile.txt'), new QtiUri('file:///abc.txt'))); $json = json_encode(array('list' => array('uri' => array('file:///aFile.txt', 'file:///abc.txt')))); $returnValue[] = array($container, $json); // intOrIdentifier multiple(2, "_id"). - $container = new MultipleContainer(BaseType::INT_OR_IDENTIFIER, array(new IntOrIdentifier(2), new IntOrIdentifier('_id'))); + $container = new MultipleContainer(BaseType::INT_OR_IDENTIFIER, array(new QtiIntOrIdentifier(2), new QtiIntOrIdentifier('_id'))); $json = json_encode(array('list' => array('intOrIdentifier' => array(2, '_id')))); $returnValue[] = array($container, $json); // identifier multiple('_id1', 'id2', 'ID3'). - $container = new MultipleContainer(BaseType::IDENTIFIER, array(new Identifier('_id1'), new Identifier('id2'), new Identifier('ID3'))); + $container = new MultipleContainer(BaseType::IDENTIFIER, array(new QtiIdentifier('_id1'), new QtiIdentifier('id2'), new QtiIdentifier('ID3'))); $json = json_encode(array('list' => array('identifier' => array('_id1', 'id2', 'ID3')))); $returnValue[] = array($container, $json); @@ -230,12 +230,12 @@ public function marshallOrderedProvider() { $returnValue[] = array($container, $json); // bool multiple(true, false, true). - $container = new OrderedContainer(BaseType::BOOLEAN, array(new Boolean(true), new Boolean(false), new Boolean(true))); + $container = new OrderedContainer(BaseType::BOOLEAN, array(new QtiBoolean(true), new QtiBoolean(false), new QtiBoolean(true))); $json = json_encode(array('list' => array('boolean' => array(true, false, true)))); $returnValue[] = array($container, $json); // bool multiple(true, null, false) - $container = new OrderedContainer(BaseType::BOOLEAN, array(new Boolean(true), null, new Boolean(false))); + $container = new OrderedContainer(BaseType::BOOLEAN, array(new QtiBoolean(true), null, new QtiBoolean(false))); $json = json_encode(array('list' => array('boolean' => array(true, null, false)))); $returnValue[] = array($container, $json); @@ -256,7 +256,7 @@ public function marshallRecordProvider() { $returnValue[] = array($record, $json); // single boolean value record. - $record = new RecordContainer(array('rock' => new Boolean(true))); + $record = new RecordContainer(array('rock' => new QtiBoolean(true))); $json = json_encode(array('record' => array(array('name' => 'rock', 'base' => array('boolean' => true))))); $returnValue[] = array($record, $json); @@ -266,7 +266,7 @@ public function marshallRecordProvider() { $returnValue[] = array($record, $json); // miscellaneous record. - $record = new RecordContainer(array('numeric' => new Float(1337.1337), 'null' => null, 'coordinates' => new Point(10, 20))); + $record = new RecordContainer(array('numeric' => new QtiFloat(1337.1337), 'null' => null, 'coordinates' => new QtiPoint(10, 20))); $json = json_encode(array('record' => array(array('name' => 'numeric', 'base' => array('float' => 1337.1337)), array('name' => 'null', 'base' => null), array('name' => 'coordinates', 'base' => array('point' => array(10, 20)))))); $returnValue[] = array($record, $json); @@ -282,22 +282,22 @@ public function marshallStateProvider() { $returnValue[] = array($state, $json); // simple state. - $state = new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('ChoiceA')))); + $state = new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('ChoiceA')))); $json = json_encode(array('RESPONSE' => array('base' => array('identifier' => 'ChoiceA')))); $returnValue[] = array($state, $json); // complex state 1. $state = new State(); - $state->setVariable(new ResponseVariable('RESPONSE1', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('ChoiceA'))); + $state->setVariable(new ResponseVariable('RESPONSE1', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('ChoiceA'))); $state->setVariable(new ResponseVariable('RESPONSE2', Cardinality::SINGLE, BaseType::DURATION)); - $state->setVariable(new ResponseVariable('RESPONSE3', Cardinality::RECORD, -1, new RecordContainer(array('A' => new Identifier('A'), 'B' => new Identifier('B'))))); + $state->setVariable(new ResponseVariable('RESPONSE3', Cardinality::RECORD, -1, new RecordContainer(array('A' => new QtiIdentifier('A'), 'B' => new QtiIdentifier('B'))))); $json = json_encode(array('RESPONSE1' => array('base' => array('identifier' => 'ChoiceA')), 'RESPONSE2' => array('base' => null), 'RESPONSE3' => array('record' => array(array('name' => 'A', 'base' => array('identifier' => 'A')), array('name' => 'B', 'base' => array('identifier' => 'B')))))); $returnValue[] = array($state, $json); // complex state 2. $state = new State(); - $state->setVariable(new OutcomeVariable('OUTCOME1', Cardinality::MULTIPLE, BaseType::FLOAT, new MultipleContainer(BaseType::FLOAT, array(new Float(0.0), new Float(10.10))))); - $state->setVariable(new ResponseVariable('RESPONSE1', Cardinality::ORDERED, BaseType::POINT, new OrderedContainer(BaseType::POINT, array(new Point(10, 20))))); + $state->setVariable(new OutcomeVariable('OUTCOME1', Cardinality::MULTIPLE, BaseType::FLOAT, new MultipleContainer(BaseType::FLOAT, array(new QtiFloat(0.0), new QtiFloat(10.10))))); + $state->setVariable(new ResponseVariable('RESPONSE1', Cardinality::ORDERED, BaseType::POINT, new OrderedContainer(BaseType::POINT, array(new QtiPoint(10, 20))))); $json = json_encode(array('OUTCOME1' => array('list' => array('float' => array(0.0, 10.10))), 'RESPONSE1' => array('list' => array('point' => array(array(10, 20)))))); $returnValue[] = array($state, $json); diff --git a/test/qtismtest/runtime/pci/json/JsonUnmarshallerTest.php b/test/qtismtest/runtime/pci/json/JsonUnmarshallerTest.php index 448b7ba00..3007b5147 100644 --- a/test/qtismtest/runtime/pci/json/JsonUnmarshallerTest.php +++ b/test/qtismtest/runtime/pci/json/JsonUnmarshallerTest.php @@ -7,20 +7,20 @@ use qtism\runtime\common\RecordContainer; use qtism\common\enums\BaseType; use qtism\runtime\common\MultipleContainer; -use qtism\common\datatypes\Duration; -use qtism\common\datatypes\DirectedPair; -use qtism\common\datatypes\Pair; +use qtism\common\datatypes\QtiDuration; +use qtism\common\datatypes\QtiDirectedPair; +use qtism\common\datatypes\QtiPair; use qtism\common\datatypes\QtiDatatype; -use qtism\common\datatypes\Identifier; -use qtism\common\datatypes\IntOrIdentifier; -use qtism\common\datatypes\Uri; -use qtism\common\datatypes\Point; -use qtism\common\datatypes\String; -use qtism\common\datatypes\Float; -use qtism\common\datatypes\Integer; -use qtism\common\datatypes\Boolean; +use qtism\common\datatypes\QtiIdentifier; +use qtism\common\datatypes\QtiIntOrIdentifier; +use qtism\common\datatypes\QtiUri; +use qtism\common\datatypes\QtiPoint; +use qtism\common\datatypes\QtiString; +use qtism\common\datatypes\QtiFloat; +use qtism\common\datatypes\QtiInteger; +use qtism\common\datatypes\QtiBoolean; use qtism\runtime\pci\json\Unmarshaller; -use qtism\common\datatypes\Scalar; +use qtism\common\datatypes\QtiScalar; class JsonUnmarshallerTest extends QtiSmTestCase { @@ -34,7 +34,7 @@ static protected function createUnmarshaller() { * @param Scalar $expectedScalar * @param string $json */ - public function testUnmarshallScalar(Scalar $expectedScalar = null, $json) { + public function testUnmarshallScalar(QtiScalar $expectedScalar = null, $json) { $unmarshaller = self::createUnmarshaller(); if (is_null($expectedScalar) === false) { $this->assertTrue($unmarshaller->unmarshall($json)->equals($expectedScalar)); @@ -120,9 +120,9 @@ public function testUnmarshallState() { $this->assertEquals(4, count($state)); $this->assertEquals(array('RESPONSE1', 'RESPONSE2', 'RESPONSE3', 'RESPONSE4'), array_keys($state)); - $response1 = new Identifier('ChoiceA'); - $response2 = new MultipleContainer(BaseType::IDENTIFIER, array(new Identifier('_id1'), new Identifier('id2'), new Identifier('ID3'))); - $response3 = new RecordContainer(array('rock' => new Identifier('Paper'))); + $response1 = new QtiIdentifier('ChoiceA'); + $response2 = new MultipleContainer(BaseType::IDENTIFIER, array(new QtiIdentifier('_id1'), new QtiIdentifier('id2'), new QtiIdentifier('ID3'))); + $response3 = new RecordContainer(array('rock' => new QtiIdentifier('Paper'))); $response4 = null; $this->assertTrue($response1->equals($state['RESPONSE1'])); @@ -133,16 +133,16 @@ public function testUnmarshallState() { public function unmarshallScalarProvider() { return array( - array(new Boolean(true), '{ "base" : {"boolean" : true } }'), - array(new Boolean(false), '{ "base" : {"boolean" : false } }'), - array(new Integer(123), '{ "base" : {"integer" : 123 } }'), - array(new Float(23.23), '{ "base" : {"float" : 23.23 } }'), - array(new Float(6.0), '{ "base" : {"float" : 6 } }'), - array(new String('string'), '{ "base" : {"string" : "string" } }'), - array(new Uri('http://www.taotesting.com'), '{ "base" : {"uri" : "http://www.taotesting.com" } }'), - array(new IntOrIdentifier(10), '{ "base" : {"intOrIdentifier" : 10 } }'), - array(new IntOrIdentifier('_id1'), '{ "base" : {"identifier" : "_id1" } }'), - array(new Identifier('_id1'), '{ "base" : {"identifier" : "_id1" } }'), + array(new QtiBoolean(true), '{ "base" : {"boolean" : true } }'), + array(new QtiBoolean(false), '{ "base" : {"boolean" : false } }'), + array(new QtiInteger(123), '{ "base" : {"integer" : 123 } }'), + array(new QtiFloat(23.23), '{ "base" : {"float" : 23.23 } }'), + array(new QtiFloat(6.0), '{ "base" : {"float" : 6 } }'), + array(new QtiString('string'), '{ "base" : {"string" : "string" } }'), + array(new QtiUri('http://www.taotesting.com'), '{ "base" : {"uri" : "http://www.taotesting.com" } }'), + array(new QtiIntOrIdentifier(10), '{ "base" : {"intOrIdentifier" : 10 } }'), + array(new QtiIntOrIdentifier('_id1'), '{ "base" : {"identifier" : "_id1" } }'), + array(new QtiIdentifier('_id1'), '{ "base" : {"identifier" : "_id1" } }'), array(null, '{ "base": null }') ); } @@ -150,10 +150,10 @@ public function unmarshallScalarProvider() { public function unmarshallComplexProvider() { $returnValue = array(); - $returnValue[] = array(new Point(10, 20), '{ "base" : { "point" : [10, 20] } }'); - $returnValue[] = array(new Pair('A', 'B'), '{ "base" : { "pair" : ["A", "B"] } }'); - $returnValue[] = array(new DirectedPair('a', 'b'), '{ "base" : { "directedPair" : ["a", "b"] } }'); - $returnValue[] = array(new Duration('PT3S'), '{ "base" : { "duration" : "PT3S" } }'); + $returnValue[] = array(new QtiPoint(10, 20), '{ "base" : { "point" : [10, 20] } }'); + $returnValue[] = array(new QtiPair('A', 'B'), '{ "base" : { "pair" : ["A", "B"] } }'); + $returnValue[] = array(new QtiDirectedPair('a', 'b'), '{ "base" : { "directedPair" : ["a", "b"] } }'); + $returnValue[] = array(new QtiDuration('PT3S'), '{ "base" : { "duration" : "PT3S" } }'); return $returnValue; } @@ -180,39 +180,39 @@ public function unmarshallFileProvider() { public function unmarshallListProvider() { $returnValue = array(); - $container = new MultipleContainer(BaseType::BOOLEAN, array(new Boolean(true), new Boolean(false), new Boolean(true), new Boolean(true))); + $container = new MultipleContainer(BaseType::BOOLEAN, array(new QtiBoolean(true), new QtiBoolean(false), new QtiBoolean(true), new QtiBoolean(true))); $json = '{ "list" : { "boolean" : [true, false, true, true] } }'; $returnValue[] = array($container, $json); - $container = new MultipleContainer(BaseType::INTEGER, array(new Integer(2), new Integer(3), new Integer(5), new Integer(7), new Integer(11), new Integer(13))); + $container = new MultipleContainer(BaseType::INTEGER, array(new QtiInteger(2), new QtiInteger(3), new QtiInteger(5), new QtiInteger(7), new QtiInteger(11), new QtiInteger(13))); $json = '{ "list" : { "integer" : [2, 3, 5, 7, 11, 13] } }'; $returnValue[] = array($container, $json); - $container = new MultipleContainer(BaseType::FLOAT, array(new Float(3.1415926), new Float(12.34), new Float(98.76))); + $container = new MultipleContainer(BaseType::FLOAT, array(new QtiFloat(3.1415926), new QtiFloat(12.34), new QtiFloat(98.76))); $json = '{ "list" : { "float" : [3.1415926, 12.34, 98.76] } }'; $returnValue[] = array($container, $json); - $container = new MultipleContainer(BaseType::STRING, array(new String('Another'), new String('And Another'))); + $container = new MultipleContainer(BaseType::STRING, array(new QtiString('Another'), new QtiString('And Another'))); $json = '{ "list" : { "string" : ["Another", "And Another"] } }'; $returnValue[] = array($container, $json); - $container = new MultipleContainer(BaseType::POINT, array(new Point(123, 456), new Point(640, 480))); + $container = new MultipleContainer(BaseType::POINT, array(new QtiPoint(123, 456), new QtiPoint(640, 480))); $json = '{ "list" : { "point" : [[123, 456], [640, 480]] } }'; $returnValue[] = array($container, $json); - $container = new MultipleContainer(BaseType::PAIR, array(new Pair('A', 'B'), new Pair('D', 'C'))); + $container = new MultipleContainer(BaseType::PAIR, array(new QtiPair('A', 'B'), new QtiPair('D', 'C'))); $json = '{ "list" : { "pair" : [["A", "B"], ["D", "C"]] } }'; $returnValue[] = array($container, $json); - $container = new MultipleContainer(BaseType::DIRECTED_PAIR, array(new DirectedPair('A', 'B'), new DirectedPair('D', 'C'))); + $container = new MultipleContainer(BaseType::DIRECTED_PAIR, array(new QtiDirectedPair('A', 'B'), new QtiDirectedPair('D', 'C'))); $json = '{ "list" : { "directedPair" : [["A", "B"], ["D", "C"]] } }'; $returnValue[] = array($container, $json); - $container = new MultipleContainer(BaseType::DURATION, array(new Duration('PT5S'), new Duration('PT10S'))); + $container = new MultipleContainer(BaseType::DURATION, array(new QtiDuration('PT5S'), new QtiDuration('PT10S'))); $json = '{ "list" : { "duration" : ["PT5S", "PT10S"] } }'; $returnValue[] = array($container, $json); - $container = new MultipleContainer(BaseType::BOOLEAN, array(new Boolean(true), null, new Boolean(false))); + $container = new MultipleContainer(BaseType::BOOLEAN, array(new QtiBoolean(true), null, new QtiBoolean(false))); $json = '{ "list" : { "boolean": [true, null, false] } }'; $returnValue[] = array($container, $json); @@ -226,11 +226,11 @@ public function unmarshallRecordProvider() { $json = '{ "record" : [] }'; $returnValue[] = array($record, $json); - $record = new RecordContainer(array('A' => new String('A'))); + $record = new RecordContainer(array('A' => new QtiString('A'))); $json = '{ "record" : [ { "name" : "A", "base" : { "string" : "A" } } ] }'; $returnValue[] = array($record, $json); - $record = new RecordContainer(array('A' => new String('A'), 'B' => null)); + $record = new RecordContainer(array('A' => new QtiString('A'), 'B' => null)); $json = '{ "record" : [ { "name" : "A", "base" : { "string" : "A" } }, { "name" : "B", "base" : null } ] }'; $returnValue[] = array($record, $json); diff --git a/test/qtismtest/runtime/processing/OutcomeProcessingEngineTest.php b/test/qtismtest/runtime/processing/OutcomeProcessingEngineTest.php index 2a660768a..2473343a7 100644 --- a/test/qtismtest/runtime/processing/OutcomeProcessingEngineTest.php +++ b/test/qtismtest/runtime/processing/OutcomeProcessingEngineTest.php @@ -2,7 +2,7 @@ namespace qtismtest\runtime\processing; use qtismtest\QtiSmTestCase; -use qtism\common\datatypes\Boolean; +use qtism\common\datatypes\QtiBoolean; use qtism\runtime\rules\RuleProcessingException; use qtism\common\enums\BaseType; use qtism\common\enums\Cardinality; @@ -52,18 +52,18 @@ public function testResponseProcessingMatchCorrect() { // SCORE is still NULL because the 't' variable was not provided to the context. $this->assertSame(null, $context['SCORE']); - $context->setVariable(new OutcomeVariable('t', Cardinality::SINGLE, BaseType::BOOLEAN, new Boolean(true))); + $context->setVariable(new OutcomeVariable('t', Cardinality::SINGLE, BaseType::BOOLEAN, new QtiBoolean(true))); $this->assertTrue($context['t']->getValue()); // After processing, the $context['SCORE'] value must be 20.0. $engine->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $context['SCORE']); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $context['SCORE']); $this->assertEquals(20.0, $context['SCORE']->getValue()); - $context['t'] = new Boolean(false); + $context['t'] = new QtiBoolean(false); // After processing, the $context['SCORE'] value must switch to 0.0. $engine->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $context['SCORE']); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $context['SCORE']); $this->assertEquals(0.0, $context['SCORE']->getValue()); } diff --git a/test/qtismtest/runtime/processing/PrintedVariableEngineTest.php b/test/qtismtest/runtime/processing/PrintedVariableEngineTest.php index 3f90f5590..117a8fa11 100644 --- a/test/qtismtest/runtime/processing/PrintedVariableEngineTest.php +++ b/test/qtismtest/runtime/processing/PrintedVariableEngineTest.php @@ -2,19 +2,19 @@ namespace qtismtest\runtime\processing; use qtismtest\QtiSmTestCase; -use qtism\common\datatypes\Identifier; -use qtism\common\datatypes\IntOrIdentifier; -use qtism\common\datatypes\Uri; -use qtism\common\datatypes\Boolean; -use qtism\common\datatypes\Float; -use qtism\common\datatypes\Integer; -use qtism\common\datatypes\String; +use qtism\common\datatypes\QtiIdentifier; +use qtism\common\datatypes\QtiIntOrIdentifier; +use qtism\common\datatypes\QtiUri; +use qtism\common\datatypes\QtiBoolean; +use qtism\common\datatypes\QtiFloat; +use qtism\common\datatypes\QtiInteger; +use qtism\common\datatypes\QtiString; use qtism\runtime\common\RecordContainer; use qtism\runtime\common\OrderedContainer; use qtism\runtime\common\MultipleContainer; -use qtism\common\datatypes\DirectedPair; -use qtism\common\datatypes\Pair; -use qtism\common\datatypes\Duration; +use qtism\common\datatypes\QtiDirectedPair; +use qtism\common\datatypes\QtiPair; +use qtism\common\datatypes\QtiDuration; use qtism\runtime\common\TemplateVariable; use qtism\common\enums\BaseType; use qtism\common\enums\Cardinality; @@ -59,88 +59,88 @@ public function printedVariableProvider() { $state->setVariable(new OutcomeVariable('nullValue', Cardinality::SINGLE, BaseType::BOOLEAN, null)); // Scalar values. - $state->setVariable(new OutcomeVariable('nonEmptyString', Cardinality::SINGLE, BaseType::STRING, new String('Non Empty String'))); - $state->setVariable(new OutcomeVariable('emptyString', Cardinality::SINGLE, BaseType::STRING, new String(''))); - $state->setVariable(new TemplateVariable('positiveInteger', Cardinality::SINGLE, BaseType::INTEGER, new Integer(25))); - $state->setVariable(new TemplateVariable('zeroInteger', Cardinality::SINGLE, BaseType::INTEGER, new Integer(0))); - $state->setVariable(new TemplateVariable('negativeInteger', Cardinality::SINGLE, BaseType::INTEGER, new Integer(-25))); - $state->setVariable(new TemplateVariable('positiveFloat', Cardinality::SINGLE, BaseType::FLOAT, new Float(25.3455322345))); - $state->setVariable(new OutcomeVariable('zeroFloat', Cardinality::SINGLE, BaseType::FLOAT, new Float(0.0))); - $state->setVariable(new OutcomeVariable('negativeFloat', Cardinality::SINGLE, BaseType::FLOAT, new Float(-53000.0))); - $state->setVariable(new OutcomeVariable('false', Cardinality::SINGLE, BaseType::BOOLEAN, new Boolean(false))); - $state->setVariable(new OutcomeVariable('true', Cardinality::SINGLE, BaseType::BOOLEAN, new Boolean(true))); - $state->setVariable(new OutcomeVariable('URI', Cardinality::SINGLE, BaseType::URI, new Uri('http://qtism.taotesting.com'))); - $state->setVariable(new TemplateVariable('zeroIntOrIdentifier', Cardinality::SINGLE, BaseType::INT_OR_IDENTIFIER, new IntOrIdentifier(0))); - $state->setVariable(new TemplateVariable('positiveIntOrIdentifier', Cardinality::SINGLE, BaseType::INT_OR_IDENTIFIER, new IntOrIdentifier(25))); - $state->setVariable(new TemplateVariable('zeroIntOrIdentifier', Cardinality::SINGLE, BaseType::INT_OR_IDENTIFIER, new IntOrIdentifier(0))); - $state->setVariable(new OutcomeVariable('identifierIntOrIdentifier', Cardinality::SINGLE, BaseType::INT_OR_IDENTIFIER, new IntOrIdentifier('woot'))); - $state->setVariable(new TemplateVariable('negativeIntOrIdentifier', Cardinality::SINGLE, BaseType::INTEGER, new Integer(-25))); - $state->setVariable(new OutcomeVariable('duration', Cardinality::SINGLE, BaseType::DURATION, new Duration('PT3M26S'))); - $state->setVariable(new OutcomeVariable('pair', Cardinality::SINGLE, BaseType::PAIR, new Pair('A', 'B'))); - $state->setVariable(new OutcomeVariable('directedPair', Cardinality::SINGLE, BaseType::DIRECTED_PAIR, new DirectedPair('B', 'C'))); - $state->setVariable(new OutcomeVariable('identifier', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('woot'))); + $state->setVariable(new OutcomeVariable('nonEmptyString', Cardinality::SINGLE, BaseType::STRING, new QtiString('Non Empty String'))); + $state->setVariable(new OutcomeVariable('emptyString', Cardinality::SINGLE, BaseType::STRING, new QtiString(''))); + $state->setVariable(new TemplateVariable('positiveInteger', Cardinality::SINGLE, BaseType::INTEGER, new QtiInteger(25))); + $state->setVariable(new TemplateVariable('zeroInteger', Cardinality::SINGLE, BaseType::INTEGER, new QtiInteger(0))); + $state->setVariable(new TemplateVariable('negativeInteger', Cardinality::SINGLE, BaseType::INTEGER, new QtiInteger(-25))); + $state->setVariable(new TemplateVariable('positiveFloat', Cardinality::SINGLE, BaseType::FLOAT, new QtiFloat(25.3455322345))); + $state->setVariable(new OutcomeVariable('zeroFloat', Cardinality::SINGLE, BaseType::FLOAT, new QtiFloat(0.0))); + $state->setVariable(new OutcomeVariable('negativeFloat', Cardinality::SINGLE, BaseType::FLOAT, new QtiFloat(-53000.0))); + $state->setVariable(new OutcomeVariable('false', Cardinality::SINGLE, BaseType::BOOLEAN, new QtiBoolean(false))); + $state->setVariable(new OutcomeVariable('true', Cardinality::SINGLE, BaseType::BOOLEAN, new QtiBoolean(true))); + $state->setVariable(new OutcomeVariable('URI', Cardinality::SINGLE, BaseType::URI, new QtiUri('http://qtism.taotesting.com'))); + $state->setVariable(new TemplateVariable('zeroIntOrIdentifier', Cardinality::SINGLE, BaseType::INT_OR_IDENTIFIER, new QtiIntOrIdentifier(0))); + $state->setVariable(new TemplateVariable('positiveIntOrIdentifier', Cardinality::SINGLE, BaseType::INT_OR_IDENTIFIER, new QtiIntOrIdentifier(25))); + $state->setVariable(new TemplateVariable('zeroIntOrIdentifier', Cardinality::SINGLE, BaseType::INT_OR_IDENTIFIER, new QtiIntOrIdentifier(0))); + $state->setVariable(new OutcomeVariable('identifierIntOrIdentifier', Cardinality::SINGLE, BaseType::INT_OR_IDENTIFIER, new QtiIntOrIdentifier('woot'))); + $state->setVariable(new TemplateVariable('negativeIntOrIdentifier', Cardinality::SINGLE, BaseType::INTEGER, new QtiInteger(-25))); + $state->setVariable(new OutcomeVariable('duration', Cardinality::SINGLE, BaseType::DURATION, new QtiDuration('PT3M26S'))); + $state->setVariable(new OutcomeVariable('pair', Cardinality::SINGLE, BaseType::PAIR, new QtiPair('A', 'B'))); + $state->setVariable(new OutcomeVariable('directedPair', Cardinality::SINGLE, BaseType::DIRECTED_PAIR, new QtiDirectedPair('B', 'C'))); + $state->setVariable(new OutcomeVariable('identifier', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('woot'))); // -- Multiple containers. - $state->setVariable(new TemplateVariable('multipleIntegerSingle', Cardinality::MULTIPLE, BaseType::INTEGER, new MultipleContainer(BaseType::INTEGER, array(new Integer(10))))); - $state->setVariable(new TemplateVariable('multipleInteger', Cardinality::MULTIPLE, BaseType::INTEGER, new MultipleContainer(BaseType::INTEGER, array(new Integer(10), new Integer(20), new Integer(-1))))); - $state->setVariable(new OutcomeVariable('multipleFloat', Cardinality::MULTIPLE, BaseType::FLOAT, new MultipleContainer(BaseType::FLOAT, array(new Float(10.0), new Float(20.0), new Float(-1.0))))); - $state->setVariable(new OutcomeVariable('multipleString', Cardinality::MULTIPLE, BaseType::STRING, new MultipleContainer(BaseType::STRING, array(new String('Ta'), new String('Daaa'), new String('h'), new String(''))))); - $state->setVariable(new OutcomeVariable('multipleBoolean', Cardinality::MULTIPLE, BaseType::BOOLEAN, new MultipleContainer(BaseType::BOOLEAN, array(new Boolean(true), new Boolean(false), new Boolean(true), new Boolean(true))))); - $state->setVariable(new OutcomeVariable('multipleURI', Cardinality::MULTIPLE, BaseType::URI, new MultipleContainer(BaseType::URI, array(new Uri('http://www.taotesting.com'), new Uri('http://www.rdfabout.com'))))); - $state->setVariable(new OutcomeVariable('multipleIdentifier', Cardinality::MULTIPLE, BaseType::IDENTIFIER, new MultipleContainer(BaseType::IDENTIFIER, array(new Identifier('9thing'), new Identifier('woot-woot'))))); - $state->setVariable(new TemplateVariable('multipleDuration', Cardinality::MULTIPLE, BaseType::DURATION, new MultipleContainer(BaseType::DURATION, array(new Duration('PT0S'), new Duration('PT3M'))))); - $state->setVariable(new OutcomeVariable('multiplePair', Cardinality::MULTIPLE, BaseType::PAIR, new MultipleContainer(BaseType::PAIR, array(new Pair('A', 'B'), new Pair('C', 'D'), new Pair('E', 'F'))))); - $state->setVariable(new OutcomeVariable('multipleDirectedPair', Cardinality::MULTIPLE, BaseType::DIRECTED_PAIR, new MultipleContainer(BaseType::DIRECTED_PAIR, array(new DirectedPair('A', 'B'), new DirectedPair('C', 'D'), new DirectedPair('E', 'F'))))); - $state->setVariable(new OutcomeVariable('multipleIntOrIdentifier', Cardinality::MULTIPLE, BaseType::INT_OR_IDENTIFIER, new MultipleContainer(BaseType::INT_OR_IDENTIFIER, array(new IntOrIdentifier('woot'), new IntOrIdentifier(25), new IntOrIdentifier(0), new IntOrIdentifier(-25))))); + $state->setVariable(new TemplateVariable('multipleIntegerSingle', Cardinality::MULTIPLE, BaseType::INTEGER, new MultipleContainer(BaseType::INTEGER, array(new QtiInteger(10))))); + $state->setVariable(new TemplateVariable('multipleInteger', Cardinality::MULTIPLE, BaseType::INTEGER, new MultipleContainer(BaseType::INTEGER, array(new QtiInteger(10), new QtiInteger(20), new QtiInteger(-1))))); + $state->setVariable(new OutcomeVariable('multipleFloat', Cardinality::MULTIPLE, BaseType::FLOAT, new MultipleContainer(BaseType::FLOAT, array(new QtiFloat(10.0), new QtiFloat(20.0), new QtiFloat(-1.0))))); + $state->setVariable(new OutcomeVariable('multipleString', Cardinality::MULTIPLE, BaseType::STRING, new MultipleContainer(BaseType::STRING, array(new QtiString('Ta'), new QtiString('Daaa'), new QtiString('h'), new QtiString(''))))); + $state->setVariable(new OutcomeVariable('multipleBoolean', Cardinality::MULTIPLE, BaseType::BOOLEAN, new MultipleContainer(BaseType::BOOLEAN, array(new QtiBoolean(true), new QtiBoolean(false), new QtiBoolean(true), new QtiBoolean(true))))); + $state->setVariable(new OutcomeVariable('multipleURI', Cardinality::MULTIPLE, BaseType::URI, new MultipleContainer(BaseType::URI, array(new QtiUri('http://www.taotesting.com'), new QtiUri('http://www.rdfabout.com'))))); + $state->setVariable(new OutcomeVariable('multipleIdentifier', Cardinality::MULTIPLE, BaseType::IDENTIFIER, new MultipleContainer(BaseType::IDENTIFIER, array(new QtiIdentifier('9thing'), new QtiIdentifier('woot-woot'))))); + $state->setVariable(new TemplateVariable('multipleDuration', Cardinality::MULTIPLE, BaseType::DURATION, new MultipleContainer(BaseType::DURATION, array(new QtiDuration('PT0S'), new QtiDuration('PT3M'))))); + $state->setVariable(new OutcomeVariable('multiplePair', Cardinality::MULTIPLE, BaseType::PAIR, new MultipleContainer(BaseType::PAIR, array(new QtiPair('A', 'B'), new QtiPair('C', 'D'), new QtiPair('E', 'F'))))); + $state->setVariable(new OutcomeVariable('multipleDirectedPair', Cardinality::MULTIPLE, BaseType::DIRECTED_PAIR, new MultipleContainer(BaseType::DIRECTED_PAIR, array(new QtiDirectedPair('A', 'B'), new QtiDirectedPair('C', 'D'), new QtiDirectedPair('E', 'F'))))); + $state->setVariable(new OutcomeVariable('multipleIntOrIdentifier', Cardinality::MULTIPLE, BaseType::INT_OR_IDENTIFIER, new MultipleContainer(BaseType::INT_OR_IDENTIFIER, array(new QtiIntOrIdentifier('woot'), new QtiIntOrIdentifier(25), new QtiIntOrIdentifier(0), new QtiIntOrIdentifier(-25))))); $state->setVariable(new OutcomeVariable('multipleEmpty', Cardinality::MULTIPLE, BaseType::INTEGER, new MultipleContainer(BaseType::INTEGER))); - $state->setVariable(new TemplateVariable('multipleContainsNull', Cardinality::MULTIPLE, BaseType::INTEGER, new MultipleContainer(BaseType::INTEGER, array(new Integer(-10), null, null)))); + $state->setVariable(new TemplateVariable('multipleContainsNull', Cardinality::MULTIPLE, BaseType::INTEGER, new MultipleContainer(BaseType::INTEGER, array(new QtiInteger(-10), null, null)))); // -- Ordered containers, no value for the 'index' attribute. - $state->setVariable(new TemplateVariable('orderedInteger', Cardinality::ORDERED, BaseType::INTEGER, new OrderedContainer(BaseType::INTEGER, array(new Integer(10), new Integer(20), new Integer(-1))))); - $state->setVariable(new OutcomeVariable('orderedFloat', Cardinality::ORDERED, BaseType::FLOAT, new OrderedContainer(BaseType::FLOAT, array(new Float(10.0), new Float(20.0), new Float(-1.0))))); - $state->setVariable(new OutcomeVariable('orderedString', Cardinality::ORDERED, BaseType::STRING, new OrderedContainer(BaseType::STRING, array(new String('Ta'), new String('Daaa'), new String('h'), new String(''))))); - $state->setVariable(new OutcomeVariable('orderedBoolean', Cardinality::ORDERED, BaseType::BOOLEAN, new OrderedContainer(BaseType::BOOLEAN, array(new Boolean(true), new Boolean(false), new Boolean(true), new Boolean(true))))); - $state->setVariable(new OutcomeVariable('orderedURI', Cardinality::ORDERED, BaseType::URI, new OrderedContainer(BaseType::URI, array(new Uri('http://www.taotesting.com'), new Uri('http://www.rdfabout.com'))))); - $state->setVariable(new OutcomeVariable('orderedIdentifier', Cardinality::ORDERED, BaseType::IDENTIFIER, new OrderedContainer(BaseType::IDENTIFIER, array(new Identifier('9thing'), new Identifier('woot-woot'))))); - $state->setVariable(new TemplateVariable('orderedDuration', Cardinality::ORDERED, BaseType::DURATION, new OrderedContainer(BaseType::DURATION, array(new Duration('PT0S'), new Duration('PT3M'))))); - $state->setVariable(new OutcomeVariable('orderedPair', Cardinality::ORDERED, BaseType::PAIR, new OrderedContainer(BaseType::PAIR, array(new Pair('A', 'B'), new Pair('C', 'D'), new Pair('E', 'F'))))); - $state->setVariable(new OutcomeVariable('orderedDirectedPair', Cardinality::ORDERED, BaseType::DIRECTED_PAIR, new OrderedContainer(BaseType::DIRECTED_PAIR, array(new DirectedPair('A', 'B'), new DirectedPair('C', 'D'), new DirectedPair('E', 'F'))))); - $state->setVariable(new OutcomeVariable('orderedIntOrIdentifier', Cardinality::ORDERED, BaseType::INT_OR_IDENTIFIER, new OrderedContainer(BaseType::INT_OR_IDENTIFIER, array(new IntOrIdentifier('woot'), new IntOrIdentifier(25), new IntOrIdentifier(0), new IntOrIdentifier(-25))))); + $state->setVariable(new TemplateVariable('orderedInteger', Cardinality::ORDERED, BaseType::INTEGER, new OrderedContainer(BaseType::INTEGER, array(new QtiInteger(10), new QtiInteger(20), new QtiInteger(-1))))); + $state->setVariable(new OutcomeVariable('orderedFloat', Cardinality::ORDERED, BaseType::FLOAT, new OrderedContainer(BaseType::FLOAT, array(new QtiFloat(10.0), new QtiFloat(20.0), new QtiFloat(-1.0))))); + $state->setVariable(new OutcomeVariable('orderedString', Cardinality::ORDERED, BaseType::STRING, new OrderedContainer(BaseType::STRING, array(new QtiString('Ta'), new QtiString('Daaa'), new QtiString('h'), new QtiString(''))))); + $state->setVariable(new OutcomeVariable('orderedBoolean', Cardinality::ORDERED, BaseType::BOOLEAN, new OrderedContainer(BaseType::BOOLEAN, array(new QtiBoolean(true), new QtiBoolean(false), new QtiBoolean(true), new QtiBoolean(true))))); + $state->setVariable(new OutcomeVariable('orderedURI', Cardinality::ORDERED, BaseType::URI, new OrderedContainer(BaseType::URI, array(new QtiUri('http://www.taotesting.com'), new QtiUri('http://www.rdfabout.com'))))); + $state->setVariable(new OutcomeVariable('orderedIdentifier', Cardinality::ORDERED, BaseType::IDENTIFIER, new OrderedContainer(BaseType::IDENTIFIER, array(new QtiIdentifier('9thing'), new QtiIdentifier('woot-woot'))))); + $state->setVariable(new TemplateVariable('orderedDuration', Cardinality::ORDERED, BaseType::DURATION, new OrderedContainer(BaseType::DURATION, array(new QtiDuration('PT0S'), new QtiDuration('PT3M'))))); + $state->setVariable(new OutcomeVariable('orderedPair', Cardinality::ORDERED, BaseType::PAIR, new OrderedContainer(BaseType::PAIR, array(new QtiPair('A', 'B'), new QtiPair('C', 'D'), new QtiPair('E', 'F'))))); + $state->setVariable(new OutcomeVariable('orderedDirectedPair', Cardinality::ORDERED, BaseType::DIRECTED_PAIR, new OrderedContainer(BaseType::DIRECTED_PAIR, array(new QtiDirectedPair('A', 'B'), new QtiDirectedPair('C', 'D'), new QtiDirectedPair('E', 'F'))))); + $state->setVariable(new OutcomeVariable('orderedIntOrIdentifier', Cardinality::ORDERED, BaseType::INT_OR_IDENTIFIER, new OrderedContainer(BaseType::INT_OR_IDENTIFIER, array(new QtiIntOrIdentifier('woot'), new QtiIntOrIdentifier(25), new QtiIntOrIdentifier(0), new QtiIntOrIdentifier(-25))))); $state->setVariable(new TemplateVariable('orderedEmpty', Cardinality::ORDERED, BaseType::INTEGER, new OrderedContainer(BaseType::INTEGER))); - $state->setVariable(new TemplateVariable('orderedContainsNull', Cardinality::ORDERED, BaseType::INTEGER, new OrderedContainer(BaseType::INTEGER, array(null, null, new Integer(10))))); + $state->setVariable(new TemplateVariable('orderedContainsNull', Cardinality::ORDERED, BaseType::INTEGER, new OrderedContainer(BaseType::INTEGER, array(null, null, new QtiInteger(10))))); // -- Ordered containers, value for the 'index' attribute set. - $state->setVariable(new TemplateVariable('orderedIndexedInteger', Cardinality::ORDERED, BaseType::INTEGER, new OrderedContainer(BaseType::INTEGER, array(new Integer(10), new Integer(20), new Integer(-1))))); + $state->setVariable(new TemplateVariable('orderedIndexedInteger', Cardinality::ORDERED, BaseType::INTEGER, new OrderedContainer(BaseType::INTEGER, array(new QtiInteger(10), new QtiInteger(20), new QtiInteger(-1))))); // The field is extracted from a variable ref. - $state->setVariable(new OutcomeVariable('fieldVariableRefInteger', Cardinality::SINGLE, BaseType::INTEGER, new Integer(1))); + $state->setVariable(new OutcomeVariable('fieldVariableRefInteger', Cardinality::SINGLE, BaseType::INTEGER, new QtiInteger(1))); // Set up a wrong variable reference for 'index' value. - $state->setVariable(new OutcomeVariable('fieldVariableRefString', Cardinality::SINGLE, BaseType::STRING, new String('index'))); - $state->setVariable(new OutcomeVariable('orderedIndexedFloat', Cardinality::ORDERED, BaseType::FLOAT, new OrderedContainer(BaseType::FLOAT, array(new Float(10.0), new Float(20.0), new Float(-1.0))))); - $state->setVariable(new OutcomeVariable('orderedIndexedString', Cardinality::ORDERED, BaseType::STRING, new OrderedContainer(BaseType::STRING, array(new String('Ta'), new String('Daaa'), new String('h'), new String(''))))); - $state->setVariable(new OutcomeVariable('orderedIndexedBoolean', Cardinality::ORDERED, BaseType::BOOLEAN, new OrderedContainer(BaseType::BOOLEAN, array(new Boolean(true), new Boolean(false), new Boolean(true), new Boolean(true))))); - $state->setVariable(new OutcomeVariable('orderedIndexedURI', Cardinality::ORDERED, BaseType::URI, new OrderedContainer(BaseType::URI, array(new Uri('http://www.taotesting.com'), new Uri('http://www.rdfabout.com'))))); - $state->setVariable(new OutcomeVariable('orderedIndexedIdentifier', Cardinality::ORDERED, BaseType::IDENTIFIER, new OrderedContainer(BaseType::IDENTIFIER, array(new Identifier('9thing'), new Identifier('woot-woot'))))); - $state->setVariable(new TemplateVariable('orderedIndexedDuration', Cardinality::ORDERED, BaseType::DURATION, new OrderedContainer(BaseType::DURATION, array(new Duration('PT0S'), new Duration('PT3M'))))); - $state->setVariable(new OutcomeVariable('orderedIndexedPair', Cardinality::ORDERED, BaseType::PAIR, new OrderedContainer(BaseType::PAIR, array(new Pair('A', 'B'), new Pair('C', 'D'), new Pair('E', 'F'))))); - $state->setVariable(new OutcomeVariable('orderedIndexedDirectedPair', Cardinality::ORDERED, BaseType::DIRECTED_PAIR, new OrderedContainer(BaseType::DIRECTED_PAIR, array(new DirectedPair('A', 'B'), new DirectedPair('C', 'D'), new DirectedPair('E', 'F'))))); - $state->setVariable(new OutcomeVariable('orderedIndexedIntOrIdentifier', Cardinality::ORDERED, BaseType::INT_OR_IDENTIFIER, new OrderedContainer(BaseType::INT_OR_IDENTIFIER, array(new IntOrIdentifier('woot'), new IntOrIdentifier(25), new IntOrIdentifier(0), new IntOrIdentifier(-25))))); + $state->setVariable(new OutcomeVariable('fieldVariableRefString', Cardinality::SINGLE, BaseType::STRING, new QtiString('index'))); + $state->setVariable(new OutcomeVariable('orderedIndexedFloat', Cardinality::ORDERED, BaseType::FLOAT, new OrderedContainer(BaseType::FLOAT, array(new QtiFloat(10.0), new QtiFloat(20.0), new QtiFloat(-1.0))))); + $state->setVariable(new OutcomeVariable('orderedIndexedString', Cardinality::ORDERED, BaseType::STRING, new OrderedContainer(BaseType::STRING, array(new QtiString('Ta'), new QtiString('Daaa'), new QtiString('h'), new QtiString(''))))); + $state->setVariable(new OutcomeVariable('orderedIndexedBoolean', Cardinality::ORDERED, BaseType::BOOLEAN, new OrderedContainer(BaseType::BOOLEAN, array(new QtiBoolean(true), new QtiBoolean(false), new QtiBoolean(true), new QtiBoolean(true))))); + $state->setVariable(new OutcomeVariable('orderedIndexedURI', Cardinality::ORDERED, BaseType::URI, new OrderedContainer(BaseType::URI, array(new QtiUri('http://www.taotesting.com'), new QtiUri('http://www.rdfabout.com'))))); + $state->setVariable(new OutcomeVariable('orderedIndexedIdentifier', Cardinality::ORDERED, BaseType::IDENTIFIER, new OrderedContainer(BaseType::IDENTIFIER, array(new QtiIdentifier('9thing'), new QtiIdentifier('woot-woot'))))); + $state->setVariable(new TemplateVariable('orderedIndexedDuration', Cardinality::ORDERED, BaseType::DURATION, new OrderedContainer(BaseType::DURATION, array(new QtiDuration('PT0S'), new QtiDuration('PT3M'))))); + $state->setVariable(new OutcomeVariable('orderedIndexedPair', Cardinality::ORDERED, BaseType::PAIR, new OrderedContainer(BaseType::PAIR, array(new QtiPair('A', 'B'), new QtiPair('C', 'D'), new QtiPair('E', 'F'))))); + $state->setVariable(new OutcomeVariable('orderedIndexedDirectedPair', Cardinality::ORDERED, BaseType::DIRECTED_PAIR, new OrderedContainer(BaseType::DIRECTED_PAIR, array(new QtiDirectedPair('A', 'B'), new QtiDirectedPair('C', 'D'), new QtiDirectedPair('E', 'F'))))); + $state->setVariable(new OutcomeVariable('orderedIndexedIntOrIdentifier', Cardinality::ORDERED, BaseType::INT_OR_IDENTIFIER, new OrderedContainer(BaseType::INT_OR_IDENTIFIER, array(new QtiIntOrIdentifier('woot'), new QtiIntOrIdentifier(25), new QtiIntOrIdentifier(0), new QtiIntOrIdentifier(-25))))); // -- Record containers. - $state->setVariable(new OutcomeVariable('recordSingle', Cardinality::RECORD, -1, new RecordContainer(array('a' => new Float(25.3))))); - $state->setVariable(new OutcomeVariable('recordMultiple', Cardinality::RECORD, -1, new RecordContainer(array('a' => new Integer(-3), 'b' => new Float(3.3), 'c' => new Boolean(true), 'd' => new Boolean(false), 'e' => new String('string'), 'f' => new Uri('http://www.rdfabout.com'), 'g' => new Duration('PT3M'), 'h' => new Pair('A', 'B'), 'i' => new DirectedPair('C', 'D'))))); + $state->setVariable(new OutcomeVariable('recordSingle', Cardinality::RECORD, -1, new RecordContainer(array('a' => new QtiFloat(25.3))))); + $state->setVariable(new OutcomeVariable('recordMultiple', Cardinality::RECORD, -1, new RecordContainer(array('a' => new QtiInteger(-3), 'b' => new QtiFloat(3.3), 'c' => new QtiBoolean(true), 'd' => new QtiBoolean(false), 'e' => new QtiString('string'), 'f' => new QtiUri('http://www.rdfabout.com'), 'g' => new QtiDuration('PT3M'), 'h' => new QtiPair('A', 'B'), 'i' => new QtiDirectedPair('C', 'D'))))); $state->setVariable(new TemplateVariable('recordEmpty', Cardinality::RECORD, -1, new RecordContainer())); - $state->setVariable(new OutcomeVariable('recordContainsNull', Cardinality::RECORD, -1, new RecordContainer(array('a' => new Integer(-3), 'b' => null, 'c' => new Boolean(true))))); + $state->setVariable(new OutcomeVariable('recordContainsNull', Cardinality::RECORD, -1, new RecordContainer(array('a' => new QtiInteger(-3), 'b' => null, 'c' => new QtiBoolean(true))))); // -- Power form. - $state->setVariable(new OutcomeVariable('powerFormScalarPositiveInteger', Cardinality::SINGLE, BaseType::INTEGER, new Integer(250))); - $state->setVariable(new OutcomeVariable('powerFormScalarZeroInteger', Cardinality::SINGLE, BaseType::INTEGER, new Integer(0))); - $state->setVariable(new OutcomeVariable('powerFormScalarNegativeInteger', Cardinality::SINGLE, BaseType::INTEGER, new Integer(-23))); - $state->setVariable(new OutcomeVariable('powerFormScalarPositiveFloat', Cardinality::SINGLE, BaseType::FLOAT, new Float(250.35))); - $state->setVariable(new OutcomeVariable('powerFormScalarZeroFloat', Cardinality::SINGLE, BaseType::FLOAT, new Float(0.0))); - $state->setVariable(new OutcomeVariable('powerFormScalarNegativeFloat', Cardinality::SINGLE, BaseType::FLOAT, new Float(-23.0))); + $state->setVariable(new OutcomeVariable('powerFormScalarPositiveInteger', Cardinality::SINGLE, BaseType::INTEGER, new QtiInteger(250))); + $state->setVariable(new OutcomeVariable('powerFormScalarZeroInteger', Cardinality::SINGLE, BaseType::INTEGER, new QtiInteger(0))); + $state->setVariable(new OutcomeVariable('powerFormScalarNegativeInteger', Cardinality::SINGLE, BaseType::INTEGER, new QtiInteger(-23))); + $state->setVariable(new OutcomeVariable('powerFormScalarPositiveFloat', Cardinality::SINGLE, BaseType::FLOAT, new QtiFloat(250.35))); + $state->setVariable(new OutcomeVariable('powerFormScalarZeroFloat', Cardinality::SINGLE, BaseType::FLOAT, new QtiFloat(0.0))); + $state->setVariable(new OutcomeVariable('powerFormScalarNegativeFloat', Cardinality::SINGLE, BaseType::FLOAT, new QtiFloat(-23.0))); // -- IMS NumberFormatting. See http://www.imsglobal.org/question/qtiv2p1/imsqti_implv2p1.html#section10017 - $state->setVariable(new OutcomeVariable('integerMinus987', Cardinality::SINGLE, BaseType::INTEGER, new Integer(-987))); + $state->setVariable(new OutcomeVariable('integerMinus987', Cardinality::SINGLE, BaseType::INTEGER, new QtiInteger(-987))); return array( array('', 'nonExistingVariable', $state), diff --git a/test/qtismtest/runtime/processing/ResponseProcessingEngineTest.php b/test/qtismtest/runtime/processing/ResponseProcessingEngineTest.php index 9fd3a2cd3..aa0152d25 100644 --- a/test/qtismtest/runtime/processing/ResponseProcessingEngineTest.php +++ b/test/qtismtest/runtime/processing/ResponseProcessingEngineTest.php @@ -2,7 +2,7 @@ namespace qtismtest\runtime\processing; use qtismtest\QtiSmTestCase; -use qtism\common\datatypes\Identifier; +use qtism\common\datatypes\QtiIdentifier; use qtism\runtime\rules\RuleProcessingException; use qtism\runtime\common\ProcessingException; use qtism\runtime\common\State; @@ -42,9 +42,9 @@ public function testResponseProcessingMatchCorrect() { $engine = new ResponseProcessingEngine($responseProcessing, $context); // --> answer as a correct response. - $context['RESPONSE'] = new Identifier('ChoiceA'); + $context['RESPONSE'] = new QtiIdentifier('ChoiceA'); $engine->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $context['SCORE']); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $context['SCORE']); $this->assertEquals(1.0, $context['SCORE']->getValue()); } diff --git a/test/qtismtest/runtime/processing/TemplateProcessingEngineTest.php b/test/qtismtest/runtime/processing/TemplateProcessingEngineTest.php index 7ea6a3550..946f21185 100644 --- a/test/qtismtest/runtime/processing/TemplateProcessingEngineTest.php +++ b/test/qtismtest/runtime/processing/TemplateProcessingEngineTest.php @@ -4,7 +4,7 @@ use qtismtest\QtiSmTestCase; use qtism\runtime\common\TemplateVariable; use qtism\runtime\processing\TemplateProcessingEngine; -use qtism\common\datatypes\Integer; +use qtism\common\datatypes\QtiInteger; use qtism\common\enums\BaseType; use qtism\common\enums\Cardinality; use qtism\runtime\common\State; @@ -33,7 +33,7 @@ public function testVeryBasic() { '); $state = new State( - array(new TemplateVariable('TEMPLATE', Cardinality::SINGLE, BaseType::INTEGER, new Integer(1336))) + array(new TemplateVariable('TEMPLATE', Cardinality::SINGLE, BaseType::INTEGER, new QtiInteger(1336))) ); $engine = new TemplateProcessingEngine($component, $state); @@ -87,7 +87,7 @@ public function testTemplateConstraintImpossibleWithTemplateVariableOnly() { '); $var = new TemplateVariable('TEMPLATE', Cardinality::SINGLE, BaseType::INTEGER); - $var->setDefaultValue(new Integer(-1)); + $var->setDefaultValue(new QtiInteger(-1)); $state = new State( array($var) ); diff --git a/test/qtismtest/runtime/rendering/markup/MarkupPostRendererTest.php b/test/qtismtest/runtime/rendering/markup/MarkupPostRendererTest.php index e98023b11..4cfde098c 100644 --- a/test/qtismtest/runtime/rendering/markup/MarkupPostRendererTest.php +++ b/test/qtismtest/runtime/rendering/markup/MarkupPostRendererTest.php @@ -51,14 +51,14 @@ public function testTemplateOrientedFeedback() { $file = file($file); // Check file consistency... - $this->assertEquals("", trim($file[3])); - $this->assertEquals("", trim($file[5])); + $this->assertEquals("", trim($file[3])); + $this->assertEquals("", trim($file[5])); $this->assertEquals("", trim($file[9])); $this->assertEquals("", trim($file[11])); - $this->assertEquals("", trim($file[13])); + $this->assertEquals("", trim($file[13])); $this->assertEquals("", trim($file[15])); $this->assertEquals("
", trim($file[17])); - $this->assertEquals("", trim($file[19])); + $this->assertEquals("", trim($file[19])); $this->assertEquals("", trim($file[21])); // Check output consistency... @@ -69,14 +69,14 @@ public function testTemplateOrientedFeedback() { file_put_contents($filename, $output); $file = file($filename); - $this->assertEquals("getValue() == 'showoutcome1'): ?>", trim($file[2])); - $this->assertEquals("getValue() != 'hideoutcome2'): ?>", trim($file[4])); + $this->assertEquals("getValue() == 'showoutcome1'): ?>", trim($file[2])); + $this->assertEquals("getValue() != 'hideoutcome2'): ?>", trim($file[4])); $this->assertEquals("", trim($file[8])); $this->assertEquals("", trim($file[10])); - $this->assertEquals("getValue() != 'hideoutcome3'): ?>", trim($file[12])); + $this->assertEquals("getValue() != 'hideoutcome3'): ?>", trim($file[12])); $this->assertEquals("", trim($file[14])); $this->assertEquals("
", trim($file[16])); - $this->assertEquals("getValue() == 'showoutcome4'): ?>", trim($file[18])); + $this->assertEquals("getValue() == 'showoutcome4'): ?>", trim($file[18])); $this->assertEquals("", trim($file[20])); unlink($filename); diff --git a/test/qtismtest/runtime/rules/LookupOutcomeValueProcessorTest.php b/test/qtismtest/runtime/rules/LookupOutcomeValueProcessorTest.php index 0aa4db95c..1b33549ca 100644 --- a/test/qtismtest/runtime/rules/LookupOutcomeValueProcessorTest.php +++ b/test/qtismtest/runtime/rules/LookupOutcomeValueProcessorTest.php @@ -2,7 +2,7 @@ namespace qtismtest\runtime\rules; use qtismtest\QtiSmTestCase; -use qtism\common\datatypes\Pair; +use qtism\common\datatypes\QtiPair; use qtism\runtime\common\State; use qtism\common\enums\BaseType; use qtism\common\enums\Cardinality; @@ -36,15 +36,15 @@ public function testLookupOutcomeValueSimpleMatchTable() { $this->assertSame(null, $state['outcome1']); $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Pair', $state['outcome1']); - $this->assertTrue($state['outcome1']->equals(new Pair('C', 'D'))); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiPair', $state['outcome1']); + $this->assertTrue($state['outcome1']->equals(new QtiPair('C', 'D'))); // Try to get the default value. $expr = $rule->getExpression(); $expr->setValue(5); $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Pair', $state['outcome1']); - $this->assertTrue($state['outcome1']->equals(new Pair('Y', 'Z'))); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiPair', $state['outcome1']); + $this->assertTrue($state['outcome1']->equals(new QtiPair('Y', 'Z'))); } public function testLookupOutcomeValueSimpleInterpolationTable() { @@ -71,7 +71,7 @@ public function testLookupOutcomeValueSimpleInterpolationTable() { $this->assertSame(null, $state['outcome1']); $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\String', $state['outcome1']); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiString', $state['outcome1']); $this->assertEquals('Awesome!', $state['outcome1']->getValue()); // include the boundary for interpolationTableEntry[1] @@ -80,14 +80,14 @@ public function testLookupOutcomeValueSimpleInterpolationTable() { $entries[1]->setIncludeBoundary(true); $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\String', $state['outcome1']); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiString', $state['outcome1']); $this->assertEquals('Piece of cake!', $state['outcome1']->getValue()); // get the default value. $expr = $rule->getExpression(); $expr->setValue(4.0); $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\String', $state['outcome1']); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiString', $state['outcome1']); $this->assertEquals("What's going on?", $state['outcome1']->getValue()); } } \ No newline at end of file diff --git a/test/qtismtest/runtime/rules/OutcomeConditionProcessorTest.php b/test/qtismtest/runtime/rules/OutcomeConditionProcessorTest.php index 328114e97..c64cb5b32 100644 --- a/test/qtismtest/runtime/rules/OutcomeConditionProcessorTest.php +++ b/test/qtismtest/runtime/rules/OutcomeConditionProcessorTest.php @@ -2,8 +2,8 @@ namespace qtismtest\runtime\rules; use qtismtest\QtiSmTestCase; -use qtism\common\datatypes\String; -use qtism\common\datatypes\Integer; +use qtism\common\datatypes\QtiString; +use qtism\common\datatypes\QtiInteger; use qtism\common\enums\BaseType; use qtism\common\enums\Cardinality; use qtism\runtime\common\OutcomeVariable; @@ -125,11 +125,11 @@ public function testWrongRuleType() { public function testOutcomeConditionComplexProvider() { return array( - array(new Integer(1), new Integer(1), 'A', 'C', null), - array(new Integer(1), new Integer(0), 'B', 'C', null), - array(new Integer(2), new Integer(0), null, 'A', 'B'), - array(new Integer(3), new Integer(0), 'V', null, null), - array(new Integer(4), new Integer(1), 'Z', null, null) + array(new QtiInteger(1), new QtiInteger(1), 'A', 'C', null), + array(new QtiInteger(1), new QtiInteger(0), 'B', 'C', null), + array(new QtiInteger(2), new QtiInteger(0), null, 'A', 'B'), + array(new QtiInteger(3), new QtiInteger(0), 'V', null, null), + array(new QtiInteger(4), new QtiInteger(1), 'Z', null, null) ); } } \ No newline at end of file diff --git a/test/qtismtest/runtime/rules/ResponseConditionProcessorTest.php b/test/qtismtest/runtime/rules/ResponseConditionProcessorTest.php index 7243733ed..a110e0ea4 100644 --- a/test/qtismtest/runtime/rules/ResponseConditionProcessorTest.php +++ b/test/qtismtest/runtime/rules/ResponseConditionProcessorTest.php @@ -2,8 +2,8 @@ namespace qtismtest\runtime\rules; use qtismtest\QtiSmTestCase; -use qtism\common\datatypes\Float; -use qtism\common\datatypes\Identifier; +use qtism\common\datatypes\QtiFloat; +use qtism\common\datatypes\QtiIdentifier; use qtism\runtime\common\ResponseVariable; use qtism\common\enums\BaseType; use qtism\common\enums\Cardinality; @@ -49,7 +49,7 @@ public function testResponseConditionMatchCorrect($response, $expectedScore) { '); $responseVar = ResponseVariable::createFromDataModel($responseVarDeclaration); - $this->assertTrue($responseVar->getCorrectResponse()->equals(new Identifier('ChoiceA'))); + $this->assertTrue($responseVar->getCorrectResponse()->equals(new QtiIdentifier('ChoiceA'))); // Set 'ChoiceA' to 'RESPONSE' in order to get a score of 1.0. $responseVar->setValue($response); @@ -69,16 +69,16 @@ public function testResponseConditionMatchCorrect($response, $expectedScore) { $processor->setState($state); $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $state['SCORE']); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $state['SCORE']); $this->assertTrue($expectedScore->equals($state['SCORE'])); } public function responseConditionMatchCorrectProvider() { return array( - array(new Identifier('ChoiceA'), new Float(1.0)), - array(new Identifier('ChoiceB'), new Float(0.0)), - array(new Identifier('ChoiceC'), new Float(0.0)), - array(new Identifier('ChoiceD'), new Float(0.0)) + array(new QtiIdentifier('ChoiceA'), new QtiFloat(1.0)), + array(new QtiIdentifier('ChoiceB'), new QtiFloat(0.0)), + array(new QtiIdentifier('ChoiceC'), new QtiFloat(0.0)), + array(new QtiIdentifier('ChoiceD'), new QtiFloat(0.0)) ); } } \ No newline at end of file diff --git a/test/qtismtest/runtime/rules/SetCorrectResponseProcessorTest.php b/test/qtismtest/runtime/rules/SetCorrectResponseProcessorTest.php index fd2f31eeb..d228d1fd9 100644 --- a/test/qtismtest/runtime/rules/SetCorrectResponseProcessorTest.php +++ b/test/qtismtest/runtime/rules/SetCorrectResponseProcessorTest.php @@ -24,7 +24,7 @@ public function testSetCorrectResponseSimple() { $processor->setState($state); $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Identifier', $state->getVariable('RESPONSE')->getCorrectResponse()); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiIdentifier', $state->getVariable('RESPONSE')->getCorrectResponse()); $this->assertEquals('ChoiceA', $state->getVariable('RESPONSE')->getCorrectResponse()->getValue()); } diff --git a/test/qtismtest/runtime/rules/SetDefaultValueProcessorTest.php b/test/qtismtest/runtime/rules/SetDefaultValueProcessorTest.php index 886095676..d710163bb 100644 --- a/test/qtismtest/runtime/rules/SetDefaultValueProcessorTest.php +++ b/test/qtismtest/runtime/rules/SetDefaultValueProcessorTest.php @@ -4,8 +4,8 @@ use qtismtest\QtiSmTestCase; use qtism\common\enums\BaseType; use qtism\common\enums\Cardinality; -use qtism\common\datatypes\Float; -use qtism\common\datatypes\Identifier; +use qtism\common\datatypes\QtiFloat; +use qtism\common\datatypes\QtiIdentifier; use qtism\runtime\common\State; use qtism\runtime\common\ResponseVariable; use qtism\runtime\common\OutcomeVariable; @@ -23,13 +23,13 @@ public function testDefaultValueOnResponseSimple() { $processor = new SetDefaultValueProcessor($rule); $response = new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER); - $response->setDefaultValue(new Identifier('hello')); + $response->setDefaultValue(new QtiIdentifier('hello')); $state = new State(array($response)); $processor->setState($state); $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Identifier', $state->getVariable('RESPONSE')->getDefaultValue()); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiIdentifier', $state->getVariable('RESPONSE')->getDefaultValue()); $this->assertEquals('there', $state->getVariable('RESPONSE')->getDefaultValue()->getValue()); } @@ -42,7 +42,7 @@ public function testDefaultValueOnOutcomeSimple() { $processor = new SetDefaultValueProcessor($rule); $response = new OutcomeVariable('SCORE', Cardinality::SINGLE, BaseType::FLOAT); - $response->setDefaultValue(new Float(0.0)); + $response->setDefaultValue(new QtiFloat(0.0)); $state = new State(array($response)); $processor->setState($state); diff --git a/test/qtismtest/runtime/rules/SetOutcomeValueProcessorTest.php b/test/qtismtest/runtime/rules/SetOutcomeValueProcessorTest.php index 722f6a36b..73bd5e883 100644 --- a/test/qtismtest/runtime/rules/SetOutcomeValueProcessorTest.php +++ b/test/qtismtest/runtime/rules/SetOutcomeValueProcessorTest.php @@ -3,7 +3,7 @@ use qtismtest\QtiSmTestCase; use qtism\runtime\rules\RuleProcessingException; -use qtism\common\datatypes\Boolean; +use qtism\common\datatypes\QtiBoolean; use qtism\runtime\common\State; use qtism\common\enums\BaseType; use qtism\common\enums\Cardinality; @@ -27,7 +27,7 @@ public function testSetOutcomeValueSimple() { // The state must be modified. // OutcomeVariable with identifier 'SCORE' must contain 4.3. - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $state['SCORE']); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $state['SCORE']); $this->assertEquals(4.3, $state['SCORE']->getValue()); } @@ -44,7 +44,7 @@ public function testSetOutcomeValueJugglingFromIntToFloat() { $processor->setState($state); $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $state['SCORE']); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $state['SCORE']); $this->assertEquals(4.0, $state['SCORE']->getValue()); } @@ -61,7 +61,7 @@ public function testSetOtucomeValueJugglingFromFloatToInt() { $processor->setState($state); $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\INTEGER', $state['SCORE']); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiInteger', $state['SCORE']); $this->assertEquals(4, $state['SCORE']->getValue()); } @@ -130,13 +130,13 @@ public function testSetOutcomeValueModerate() { '); $processor = new SetOutcomeValueProcessor($rule); - $myBool = new OutcomeVariable('myBool', Cardinality::SINGLE, BaseType::BOOLEAN, new Boolean(false)); + $myBool = new OutcomeVariable('myBool', Cardinality::SINGLE, BaseType::BOOLEAN, new QtiBoolean(false)); $state = new State(array($myBool)); $this->assertFalse($state['myBool']->getValue()); $processor->setState($state); $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Boolean', $state['myBool']); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiBoolean', $state['myBool']); $this->assertTrue($state['myBool']->getValue()); } diff --git a/test/qtismtest/runtime/rules/SetTemplateValueProcessorTest.php b/test/qtismtest/runtime/rules/SetTemplateValueProcessorTest.php index b837b9742..c25c5455a 100644 --- a/test/qtismtest/runtime/rules/SetTemplateValueProcessorTest.php +++ b/test/qtismtest/runtime/rules/SetTemplateValueProcessorTest.php @@ -3,7 +3,7 @@ use qtismtest\QtiSmTestCase; use qtism\runtime\rules\RuleProcessingException; -use qtism\common\datatypes\Boolean; +use qtism\common\datatypes\QtiBoolean; use qtism\runtime\common\State; use qtism\common\enums\BaseType; use qtism\common\enums\Cardinality; @@ -27,7 +27,7 @@ public function testSetTemplateValueSimple() { // The state must be modified. // TemplateVariable with identifier 'TPL1' must contain 4.3. - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $state['TPL1']); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $state['TPL1']); $this->assertEquals(4.3, $state['TPL1']->getValue()); } @@ -44,7 +44,7 @@ public function testSetTemplateValueJugglingFromIntToFloat() { $processor->setState($state); $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $state['TPL1']); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $state['TPL1']); $this->assertEquals(4.0, $state['TPL1']->getValue()); } @@ -61,7 +61,7 @@ public function testSetTemplateValueJugglingFromFloatToInt() { $processor->setState($state); $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\INTEGER', $state['TPL1']); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiInteger', $state['TPL1']); $this->assertEquals(4, $state['TPL1']->getValue()); } @@ -130,13 +130,13 @@ public function testSetOutcomeValueModerate() { '); $processor = new SetTemplateValueProcessor($rule); - $myBool = new TemplateVariable('myBool', Cardinality::SINGLE, BaseType::BOOLEAN, new Boolean(false)); + $myBool = new TemplateVariable('myBool', Cardinality::SINGLE, BaseType::BOOLEAN, new QtiBoolean(false)); $state = new State(array($myBool)); $this->assertFalse($state['myBool']->getValue()); $processor->setState($state); $processor->process(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Boolean', $state['myBool']); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiBoolean', $state['myBool']); $this->assertTrue($state['myBool']->getValue()); } diff --git a/test/qtismtest/runtime/rules/TemplateConditionProcessorTest.php b/test/qtismtest/runtime/rules/TemplateConditionProcessorTest.php index 97b4472a7..d2afb75b2 100644 --- a/test/qtismtest/runtime/rules/TemplateConditionProcessorTest.php +++ b/test/qtismtest/runtime/rules/TemplateConditionProcessorTest.php @@ -2,7 +2,7 @@ namespace qtismtest\runtime\rules; use qtismtest\QtiSmTestCase; -use qtism\common\datatypes\Integer; +use qtism\common\datatypes\QtiInteger; use qtism\runtime\common\OutcomeVariable; use qtism\runtime\common\ResponseVariable; use qtism\runtime\rules\TemplateConditionProcessor; @@ -102,7 +102,7 @@ public function testTemplateConditionSimpleIfElseIfElse($controlValue, $expected '); $stateArray = array( - new OutcomeVariable('CONTROL', Cardinality::SINGLE, BaseType::INTEGER, new Integer($controlValue)), + new OutcomeVariable('CONTROL', Cardinality::SINGLE, BaseType::INTEGER, new QtiInteger($controlValue)), new TemplateVariable('TPL1', Cardinality::SINGLE, BaseType::INTEGER) ); $state = new State($stateArray); diff --git a/test/qtismtest/runtime/storage/binary/QtiBinaryStreamAccessFsFileTest.php b/test/qtismtest/runtime/storage/binary/QtiBinaryStreamAccessFsFileTest.php index bdf96e87d..9b74875f8 100644 --- a/test/qtismtest/runtime/storage/binary/QtiBinaryStreamAccessFsFileTest.php +++ b/test/qtismtest/runtime/storage/binary/QtiBinaryStreamAccessFsFileTest.php @@ -5,13 +5,13 @@ use qtism\runtime\tests\SessionManager; use qtism\common\datatypes\files\DefaultFileManager; use qtism\common\datatypes\files\FileSystemFile; -use qtism\common\datatypes\Uri; -use qtism\common\datatypes\IntOrIdentifier; -use qtism\common\datatypes\String; -use qtism\common\datatypes\Boolean; -use qtism\common\datatypes\Float; -use qtism\common\datatypes\Identifier; -use qtism\common\datatypes\Integer; +use qtism\common\datatypes\QtiUri; +use qtism\common\datatypes\QtiIntOrIdentifier; +use qtism\common\datatypes\QtiString; +use qtism\common\datatypes\QtiBoolean; +use qtism\common\datatypes\QtiFloat; +use qtism\common\datatypes\QtiIdentifier; +use qtism\common\datatypes\QtiInteger; use qtism\common\collections\IdentifierCollection; use qtism\data\SubmissionMode; use qtism\data\NavigationMode; @@ -23,11 +23,11 @@ use qtism\runtime\tests\AssessmentItemSessionState; use qtism\runtime\storage\common\AssessmentTestSeeker; use qtism\data\storage\xml\XmlCompactDocument; -use qtism\common\datatypes\Point; -use qtism\common\datatypes\DirectedPair; -use qtism\common\datatypes\Pair; +use qtism\common\datatypes\QtiPoint; +use qtism\common\datatypes\QtiDirectedPair; +use qtism\common\datatypes\QtiPair; use qtism\common\Comparable; -use qtism\common\datatypes\Duration; +use qtism\common\datatypes\QtiDuration; use qtism\runtime\common\RecordContainer; use qtism\runtime\common\OrderedContainer; use qtism\runtime\common\MultipleContainer; @@ -104,175 +104,175 @@ public function readVariableValueProvider() { $rw_defaultValue = QtiBinaryStreamAccessFsFile::RW_DEFAULTVALUE; $rw_correctResponse = QtiBinaryStreamAccessFsFile::RW_CORRECTRESPONSE; - $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::SINGLE, BaseType::INTEGER, new Integer(45)), "\x01", null); - $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::SINGLE, BaseType::INTEGER, new Integer(45)), "\x01", null, $rw_defaultValue); + $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::SINGLE, BaseType::INTEGER, new QtiInteger(45)), "\x01", null); + $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::SINGLE, BaseType::INTEGER, new QtiInteger(45)), "\x01", null, $rw_defaultValue); $returnValue[] = array(new ResponseVariable('VAR', Cardinality::SINGLE, BaseType::INTEGER), "\x00" . "\x01" . pack('l', 45), 45); $returnValue[] = array(new ResponseVariable('VAR', Cardinality::SINGLE, BaseType::INTEGER), "\x00" . "\x01" . pack('l', 45), 45, $rw_defaultValue); $returnValue[] = array(new ResponseVariable('VAR', Cardinality::SINGLE, BaseType::INTEGER), "\x00" . "\x01" . pack('l', 45), 45, $rw_correctResponse); - $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::INTEGER), "\x00" . "\x00" . pack('S', 3) . "\x00" . pack('l', 0) . "\x00" . pack('l', -20) . "\x00" . pack('l', 65000), new MultipleContainer(BaseType::INTEGER, array(new Integer(0), new Integer(-20), new Integer(65000)))); - $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::INTEGER), "\x00" . "\x00" . pack('S', 3) . "\x00" . pack('l', 0) . "\x00" . pack('l', -20) . "\x00" . pack('l', 65000), new MultipleContainer(BaseType::INTEGER, array(new Integer(0), new Integer(-20), new Integer(65000))), $rw_defaultValue); - $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::INTEGER), "\x00" . "\x00" . pack('S', 3) . "\x00" . pack('l', 0) . "\x01" . "\x00" . pack('l', 65000), new MultipleContainer(BaseType::INTEGER, array(new Integer(0), null, new Integer(65000)))); - $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::INTEGER), "\x00" . "\x00" . pack('S', 3) . "\x00" . pack('l', 0) . "\x01" . "\x00" . pack('l', 65000), new MultipleContainer(BaseType::INTEGER, array(new Integer(0), null, new Integer(65000))), $rw_defaultValue); - $returnValue[] = array(new ResponseVariable('VAR', Cardinality::ORDERED, BaseType::INTEGER), "\x00" . "\x00" . pack('S', 1) . "\x00" . pack('l', 1337), new OrderedContainer(BaseType::INTEGER, array(new Integer(1337)))); - $returnValue[] = array(new ResponseVariable('VAR', Cardinality::ORDERED, BaseType::INTEGER), "\x00" . "\x00" . pack('S', 1) . "\x00" . pack('l', 1337), new OrderedContainer(BaseType::INTEGER, array(new Integer(1337))), $rw_defaultValue); - $returnValue[] = array(new ResponseVariable('VAR', Cardinality::ORDERED, BaseType::INTEGER), "\x00" . "\x00" . pack('S', 1) . "\x00" . pack('l', 1337), new OrderedContainer(BaseType::INTEGER, array(new Integer(1337))), $rw_correctResponse); + $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::INTEGER), "\x00" . "\x00" . pack('S', 3) . "\x00" . pack('l', 0) . "\x00" . pack('l', -20) . "\x00" . pack('l', 65000), new MultipleContainer(BaseType::INTEGER, array(new QtiInteger(0), new QtiInteger(-20), new QtiInteger(65000)))); + $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::INTEGER), "\x00" . "\x00" . pack('S', 3) . "\x00" . pack('l', 0) . "\x00" . pack('l', -20) . "\x00" . pack('l', 65000), new MultipleContainer(BaseType::INTEGER, array(new QtiInteger(0), new QtiInteger(-20), new QtiInteger(65000))), $rw_defaultValue); + $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::INTEGER), "\x00" . "\x00" . pack('S', 3) . "\x00" . pack('l', 0) . "\x01" . "\x00" . pack('l', 65000), new MultipleContainer(BaseType::INTEGER, array(new QtiInteger(0), null, new QtiInteger(65000)))); + $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::INTEGER), "\x00" . "\x00" . pack('S', 3) . "\x00" . pack('l', 0) . "\x01" . "\x00" . pack('l', 65000), new MultipleContainer(BaseType::INTEGER, array(new QtiInteger(0), null, new QtiInteger(65000))), $rw_defaultValue); + $returnValue[] = array(new ResponseVariable('VAR', Cardinality::ORDERED, BaseType::INTEGER), "\x00" . "\x00" . pack('S', 1) . "\x00" . pack('l', 1337), new OrderedContainer(BaseType::INTEGER, array(new QtiInteger(1337)))); + $returnValue[] = array(new ResponseVariable('VAR', Cardinality::ORDERED, BaseType::INTEGER), "\x00" . "\x00" . pack('S', 1) . "\x00" . pack('l', 1337), new OrderedContainer(BaseType::INTEGER, array(new QtiInteger(1337))), $rw_defaultValue); + $returnValue[] = array(new ResponseVariable('VAR', Cardinality::ORDERED, BaseType::INTEGER), "\x00" . "\x00" . pack('S', 1) . "\x00" . pack('l', 1337), new OrderedContainer(BaseType::INTEGER, array(new QtiInteger(1337))), $rw_correctResponse); $returnValue[] = array(new TemplateVariable('VAR', Cardinality::MULTIPLE, BaseType::INTEGER), "\x00" . "\x00" . pack('S', 0), new MultipleContainer(BaseType::INTEGER)); $returnValue[] = array(new TemplateVariable('VAR', Cardinality::MULTIPLE, BaseType::INTEGER), "\x00" . "\x00" . pack('S', 0), new MultipleContainer(BaseType::INTEGER), $rw_defaultValue); - $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::INTEGER, new OrderedContainer(BaseType::INTEGER, array(new Integer(1)))), "\x01", null); - $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::INTEGER, new OrderedContainer(BaseType::INTEGER, array(new Integer(1)))), "\x01", null, $rw_defaultValue); + $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::INTEGER, new OrderedContainer(BaseType::INTEGER, array(new QtiInteger(1)))), "\x01", null); + $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::INTEGER, new OrderedContainer(BaseType::INTEGER, array(new QtiInteger(1)))), "\x01", null, $rw_defaultValue); - $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::SINGLE, BaseType::FLOAT, new Float(45.5)), "\x01", null); - $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::SINGLE, BaseType::FLOAT, new Float(45.5)), "\x01", null, $rw_defaultValue); + $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::SINGLE, BaseType::FLOAT, new QtiFloat(45.5)), "\x01", null); + $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::SINGLE, BaseType::FLOAT, new QtiFloat(45.5)), "\x01", null, $rw_defaultValue); $returnValue[] = array(new ResponseVariable('VAR', Cardinality::SINGLE, BaseType::FLOAT), "\x00" . "\x01" . pack('d', 45.5), 45.5); $returnValue[] = array(new ResponseVariable('VAR', Cardinality::SINGLE, BaseType::FLOAT), "\x00" . "\x01" . pack('d', 45.5), 45.5, $rw_defaultValue); $returnValue[] = array(new ResponseVariable('VAR', Cardinality::SINGLE, BaseType::FLOAT), "\x00" . "\x01" . pack('d', 45.5), 45.5, $rw_correctResponse); - $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::FLOAT), "\x00" . "\x00" . pack('S', 3) . "\x00" . pack('d', 0.0) . "\x00" . pack('d', -20.666) . "\x00" . pack('d', 65000.56), new MultipleContainer(BaseType::FLOAT, array(new Float(0.0), new Float(-20.666), new Float(65000.56)))); - $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::FLOAT), "\x00" . "\x00" . pack('S', 3) . "\x00" . pack('d', 0.0) . "\x00" . pack('d', -20.666) . "\x00" . pack('d', 65000.56), new MultipleContainer(BaseType::FLOAT, array(new Float(0.0), new Float(-20.666), new Float(65000.56))), $rw_defaultValue); - $returnValue[] = array(new ResponseVariable('VAR', Cardinality::ORDERED, BaseType::FLOAT), "\x00" . "\x00" . pack('S', 1) . "\x00" . pack('d', 1337.666), new OrderedContainer(BaseType::FLOAT, array(new Float(1337.666)))); - $returnValue[] = array(new ResponseVariable('VAR', Cardinality::ORDERED, BaseType::FLOAT), "\x00" . "\x00" . pack('S', 1) . "\x00" . pack('d', 1337.666), new OrderedContainer(BaseType::FLOAT, array(new Float(1337.666))), $rw_defaultValue); - $returnValue[] = array(new ResponseVariable('VAR', Cardinality::ORDERED, BaseType::FLOAT), "\x00" . "\x00" . pack('S', 1) . "\x00" . pack('d', 1337.666), new OrderedContainer(BaseType::FLOAT, array(new Float(1337.666))), $rw_correctResponse); + $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::FLOAT), "\x00" . "\x00" . pack('S', 3) . "\x00" . pack('d', 0.0) . "\x00" . pack('d', -20.666) . "\x00" . pack('d', 65000.56), new MultipleContainer(BaseType::FLOAT, array(new QtiFloat(0.0), new QtiFloat(-20.666), new QtiFloat(65000.56)))); + $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::FLOAT), "\x00" . "\x00" . pack('S', 3) . "\x00" . pack('d', 0.0) . "\x00" . pack('d', -20.666) . "\x00" . pack('d', 65000.56), new MultipleContainer(BaseType::FLOAT, array(new QtiFloat(0.0), new QtiFloat(-20.666), new QtiFloat(65000.56))), $rw_defaultValue); + $returnValue[] = array(new ResponseVariable('VAR', Cardinality::ORDERED, BaseType::FLOAT), "\x00" . "\x00" . pack('S', 1) . "\x00" . pack('d', 1337.666), new OrderedContainer(BaseType::FLOAT, array(new QtiFloat(1337.666)))); + $returnValue[] = array(new ResponseVariable('VAR', Cardinality::ORDERED, BaseType::FLOAT), "\x00" . "\x00" . pack('S', 1) . "\x00" . pack('d', 1337.666), new OrderedContainer(BaseType::FLOAT, array(new QtiFloat(1337.666))), $rw_defaultValue); + $returnValue[] = array(new ResponseVariable('VAR', Cardinality::ORDERED, BaseType::FLOAT), "\x00" . "\x00" . pack('S', 1) . "\x00" . pack('d', 1337.666), new OrderedContainer(BaseType::FLOAT, array(new QtiFloat(1337.666))), $rw_correctResponse); $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::FLOAT), "\x00" . "\x00" . pack('S', 0), new MultipleContainer(BaseType::FLOAT)); $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::FLOAT), "\x00" . "\x00" . pack('S', 0), new MultipleContainer(BaseType::FLOAT), $rw_defaultValue); - $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::FLOAT, new OrderedContainer(BaseType::FLOAT, array(new Float(0.0)))), "\x01", null); - $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::FLOAT, new OrderedContainer(BaseType::FLOAT, array(new Float(0.0)))), "\x01", null, $rw_defaultValue); + $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::FLOAT, new OrderedContainer(BaseType::FLOAT, array(new QtiFloat(0.0)))), "\x01", null); + $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::FLOAT, new OrderedContainer(BaseType::FLOAT, array(new QtiFloat(0.0)))), "\x01", null, $rw_defaultValue); - $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::SINGLE, BaseType::BOOLEAN, new Boolean(true)), "\x01", null); - $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::SINGLE, BaseType::BOOLEAN, new Boolean(true)), "\x01", null, $rw_defaultValue); + $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::SINGLE, BaseType::BOOLEAN, new QtiBoolean(true)), "\x01", null); + $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::SINGLE, BaseType::BOOLEAN, new QtiBoolean(true)), "\x01", null, $rw_defaultValue); $returnValue[] = array(new ResponseVariable('VAR', Cardinality::SINGLE, BaseType::BOOLEAN), "\x00" . "\x01" . "\x01", true); $returnValue[] = array(new ResponseVariable('VAR', Cardinality::SINGLE, BaseType::BOOLEAN), "\x00" . "\x01" . "\x01", true, $rw_defaultValue); $returnValue[] = array(new ResponseVariable('VAR', Cardinality::SINGLE, BaseType::BOOLEAN), "\x00" . "\x01" . "\x01", true, $rw_correctResponse); $returnValue[] = array(new ResponseVariable('VAR', Cardinality::SINGLE, BaseType::BOOLEAN), "\x00" . "\x01" . "\x00", false); $returnValue[] = array(new ResponseVariable('VAR', Cardinality::SINGLE, BaseType::BOOLEAN), "\x00" . "\x01" . "\x00", false, $rw_defaultValue); $returnValue[] = array(new ResponseVariable('VAR', Cardinality::SINGLE, BaseType::BOOLEAN), "\x00" . "\x01" . "\x00", false, $rw_correctResponse); - $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::BOOLEAN), "\x00" . "\x00" . pack('S', 3) . "\x00\x00\x00\x01\x00\x00", new MultipleContainer(BaseType::BOOLEAN, array(new Boolean(false), new Boolean(true), new Boolean(false)))); - $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::BOOLEAN), "\x00" . "\x00" . pack('S', 3) . "\x00\x00\x00\x01\x00\x00", new MultipleContainer(BaseType::BOOLEAN, array(new Boolean(false), new Boolean(true), new Boolean(false))), $rw_defaultValue); - $returnValue[] = array(new ResponseVariable('VAR', Cardinality::ORDERED, BaseType::BOOLEAN), "\x00" . "\x00" . pack('S', 1) . "\x00\x01", new OrderedContainer(BaseType::BOOLEAN, array(new Boolean(true)))); - $returnValue[] = array(new ResponseVariable('VAR', Cardinality::ORDERED, BaseType::BOOLEAN), "\x00" . "\x00" . pack('S', 1) . "\x00\x01", new OrderedContainer(BaseType::BOOLEAN, array(new Boolean(true))), $rw_defaultValue); - $returnValue[] = array(new ResponseVariable('VAR', Cardinality::ORDERED, BaseType::BOOLEAN), "\x00" . "\x00" . pack('S', 1) . "\x00\x01", new OrderedContainer(BaseType::BOOLEAN, array(new Boolean(true))), $rw_correctResponse); + $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::BOOLEAN), "\x00" . "\x00" . pack('S', 3) . "\x00\x00\x00\x01\x00\x00", new MultipleContainer(BaseType::BOOLEAN, array(new QtiBoolean(false), new QtiBoolean(true), new QtiBoolean(false)))); + $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::BOOLEAN), "\x00" . "\x00" . pack('S', 3) . "\x00\x00\x00\x01\x00\x00", new MultipleContainer(BaseType::BOOLEAN, array(new QtiBoolean(false), new QtiBoolean(true), new QtiBoolean(false))), $rw_defaultValue); + $returnValue[] = array(new ResponseVariable('VAR', Cardinality::ORDERED, BaseType::BOOLEAN), "\x00" . "\x00" . pack('S', 1) . "\x00\x01", new OrderedContainer(BaseType::BOOLEAN, array(new QtiBoolean(true)))); + $returnValue[] = array(new ResponseVariable('VAR', Cardinality::ORDERED, BaseType::BOOLEAN), "\x00" . "\x00" . pack('S', 1) . "\x00\x01", new OrderedContainer(BaseType::BOOLEAN, array(new QtiBoolean(true))), $rw_defaultValue); + $returnValue[] = array(new ResponseVariable('VAR', Cardinality::ORDERED, BaseType::BOOLEAN), "\x00" . "\x00" . pack('S', 1) . "\x00\x01", new OrderedContainer(BaseType::BOOLEAN, array(new QtiBoolean(true))), $rw_correctResponse); $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::BOOLEAN), "\x00" . "\x00" . pack('S', 0), new MultipleContainer(BaseType::BOOLEAN)); $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::BOOLEAN), "\x00" . "\x00" . pack('S', 0), new MultipleContainer(BaseType::BOOLEAN), $rw_defaultValue); - $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::BOOLEAN, new OrderedContainer(BaseType::BOOLEAN, array(new Boolean(true)))), "\x01", null); - $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::BOOLEAN, new OrderedContainer(BaseType::BOOLEAN, array(new Boolean(true)))), "\x01", null, $rw_defaultValue); + $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::BOOLEAN, new OrderedContainer(BaseType::BOOLEAN, array(new QtiBoolean(true)))), "\x01", null); + $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::BOOLEAN, new OrderedContainer(BaseType::BOOLEAN, array(new QtiBoolean(true)))), "\x01", null, $rw_defaultValue); - $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::SINGLE, BaseType::STRING, new String('String!')), "\x01", null); - $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::SINGLE, BaseType::STRING, new String('String!')), "\x01", null, $rw_defaultValue); + $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::SINGLE, BaseType::STRING, new QtiString('String!')), "\x01", null); + $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::SINGLE, BaseType::STRING, new QtiString('String!')), "\x01", null, $rw_defaultValue); $returnValue[] = array(new ResponseVariable('VAR', Cardinality::SINGLE, BaseType::STRING), "\x00" . "\x01" . pack('S', 0) . '', ''); $returnValue[] = array(new ResponseVariable('VAR', Cardinality::SINGLE, BaseType::STRING), "\x00" . "\x01" . pack('S', 0) . '', '', $rw_defaultValue); $returnValue[] = array(new ResponseVariable('VAR', Cardinality::SINGLE, BaseType::STRING), "\x00" . "\x01" . pack('S', 0) . '', '', $rw_correctResponse); $returnValue[] = array(new ResponseVariable('VAR', Cardinality::SINGLE, BaseType::STRING), "\x00" . "\x01" . pack('S', 7) . 'String!', 'String!'); $returnValue[] = array(new ResponseVariable('VAR', Cardinality::SINGLE, BaseType::STRING), "\x00" . "\x01" . pack('S', 7) . 'String!', 'String!', $rw_defaultValue); $returnValue[] = array(new ResponseVariable('VAR', Cardinality::SINGLE, BaseType::STRING), "\x00" . "\x01" . pack('S', 7) . 'String!', 'String!', $rw_correctResponse); - $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::STRING), "\x00" . "\x00" . pack('S', 3) . "\x00" . pack('S', 3) . 'ABC' . "\x00" . pack('S', 0) . '' . "\x00" . pack('S', 7) . 'String!', new MultipleContainer(BaseType::STRING, array(new String('ABC'), new String(''), new String('String!')))); - $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::STRING), "\x00" . "\x00" . pack('S', 3) . "\x00" . pack('S', 3) . 'ABC' . "\x00" . pack('S', 0) . '' . "\x00" . pack('S', 7) . 'String!', new MultipleContainer(BaseType::STRING, array(new String('ABC'), new String(''), new String('String!'))), $rw_defaultValue); - $returnValue[] = array(new ResponseVariable('VAR', Cardinality::ORDERED, BaseType::STRING), "\x00" . "\x00" . pack('S', 1) . "\x00" . pack('S', 7) . 'String!', new OrderedContainer(BaseType::STRING, array(new String('String!')))); - $returnValue[] = array(new ResponseVariable('VAR', Cardinality::ORDERED, BaseType::STRING), "\x00" . "\x00" . pack('S', 1) . "\x00" . pack('S', 7) . 'String!', new OrderedContainer(BaseType::STRING, array(new String('String!'))), $rw_defaultValue); - $returnValue[] = array(new ResponseVariable('VAR', Cardinality::ORDERED, BaseType::STRING), "\x00" . "\x00" . pack('S', 1) . "\x00" . pack('S', 7) . 'String!', new OrderedContainer(BaseType::STRING, array(new String('String!'))), $rw_correctResponse); + $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::STRING), "\x00" . "\x00" . pack('S', 3) . "\x00" . pack('S', 3) . 'ABC' . "\x00" . pack('S', 0) . '' . "\x00" . pack('S', 7) . 'String!', new MultipleContainer(BaseType::STRING, array(new QtiString('ABC'), new QtiString(''), new QtiString('String!')))); + $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::STRING), "\x00" . "\x00" . pack('S', 3) . "\x00" . pack('S', 3) . 'ABC' . "\x00" . pack('S', 0) . '' . "\x00" . pack('S', 7) . 'String!', new MultipleContainer(BaseType::STRING, array(new QtiString('ABC'), new QtiString(''), new QtiString('String!'))), $rw_defaultValue); + $returnValue[] = array(new ResponseVariable('VAR', Cardinality::ORDERED, BaseType::STRING), "\x00" . "\x00" . pack('S', 1) . "\x00" . pack('S', 7) . 'String!', new OrderedContainer(BaseType::STRING, array(new QtiString('String!')))); + $returnValue[] = array(new ResponseVariable('VAR', Cardinality::ORDERED, BaseType::STRING), "\x00" . "\x00" . pack('S', 1) . "\x00" . pack('S', 7) . 'String!', new OrderedContainer(BaseType::STRING, array(new QtiString('String!'))), $rw_defaultValue); + $returnValue[] = array(new ResponseVariable('VAR', Cardinality::ORDERED, BaseType::STRING), "\x00" . "\x00" . pack('S', 1) . "\x00" . pack('S', 7) . 'String!', new OrderedContainer(BaseType::STRING, array(new QtiString('String!'))), $rw_correctResponse); $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::STRING), "\x00" . "\x00" . pack('S', 0), new MultipleContainer(BaseType::STRING)); $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::STRING), "\x00" . "\x00" . pack('S', 0), new MultipleContainer(BaseType::STRING), $rw_defaultValue); - $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::STRING, new OrderedContainer(BaseType::STRING, array(new String('pouet')))), "\x01", null, $rw_defaultValue); + $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::STRING, new OrderedContainer(BaseType::STRING, array(new QtiString('pouet')))), "\x01", null, $rw_defaultValue); - $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('Identifier')), "\x01", null); - $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('Identifier')), "\x01", null, $rw_defaultValue); + $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('Identifier')), "\x01", null); + $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('Identifier')), "\x01", null, $rw_defaultValue); $returnValue[] = array(new ResponseVariable('VAR', Cardinality::SINGLE, BaseType::IDENTIFIER), "\x00" . "\x01" . pack('S', 1) . 'A', 'A'); $returnValue[] = array(new ResponseVariable('VAR', Cardinality::SINGLE, BaseType::IDENTIFIER), "\x00" . "\x01" . pack('S', 1) . 'A', 'A', $rw_defaultValue); $returnValue[] = array(new ResponseVariable('VAR', Cardinality::SINGLE, BaseType::IDENTIFIER), "\x00" . "\x01" . pack('S', 1) . 'A', 'A', $rw_correctResponse); $returnValue[] = array(new ResponseVariable('VAR', Cardinality::SINGLE, BaseType::IDENTIFIER), "\x00" . "\x01" . pack('S', 10) . 'Identifier', 'Identifier'); $returnValue[] = array(new ResponseVariable('VAR', Cardinality::SINGLE, BaseType::IDENTIFIER), "\x00" . "\x01" . pack('S', 10) . 'Identifier', 'Identifier', $rw_defaultValue); $returnValue[] = array(new ResponseVariable('VAR', Cardinality::SINGLE, BaseType::IDENTIFIER), "\x00" . "\x01" . pack('S', 10) . 'Identifier', 'Identifier', $rw_correctResponse); - $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::IDENTIFIER), "\x00" . "\x00" . pack('S', 3) . "\x00" . pack('S', 3) . 'Q01' . "\x00" . pack('S', 1) . 'A' . "\x00" . pack('S', 3) . 'Q02', new MultipleContainer(BaseType::IDENTIFIER, array(new Identifier('Q01'), new Identifier('A'), new Identifier('Q02')))); - $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::IDENTIFIER), "\x00" . "\x00" . pack('S', 3) . "\x00" . pack('S', 3) . 'Q01' . "\x00" . pack('S', 1) . 'A' . "\x00" . pack('S', 3) . 'Q02', new MultipleContainer(BaseType::IDENTIFIER, array(new Identifier('Q01'), new Identifier('A'), new Identifier('Q02'))), $rw_defaultValue); - $returnValue[] = array(new ResponseVariable('VAR', Cardinality::ORDERED, BaseType::IDENTIFIER), "\x00" . "\x00" . pack('S', 1) . "\x00" . pack('S', 10) . 'Identifier', new OrderedContainer(BaseType::IDENTIFIER, array(new Identifier('Identifier')))); - $returnValue[] = array(new ResponseVariable('VAR', Cardinality::ORDERED, BaseType::IDENTIFIER), "\x00" . "\x00" . pack('S', 1) . "\x00" . pack('S', 10) . 'Identifier', new OrderedContainer(BaseType::IDENTIFIER, array(new Identifier('Identifier'))), $rw_defaultValue); - $returnValue[] = array(new ResponseVariable('VAR', Cardinality::ORDERED, BaseType::IDENTIFIER), "\x00" . "\x00" . pack('S', 1) . "\x00" . pack('S', 10) . 'Identifier', new OrderedContainer(BaseType::IDENTIFIER, array(new Identifier('Identifier'))), $rw_correctResponse); + $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::IDENTIFIER), "\x00" . "\x00" . pack('S', 3) . "\x00" . pack('S', 3) . 'Q01' . "\x00" . pack('S', 1) . 'A' . "\x00" . pack('S', 3) . 'Q02', new MultipleContainer(BaseType::IDENTIFIER, array(new QtiIdentifier('Q01'), new QtiIdentifier('A'), new QtiIdentifier('Q02')))); + $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::IDENTIFIER), "\x00" . "\x00" . pack('S', 3) . "\x00" . pack('S', 3) . 'Q01' . "\x00" . pack('S', 1) . 'A' . "\x00" . pack('S', 3) . 'Q02', new MultipleContainer(BaseType::IDENTIFIER, array(new QtiIdentifier('Q01'), new QtiIdentifier('A'), new QtiIdentifier('Q02'))), $rw_defaultValue); + $returnValue[] = array(new ResponseVariable('VAR', Cardinality::ORDERED, BaseType::IDENTIFIER), "\x00" . "\x00" . pack('S', 1) . "\x00" . pack('S', 10) . 'Identifier', new OrderedContainer(BaseType::IDENTIFIER, array(new QtiIdentifier('Identifier')))); + $returnValue[] = array(new ResponseVariable('VAR', Cardinality::ORDERED, BaseType::IDENTIFIER), "\x00" . "\x00" . pack('S', 1) . "\x00" . pack('S', 10) . 'Identifier', new OrderedContainer(BaseType::IDENTIFIER, array(new QtiIdentifier('Identifier'))), $rw_defaultValue); + $returnValue[] = array(new ResponseVariable('VAR', Cardinality::ORDERED, BaseType::IDENTIFIER), "\x00" . "\x00" . pack('S', 1) . "\x00" . pack('S', 10) . 'Identifier', new OrderedContainer(BaseType::IDENTIFIER, array(new QtiIdentifier('Identifier'))), $rw_correctResponse); $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::IDENTIFIER), "\x00" . "\x00" . pack('S', 0), new MultipleContainer(BaseType::IDENTIFIER)); $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::IDENTIFIER), "\x00" . "\x00" . pack('S', 0), new MultipleContainer(BaseType::IDENTIFIER), $rw_defaultValue); - $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::IDENTIFIER, new OrderedContainer(BaseType::IDENTIFIER, array(new Identifier('OUTCOMEX')))), "\x01", null); - $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::IDENTIFIER, new OrderedContainer(BaseType::IDENTIFIER, array(new Identifier('OUTCOMEX')))), "\x01", null, $rw_defaultValue); - - $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::SINGLE, BaseType::DURATION, new Duration('PT1S')), "\x01", null); - $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::SINGLE, BaseType::DURATION, new Duration('PT1S')), "\x01", null, $rw_defaultValue); - $returnValue[] = array(new ResponseVariable('VAR', Cardinality::SINGLE, BaseType::DURATION), "\x00" . "\x01" . pack('S', 4) . 'PT1S', new Duration('PT1S')); - $returnValue[] = array(new ResponseVariable('VAR', Cardinality::SINGLE, BaseType::DURATION), "\x00" . "\x01" . pack('S', 4) . 'PT1S', new Duration('PT1S'), $rw_defaultValue); - $returnValue[] = array(new ResponseVariable('VAR', Cardinality::SINGLE, BaseType::DURATION), "\x00" . "\x01" . pack('S', 4) . 'PT1S', new Duration('PT1S'), $rw_correctResponse); - $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::DURATION), "\x00" . "\x00" . pack('S', 3) . "\x00" . pack('S', 4) . 'PT0S' . "\x00" . pack('S', 4) . 'PT1S' . "\x00" . pack('S', 4) . 'PT2S', new MultipleContainer(BaseType::DURATION, array(new Duration('PT0S'), new Duration('PT1S'), new Duration('PT2S')))); - $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::DURATION), "\x00" . "\x00" . pack('S', 3) . "\x00" . pack('S', 4) . 'PT0S' . "\x00" . pack('S', 4) . 'PT1S' . "\x00" . pack('S', 4) . 'PT2S', new MultipleContainer(BaseType::DURATION, array(new Duration('PT0S'), new Duration('PT1S'), new Duration('PT2S'))), $rw_defaultValue); - $returnValue[] = array(new ResponseVariable('VAR', Cardinality::ORDERED, BaseType::DURATION), "\x00" . "\x00" . pack('S', 1) . "\x00" . pack('S', 6) . 'PT2M2S', new OrderedContainer(BaseType::DURATION, array(new Duration('PT2M2S')))); - $returnValue[] = array(new ResponseVariable('VAR', Cardinality::ORDERED, BaseType::DURATION), "\x00" . "\x00" . pack('S', 1) . "\x00" . pack('S', 6) . 'PT2M2S', new OrderedContainer(BaseType::DURATION, array(new Duration('PT2M2S'))), $rw_defaultValue); - $returnValue[] = array(new ResponseVariable('VAR', Cardinality::ORDERED, BaseType::DURATION), "\x00" . "\x00" . pack('S', 1) . "\x00" . pack('S', 6) . 'PT2M2S', new OrderedContainer(BaseType::DURATION, array(new Duration('PT2M2S'))), $rw_correctResponse); + $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::IDENTIFIER, new OrderedContainer(BaseType::IDENTIFIER, array(new QtiIdentifier('OUTCOMEX')))), "\x01", null); + $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::IDENTIFIER, new OrderedContainer(BaseType::IDENTIFIER, array(new QtiIdentifier('OUTCOMEX')))), "\x01", null, $rw_defaultValue); + + $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::SINGLE, BaseType::DURATION, new QtiDuration('PT1S')), "\x01", null); + $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::SINGLE, BaseType::DURATION, new QtiDuration('PT1S')), "\x01", null, $rw_defaultValue); + $returnValue[] = array(new ResponseVariable('VAR', Cardinality::SINGLE, BaseType::DURATION), "\x00" . "\x01" . pack('S', 4) . 'PT1S', new QtiDuration('PT1S')); + $returnValue[] = array(new ResponseVariable('VAR', Cardinality::SINGLE, BaseType::DURATION), "\x00" . "\x01" . pack('S', 4) . 'PT1S', new QtiDuration('PT1S'), $rw_defaultValue); + $returnValue[] = array(new ResponseVariable('VAR', Cardinality::SINGLE, BaseType::DURATION), "\x00" . "\x01" . pack('S', 4) . 'PT1S', new QtiDuration('PT1S'), $rw_correctResponse); + $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::DURATION), "\x00" . "\x00" . pack('S', 3) . "\x00" . pack('S', 4) . 'PT0S' . "\x00" . pack('S', 4) . 'PT1S' . "\x00" . pack('S', 4) . 'PT2S', new MultipleContainer(BaseType::DURATION, array(new QtiDuration('PT0S'), new QtiDuration('PT1S'), new QtiDuration('PT2S')))); + $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::DURATION), "\x00" . "\x00" . pack('S', 3) . "\x00" . pack('S', 4) . 'PT0S' . "\x00" . pack('S', 4) . 'PT1S' . "\x00" . pack('S', 4) . 'PT2S', new MultipleContainer(BaseType::DURATION, array(new QtiDuration('PT0S'), new QtiDuration('PT1S'), new QtiDuration('PT2S'))), $rw_defaultValue); + $returnValue[] = array(new ResponseVariable('VAR', Cardinality::ORDERED, BaseType::DURATION), "\x00" . "\x00" . pack('S', 1) . "\x00" . pack('S', 6) . 'PT2M2S', new OrderedContainer(BaseType::DURATION, array(new QtiDuration('PT2M2S')))); + $returnValue[] = array(new ResponseVariable('VAR', Cardinality::ORDERED, BaseType::DURATION), "\x00" . "\x00" . pack('S', 1) . "\x00" . pack('S', 6) . 'PT2M2S', new OrderedContainer(BaseType::DURATION, array(new QtiDuration('PT2M2S'))), $rw_defaultValue); + $returnValue[] = array(new ResponseVariable('VAR', Cardinality::ORDERED, BaseType::DURATION), "\x00" . "\x00" . pack('S', 1) . "\x00" . pack('S', 6) . 'PT2M2S', new OrderedContainer(BaseType::DURATION, array(new QtiDuration('PT2M2S'))), $rw_correctResponse); $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::DURATION), "\x00" . "\x00" . pack('S', 0), new MultipleContainer(BaseType::DURATION)); $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::DURATION), "\x00" . "\x00" . pack('S', 0), new MultipleContainer(BaseType::DURATION), $rw_defaultValue); - $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::DURATION, new OrderedContainer(BaseType::DURATION, array(new Duration('PT1S')))), "\x01", null); - $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::DURATION, new OrderedContainer(BaseType::DURATION, array(new Duration('PT1S')))), "\x01", null, $rw_defaultValue); - - $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::SINGLE, BaseType::PAIR, new Pair('A', 'B')), "\x01", null); - $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::SINGLE, BaseType::PAIR, new Pair('A', 'B')), "\x01", null, $rw_defaultValue); - $returnValue[] = array(new ResponseVariable('VAR', Cardinality::SINGLE, BaseType::PAIR), "\x00" . "\x01" . pack('S', 1) . 'A' . pack('S', 1) . 'B', new Pair('A', 'B')); - $returnValue[] = array(new ResponseVariable('VAR', Cardinality::SINGLE, BaseType::PAIR), "\x00" . "\x01" . pack('S', 1) . 'A' . pack('S', 1) . 'B', new Pair('A', 'B'), $rw_defaultValue); - $returnValue[] = array(new ResponseVariable('VAR', Cardinality::SINGLE, BaseType::PAIR), "\x00" . "\x01" . pack('S', 1) . 'A' . pack('S', 1) . 'B', new Pair('A', 'B'), $rw_correctResponse); - $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::PAIR), "\x00" . "\x00" . pack('S', 3) . "\x00" . pack('S', 1) . 'A' . pack('S', 1) . 'B' . "\x00" . pack('S', 1) . 'C' . pack('S', 1) . 'D' . "\x00" . pack('S', 1) . 'E' . pack('S', 1) . 'F', new MultipleContainer(BaseType::PAIR, array(new Pair('A', 'B'), new Pair('C', 'D'), new Pair('E', 'F')))); - $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::PAIR), "\x00" . "\x00" . pack('S', 3) . "\x00" . pack('S', 1) . 'A' . pack('S', 1) . 'B' . "\x00" . pack('S', 1) . 'C' . pack('S', 1) . 'D' . "\x00" . pack('S', 1) . 'E' . pack('S', 1) . 'F', new MultipleContainer(BaseType::PAIR, array(new Pair('A', 'B'), new Pair('C', 'D'), new Pair('E', 'F'))), $rw_defaultValue); - $returnValue[] = array(new ResponseVariable('VAR', Cardinality::ORDERED, BaseType::PAIR), "\x00" . "\x00" . pack('S', 1) . "\x00" . pack('S', 2) . 'P1' . pack('S', 2) . 'P2', new OrderedContainer(BaseType::PAIR, array(new Pair('P1', 'P2')))); - $returnValue[] = array(new ResponseVariable('VAR', Cardinality::ORDERED, BaseType::PAIR), "\x00" . "\x00" . pack('S', 1) . "\x00" . pack('S', 2) . 'P1' . pack('S', 2) . 'P2', new OrderedContainer(BaseType::PAIR, array(new Pair('P1', 'P2'))), $rw_defaultValue); - $returnValue[] = array(new ResponseVariable('VAR', Cardinality::ORDERED, BaseType::PAIR), "\x00" . "\x00" . pack('S', 1) . "\x00" . pack('S', 2) . 'P1' . pack('S', 2) . 'P2', new OrderedContainer(BaseType::PAIR, array(new Pair('P1', 'P2'))), $rw_correctResponse); + $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::DURATION, new OrderedContainer(BaseType::DURATION, array(new QtiDuration('PT1S')))), "\x01", null); + $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::DURATION, new OrderedContainer(BaseType::DURATION, array(new QtiDuration('PT1S')))), "\x01", null, $rw_defaultValue); + + $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::SINGLE, BaseType::PAIR, new QtiPair('A', 'B')), "\x01", null); + $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::SINGLE, BaseType::PAIR, new QtiPair('A', 'B')), "\x01", null, $rw_defaultValue); + $returnValue[] = array(new ResponseVariable('VAR', Cardinality::SINGLE, BaseType::PAIR), "\x00" . "\x01" . pack('S', 1) . 'A' . pack('S', 1) . 'B', new QtiPair('A', 'B')); + $returnValue[] = array(new ResponseVariable('VAR', Cardinality::SINGLE, BaseType::PAIR), "\x00" . "\x01" . pack('S', 1) . 'A' . pack('S', 1) . 'B', new QtiPair('A', 'B'), $rw_defaultValue); + $returnValue[] = array(new ResponseVariable('VAR', Cardinality::SINGLE, BaseType::PAIR), "\x00" . "\x01" . pack('S', 1) . 'A' . pack('S', 1) . 'B', new QtiPair('A', 'B'), $rw_correctResponse); + $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::PAIR), "\x00" . "\x00" . pack('S', 3) . "\x00" . pack('S', 1) . 'A' . pack('S', 1) . 'B' . "\x00" . pack('S', 1) . 'C' . pack('S', 1) . 'D' . "\x00" . pack('S', 1) . 'E' . pack('S', 1) . 'F', new MultipleContainer(BaseType::PAIR, array(new QtiPair('A', 'B'), new QtiPair('C', 'D'), new QtiPair('E', 'F')))); + $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::PAIR), "\x00" . "\x00" . pack('S', 3) . "\x00" . pack('S', 1) . 'A' . pack('S', 1) . 'B' . "\x00" . pack('S', 1) . 'C' . pack('S', 1) . 'D' . "\x00" . pack('S', 1) . 'E' . pack('S', 1) . 'F', new MultipleContainer(BaseType::PAIR, array(new QtiPair('A', 'B'), new QtiPair('C', 'D'), new QtiPair('E', 'F'))), $rw_defaultValue); + $returnValue[] = array(new ResponseVariable('VAR', Cardinality::ORDERED, BaseType::PAIR), "\x00" . "\x00" . pack('S', 1) . "\x00" . pack('S', 2) . 'P1' . pack('S', 2) . 'P2', new OrderedContainer(BaseType::PAIR, array(new QtiPair('P1', 'P2')))); + $returnValue[] = array(new ResponseVariable('VAR', Cardinality::ORDERED, BaseType::PAIR), "\x00" . "\x00" . pack('S', 1) . "\x00" . pack('S', 2) . 'P1' . pack('S', 2) . 'P2', new OrderedContainer(BaseType::PAIR, array(new QtiPair('P1', 'P2'))), $rw_defaultValue); + $returnValue[] = array(new ResponseVariable('VAR', Cardinality::ORDERED, BaseType::PAIR), "\x00" . "\x00" . pack('S', 1) . "\x00" . pack('S', 2) . 'P1' . pack('S', 2) . 'P2', new OrderedContainer(BaseType::PAIR, array(new QtiPair('P1', 'P2'))), $rw_correctResponse); $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::PAIR), "\x00" . "\x00" . pack('S', 0), new MultipleContainer(BaseType::PAIR)); $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::PAIR), "\x00" . "\x00" . pack('S', 0), new MultipleContainer(BaseType::PAIR), $rw_defaultValue); - $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::PAIR, new OrderedContainer(BaseType::PAIR, array(new Pair('my', 'pair')))), "\x01", null); - $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::PAIR, new OrderedContainer(BaseType::PAIR, array(new Pair('my', 'pair')))), "\x01", null, $rw_defaultValue); - - $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::SINGLE, BaseType::DIRECTED_PAIR, new DirectedPair('A', 'B')), "\x01", null); - $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::SINGLE, BaseType::DIRECTED_PAIR, new DirectedPair('A', 'B')), "\x01", null, $rw_defaultValue); - $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::SINGLE, BaseType::DIRECTED_PAIR, new DirectedPair('A', 'B')), "\x01", null); - $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::SINGLE, BaseType::DIRECTED_PAIR, new DirectedPair('A', 'B')), "\x01", null, $rw_defaultValue); - $returnValue[] = array(new ResponseVariable('VAR', Cardinality::SINGLE, BaseType::DIRECTED_PAIR), "\x00" . "\x01" . pack('S', 1) . 'A' . pack('S', 1) . 'B', new DirectedPair('A', 'B')); - $returnValue[] = array(new ResponseVariable('VAR', Cardinality::SINGLE, BaseType::DIRECTED_PAIR), "\x00" . "\x01" . pack('S', 1) . 'A' . pack('S', 1) . 'B', new DirectedPair('A', 'B'), $rw_defaultValue); - $returnValue[] = array(new ResponseVariable('VAR', Cardinality::SINGLE, BaseType::DIRECTED_PAIR), "\x00" . "\x01" . pack('S', 1) . 'A' . pack('S', 1) . 'B', new DirectedPair('A', 'B'), $rw_correctResponse); - $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::DIRECTED_PAIR), "\x00" . "\x00" . pack('S', 3) . "\x00" . pack('S', 1) . 'A' . pack('S', 1) . 'B' . "\x00" . pack('S', 1) . 'C' . pack('S', 1) . 'D' . "\x00" . pack('S', 1) . 'E' . pack('S', 1) . 'F', new MultipleContainer(BaseType::DIRECTED_PAIR, array(new DirectedPair('A', 'B'), new DirectedPair('C', 'D'), new DirectedPair('E', 'F')))); - $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::DIRECTED_PAIR), "\x00" . "\x00" . pack('S', 3) . "\x00" . pack('S', 1) . 'A' . pack('S', 1) . 'B' . "\x00" . pack('S', 1) . 'C' . pack('S', 1) . 'D' . "\x00" . pack('S', 1) . 'E' . pack('S', 1) . 'F', new MultipleContainer(BaseType::DIRECTED_PAIR, array(new DirectedPair('A', 'B'), new DirectedPair('C', 'D'), new DirectedPair('E', 'F'))), $rw_defaultValue); - $returnValue[] = array(new ResponseVariable('VAR', Cardinality::ORDERED, BaseType::DIRECTED_PAIR), "\x00" . "\x00" . pack('S', 1) . "\x00" . pack('S', 2) . 'P1' . pack('S', 2) . 'P2', new OrderedContainer(BaseType::DIRECTED_PAIR, array(new DirectedPair('P1', 'P2')))); - $returnValue[] = array(new ResponseVariable('VAR', Cardinality::ORDERED, BaseType::DIRECTED_PAIR), "\x00" . "\x00" . pack('S', 1) . "\x00" . pack('S', 2) . 'P1' . pack('S', 2) . 'P2', new OrderedContainer(BaseType::DIRECTED_PAIR, array(new DirectedPair('P1', 'P2'))), $rw_defaultValue); - $returnValue[] = array(new ResponseVariable('VAR', Cardinality::ORDERED, BaseType::DIRECTED_PAIR), "\x00" . "\x00" . pack('S', 1) . "\x00" . pack('S', 2) . 'P1' . pack('S', 2) . 'P2', new OrderedContainer(BaseType::DIRECTED_PAIR, array(new DirectedPair('P1', 'P2'))), $rw_correctResponse); + $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::PAIR, new OrderedContainer(BaseType::PAIR, array(new QtiPair('my', 'pair')))), "\x01", null); + $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::PAIR, new OrderedContainer(BaseType::PAIR, array(new QtiPair('my', 'pair')))), "\x01", null, $rw_defaultValue); + + $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::SINGLE, BaseType::DIRECTED_PAIR, new QtiDirectedPair('A', 'B')), "\x01", null); + $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::SINGLE, BaseType::DIRECTED_PAIR, new QtiDirectedPair('A', 'B')), "\x01", null, $rw_defaultValue); + $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::SINGLE, BaseType::DIRECTED_PAIR, new QtiDirectedPair('A', 'B')), "\x01", null); + $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::SINGLE, BaseType::DIRECTED_PAIR, new QtiDirectedPair('A', 'B')), "\x01", null, $rw_defaultValue); + $returnValue[] = array(new ResponseVariable('VAR', Cardinality::SINGLE, BaseType::DIRECTED_PAIR), "\x00" . "\x01" . pack('S', 1) . 'A' . pack('S', 1) . 'B', new QtiDirectedPair('A', 'B')); + $returnValue[] = array(new ResponseVariable('VAR', Cardinality::SINGLE, BaseType::DIRECTED_PAIR), "\x00" . "\x01" . pack('S', 1) . 'A' . pack('S', 1) . 'B', new QtiDirectedPair('A', 'B'), $rw_defaultValue); + $returnValue[] = array(new ResponseVariable('VAR', Cardinality::SINGLE, BaseType::DIRECTED_PAIR), "\x00" . "\x01" . pack('S', 1) . 'A' . pack('S', 1) . 'B', new QtiDirectedPair('A', 'B'), $rw_correctResponse); + $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::DIRECTED_PAIR), "\x00" . "\x00" . pack('S', 3) . "\x00" . pack('S', 1) . 'A' . pack('S', 1) . 'B' . "\x00" . pack('S', 1) . 'C' . pack('S', 1) . 'D' . "\x00" . pack('S', 1) . 'E' . pack('S', 1) . 'F', new MultipleContainer(BaseType::DIRECTED_PAIR, array(new QtiDirectedPair('A', 'B'), new QtiDirectedPair('C', 'D'), new QtiDirectedPair('E', 'F')))); + $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::DIRECTED_PAIR), "\x00" . "\x00" . pack('S', 3) . "\x00" . pack('S', 1) . 'A' . pack('S', 1) . 'B' . "\x00" . pack('S', 1) . 'C' . pack('S', 1) . 'D' . "\x00" . pack('S', 1) . 'E' . pack('S', 1) . 'F', new MultipleContainer(BaseType::DIRECTED_PAIR, array(new QtiDirectedPair('A', 'B'), new QtiDirectedPair('C', 'D'), new QtiDirectedPair('E', 'F'))), $rw_defaultValue); + $returnValue[] = array(new ResponseVariable('VAR', Cardinality::ORDERED, BaseType::DIRECTED_PAIR), "\x00" . "\x00" . pack('S', 1) . "\x00" . pack('S', 2) . 'P1' . pack('S', 2) . 'P2', new OrderedContainer(BaseType::DIRECTED_PAIR, array(new QtiDirectedPair('P1', 'P2')))); + $returnValue[] = array(new ResponseVariable('VAR', Cardinality::ORDERED, BaseType::DIRECTED_PAIR), "\x00" . "\x00" . pack('S', 1) . "\x00" . pack('S', 2) . 'P1' . pack('S', 2) . 'P2', new OrderedContainer(BaseType::DIRECTED_PAIR, array(new QtiDirectedPair('P1', 'P2'))), $rw_defaultValue); + $returnValue[] = array(new ResponseVariable('VAR', Cardinality::ORDERED, BaseType::DIRECTED_PAIR), "\x00" . "\x00" . pack('S', 1) . "\x00" . pack('S', 2) . 'P1' . pack('S', 2) . 'P2', new OrderedContainer(BaseType::DIRECTED_PAIR, array(new QtiDirectedPair('P1', 'P2'))), $rw_correctResponse); $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::DIRECTED_PAIR), "\x00" . "\x00" . pack('S', 0), new MultipleContainer(BaseType::DIRECTED_PAIR)); $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::DIRECTED_PAIR), "\x00" . "\x00" . pack('S', 0), new MultipleContainer(BaseType::DIRECTED_PAIR), $rw_defaultValue); - $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::DIRECTED_PAIR, new OrderedContainer(BaseType::DIRECTED_PAIR, array(new DirectedPair('my', 'pair')))), "\x01", null); - $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::DIRECTED_PAIR, new OrderedContainer(BaseType::DIRECTED_PAIR, array(new DirectedPair('my', 'pair')))), "\x01", null, $rw_defaultValue); - - $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::SINGLE, BaseType::POINT, new Point(0, 1)), "\x01", null); - $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::SINGLE, BaseType::POINT, new Point(0, 1)), "\x01", null, $rw_defaultValue); - $returnValue[] = array(new ResponseVariable('VAR', Cardinality::SINGLE, BaseType::POINT), "\x00" . "\x01" . pack('S', 0) . pack('S', 0), new Point(0, 0)); - $returnValue[] = array(new ResponseVariable('VAR', Cardinality::SINGLE, BaseType::POINT), "\x00" . "\x01" . pack('S', 0) . pack('S', 0), new Point(0, 0), $rw_defaultValue); - $returnValue[] = array(new ResponseVariable('VAR', Cardinality::SINGLE, BaseType::POINT), "\x00" . "\x01" . pack('S', 0) . pack('S', 0), new Point(0, 0), $rw_correctResponse); - $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::POINT), "\x00" . "\x00" . pack('S', 3) . "\x00" . pack('S', 4) . pack('S', 3) . "\x01" . "\x00" . pack('S', 2) . pack('S', 1), new MultipleContainer(BaseType::POINT, array(new Point(4, 3), null, new Point(2, 1)))); - $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::POINT), "\x00" . "\x00" . pack('S', 3) . "\x00" . pack('S', 4) . pack('S', 3) . "\x01" . "\x00" . pack('S', 2) . pack('S', 1), new MultipleContainer(BaseType::POINT, array(new Point(4, 3), null, new Point(2, 1))), $rw_defaultValue); - $returnValue[] = array(new ResponseVariable('VAR', Cardinality::ORDERED, BaseType::POINT), "\x00" . "\x00" . pack('S', 1) . "\x00" . pack('S', 6) . pack('S', 1234), new OrderedContainer(BaseType::POINT, array(new Point(6, 1234)))); - $returnValue[] = array(new ResponseVariable('VAR', Cardinality::ORDERED, BaseType::POINT), "\x00" . "\x00" . pack('S', 1) . "\x00" . pack('S', 6) . pack('S', 1234), new OrderedContainer(BaseType::POINT, array(new Point(6, 1234))), $rw_correctResponse); + $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::DIRECTED_PAIR, new OrderedContainer(BaseType::DIRECTED_PAIR, array(new QtiDirectedPair('my', 'pair')))), "\x01", null); + $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::DIRECTED_PAIR, new OrderedContainer(BaseType::DIRECTED_PAIR, array(new QtiDirectedPair('my', 'pair')))), "\x01", null, $rw_defaultValue); + + $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::SINGLE, BaseType::POINT, new QtiPoint(0, 1)), "\x01", null); + $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::SINGLE, BaseType::POINT, new QtiPoint(0, 1)), "\x01", null, $rw_defaultValue); + $returnValue[] = array(new ResponseVariable('VAR', Cardinality::SINGLE, BaseType::POINT), "\x00" . "\x01" . pack('S', 0) . pack('S', 0), new QtiPoint(0, 0)); + $returnValue[] = array(new ResponseVariable('VAR', Cardinality::SINGLE, BaseType::POINT), "\x00" . "\x01" . pack('S', 0) . pack('S', 0), new QtiPoint(0, 0), $rw_defaultValue); + $returnValue[] = array(new ResponseVariable('VAR', Cardinality::SINGLE, BaseType::POINT), "\x00" . "\x01" . pack('S', 0) . pack('S', 0), new QtiPoint(0, 0), $rw_correctResponse); + $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::POINT), "\x00" . "\x00" . pack('S', 3) . "\x00" . pack('S', 4) . pack('S', 3) . "\x01" . "\x00" . pack('S', 2) . pack('S', 1), new MultipleContainer(BaseType::POINT, array(new QtiPoint(4, 3), null, new QtiPoint(2, 1)))); + $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::POINT), "\x00" . "\x00" . pack('S', 3) . "\x00" . pack('S', 4) . pack('S', 3) . "\x01" . "\x00" . pack('S', 2) . pack('S', 1), new MultipleContainer(BaseType::POINT, array(new QtiPoint(4, 3), null, new QtiPoint(2, 1))), $rw_defaultValue); + $returnValue[] = array(new ResponseVariable('VAR', Cardinality::ORDERED, BaseType::POINT), "\x00" . "\x00" . pack('S', 1) . "\x00" . pack('S', 6) . pack('S', 1234), new OrderedContainer(BaseType::POINT, array(new QtiPoint(6, 1234)))); + $returnValue[] = array(new ResponseVariable('VAR', Cardinality::ORDERED, BaseType::POINT), "\x00" . "\x00" . pack('S', 1) . "\x00" . pack('S', 6) . pack('S', 1234), new OrderedContainer(BaseType::POINT, array(new QtiPoint(6, 1234))), $rw_correctResponse); $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::POINT), "\x00" . "\x00" . pack('S', 0), new MultipleContainer(BaseType::POINT)); $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::POINT), "\x00" . "\x00" . pack('S', 0), new MultipleContainer(BaseType::POINT), $rw_defaultValue); - $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::POINT, new OrderedContainer(BaseType::POINT, array(new Point(1, 1)))), "\x01", null); - $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::POINT, new OrderedContainer(BaseType::POINT, array(new Point(1, 1)))), "\x01", null, $rw_defaultValue); + $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::POINT, new OrderedContainer(BaseType::POINT, array(new QtiPoint(1, 1)))), "\x01", null); + $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::POINT, new OrderedContainer(BaseType::POINT, array(new QtiPoint(1, 1)))), "\x01", null, $rw_defaultValue); - $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::SINGLE, BaseType::INT_OR_IDENTIFIER, new IntOrIdentifier(45)), "\x01", null); - $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::SINGLE, BaseType::INT_OR_IDENTIFIER, new IntOrIdentifier(45)), "\x01", null, $rw_defaultValue); + $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::SINGLE, BaseType::INT_OR_IDENTIFIER, new QtiIntOrIdentifier(45)), "\x01", null); + $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::SINGLE, BaseType::INT_OR_IDENTIFIER, new QtiIntOrIdentifier(45)), "\x01", null, $rw_defaultValue); $returnValue[] = array(new ResponseVariable('VAR', Cardinality::SINGLE, BaseType::INT_OR_IDENTIFIER), "\x00" . "\x01" . "\x01" . pack('l', 45), 45); $returnValue[] = array(new ResponseVariable('VAR', Cardinality::SINGLE, BaseType::INT_OR_IDENTIFIER), "\x00" . "\x01" . "\x01" . pack('l', 45), 45, $rw_defaultValue); $returnValue[] = array(new ResponseVariable('VAR', Cardinality::SINGLE, BaseType::INT_OR_IDENTIFIER), "\x00" . "\x01" . "\x01" . pack('l', 45), 45, $rw_correctResponse); $returnValue[] = array(new ResponseVariable('VAR', Cardinality::SINGLE, BaseType::INT_OR_IDENTIFIER), "\x00" . "\x01" . "\x00" . pack('S', 10) . 'Identifier', 'Identifier'); $returnValue[] = array(new ResponseVariable('VAR', Cardinality::SINGLE, BaseType::INT_OR_IDENTIFIER), "\x00" . "\x01" . "\x00" . pack('S', 10) . 'Identifier', 'Identifier', $rw_defaultValue); $returnValue[] = array(new ResponseVariable('VAR', Cardinality::SINGLE, BaseType::INT_OR_IDENTIFIER), "\x00" . "\x01" . "\x00" . pack('S', 10) . 'Identifier', 'Identifier', $rw_correctResponse); - $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::INT_OR_IDENTIFIER), "\x00" . "\x00" . pack('S', 3) . "\x00" . "\x01" . pack('l', 0) . "\x00" . "\x01" . pack('l', -20) . "\x00" . "\x01" . pack('l', 65000), new MultipleContainer(BaseType::INT_OR_IDENTIFIER, array(new IntOrIdentifier(0), new IntOrIdentifier(-20), new IntOrIdentifier(65000)))); - $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::INT_OR_IDENTIFIER), "\x00" . "\x00" . pack('S', 3) . "\x00" . "\x01" . pack('l', 0) . "\x00" . "\x01" . pack('l', -20) . "\x00" . "\x01" . pack('l', 65000), new MultipleContainer(BaseType::INT_OR_IDENTIFIER, array(new IntOrIdentifier(0), new IntOrIdentifier(-20), new IntOrIdentifier(65000))), $rw_defaultValue); - $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::INT_OR_IDENTIFIER), "\x00" . "\x00" . pack('S', 3) . "\x00" . "\x00" . pack('S', 1) . 'A' . "\x00" . "\x00" . pack('S', 1) . 'B' . "\x00" . "\x00" . pack('S', 1) . 'C', new MultipleContainer(BaseType::INT_OR_IDENTIFIER, array(new IntOrIdentifier('A'), new IntOrIdentifier('B'), new IntOrIdentifier('C')))); - $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::INT_OR_IDENTIFIER), "\x00" . "\x00" . pack('S', 3) . "\x00" . "\x00" . pack('S', 1) . 'A' . "\x00" . "\x00" . pack('S', 1) . 'B' . "\x00" . "\x00" . pack('S', 1) . 'C', new MultipleContainer(BaseType::INT_OR_IDENTIFIER, array(new IntOrIdentifier('A'), new IntOrIdentifier('B'), new IntOrIdentifier('C'))), $rw_defaultValue); - $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::INT_OR_IDENTIFIER), "\x00" . "\x00" . pack('S', 3) . "\x00" . "\x00" . pack('S', 1) . 'A' . "\x00" . "\x01" . pack('l', 1337) . "\x00" . "\x00" . pack('S', 1) . 'C', new MultipleContainer(BaseType::INT_OR_IDENTIFIER, array(new IntOrIdentifier('A'), new IntOrIdentifier(1337), new IntOrIdentifier('C')))); - $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::INT_OR_IDENTIFIER), "\x00" . "\x00" . pack('S', 3) . "\x00" . "\x00" . pack('S', 1) . 'A' . "\x00" . "\x01" . pack('l', 1337) . "\x00" . "\x00" . pack('S', 1) . 'C', new MultipleContainer(BaseType::INT_OR_IDENTIFIER, array(new IntOrIdentifier('A'), new IntOrIdentifier(1337), new IntOrIdentifier('C'))), $rw_defaultValue); - $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::INT_OR_IDENTIFIER), "\x00" . "\x00" . pack('S', 3) . "\x00" . "\x01" . pack('l', 0) . "\x01" . "\x00" . "\x01" . pack('l', 65000), new MultipleContainer(BaseType::INT_OR_IDENTIFIER, array(new IntOrIdentifier(0), null, new IntOrIdentifier(65000)))); - $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::INT_OR_IDENTIFIER), "\x00" . "\x00" . pack('S', 3) . "\x00" . "\x01" . pack('l', 0) . "\x01" . "\x00" . "\x01" . pack('l', 65000), new MultipleContainer(BaseType::INT_OR_IDENTIFIER, array(new IntOrIdentifier(0), null, new IntOrIdentifier(65000))), $rw_defaultValue); - $returnValue[] = array(new ResponseVariable('VAR', Cardinality::ORDERED, BaseType::INT_OR_IDENTIFIER), "\x00" . "\x00" . pack('S', 1) . "\x00" . "\x01" . pack('l', 1337), new OrderedContainer(BaseType::INT_OR_IDENTIFIER, array(new IntOrIdentifier(1337)))); - $returnValue[] = array(new ResponseVariable('VAR', Cardinality::ORDERED, BaseType::INT_OR_IDENTIFIER), "\x00" . "\x00" . pack('S', 1) . "\x00" . "\x01" . pack('l', 1337), new OrderedContainer(BaseType::INT_OR_IDENTIFIER, array(new IntOrIdentifier(1337))), $rw_defaultValue); - $returnValue[] = array(new ResponseVariable('VAR', Cardinality::ORDERED, BaseType::INT_OR_IDENTIFIER), "\x00" . "\x00" . pack('S', 1) . "\x00" . "\x01" . pack('l', 1337), new OrderedContainer(BaseType::INT_OR_IDENTIFIER, array(new IntOrIdentifier(1337))), $rw_correctResponse); + $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::INT_OR_IDENTIFIER), "\x00" . "\x00" . pack('S', 3) . "\x00" . "\x01" . pack('l', 0) . "\x00" . "\x01" . pack('l', -20) . "\x00" . "\x01" . pack('l', 65000), new MultipleContainer(BaseType::INT_OR_IDENTIFIER, array(new QtiIntOrIdentifier(0), new QtiIntOrIdentifier(-20), new QtiIntOrIdentifier(65000)))); + $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::INT_OR_IDENTIFIER), "\x00" . "\x00" . pack('S', 3) . "\x00" . "\x01" . pack('l', 0) . "\x00" . "\x01" . pack('l', -20) . "\x00" . "\x01" . pack('l', 65000), new MultipleContainer(BaseType::INT_OR_IDENTIFIER, array(new QtiIntOrIdentifier(0), new QtiIntOrIdentifier(-20), new QtiIntOrIdentifier(65000))), $rw_defaultValue); + $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::INT_OR_IDENTIFIER), "\x00" . "\x00" . pack('S', 3) . "\x00" . "\x00" . pack('S', 1) . 'A' . "\x00" . "\x00" . pack('S', 1) . 'B' . "\x00" . "\x00" . pack('S', 1) . 'C', new MultipleContainer(BaseType::INT_OR_IDENTIFIER, array(new QtiIntOrIdentifier('A'), new QtiIntOrIdentifier('B'), new QtiIntOrIdentifier('C')))); + $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::INT_OR_IDENTIFIER), "\x00" . "\x00" . pack('S', 3) . "\x00" . "\x00" . pack('S', 1) . 'A' . "\x00" . "\x00" . pack('S', 1) . 'B' . "\x00" . "\x00" . pack('S', 1) . 'C', new MultipleContainer(BaseType::INT_OR_IDENTIFIER, array(new QtiIntOrIdentifier('A'), new QtiIntOrIdentifier('B'), new QtiIntOrIdentifier('C'))), $rw_defaultValue); + $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::INT_OR_IDENTIFIER), "\x00" . "\x00" . pack('S', 3) . "\x00" . "\x00" . pack('S', 1) . 'A' . "\x00" . "\x01" . pack('l', 1337) . "\x00" . "\x00" . pack('S', 1) . 'C', new MultipleContainer(BaseType::INT_OR_IDENTIFIER, array(new QtiIntOrIdentifier('A'), new QtiIntOrIdentifier(1337), new QtiIntOrIdentifier('C')))); + $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::INT_OR_IDENTIFIER), "\x00" . "\x00" . pack('S', 3) . "\x00" . "\x00" . pack('S', 1) . 'A' . "\x00" . "\x01" . pack('l', 1337) . "\x00" . "\x00" . pack('S', 1) . 'C', new MultipleContainer(BaseType::INT_OR_IDENTIFIER, array(new QtiIntOrIdentifier('A'), new QtiIntOrIdentifier(1337), new QtiIntOrIdentifier('C'))), $rw_defaultValue); + $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::INT_OR_IDENTIFIER), "\x00" . "\x00" . pack('S', 3) . "\x00" . "\x01" . pack('l', 0) . "\x01" . "\x00" . "\x01" . pack('l', 65000), new MultipleContainer(BaseType::INT_OR_IDENTIFIER, array(new QtiIntOrIdentifier(0), null, new QtiIntOrIdentifier(65000)))); + $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::INT_OR_IDENTIFIER), "\x00" . "\x00" . pack('S', 3) . "\x00" . "\x01" . pack('l', 0) . "\x01" . "\x00" . "\x01" . pack('l', 65000), new MultipleContainer(BaseType::INT_OR_IDENTIFIER, array(new QtiIntOrIdentifier(0), null, new QtiIntOrIdentifier(65000))), $rw_defaultValue); + $returnValue[] = array(new ResponseVariable('VAR', Cardinality::ORDERED, BaseType::INT_OR_IDENTIFIER), "\x00" . "\x00" . pack('S', 1) . "\x00" . "\x01" . pack('l', 1337), new OrderedContainer(BaseType::INT_OR_IDENTIFIER, array(new QtiIntOrIdentifier(1337)))); + $returnValue[] = array(new ResponseVariable('VAR', Cardinality::ORDERED, BaseType::INT_OR_IDENTIFIER), "\x00" . "\x00" . pack('S', 1) . "\x00" . "\x01" . pack('l', 1337), new OrderedContainer(BaseType::INT_OR_IDENTIFIER, array(new QtiIntOrIdentifier(1337))), $rw_defaultValue); + $returnValue[] = array(new ResponseVariable('VAR', Cardinality::ORDERED, BaseType::INT_OR_IDENTIFIER), "\x00" . "\x00" . pack('S', 1) . "\x00" . "\x01" . pack('l', 1337), new OrderedContainer(BaseType::INT_OR_IDENTIFIER, array(new QtiIntOrIdentifier(1337))), $rw_correctResponse); $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::INT_OR_IDENTIFIER), "\x00" . "\x00" . pack('S', 0), new MultipleContainer(BaseType::INT_OR_IDENTIFIER)); $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::INT_OR_IDENTIFIER), "\x00" . "\x00" . pack('S', 0), new MultipleContainer(BaseType::INT_OR_IDENTIFIER), $rw_defaultValue); - $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::INT_OR_IDENTIFIER, new OrderedContainer(BaseType::INT_OR_IDENTIFIER, array(new IntOrIdentifier(1)))), "\x01", null); - $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::INT_OR_IDENTIFIER, new OrderedContainer(BaseType::INT_OR_IDENTIFIER, array(new IntOrIdentifier(1)))), "\x01", null, $rw_defaultValue); + $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::INT_OR_IDENTIFIER, new OrderedContainer(BaseType::INT_OR_IDENTIFIER, array(new QtiIntOrIdentifier(1)))), "\x01", null); + $returnValue[] = array(new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::INT_OR_IDENTIFIER, new OrderedContainer(BaseType::INT_OR_IDENTIFIER, array(new QtiIntOrIdentifier(1)))), "\x01", null, $rw_defaultValue); $returnValue[] = array(new ResponseVariable('VAR', Cardinality::SINGLE, BaseType::FILE), "\x01", null); $returnValue[] = array(new ResponseVariable('VAR', Cardinality::SINGLE, BaseType::FILE), "\x01", null, $rw_defaultValue); @@ -289,15 +289,15 @@ public function readVariableValueProvider() { $returnValue[] = array(new ResponseVariable('VAR', Cardinality::RECORD), "\x00" . "\x00" . pack('S', 0), new RecordContainer()); $returnValue[] = array(new ResponseVariable('VAR', Cardinality::RECORD), "\x00" . "\x00" . pack('S', 0), new RecordContainer(), $rw_defaultValue); $returnValue[] = array(new ResponseVariable('VAR', Cardinality::RECORD), "\x00" . "\x00" . pack('S', 0), new RecordContainer(), $rw_correctResponse); - $returnValue[] = array(new ResponseVariable('VAR', Cardinality::RECORD), "\x00" . "\x00" . pack('S', 1) . "\x00" . pack('S', 4) . 'key1' . "\x02" . pack('l', 1337), new RecordContainer(array('key1' => new Integer(1337)))); - $returnValue[] = array(new ResponseVariable('VAR', Cardinality::RECORD), "\x00" . "\x00" . pack('S', 1) . "\x00" . pack('S', 4) . 'key1' . "\x02" . pack('l', 1337), new RecordContainer(array('key1' => new Integer(1337))), $rw_defaultValue); - $returnValue[] = array(new ResponseVariable('VAR', Cardinality::RECORD), "\x00" . "\x00" . pack('S', 1) . "\x00" . pack('S', 4) . 'key1' . "\x02" . pack('l', 1337), new RecordContainer(array('key1' => new Integer(1337))), $rw_correctResponse); - $returnValue[] = array(new ResponseVariable('VAR', Cardinality::RECORD), "\x00" . "\x00" . pack('S', 2) . "\x00" . pack('S', 4) . 'key1' . "\x02" . pack('l', 1337) . "\x00" . pack('S', 4) . 'key2' . "\x04" . pack('S', 7) . 'String!', new RecordContainer(array('key1' => new Integer(1337), 'key2' => new String('String!')))); - $returnValue[] = array(new ResponseVariable('VAR', Cardinality::RECORD), "\x00" . "\x00" . pack('S', 2) . "\x00" . pack('S', 4) . 'key1' . "\x02" . pack('l', 1337) . "\x00" . pack('S', 4) . 'key2' . "\x04" . pack('S', 7) . 'String!', new RecordContainer(array('key1' => new Integer(1337), 'key2' => new String('String!'))), $rw_defaultValue); - $returnValue[] = array(new ResponseVariable('VAR', Cardinality::RECORD), "\x00" . "\x00" . pack('S', 2) . "\x00" . pack('S', 4) . 'key1' . "\x02" . pack('l', 1337) . "\x00" . pack('S', 4) . 'key2' . "\x04" . pack('S', 7) . 'String!', new RecordContainer(array('key1' => new Integer(1337), 'key2' => new String('String!'))), $rw_correctResponse); - $returnValue[] = array(new ResponseVariable('VAR', Cardinality::RECORD), "\x00" . "\x00" . pack('S', 3) . "\x00" . pack('S', 4) . 'key1' . "\x02" . pack('l', 1337) . "\x01" . pack('S', 4) . 'key2' . "\x00" . pack('S', 4) . 'key3' . "\x04" . pack('S', 7) . 'String!', new RecordContainer(array('key1' => new Integer(1337), 'key2' => null, 'key3' => new String('String!')))); - $returnValue[] = array(new ResponseVariable('VAR', Cardinality::RECORD), "\x00" . "\x00" . pack('S', 3) . "\x00" . pack('S', 4) . 'key1' . "\x02" . pack('l', 1337) . "\x01" . pack('S', 4) . 'key2' . "\x00" . pack('S', 4) . 'key3' . "\x04" . pack('S', 7) . 'String!', new RecordContainer(array('key1' => new Integer(1337), 'key2' => null, 'key3' => new String('String!'))), $rw_defaultValue); - $returnValue[] = array(new ResponseVariable('VAR', Cardinality::RECORD), "\x00" . "\x00" . pack('S', 3) . "\x00" . pack('S', 4) . 'key1' . "\x02" . pack('l', 1337) . "\x01" . pack('S', 4) . 'key2' . "\x00" . pack('S', 4) . 'key3' . "\x04" . pack('S', 7) . 'String!', new RecordContainer(array('key1' => new Integer(1337), 'key2' => null, 'key3' => new String('String!'))), $rw_correctResponse); + $returnValue[] = array(new ResponseVariable('VAR', Cardinality::RECORD), "\x00" . "\x00" . pack('S', 1) . "\x00" . pack('S', 4) . 'key1' . "\x02" . pack('l', 1337), new RecordContainer(array('key1' => new QtiInteger(1337)))); + $returnValue[] = array(new ResponseVariable('VAR', Cardinality::RECORD), "\x00" . "\x00" . pack('S', 1) . "\x00" . pack('S', 4) . 'key1' . "\x02" . pack('l', 1337), new RecordContainer(array('key1' => new QtiInteger(1337))), $rw_defaultValue); + $returnValue[] = array(new ResponseVariable('VAR', Cardinality::RECORD), "\x00" . "\x00" . pack('S', 1) . "\x00" . pack('S', 4) . 'key1' . "\x02" . pack('l', 1337), new RecordContainer(array('key1' => new QtiInteger(1337))), $rw_correctResponse); + $returnValue[] = array(new ResponseVariable('VAR', Cardinality::RECORD), "\x00" . "\x00" . pack('S', 2) . "\x00" . pack('S', 4) . 'key1' . "\x02" . pack('l', 1337) . "\x00" . pack('S', 4) . 'key2' . "\x04" . pack('S', 7) . 'String!', new RecordContainer(array('key1' => new QtiInteger(1337), 'key2' => new QtiString('String!')))); + $returnValue[] = array(new ResponseVariable('VAR', Cardinality::RECORD), "\x00" . "\x00" . pack('S', 2) . "\x00" . pack('S', 4) . 'key1' . "\x02" . pack('l', 1337) . "\x00" . pack('S', 4) . 'key2' . "\x04" . pack('S', 7) . 'String!', new RecordContainer(array('key1' => new QtiInteger(1337), 'key2' => new QtiString('String!'))), $rw_defaultValue); + $returnValue[] = array(new ResponseVariable('VAR', Cardinality::RECORD), "\x00" . "\x00" . pack('S', 2) . "\x00" . pack('S', 4) . 'key1' . "\x02" . pack('l', 1337) . "\x00" . pack('S', 4) . 'key2' . "\x04" . pack('S', 7) . 'String!', new RecordContainer(array('key1' => new QtiInteger(1337), 'key2' => new QtiString('String!'))), $rw_correctResponse); + $returnValue[] = array(new ResponseVariable('VAR', Cardinality::RECORD), "\x00" . "\x00" . pack('S', 3) . "\x00" . pack('S', 4) . 'key1' . "\x02" . pack('l', 1337) . "\x01" . pack('S', 4) . 'key2' . "\x00" . pack('S', 4) . 'key3' . "\x04" . pack('S', 7) . 'String!', new RecordContainer(array('key1' => new QtiInteger(1337), 'key2' => null, 'key3' => new QtiString('String!')))); + $returnValue[] = array(new ResponseVariable('VAR', Cardinality::RECORD), "\x00" . "\x00" . pack('S', 3) . "\x00" . pack('S', 4) . 'key1' . "\x02" . pack('l', 1337) . "\x01" . pack('S', 4) . 'key2' . "\x00" . pack('S', 4) . 'key3' . "\x04" . pack('S', 7) . 'String!', new RecordContainer(array('key1' => new QtiInteger(1337), 'key2' => null, 'key3' => new QtiString('String!'))), $rw_defaultValue); + $returnValue[] = array(new ResponseVariable('VAR', Cardinality::RECORD), "\x00" . "\x00" . pack('S', 3) . "\x00" . pack('S', 4) . 'key1' . "\x02" . pack('l', 1337) . "\x01" . pack('S', 4) . 'key2' . "\x00" . pack('S', 4) . 'key3' . "\x04" . pack('S', 7) . 'String!', new RecordContainer(array('key1' => new QtiInteger(1337), 'key2' => null, 'key3' => new QtiString('String!'))), $rw_correctResponse); return $returnValue; } @@ -379,193 +379,193 @@ public function writeVariableValueProvider() { $data = array(); // -- Integers - $data[] = array(new OutcomeVariable('VAR', Cardinality::SINGLE, BaseType::INTEGER, new Integer(26))); - $data[] = array(new OutcomeVariable('VAR', Cardinality::SINGLE, BaseType::INTEGER, new Integer(-34455))); + $data[] = array(new OutcomeVariable('VAR', Cardinality::SINGLE, BaseType::INTEGER, new QtiInteger(26))); + $data[] = array(new OutcomeVariable('VAR', Cardinality::SINGLE, BaseType::INTEGER, new QtiInteger(-34455))); $data[] = array(new OutcomeVariable('VAR', Cardinality::SINGLE, BaseType::INTEGER)); $data[] = array(new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::INTEGER)); $data[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::INTEGER)); - $data[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::INTEGER, new MultipleContainer(BaseType::INTEGER, array(new Integer(-2147483647))))); - $data[] = array(new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::INTEGER, new OrderedContainer(BaseType::INTEGER, array(new Integer(2147483647))))); - $data[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::INTEGER, new MultipleContainer(BaseType::INTEGER, array(new Integer(0), new Integer(-1), new Integer(1), new Integer(-200000), new Integer(200000))))); - $data[] = array(new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::INTEGER, new OrderedContainer(BaseType::INTEGER, array(new Integer(0), new Integer(-1), new Integer(1), new Integer(-200000), new Integer(200000))))); + $data[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::INTEGER, new MultipleContainer(BaseType::INTEGER, array(new QtiInteger(-2147483647))))); + $data[] = array(new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::INTEGER, new OrderedContainer(BaseType::INTEGER, array(new QtiInteger(2147483647))))); + $data[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::INTEGER, new MultipleContainer(BaseType::INTEGER, array(new QtiInteger(0), new QtiInteger(-1), new QtiInteger(1), new QtiInteger(-200000), new QtiInteger(200000))))); + $data[] = array(new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::INTEGER, new OrderedContainer(BaseType::INTEGER, array(new QtiInteger(0), new QtiInteger(-1), new QtiInteger(1), new QtiInteger(-200000), new QtiInteger(200000))))); $data[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::INTEGER, new MultipleContainer(BaseType::INTEGER, array(null)))); $data[] = array(new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::INTEGER, new OrderedContainer(BaseType::INTEGER, array(null)))); - $data[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::INTEGER, new MultipleContainer(BaseType::INTEGER, array(new Integer(0), null, new Integer(1), null, new Integer(200000))))); - $data[] = array(new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::INTEGER, new OrderedContainer(BaseType::INTEGER, array(new Integer(0), null, new Integer(1), null, new Integer(200000))))); + $data[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::INTEGER, new MultipleContainer(BaseType::INTEGER, array(new QtiInteger(0), null, new QtiInteger(1), null, new QtiInteger(200000))))); + $data[] = array(new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::INTEGER, new OrderedContainer(BaseType::INTEGER, array(new QtiInteger(0), null, new QtiInteger(1), null, new QtiInteger(200000))))); $v = new OutcomeVariable('VAR', Cardinality::SINGLE, BaseType::INTEGER); $v->setDefaultValue(null); $data[] = array($v, $rw_defaultValue); - $v = new ResponseVariable('VAR', Cardinality::SINGLE, BaseType::INTEGER); $v->setDefaultValue(new Integer(26)); $data[] = array($v, $rw_defaultValue); - $v = new ResponseVariable('VAR', Cardinality::SINGLE, BaseType::INTEGER); $v->setCorrectResponse(new Integer(26)); $data[] = array($v, $rw_correctResponse); - $v = new OutcomeVariable('VAR', Cardinality::SINGLE, BaseType::INTEGER); $v->setDefaultValue(new Integer(-34455)); $data[] = array($v, $rw_defaultValue); - $v = new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::INTEGER); $v->setDefaultValue(new MultipleContainer(BaseType::INTEGER, array(new Integer(-2147483647)))); $data[] = array($v, $rw_defaultValue); - $v = new ResponseVariable('VAR', Cardinality::ORDERED, BaseType::INTEGER); $v->setCorrectResponse(new OrderedContainer(BaseType::INTEGER, array(new Integer(2147483647)))); $data[] = array($v, $rw_correctResponse); + $v = new ResponseVariable('VAR', Cardinality::SINGLE, BaseType::INTEGER); $v->setDefaultValue(new QtiInteger(26)); $data[] = array($v, $rw_defaultValue); + $v = new ResponseVariable('VAR', Cardinality::SINGLE, BaseType::INTEGER); $v->setCorrectResponse(new QtiInteger(26)); $data[] = array($v, $rw_correctResponse); + $v = new OutcomeVariable('VAR', Cardinality::SINGLE, BaseType::INTEGER); $v->setDefaultValue(new QtiInteger(-34455)); $data[] = array($v, $rw_defaultValue); + $v = new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::INTEGER); $v->setDefaultValue(new MultipleContainer(BaseType::INTEGER, array(new QtiInteger(-2147483647)))); $data[] = array($v, $rw_defaultValue); + $v = new ResponseVariable('VAR', Cardinality::ORDERED, BaseType::INTEGER); $v->setCorrectResponse(new OrderedContainer(BaseType::INTEGER, array(new QtiInteger(2147483647)))); $data[] = array($v, $rw_correctResponse); // -- Floats - $data[] = array(new OutcomeVariable('VAR', Cardinality::SINGLE, BaseType::FLOAT, new Float(26.1))); - $data[] = array(new OutcomeVariable('VAR', Cardinality::SINGLE, BaseType::FLOAT, new Float(-34455.0))); + $data[] = array(new OutcomeVariable('VAR', Cardinality::SINGLE, BaseType::FLOAT, new QtiFloat(26.1))); + $data[] = array(new OutcomeVariable('VAR', Cardinality::SINGLE, BaseType::FLOAT, new QtiFloat(-34455.0))); $data[] = array(new OutcomeVariable('VAR', Cardinality::SINGLE, BaseType::FLOAT)); $data[] = array(new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::FLOAT)); $data[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::FLOAT)); - $data[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::FLOAT, new MultipleContainer(BaseType::FLOAT, array(new Float(-21474.654))))); - $data[] = array(new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::FLOAT, new OrderedContainer(BaseType::FLOAT, array(new Float(21474.3))))); - $data[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::FLOAT, new MultipleContainer(BaseType::FLOAT, array(new Float(0.0), new Float(-1.1), new Float(1.1), new Float(-200000.005), new Float(200000.005))))); - $data[] = array(new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::FLOAT, new OrderedContainer(BaseType::FLOAT, array(new Float(0.0), new Float(-1.1), new Float(1.1), new Float(-200000.005), new Float(200000.005))))); + $data[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::FLOAT, new MultipleContainer(BaseType::FLOAT, array(new QtiFloat(-21474.654))))); + $data[] = array(new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::FLOAT, new OrderedContainer(BaseType::FLOAT, array(new QtiFloat(21474.3))))); + $data[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::FLOAT, new MultipleContainer(BaseType::FLOAT, array(new QtiFloat(0.0), new QtiFloat(-1.1), new QtiFloat(1.1), new QtiFloat(-200000.005), new QtiFloat(200000.005))))); + $data[] = array(new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::FLOAT, new OrderedContainer(BaseType::FLOAT, array(new QtiFloat(0.0), new QtiFloat(-1.1), new QtiFloat(1.1), new QtiFloat(-200000.005), new QtiFloat(200000.005))))); $data[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::FLOAT, new MultipleContainer(BaseType::FLOAT, array(null)))); $data[] = array(new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::FLOAT, new OrderedContainer(BaseType::FLOAT, array(null)))); - $data[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::FLOAT, new MultipleContainer(BaseType::FLOAT, array(new Float(0.0), null, new Float(1.1), null, new Float(200000.005))))); - $data[] = array(new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::FLOAT, new OrderedContainer(BaseType::FLOAT, array(new Float(0.0), null, new Float(1.1), null, new Float(200000.005))))); + $data[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::FLOAT, new MultipleContainer(BaseType::FLOAT, array(new QtiFloat(0.0), null, new QtiFloat(1.1), null, new QtiFloat(200000.005))))); + $data[] = array(new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::FLOAT, new OrderedContainer(BaseType::FLOAT, array(new QtiFloat(0.0), null, new QtiFloat(1.1), null, new QtiFloat(200000.005))))); - $v = new ResponseVariable('VAR', Cardinality::SINGLE, BaseType::FLOAT); $v->setDefaultValue(new Float(26.1)); $data[] = array($v, $rw_defaultValue); - $v = new ResponseVariable('VAR', Cardinality::SINGLE, BaseType::FLOAT); $v->setCorrectResponse(new Float(26.1)); $data[] = array($v, $rw_correctResponse); - $v = new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::FLOAT); $v->setDefaultValue(new OrderedContainer(BaseType::FLOAT, array(new Float(0.0), new Float(-1.1), new Float(1.1), new Float(-200000.005), new Float(200000.005)))); $data[] = array($v, $rw_defaultValue); - $v = new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::FLOAT); $v->setDefaultValue(new MultipleContainer(BaseType::FLOAT, array(new Float(0.0), new Float(-1.1), new Float(1.1), new Float(-200000.005), new Float(200000.005)))); $data[] = array($v, $rw_defaultValue); + $v = new ResponseVariable('VAR', Cardinality::SINGLE, BaseType::FLOAT); $v->setDefaultValue(new QtiFloat(26.1)); $data[] = array($v, $rw_defaultValue); + $v = new ResponseVariable('VAR', Cardinality::SINGLE, BaseType::FLOAT); $v->setCorrectResponse(new QtiFloat(26.1)); $data[] = array($v, $rw_correctResponse); + $v = new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::FLOAT); $v->setDefaultValue(new OrderedContainer(BaseType::FLOAT, array(new QtiFloat(0.0), new QtiFloat(-1.1), new QtiFloat(1.1), new QtiFloat(-200000.005), new QtiFloat(200000.005)))); $data[] = array($v, $rw_defaultValue); + $v = new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::FLOAT); $v->setDefaultValue(new MultipleContainer(BaseType::FLOAT, array(new QtiFloat(0.0), new QtiFloat(-1.1), new QtiFloat(1.1), new QtiFloat(-200000.005), new QtiFloat(200000.005)))); $data[] = array($v, $rw_defaultValue); // $data[] = array(); // -- Booleans - $data[] = array(new OutcomeVariable('VAR', Cardinality::SINGLE, BaseType::BOOLEAN, new Boolean(true))); - $data[] = array(new OutcomeVariable('VAR', Cardinality::SINGLE, BaseType::BOOLEAN, new Boolean(false))); + $data[] = array(new OutcomeVariable('VAR', Cardinality::SINGLE, BaseType::BOOLEAN, new QtiBoolean(true))); + $data[] = array(new OutcomeVariable('VAR', Cardinality::SINGLE, BaseType::BOOLEAN, new QtiBoolean(false))); $data[] = array(new OutcomeVariable('VAR', Cardinality::SINGLE, BaseType::BOOLEAN)); $data[] = array(new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::BOOLEAN)); $data[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::BOOLEAN)); - $data[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::BOOLEAN, new MultipleContainer(BaseType::BOOLEAN, array(new Boolean(true))))); - $data[] = array(new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::BOOLEAN, new OrderedContainer(BaseType::BOOLEAN, array(new Boolean(false))))); - $data[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::BOOLEAN, new MultipleContainer(BaseType::BOOLEAN, array(new Boolean(false), new Boolean(true), new Boolean(false), new Boolean(true), new Boolean(true))))); - $data[] = array(new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::BOOLEAN, new OrderedContainer(BaseType::BOOLEAN, array(new Boolean(false), new Boolean(true), new Boolean(false), new Boolean(true), new Boolean(false))))); + $data[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::BOOLEAN, new MultipleContainer(BaseType::BOOLEAN, array(new QtiBoolean(true))))); + $data[] = array(new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::BOOLEAN, new OrderedContainer(BaseType::BOOLEAN, array(new QtiBoolean(false))))); + $data[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::BOOLEAN, new MultipleContainer(BaseType::BOOLEAN, array(new QtiBoolean(false), new QtiBoolean(true), new QtiBoolean(false), new QtiBoolean(true), new QtiBoolean(true))))); + $data[] = array(new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::BOOLEAN, new OrderedContainer(BaseType::BOOLEAN, array(new QtiBoolean(false), new QtiBoolean(true), new QtiBoolean(false), new QtiBoolean(true), new QtiBoolean(false))))); $data[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::BOOLEAN, new MultipleContainer(BaseType::BOOLEAN, array(null)))); $data[] = array(new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::BOOLEAN, new OrderedContainer(BaseType::BOOLEAN, array(null)))); - $data[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::BOOLEAN, new MultipleContainer(BaseType::BOOLEAN, array(new Boolean(false), null, new Boolean(true), null, new Boolean(false))))); - $data[] = array(new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::BOOLEAN, new OrderedContainer(BaseType::BOOLEAN, array(new Boolean(false), null, new Boolean(true), null, new Boolean(false))))); + $data[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::BOOLEAN, new MultipleContainer(BaseType::BOOLEAN, array(new QtiBoolean(false), null, new QtiBoolean(true), null, new QtiBoolean(false))))); + $data[] = array(new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::BOOLEAN, new OrderedContainer(BaseType::BOOLEAN, array(new QtiBoolean(false), null, new QtiBoolean(true), null, new QtiBoolean(false))))); - $v = new ResponseVariable('VAR', Cardinality::SINGLE, BaseType::BOOLEAN); $v->setDefaultValue(new Boolean(true)); $data[] = array($v, $rw_defaultValue); - $v = new ResponseVariable('VAR', Cardinality::SINGLE, BaseType::BOOLEAN); $v->setCorrectResponse(new Boolean(true)); $data[] = array($v, $rw_correctResponse); - $v = new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::IDENTIFIER); $v->setDefaultValue(new MultipleContainer(BaseType::IDENTIFIER, array(new Identifier('identifier1'), new Identifier('identifier2'), new Identifier('identifier3'), new Identifier('identifier4'), new Identifier('identifier5')))); $data[] = array($v, $rw_defaultValue); + $v = new ResponseVariable('VAR', Cardinality::SINGLE, BaseType::BOOLEAN); $v->setDefaultValue(new QtiBoolean(true)); $data[] = array($v, $rw_defaultValue); + $v = new ResponseVariable('VAR', Cardinality::SINGLE, BaseType::BOOLEAN); $v->setCorrectResponse(new QtiBoolean(true)); $data[] = array($v, $rw_correctResponse); + $v = new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::IDENTIFIER); $v->setDefaultValue(new MultipleContainer(BaseType::IDENTIFIER, array(new QtiIdentifier('identifier1'), new QtiIdentifier('identifier2'), new QtiIdentifier('identifier3'), new QtiIdentifier('identifier4'), new QtiIdentifier('identifier5')))); $data[] = array($v, $rw_defaultValue); // -- Identifiers - $data[] = array(new OutcomeVariable('VAR', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('identifier'))); - $data[] = array(new OutcomeVariable('VAR', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('non-identifier'))); + $data[] = array(new OutcomeVariable('VAR', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('identifier'))); + $data[] = array(new OutcomeVariable('VAR', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('non-identifier'))); $data[] = array(new OutcomeVariable('VAR', Cardinality::SINGLE, BaseType::IDENTIFIER)); $data[] = array(new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::IDENTIFIER)); $data[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::IDENTIFIER)); - $data[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::IDENTIFIER, new MultipleContainer(BaseType::IDENTIFIER, array(new Identifier('identifier'))))); - $data[] = array(new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::IDENTIFIER, new OrderedContainer(BaseType::IDENTIFIER, array(new Identifier('identifier'))))); - $data[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::IDENTIFIER, new MultipleContainer(BaseType::IDENTIFIER, array(new Identifier('identifier1'), new Identifier('identifier2'), new Identifier('identifier3'), new Identifier('identifier4'), new Identifier('identifier5'))))); - $data[] = array(new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::IDENTIFIER, new OrderedContainer(BaseType::IDENTIFIER, array(new Identifier('identifier1'), new Identifier('identifier2'), new Identifier('identifier3'), new Identifier('X-Y-Z'), new Identifier('identifier4'))))); + $data[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::IDENTIFIER, new MultipleContainer(BaseType::IDENTIFIER, array(new QtiIdentifier('identifier'))))); + $data[] = array(new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::IDENTIFIER, new OrderedContainer(BaseType::IDENTIFIER, array(new QtiIdentifier('identifier'))))); + $data[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::IDENTIFIER, new MultipleContainer(BaseType::IDENTIFIER, array(new QtiIdentifier('identifier1'), new QtiIdentifier('identifier2'), new QtiIdentifier('identifier3'), new QtiIdentifier('identifier4'), new QtiIdentifier('identifier5'))))); + $data[] = array(new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::IDENTIFIER, new OrderedContainer(BaseType::IDENTIFIER, array(new QtiIdentifier('identifier1'), new QtiIdentifier('identifier2'), new QtiIdentifier('identifier3'), new QtiIdentifier('X-Y-Z'), new QtiIdentifier('identifier4'))))); $data[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::IDENTIFIER, new MultipleContainer(BaseType::IDENTIFIER, array(null)))); $data[] = array(new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::IDENTIFIER, new OrderedContainer(BaseType::IDENTIFIER, array(null)))); - $data[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::IDENTIFIER, new MultipleContainer(BaseType::IDENTIFIER, array(new Identifier('identifier1'), null, new Identifier('identifier2'), null, new Identifier('identifier3'))))); - $data[] = array(new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::IDENTIFIER, new OrderedContainer(BaseType::IDENTIFIER, array(new Identifier('identifier1'), null, new Identifier('identifier2'), null, new Identifier('identifier3'))))); + $data[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::IDENTIFIER, new MultipleContainer(BaseType::IDENTIFIER, array(new QtiIdentifier('identifier1'), null, new QtiIdentifier('identifier2'), null, new QtiIdentifier('identifier3'))))); + $data[] = array(new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::IDENTIFIER, new OrderedContainer(BaseType::IDENTIFIER, array(new QtiIdentifier('identifier1'), null, new QtiIdentifier('identifier2'), null, new QtiIdentifier('identifier3'))))); - $v = new ResponseVariable('VAR', Cardinality::SINGLE, BaseType::IDENTIFIER); $v->setDefaultValue(new Identifier('non-identifier')); $data[] = array($v, $rw_defaultValue); - $v = new ResponseVariable('VAR', Cardinality::SINGLE, BaseType::IDENTIFIER); $v->setDefaultValue(new Identifier('non-identifier')); $data[] = array($v, $rw_correctResponse); + $v = new ResponseVariable('VAR', Cardinality::SINGLE, BaseType::IDENTIFIER); $v->setDefaultValue(new QtiIdentifier('non-identifier')); $data[] = array($v, $rw_defaultValue); + $v = new ResponseVariable('VAR', Cardinality::SINGLE, BaseType::IDENTIFIER); $v->setDefaultValue(new QtiIdentifier('non-identifier')); $data[] = array($v, $rw_correctResponse); // -- URIs - $data[] = array(new OutcomeVariable('VAR', Cardinality::SINGLE, BaseType::URI, new Uri('http://www.my.uri'))); - $data[] = array(new OutcomeVariable('VAR', Cardinality::SINGLE, BaseType::URI, new Uri('http://www.my.uri'))); + $data[] = array(new OutcomeVariable('VAR', Cardinality::SINGLE, BaseType::URI, new QtiUri('http://www.my.uri'))); + $data[] = array(new OutcomeVariable('VAR', Cardinality::SINGLE, BaseType::URI, new QtiUri('http://www.my.uri'))); $data[] = array(new OutcomeVariable('VAR', Cardinality::SINGLE, BaseType::URI)); $data[] = array(new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::URI)); $data[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::URI)); - $data[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::URI, new MultipleContainer(BaseType::URI, array(new Uri('http://www.my.uri'))))); - $data[] = array(new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::URI, new OrderedContainer(BaseType::URI, array(new Uri('http://www.my.uri'))))); - $data[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::URI, new MultipleContainer(BaseType::URI, array(new Uri('http://www.my.uri1'), new Uri('http://www.my.uri2'), new Uri('http://www.my.uri3'), new Uri('http://www.my.uri4'), new Uri('http://www.my.uri6'))))); - $data[] = array(new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::URI, new OrderedContainer(BaseType::URI, array(new Uri('http://www.my.uri1'), new Uri('http://www.my.uri2'), new Uri('http://www.my.uri3'), new Uri('http://www.my.uri4'), new Uri('http://www.my.uri5'))))); + $data[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::URI, new MultipleContainer(BaseType::URI, array(new QtiUri('http://www.my.uri'))))); + $data[] = array(new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::URI, new OrderedContainer(BaseType::URI, array(new QtiUri('http://www.my.uri'))))); + $data[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::URI, new MultipleContainer(BaseType::URI, array(new QtiUri('http://www.my.uri1'), new QtiUri('http://www.my.uri2'), new QtiUri('http://www.my.uri3'), new QtiUri('http://www.my.uri4'), new QtiUri('http://www.my.uri6'))))); + $data[] = array(new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::URI, new OrderedContainer(BaseType::URI, array(new QtiUri('http://www.my.uri1'), new QtiUri('http://www.my.uri2'), new QtiUri('http://www.my.uri3'), new QtiUri('http://www.my.uri4'), new QtiUri('http://www.my.uri5'))))); $data[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::URI, new MultipleContainer(BaseType::URI, array(null)))); $data[] = array(new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::URI, new OrderedContainer(BaseType::URI, array(null)))); - $data[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::URI, new MultipleContainer(BaseType::URI, array(new Uri('http://www.my.uri1'), null, new Uri('http://www.my.uri2'), null, new Uri('http://www.my.uri3'))))); - $data[] = array(new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::URI, new OrderedContainer(BaseType::URI, array(new Uri('http://www.my.uri1'), null, new Uri('http://www.my.uri2'), null, new Uri('http://www.my.uri3'))))); + $data[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::URI, new MultipleContainer(BaseType::URI, array(new QtiUri('http://www.my.uri1'), null, new QtiUri('http://www.my.uri2'), null, new QtiUri('http://www.my.uri3'))))); + $data[] = array(new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::URI, new OrderedContainer(BaseType::URI, array(new QtiUri('http://www.my.uri1'), null, new QtiUri('http://www.my.uri2'), null, new QtiUri('http://www.my.uri3'))))); - $v = new OutcomeVariable('VAR', Cardinality::SINGLE, BaseType::URI); $v->setDefaultValue(new Uri('http://www.my.uri')); $data[] = array($v, $rw_defaultValue); - $v = new ResponseVariable('VAR', Cardinality::MULTIPLE, BaseType::URI); $v->setDefaultValue(new MultipleContainer(BaseType::URI, array(new Uri('http://www.my.uri1'), null, new Uri('http://www.my.uri2'), null, new Uri('http://www.my.uri3')))); $data[] = array($v, $rw_defaultValue); - $v = new ResponseVariable('VAR', Cardinality::MULTIPLE, BaseType::URI); $v->setCorrectResponse(new MultipleContainer(BaseType::URI, array(new Uri('http://www.my.uri1'), null, new Uri('http://www.my.uri2'), null, new Uri('http://www.my.uri3')))); $data[] = array($v, $rw_correctResponse); + $v = new OutcomeVariable('VAR', Cardinality::SINGLE, BaseType::URI); $v->setDefaultValue(new QtiUri('http://www.my.uri')); $data[] = array($v, $rw_defaultValue); + $v = new ResponseVariable('VAR', Cardinality::MULTIPLE, BaseType::URI); $v->setDefaultValue(new MultipleContainer(BaseType::URI, array(new QtiUri('http://www.my.uri1'), null, new QtiUri('http://www.my.uri2'), null, new QtiUri('http://www.my.uri3')))); $data[] = array($v, $rw_defaultValue); + $v = new ResponseVariable('VAR', Cardinality::MULTIPLE, BaseType::URI); $v->setCorrectResponse(new MultipleContainer(BaseType::URI, array(new QtiUri('http://www.my.uri1'), null, new QtiUri('http://www.my.uri2'), null, new QtiUri('http://www.my.uri3')))); $data[] = array($v, $rw_correctResponse); // -- Durations - $data[] = array(new OutcomeVariable('VAR', Cardinality::SINGLE, BaseType::DURATION, new Duration('P3DT2H1S'))); + $data[] = array(new OutcomeVariable('VAR', Cardinality::SINGLE, BaseType::DURATION, new QtiDuration('P3DT2H1S'))); $data[] = array(new OutcomeVariable('VAR', Cardinality::SINGLE, BaseType::DURATION)); $data[] = array(new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::DURATION)); $data[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::DURATION)); - $data[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::DURATION, new MultipleContainer(BaseType::DURATION, array(new Duration('PT2S'))))); - $data[] = array(new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::DURATION, new OrderedContainer(BaseType::DURATION, array(new Duration('P2YT2S'))))); - $data[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::DURATION, new MultipleContainer(BaseType::DURATION, array(new Duration('PT1S'), new Duration('PT2S'), new Duration('PT3S'), new Duration('PT4S'), new Duration('PT5S'))))); - $data[] = array(new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::DURATION, new OrderedContainer(BaseType::DURATION, array(new Duration('PT1S'), new Duration('PT2S'), new Duration('PT3S'), new Duration('PT4S'), new Duration('PT5S'))))); + $data[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::DURATION, new MultipleContainer(BaseType::DURATION, array(new QtiDuration('PT2S'))))); + $data[] = array(new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::DURATION, new OrderedContainer(BaseType::DURATION, array(new QtiDuration('P2YT2S'))))); + $data[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::DURATION, new MultipleContainer(BaseType::DURATION, array(new QtiDuration('PT1S'), new QtiDuration('PT2S'), new QtiDuration('PT3S'), new QtiDuration('PT4S'), new QtiDuration('PT5S'))))); + $data[] = array(new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::DURATION, new OrderedContainer(BaseType::DURATION, array(new QtiDuration('PT1S'), new QtiDuration('PT2S'), new QtiDuration('PT3S'), new QtiDuration('PT4S'), new QtiDuration('PT5S'))))); $data[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::DURATION, new MultipleContainer(BaseType::DURATION, array(null)))); $data[] = array(new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::DURATION, new OrderedContainer(BaseType::DURATION, array(null)))); - $data[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::DURATION, new MultipleContainer(BaseType::DURATION, array(new Duration('P4D'), null, new Duration('P10D'), null, new Duration('P20D'))))); - $data[] = array(new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::DURATION, new OrderedContainer(BaseType::DURATION, array(new Duration('P4D'), null, new Duration('P10D'), null, new Duration('P20D'))))); + $data[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::DURATION, new MultipleContainer(BaseType::DURATION, array(new QtiDuration('P4D'), null, new QtiDuration('P10D'), null, new QtiDuration('P20D'))))); + $data[] = array(new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::DURATION, new OrderedContainer(BaseType::DURATION, array(new QtiDuration('P4D'), null, new QtiDuration('P10D'), null, new QtiDuration('P20D'))))); - $v = new OutcomeVariable('VAR', Cardinality::SINGLE, BaseType::DURATION); $v->setDefaultValue(new Duration('P3DT2H1S')); $data[] = array($v, $rw_defaultValue); - $v = new ResponseVariable('VAR', Cardinality::ORDERED, BaseType::DURATION); $v->setDefaultValue(new OrderedContainer(BaseType::DURATION, array(new Duration('PT1S'), new Duration('PT2S'), new Duration('PT3S'), new Duration('PT4S'), new Duration('PT5S')))); array($v, $rw_defaultValue); - $v = new ResponseVariable('VAR', Cardinality::ORDERED, BaseType::DURATION); $v->setCorrectResponse(new OrderedContainer(BaseType::DURATION, array(new Duration('PT1S'), new Duration('PT2S'), new Duration('PT3S'), new Duration('PT4S'), new Duration('PT5S')))); array($v, $rw_correctResponse); + $v = new OutcomeVariable('VAR', Cardinality::SINGLE, BaseType::DURATION); $v->setDefaultValue(new QtiDuration('P3DT2H1S')); $data[] = array($v, $rw_defaultValue); + $v = new ResponseVariable('VAR', Cardinality::ORDERED, BaseType::DURATION); $v->setDefaultValue(new OrderedContainer(BaseType::DURATION, array(new QtiDuration('PT1S'), new QtiDuration('PT2S'), new QtiDuration('PT3S'), new QtiDuration('PT4S'), new QtiDuration('PT5S')))); array($v, $rw_defaultValue); + $v = new ResponseVariable('VAR', Cardinality::ORDERED, BaseType::DURATION); $v->setCorrectResponse(new OrderedContainer(BaseType::DURATION, array(new QtiDuration('PT1S'), new QtiDuration('PT2S'), new QtiDuration('PT3S'), new QtiDuration('PT4S'), new QtiDuration('PT5S')))); array($v, $rw_correctResponse); // -- Pairs - $data[] = array(new OutcomeVariable('VAR', Cardinality::SINGLE, BaseType::PAIR, new Pair('A', 'B'))); + $data[] = array(new OutcomeVariable('VAR', Cardinality::SINGLE, BaseType::PAIR, new QtiPair('A', 'B'))); $data[] = array(new OutcomeVariable('VAR', Cardinality::SINGLE, BaseType::PAIR)); $data[] = array(new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::PAIR)); $data[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::PAIR)); - $data[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::PAIR, new MultipleContainer(BaseType::PAIR, array(new Pair('A', 'B'))))); - $data[] = array(new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::PAIR, new OrderedContainer(BaseType::PAIR, array(new Pair('A', 'B'))))); - $data[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::PAIR, new MultipleContainer(BaseType::PAIR, array(new Pair('A', 'B'), new Pair('C', 'D'), new Pair('E', 'F'), new Pair('G', 'H'), new Pair('I', 'J'))))); - $data[] = array(new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::PAIR, new OrderedContainer(BaseType::PAIR, array(new Pair('A', 'B'), new Pair('C', 'D'), new Pair('E', 'F'), new Pair('G', 'H'), new Pair('I', 'J'))))); + $data[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::PAIR, new MultipleContainer(BaseType::PAIR, array(new QtiPair('A', 'B'))))); + $data[] = array(new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::PAIR, new OrderedContainer(BaseType::PAIR, array(new QtiPair('A', 'B'))))); + $data[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::PAIR, new MultipleContainer(BaseType::PAIR, array(new QtiPair('A', 'B'), new QtiPair('C', 'D'), new QtiPair('E', 'F'), new QtiPair('G', 'H'), new QtiPair('I', 'J'))))); + $data[] = array(new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::PAIR, new OrderedContainer(BaseType::PAIR, array(new QtiPair('A', 'B'), new QtiPair('C', 'D'), new QtiPair('E', 'F'), new QtiPair('G', 'H'), new QtiPair('I', 'J'))))); $data[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::PAIR, new MultipleContainer(BaseType::PAIR, array(null)))); $data[] = array(new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::PAIR, new OrderedContainer(BaseType::PAIR, array(null)))); - $data[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::PAIR, new MultipleContainer(BaseType::PAIR, array(new Pair('A', 'B'), null, new Pair('C', 'D'), null, new Pair('E', 'F'))))); - $data[] = array(new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::PAIR, new OrderedContainer(BaseType::PAIR, array(new Pair('A', 'B'), null, new Pair('D', 'E'), null, new Pair('F', 'G'))))); + $data[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::PAIR, new MultipleContainer(BaseType::PAIR, array(new QtiPair('A', 'B'), null, new QtiPair('C', 'D'), null, new QtiPair('E', 'F'))))); + $data[] = array(new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::PAIR, new OrderedContainer(BaseType::PAIR, array(new QtiPair('A', 'B'), null, new QtiPair('D', 'E'), null, new QtiPair('F', 'G'))))); - $v = new OutcomeVariable('VAR', Cardinality::SINGLE, BaseType::PAIR); $v->setDefaultValue(new Pair('A', 'B')); $data[] = array($v, $rw_defaultValue); + $v = new OutcomeVariable('VAR', Cardinality::SINGLE, BaseType::PAIR); $v->setDefaultValue(new QtiPair('A', 'B')); $data[] = array($v, $rw_defaultValue); $v = new ResponseVariable('VAR', Cardinality::MULTIPLE, BaseType::PAIR); $v->setDefaultValue(new MultipleContainer(BaseType::PAIR, array(null))); $data[] = array($v, $rw_defaultValue); $v = new ResponseVariable('VAR', Cardinality::MULTIPLE, BaseType::PAIR); $v->setCorrectResponse(new MultipleContainer(BaseType::PAIR, array(null))); $data[] = array($v, $rw_correctResponse); // -- DirectedPairs - $data[] = array(new OutcomeVariable('VAR', Cardinality::SINGLE, BaseType::DIRECTED_PAIR, new DirectedPair('A', 'B'))); + $data[] = array(new OutcomeVariable('VAR', Cardinality::SINGLE, BaseType::DIRECTED_PAIR, new QtiDirectedPair('A', 'B'))); $data[] = array(new OutcomeVariable('VAR', Cardinality::SINGLE, BaseType::DIRECTED_PAIR)); $data[] = array(new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::DIRECTED_PAIR)); $data[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::DIRECTED_PAIR)); - $data[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::DIRECTED_PAIR, new MultipleContainer(BaseType::DIRECTED_PAIR, array(new DirectedPair('A', 'B'))))); - $data[] = array(new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::DIRECTED_PAIR, new OrderedContainer(BaseType::DIRECTED_PAIR, array(new DirectedPair('A', 'B'))))); - $data[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::DIRECTED_PAIR, new MultipleContainer(BaseType::DIRECTED_PAIR, array(new DirectedPair('A', 'B'), new DirectedPair('C', 'D'), new DirectedPair('E', 'F'), new DirectedPair('G', 'H'), new DirectedPair('I', 'J'))))); - $data[] = array(new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::DIRECTED_PAIR, new OrderedContainer(BaseType::DIRECTED_PAIR, array(new DirectedPair('A', 'B'), new DirectedPair('C', 'D'), new DirectedPair('E', 'F'), new DirectedPair('G', 'H'), new DirectedPair('I', 'J'))))); + $data[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::DIRECTED_PAIR, new MultipleContainer(BaseType::DIRECTED_PAIR, array(new QtiDirectedPair('A', 'B'))))); + $data[] = array(new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::DIRECTED_PAIR, new OrderedContainer(BaseType::DIRECTED_PAIR, array(new QtiDirectedPair('A', 'B'))))); + $data[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::DIRECTED_PAIR, new MultipleContainer(BaseType::DIRECTED_PAIR, array(new QtiDirectedPair('A', 'B'), new QtiDirectedPair('C', 'D'), new QtiDirectedPair('E', 'F'), new QtiDirectedPair('G', 'H'), new QtiDirectedPair('I', 'J'))))); + $data[] = array(new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::DIRECTED_PAIR, new OrderedContainer(BaseType::DIRECTED_PAIR, array(new QtiDirectedPair('A', 'B'), new QtiDirectedPair('C', 'D'), new QtiDirectedPair('E', 'F'), new QtiDirectedPair('G', 'H'), new QtiDirectedPair('I', 'J'))))); $data[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::DIRECTED_PAIR, new MultipleContainer(BaseType::DIRECTED_PAIR, array(null)))); $data[] = array(new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::DIRECTED_PAIR, new OrderedContainer(BaseType::DIRECTED_PAIR, array(null)))); - $data[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::DIRECTED_PAIR, new MultipleContainer(BaseType::DIRECTED_PAIR, array(new DirectedPair('A', 'B'), null, new DirectedPair('C', 'D'), null, new DirectedPair('E', 'F'))))); - $data[] = array(new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::DIRECTED_PAIR, new OrderedContainer(BaseType::DIRECTED_PAIR, array(new DirectedPair('A', 'B'), null, new DirectedPair('D', 'E'), null, new DirectedPair('F', 'G'))))); + $data[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::DIRECTED_PAIR, new MultipleContainer(BaseType::DIRECTED_PAIR, array(new QtiDirectedPair('A', 'B'), null, new QtiDirectedPair('C', 'D'), null, new QtiDirectedPair('E', 'F'))))); + $data[] = array(new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::DIRECTED_PAIR, new OrderedContainer(BaseType::DIRECTED_PAIR, array(new QtiDirectedPair('A', 'B'), null, new QtiDirectedPair('D', 'E'), null, new QtiDirectedPair('F', 'G'))))); - $v = new OutcomeVariable('VAR', Cardinality::SINGLE, BaseType::DIRECTED_PAIR); $v->setDefaultValue(new DirectedPair('A', 'B')); array($v, $rw_defaultValue); - $v = new ResponseVariable('VAR', Cardinality::MULTIPLE, BaseType::DIRECTED_PAIR); $v->setDefaultValue(new MultipleContainer(BaseType::DIRECTED_PAIR, array(new DirectedPair('A', 'B'), new DirectedPair('C', 'D'), new DirectedPair('E', 'F'), new DirectedPair('G', 'H'), new DirectedPair('I', 'J')))); $data[] = array($v, $rw_defaultValue); - $v = new ResponseVariable('VAR', Cardinality::MULTIPLE, BaseType::DIRECTED_PAIR); $v->setCorrectResponse(new MultipleContainer(BaseType::DIRECTED_PAIR, array(new DirectedPair('A', 'B'), new DirectedPair('C', 'D'), new DirectedPair('E', 'F'), new DirectedPair('G', 'H'), new DirectedPair('I', 'J')))); $data[] = array($v, $rw_correctResponse); + $v = new OutcomeVariable('VAR', Cardinality::SINGLE, BaseType::DIRECTED_PAIR); $v->setDefaultValue(new QtiDirectedPair('A', 'B')); array($v, $rw_defaultValue); + $v = new ResponseVariable('VAR', Cardinality::MULTIPLE, BaseType::DIRECTED_PAIR); $v->setDefaultValue(new MultipleContainer(BaseType::DIRECTED_PAIR, array(new QtiDirectedPair('A', 'B'), new QtiDirectedPair('C', 'D'), new QtiDirectedPair('E', 'F'), new QtiDirectedPair('G', 'H'), new QtiDirectedPair('I', 'J')))); $data[] = array($v, $rw_defaultValue); + $v = new ResponseVariable('VAR', Cardinality::MULTIPLE, BaseType::DIRECTED_PAIR); $v->setCorrectResponse(new MultipleContainer(BaseType::DIRECTED_PAIR, array(new QtiDirectedPair('A', 'B'), new QtiDirectedPair('C', 'D'), new QtiDirectedPair('E', 'F'), new QtiDirectedPair('G', 'H'), new QtiDirectedPair('I', 'J')))); $data[] = array($v, $rw_correctResponse); // -- Points - $data[] = array(new OutcomeVariable('VAR', Cardinality::SINGLE, BaseType::POINT, new Point(50, 50))); + $data[] = array(new OutcomeVariable('VAR', Cardinality::SINGLE, BaseType::POINT, new QtiPoint(50, 50))); $data[] = array(new OutcomeVariable('VAR', Cardinality::SINGLE, BaseType::POINT)); $data[] = array(new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::POINT)); $data[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::POINT)); - $data[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::POINT, new MultipleContainer(BaseType::POINT, array(new Point(50, 50))))); - $data[] = array(new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::POINT, new OrderedContainer(BaseType::POINT, array(new Point(50, 50))))); - $data[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::POINT, new MultipleContainer(BaseType::POINT, array(new Point(50, 50), new Point(0, 0), new Point(100, 50), new Point(150, 3), new Point(50, 50))))); - $data[] = array(new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::POINT, new OrderedContainer(BaseType::POINT, array(new Point(50, 50), new Point(0, 35), new Point(30, 50), new Point(40, 55), new Point(0, 0))))); + $data[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::POINT, new MultipleContainer(BaseType::POINT, array(new QtiPoint(50, 50))))); + $data[] = array(new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::POINT, new OrderedContainer(BaseType::POINT, array(new QtiPoint(50, 50))))); + $data[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::POINT, new MultipleContainer(BaseType::POINT, array(new QtiPoint(50, 50), new QtiPoint(0, 0), new QtiPoint(100, 50), new QtiPoint(150, 3), new QtiPoint(50, 50))))); + $data[] = array(new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::POINT, new OrderedContainer(BaseType::POINT, array(new QtiPoint(50, 50), new QtiPoint(0, 35), new QtiPoint(30, 50), new QtiPoint(40, 55), new QtiPoint(0, 0))))); $data[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::POINT, new MultipleContainer(BaseType::POINT, array(null)))); $data[] = array(new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::POINT, new OrderedContainer(BaseType::POINT, array(null)))); - $data[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::POINT, new MultipleContainer(BaseType::POINT, array(new Point(30, 50), null, new Point(20, 50), null, new Point(45, 32))))); - $data[] = array(new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::POINT, new OrderedContainer(BaseType::POINT, array(new Point(20, 11), null, new Point(36, 43), null, new Point(50, 44))))); + $data[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::POINT, new MultipleContainer(BaseType::POINT, array(new QtiPoint(30, 50), null, new QtiPoint(20, 50), null, new QtiPoint(45, 32))))); + $data[] = array(new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::POINT, new OrderedContainer(BaseType::POINT, array(new QtiPoint(20, 11), null, new QtiPoint(36, 43), null, new QtiPoint(50, 44))))); - $v = new OutcomeVariable('VAR', Cardinality::SINGLE, BaseType::POINT); $v->setDefaultValue(new Point(50, 50)); $data[] = array($v, $rw_defaultValue); - $v = new ResponseVariable('VAR', Cardinality::ORDERED, BaseType::POINT); $v->setDefaultValue(new OrderedContainer(BaseType::POINT, array(new Point(50, 50)))); $data[] = array($v, $rw_defaultValue); - $v = new ResponseVariable('VAR', Cardinality::ORDERED, BaseType::POINT); $v->setCorrectResponse(new OrderedContainer(BaseType::POINT, array(new Point(50, 50)))); $data[] = array($v, $rw_correctResponse); + $v = new OutcomeVariable('VAR', Cardinality::SINGLE, BaseType::POINT); $v->setDefaultValue(new QtiPoint(50, 50)); $data[] = array($v, $rw_defaultValue); + $v = new ResponseVariable('VAR', Cardinality::ORDERED, BaseType::POINT); $v->setDefaultValue(new OrderedContainer(BaseType::POINT, array(new QtiPoint(50, 50)))); $data[] = array($v, $rw_defaultValue); + $v = new ResponseVariable('VAR', Cardinality::ORDERED, BaseType::POINT); $v->setCorrectResponse(new OrderedContainer(BaseType::POINT, array(new QtiPoint(50, 50)))); $data[] = array($v, $rw_correctResponse); // IntOrIdentifiers - $data[] = array(new OutcomeVariable('VAR', Cardinality::SINGLE, BaseType::INT_OR_IDENTIFIER, new IntOrIdentifier(26))); - $data[] = array(new OutcomeVariable('VAR', Cardinality::SINGLE, BaseType::INT_OR_IDENTIFIER, new IntOrIdentifier('Q01'))); + $data[] = array(new OutcomeVariable('VAR', Cardinality::SINGLE, BaseType::INT_OR_IDENTIFIER, new QtiIntOrIdentifier(26))); + $data[] = array(new OutcomeVariable('VAR', Cardinality::SINGLE, BaseType::INT_OR_IDENTIFIER, new QtiIntOrIdentifier('Q01'))); $data[] = array(new OutcomeVariable('VAR', Cardinality::SINGLE, BaseType::INT_OR_IDENTIFIER)); $data[] = array(new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::INT_OR_IDENTIFIER)); $data[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::INT_OR_IDENTIFIER)); - $data[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::INT_OR_IDENTIFIER, new MultipleContainer(BaseType::INT_OR_IDENTIFIER, array(new IntOrIdentifier(-2147483647))))); - $data[] = array(new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::INT_OR_IDENTIFIER, new OrderedContainer(BaseType::INT_OR_IDENTIFIER, array(new IntOrIdentifier('Section1'))))); - $data[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::INT_OR_IDENTIFIER, new MultipleContainer(BaseType::INT_OR_IDENTIFIER, array(new IntOrIdentifier(0), new IntOrIdentifier('Q01'), new IntOrIdentifier('Q02'), new IntOrIdentifier(-200000), new IntOrIdentifier(200000))))); - $data[] = array(new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::INT_OR_IDENTIFIER, new OrderedContainer(BaseType::INT_OR_IDENTIFIER, array(new IntOrIdentifier(0), new IntOrIdentifier(-1), new IntOrIdentifier(1), new IntOrIdentifier(-200000), new IntOrIdentifier('Q05'))))); + $data[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::INT_OR_IDENTIFIER, new MultipleContainer(BaseType::INT_OR_IDENTIFIER, array(new QtiIntOrIdentifier(-2147483647))))); + $data[] = array(new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::INT_OR_IDENTIFIER, new OrderedContainer(BaseType::INT_OR_IDENTIFIER, array(new QtiIntOrIdentifier('Section1'))))); + $data[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::INT_OR_IDENTIFIER, new MultipleContainer(BaseType::INT_OR_IDENTIFIER, array(new QtiIntOrIdentifier(0), new QtiIntOrIdentifier('Q01'), new QtiIntOrIdentifier('Q02'), new QtiIntOrIdentifier(-200000), new QtiIntOrIdentifier(200000))))); + $data[] = array(new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::INT_OR_IDENTIFIER, new OrderedContainer(BaseType::INT_OR_IDENTIFIER, array(new QtiIntOrIdentifier(0), new QtiIntOrIdentifier(-1), new QtiIntOrIdentifier(1), new QtiIntOrIdentifier(-200000), new QtiIntOrIdentifier('Q05'))))); $data[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::INT_OR_IDENTIFIER, new MultipleContainer(BaseType::INT_OR_IDENTIFIER, array(null)))); $data[] = array(new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::INT_OR_IDENTIFIER, new OrderedContainer(BaseType::INT_OR_IDENTIFIER, array(null)))); - $data[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::INT_OR_IDENTIFIER, new MultipleContainer(BaseType::INT_OR_IDENTIFIER, array(new IntOrIdentifier(0), null, new IntOrIdentifier(1), null, new IntOrIdentifier(200000))))); - $data[] = array(new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::INT_OR_IDENTIFIER, new OrderedContainer(BaseType::INT_OR_IDENTIFIER, array(new IntOrIdentifier(0), null, new IntOrIdentifier('Q01'), null, new IntOrIdentifier(200000))))); + $data[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::INT_OR_IDENTIFIER, new MultipleContainer(BaseType::INT_OR_IDENTIFIER, array(new QtiIntOrIdentifier(0), null, new QtiIntOrIdentifier(1), null, new QtiIntOrIdentifier(200000))))); + $data[] = array(new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::INT_OR_IDENTIFIER, new OrderedContainer(BaseType::INT_OR_IDENTIFIER, array(new QtiIntOrIdentifier(0), null, new QtiIntOrIdentifier('Q01'), null, new QtiIntOrIdentifier(200000))))); - $v = new OutcomeVariable('VAR', Cardinality::SINGLE, BaseType::INT_OR_IDENTIFIER); $v->setDefaultValue(new IntOrIdentifier(26)); $data[] = array($v, $rw_defaultValue); - $v = new OutcomeVariable('VAR', Cardinality::SINGLE, BaseType::INT_OR_IDENTIFIER); $v->setDefaultValue(new IntOrIdentifier('Q01')); $data[] = array($v, $rw_defaultValue); - $v = new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::INT_OR_IDENTIFIER); $v->setDefaultValue(new OrderedContainer(BaseType::INT_OR_IDENTIFIER, array(new IntOrIdentifier(0), new IntOrIdentifier(-1), new IntOrIdentifier(1), new IntOrIdentifier(-200000), new IntOrIdentifier('Q05')))); $data[] = array($v, $rw_defaultValue); + $v = new OutcomeVariable('VAR', Cardinality::SINGLE, BaseType::INT_OR_IDENTIFIER); $v->setDefaultValue(new QtiIntOrIdentifier(26)); $data[] = array($v, $rw_defaultValue); + $v = new OutcomeVariable('VAR', Cardinality::SINGLE, BaseType::INT_OR_IDENTIFIER); $v->setDefaultValue(new QtiIntOrIdentifier('Q01')); $data[] = array($v, $rw_defaultValue); + $v = new OutcomeVariable('VAR', Cardinality::ORDERED, BaseType::INT_OR_IDENTIFIER); $v->setDefaultValue(new OrderedContainer(BaseType::INT_OR_IDENTIFIER, array(new QtiIntOrIdentifier(0), new QtiIntOrIdentifier(-1), new QtiIntOrIdentifier(1), new QtiIntOrIdentifier(-200000), new QtiIntOrIdentifier('Q05')))); $data[] = array($v, $rw_defaultValue); // Files $data[] = array(new ResponseVariable('VAR', Cardinality::SINGLE, BaseType::FILE, FileSystemFile::retrieveFile(self::samplesDir() . 'datatypes/file/text-plain_text_data.txt'))); @@ -577,11 +577,11 @@ public function writeVariableValueProvider() { // Records $data[] = array(new OutcomeVariable('VAR', Cardinality::RECORD)); $data[] = array(new OutcomeVariable('VAR', Cardinality::RECORD, -1, new RecordContainer(array('key1' => null)))); - $data[] = array(new OutcomeVariable('Var', Cardinality::RECORD, -1, new RecordContainer(array('key1' => new Duration('PT1S'), 'key2' => new Float(25.5), 'key3' => new Integer(2), 'key4' => new String('String!'), 'key5' => null, 'key6' => new Boolean(true))))); + $data[] = array(new OutcomeVariable('Var', Cardinality::RECORD, -1, new RecordContainer(array('key1' => new QtiDuration('PT1S'), 'key2' => new QtiFloat(25.5), 'key3' => new QtiInteger(2), 'key4' => new QtiString('String!'), 'key5' => null, 'key6' => new QtiBoolean(true))))); $v = new OutcomeVariable('VAR', Cardinality::RECORD, -1); $v->setDefaultValue(new RecordContainer(array('key1' => null))); array($v, $rw_defaultValue); - $v = new ResponseVariable('Var', Cardinality::RECORD, -1); $v->setDefaultValue(new RecordContainer(array('key1' => new Duration('PT1S'), 'key2' => new Float(25.5), 'key3' => new Integer(2), 'key4' => new String('String!'), 'key5' => null, 'key6' => new Boolean(true)))); $data[] = array($v, $rw_defaultValue); - $v = new ResponseVariable('Var', Cardinality::RECORD, -1); $v->setCorrectResponse(new RecordContainer(array('key1' => new Duration('PT1S'), 'key2' => new Float(25.5), 'key3' => new Integer(2), 'key4' => new String('String!'), 'key5' => null, 'key6' => new Boolean(true)))); $data[] = array($v, $rw_defaultValue); + $v = new ResponseVariable('Var', Cardinality::RECORD, -1); $v->setDefaultValue(new RecordContainer(array('key1' => new QtiDuration('PT1S'), 'key2' => new QtiFloat(25.5), 'key3' => new QtiInteger(2), 'key4' => new QtiString('String!'), 'key5' => null, 'key6' => new QtiBoolean(true)))); $data[] = array($v, $rw_defaultValue); + $v = new ResponseVariable('Var', Cardinality::RECORD, -1); $v->setCorrectResponse(new RecordContainer(array('key1' => new QtiDuration('PT1S'), 'key2' => new QtiFloat(25.5), 'key3' => new QtiInteger(2), 'key4' => new QtiString('String!'), 'key5' => null, 'key6' => new QtiBoolean(true)))); $data[] = array($v, $rw_defaultValue); return $data; } @@ -625,11 +625,11 @@ public function testReadAssessmentItemSession1() { $this->assertEquals('PT0S', $session['duration']->__toString()); $this->assertEquals('incomplete', $session['completionStatus']->getValue()); $this->assertInstanceOf('qtism\\runtime\\common\\OutcomeVariable', $session->getVariable('scoring')); - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $session['scoring']); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $session['scoring']); $this->assertEquals(1.0, $session['scoring']->getValue()); $this->assertInstanceOf('qtism\\runtime\\common\\ResponseVariable', $session->getVariable('RESPONSE')); $this->assertEquals(BaseType::IDENTIFIER, $session->getVariable('RESPONSE')->getBaseType()); - $this->assertInstanceOf('qtism\\common\\datatypes\\String', $session['RESPONSE']); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiString', $session['RESPONSE']); $this->assertEquals('ChoiceA', $session['RESPONSE']->getValue()); } @@ -695,14 +695,14 @@ public function testReadAssessmentItemSession2() { $this->assertEquals('PT20S', $session['duration']->__toString()); $this->assertEquals('complete', $session['completionStatus']->getValue()); $this->assertInstanceOf('qtism\\runtime\\common\\OutcomeVariable', $session->getVariable('SCORE')); - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $session['SCORE']); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $session['SCORE']); $this->assertEquals(1.0, $session['SCORE']->getValue()); $this->assertInstanceOf('qtism\\runtime\\common\\ResponseVariable', $session->getVariable('RESPONSE')); $this->assertSame(BaseType::IDENTIFIER, $session->getVariable('RESPONSE')->getBaseType()); - $this->assertInstanceOf('qtism\\common\\datatypes\\String', $session['RESPONSE']); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiString', $session['RESPONSE']); $this->assertEquals('ChoiceA', $session['RESPONSE']->getValue()); $this->assertInstanceOf('qtism\\runtime\\common\\TemplateVariable', $session->getVariable('TPL')); - $this->assertInstanceOf('qtism\\common\\datatypes\\Integer', $session['TPL']); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiInteger', $session['TPL']); $this->assertSame(10, $session['TPL']->getValue()); } @@ -893,7 +893,7 @@ public function testWritePendingResponses() { $session->beginTestSession(); $session->beginAttempt(); - $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('ChoiceB'))))); + $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('ChoiceB'))))); $store = $session->getPendingResponseStore(); $pendingResponses = $store->getPendingResponses($doc->getDocumentComponent()->getComponentByIdentifier('Q01')); diff --git a/test/qtismtest/runtime/storage/binary/TemporaryQtiBinaryStorageTest.php b/test/qtismtest/runtime/storage/binary/TemporaryQtiBinaryStorageTest.php index 4776f70b9..94c5fc819 100644 --- a/test/qtismtest/runtime/storage/binary/TemporaryQtiBinaryStorageTest.php +++ b/test/qtismtest/runtime/storage/binary/TemporaryQtiBinaryStorageTest.php @@ -6,14 +6,14 @@ use qtismtest\QtiSmTestCase; use qtism\runtime\storage\binary\BinaryAssessmentTestSeeker; use qtism\common\datatypes\files\FileSystemFile; -use qtism\common\datatypes\Duration; -use qtism\common\datatypes\Identifier; +use qtism\common\datatypes\QtiDuration; +use qtism\common\datatypes\QtiIdentifier; use qtism\runtime\tests\SessionManager; use qtism\common\enums\BaseType; use qtism\common\enums\Cardinality; -use qtism\common\datatypes\Pair; -use qtism\common\datatypes\DirectedPair; -use qtism\common\datatypes\Point; +use qtism\common\datatypes\QtiPair; +use qtism\common\datatypes\QtiDirectedPair; +use qtism\common\datatypes\QtiPoint; use qtism\runtime\common\ResponseVariable; use qtism\runtime\common\State; use qtism\runtime\common\MultipleContainer; @@ -75,7 +75,7 @@ public function testTemporaryQtiBinaryStorage() { // S01 -> Q01 - Correct response. - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $session['Q01.scoring']); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $session['Q01.scoring']); $this->assertEquals(0.0, $session['Q01.scoring']->getValue()); $this->assertSame(null, $session['Q01.RESPONSE']); @@ -85,15 +85,15 @@ public function testTemporaryQtiBinaryStorage() { // The canditate spends 1 second on item Q01. $session->setTime(new DateTime('2014-07-14T13:00:01+00:00', new DateTimeZone('UTC'))); - $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('ChoiceA'))))); + $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('ChoiceA'))))); // Are durations correct? - $this->assertTrue($session['itemsubset.duration']->equals(new Duration('PT1S'))); - $this->assertTrue($session['P01.duration']->equals(new Duration('PT1S'))); - $this->assertTrue($session['S01.duration']->equals(new Duration('PT1S'))); - $this->assertTrue($session['S02.duration']->equals(new Duration('PT0S'))); - $this->assertTrue($session['S03.duration']->equals(new Duration('PT0S'))); - $this->assertTrue($session['Q01.duration']->equals(new Duration('PT1S'))); + $this->assertTrue($session['itemsubset.duration']->equals(new QtiDuration('PT1S'))); + $this->assertTrue($session['P01.duration']->equals(new QtiDuration('PT1S'))); + $this->assertTrue($session['S01.duration']->equals(new QtiDuration('PT1S'))); + $this->assertTrue($session['S02.duration']->equals(new QtiDuration('PT0S'))); + $this->assertTrue($session['S03.duration']->equals(new QtiDuration('PT0S'))); + $this->assertTrue($session['Q01.duration']->equals(new QtiDuration('PT1S'))); $session->moveNext(); @@ -105,10 +105,10 @@ public function testTemporaryQtiBinaryStorage() { $session = $storage->retrieve($test, $sessionId); // After the persist, do we still have the correct scores and durations for Q01?. - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $session['Q01.scoring']); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $session['Q01.scoring']); $this->assertEquals(1.0, $session['Q01.scoring']->getValue()); $this->assertEquals('ChoiceA', $session['Q01.RESPONSE']->getValue()); - $this->assertTrue($session['Q01.duration']->equals(new Duration('PT1S'))); + $this->assertTrue($session['Q01.duration']->equals(new QtiDuration('PT1S'))); // S01 -> Q02 - Incorrect response. @@ -122,20 +122,20 @@ public function testTemporaryQtiBinaryStorage() { // The candidate spends 2 seconds on item Q02. $session->setTime(new DateTime('2014-07-14T13:00:04+00:00', new DateTimeZone('UTC'))); - $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::MULTIPLE, BaseType::PAIR, new MultipleContainer(BaseType::PAIR, array(new Pair('C', 'M'))))))); + $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::MULTIPLE, BaseType::PAIR, new MultipleContainer(BaseType::PAIR, array(new QtiPair('C', 'M'))))))); // Whate about scores of Q02? - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $session['Q02.SCORE']); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $session['Q02.SCORE']); $this->assertEquals(1.0, $session['Q02.SCORE']->getValue()); // Are the durations correct? - $this->assertTrue($session['itemsubset.duration']->equals(new Duration('PT4S'))); - $this->assertTrue($session['P01.duration']->equals(new Duration('PT4S'))); - $this->assertTrue($session['S01.duration']->equals(new Duration('PT4S'))); - $this->assertTrue($session['S02.duration']->equals(new Duration('PT0S'))); - $this->assertTrue($session['S03.duration']->equals(new Duration('PT0S'))); - $this->assertTrue($session['Q01.duration']->equals(new Duration('PT1S'))); - $this->assertTrue($session['Q02.duration']->equals(new Duration('PT2S'))); + $this->assertTrue($session['itemsubset.duration']->equals(new QtiDuration('PT4S'))); + $this->assertTrue($session['P01.duration']->equals(new QtiDuration('PT4S'))); + $this->assertTrue($session['S01.duration']->equals(new QtiDuration('PT4S'))); + $this->assertTrue($session['S02.duration']->equals(new QtiDuration('PT0S'))); + $this->assertTrue($session['S03.duration']->equals(new QtiDuration('PT0S'))); + $this->assertTrue($session['Q01.duration']->equals(new QtiDuration('PT1S'))); + $this->assertTrue($session['Q02.duration']->equals(new QtiDuration('PT2S'))); $session->moveNext(); @@ -150,14 +150,14 @@ public function testTemporaryQtiBinaryStorage() { $session->skip(); // Are the durations correct? - $this->assertTrue($session['itemsubset.duration']->equals(new Duration('PT14S'))); - $this->assertTrue($session['P01.duration']->equals(new Duration('PT14S'))); - $this->assertTrue($session['S01.duration']->equals(new Duration('PT14S'))); - $this->assertTrue($session['S02.duration']->equals(new Duration('PT0S'))); - $this->assertTrue($session['S03.duration']->equals(new Duration('PT0S'))); - $this->assertTrue($session['Q01.duration']->equals(new Duration('PT1S'))); - $this->assertTrue($session['Q02.duration']->equals(new Duration('PT2S'))); - $this->assertTrue($session['Q03.duration']->equals(new Duration('PT10S'))); + $this->assertTrue($session['itemsubset.duration']->equals(new QtiDuration('PT14S'))); + $this->assertTrue($session['P01.duration']->equals(new QtiDuration('PT14S'))); + $this->assertTrue($session['S01.duration']->equals(new QtiDuration('PT14S'))); + $this->assertTrue($session['S02.duration']->equals(new QtiDuration('PT0S'))); + $this->assertTrue($session['S03.duration']->equals(new QtiDuration('PT0S'))); + $this->assertTrue($session['Q01.duration']->equals(new QtiDuration('PT1S'))); + $this->assertTrue($session['Q02.duration']->equals(new QtiDuration('PT2S'))); + $this->assertTrue($session['Q03.duration']->equals(new QtiDuration('PT10S'))); // !!! We move to the next section S02. $session->moveNext(); @@ -179,29 +179,29 @@ public function testTemporaryQtiBinaryStorage() { // The candidate spends 5 seconds on Q04. $session->setTime(new DateTime('2014-07-14T13:00:20+00:00', new DateTimeZone('UTC'))); - $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::MULTIPLE, BaseType::DIRECTED_PAIR, new MultipleContainer(BaseType::DIRECTED_PAIR, array(new DirectedPair('W', 'G1'), new DirectedPair('Su', 'G2'))))))); + $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::MULTIPLE, BaseType::DIRECTED_PAIR, new MultipleContainer(BaseType::DIRECTED_PAIR, array(new QtiDirectedPair('W', 'G1'), new QtiDirectedPair('Su', 'G2'))))))); // A little bit of noisy persistence... $storage->persist($session); $session = $storage->retrieve($test, $sessionId); // What about score of Q04. - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $session['Q04.SCORE']); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $session['Q04.SCORE']); $this->assertEquals(3.0, $session['Q04.SCORE']->getValue()); $storage->persist($session); $session = $storage->retrieve($test, $sessionId); - $this->assertTrue($session['Q04.RESPONSE']->equals(new MultipleContainer(BaseType::DIRECTED_PAIR, array(new DirectedPair('W', 'G1'), new DirectedPair('Su', 'G2'))))); + $this->assertTrue($session['Q04.RESPONSE']->equals(new MultipleContainer(BaseType::DIRECTED_PAIR, array(new QtiDirectedPair('W', 'G1'), new QtiDirectedPair('Su', 'G2'))))); // Are the durations correct? - $this->assertTrue($session['itemsubset.duration']->equals(new Duration('PT20S'))); - $this->assertTrue($session['P01.duration']->equals(new Duration('PT20S'))); - $this->assertTrue($session['S01.duration']->equals(new Duration('PT14S'))); - $this->assertTrue($session['S02.duration']->equals(new Duration('PT6S'))); - $this->assertTrue($session['S03.duration']->equals(new Duration('PT0S'))); - $this->assertTrue($session['Q01.duration']->equals(new Duration('PT1S'))); - $this->assertTrue($session['Q02.duration']->equals(new Duration('PT2S'))); - $this->assertTrue($session['Q03.duration']->equals(new Duration('PT10S'))); - $this->assertTrue($session['Q04.duration']->equals(new Duration('PT5S'))); + $this->assertTrue($session['itemsubset.duration']->equals(new QtiDuration('PT20S'))); + $this->assertTrue($session['P01.duration']->equals(new QtiDuration('PT20S'))); + $this->assertTrue($session['S01.duration']->equals(new QtiDuration('PT14S'))); + $this->assertTrue($session['S02.duration']->equals(new QtiDuration('PT6S'))); + $this->assertTrue($session['S03.duration']->equals(new QtiDuration('PT0S'))); + $this->assertTrue($session['Q01.duration']->equals(new QtiDuration('PT1S'))); + $this->assertTrue($session['Q02.duration']->equals(new QtiDuration('PT2S'))); + $this->assertTrue($session['Q03.duration']->equals(new QtiDuration('PT10S'))); + $this->assertTrue($session['Q04.duration']->equals(new QtiDuration('PT5S'))); // A little bit of noisy persistence... $storage->persist($session); @@ -220,16 +220,16 @@ public function testTemporaryQtiBinaryStorage() { $session->skip(); // Are the durations correct? - $this->assertTrue($session['itemsubset.duration']->equals(new Duration('PT21S'))); - $this->assertTrue($session['P01.duration']->equals(new Duration('PT21S'))); - $this->assertTrue($session['S01.duration']->equals(new Duration('PT14S'))); - $this->assertTrue($session['S02.duration']->equals(new Duration('PT7S'))); - $this->assertTrue($session['S03.duration']->equals(new Duration('PT0S'))); - $this->assertTrue($session['Q01.duration']->equals(new Duration('PT1S'))); - $this->assertTrue($session['Q02.duration']->equals(new Duration('PT2S'))); - $this->assertTrue($session['Q03.duration']->equals(new Duration('PT10S'))); - $this->assertTrue($session['Q04.duration']->equals(new Duration('PT5S'))); - $this->assertTrue($session['Q05.duration']->equals(new Duration('PT1S'))); + $this->assertTrue($session['itemsubset.duration']->equals(new QtiDuration('PT21S'))); + $this->assertTrue($session['P01.duration']->equals(new QtiDuration('PT21S'))); + $this->assertTrue($session['S01.duration']->equals(new QtiDuration('PT14S'))); + $this->assertTrue($session['S02.duration']->equals(new QtiDuration('PT7S'))); + $this->assertTrue($session['S03.duration']->equals(new QtiDuration('PT0S'))); + $this->assertTrue($session['Q01.duration']->equals(new QtiDuration('PT1S'))); + $this->assertTrue($session['Q02.duration']->equals(new QtiDuration('PT2S'))); + $this->assertTrue($session['Q03.duration']->equals(new QtiDuration('PT10S'))); + $this->assertTrue($session['Q04.duration']->equals(new QtiDuration('PT5S'))); + $this->assertTrue($session['Q05.duration']->equals(new QtiDuration('PT1S'))); // !!! We move to the next section S03. $session->moveNext(); @@ -245,17 +245,17 @@ public function testTemporaryQtiBinaryStorage() { $session->skip(); // Are the durations correct? - $this->assertTrue($session['itemsubset.duration']->equals(new Duration('PT26S'))); - $this->assertTrue($session['P01.duration']->equals(new Duration('PT26S'))); - $this->assertTrue($session['S01.duration']->equals(new Duration('PT14S'))); - $this->assertTrue($session['S02.duration']->equals(new Duration('PT12S'))); - $this->assertTrue($session['S03.duration']->equals(new Duration('PT0S'))); - $this->assertTrue($session['Q01.duration']->equals(new Duration('PT1S'))); - $this->assertTrue($session['Q02.duration']->equals(new Duration('PT2S'))); - $this->assertTrue($session['Q03.duration']->equals(new Duration('PT10S'))); - $this->assertTrue($session['Q04.duration']->equals(new Duration('PT5S'))); - $this->assertTrue($session['Q05.duration']->equals(new Duration('PT1S'))); - $this->assertTrue($session['Q06.duration']->equals(new Duration('PT2S'))); + $this->assertTrue($session['itemsubset.duration']->equals(new QtiDuration('PT26S'))); + $this->assertTrue($session['P01.duration']->equals(new QtiDuration('PT26S'))); + $this->assertTrue($session['S01.duration']->equals(new QtiDuration('PT14S'))); + $this->assertTrue($session['S02.duration']->equals(new QtiDuration('PT12S'))); + $this->assertTrue($session['S03.duration']->equals(new QtiDuration('PT0S'))); + $this->assertTrue($session['Q01.duration']->equals(new QtiDuration('PT1S'))); + $this->assertTrue($session['Q02.duration']->equals(new QtiDuration('PT2S'))); + $this->assertTrue($session['Q03.duration']->equals(new QtiDuration('PT10S'))); + $this->assertTrue($session['Q04.duration']->equals(new QtiDuration('PT5S'))); + $this->assertTrue($session['Q05.duration']->equals(new QtiDuration('PT1S'))); + $this->assertTrue($session['Q06.duration']->equals(new QtiDuration('PT2S'))); // !!! We move to the next section S03. $session->moveNext(); @@ -276,21 +276,21 @@ public function testTemporaryQtiBinaryStorage() { // The candidate spends 10 seconds on Q07.1. $session->setTime(new DateTime('2014-07-14T13:00:38+00:00', new DateTimeZone('UTC'))); - $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::POINT, new Point(103, 114))))); + $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::POINT, new QtiPoint(103, 114))))); // Are the durations correct? - $this->assertTrue($session['itemsubset.duration']->equals(new Duration('PT38S'))); - $this->assertTrue($session['P01.duration']->equals(new Duration('PT38S'))); - $this->assertTrue($session['S01.duration']->equals(new Duration('PT14S'))); - $this->assertTrue($session['S02.duration']->equals(new Duration('PT12S'))); - $this->assertTrue($session['S03.duration']->equals(new Duration('PT12S'))); - $this->assertTrue($session['Q01.duration']->equals(new Duration('PT1S'))); - $this->assertTrue($session['Q02.duration']->equals(new Duration('PT2S'))); - $this->assertTrue($session['Q03.duration']->equals(new Duration('PT10S'))); - $this->assertTrue($session['Q04.duration']->equals(new Duration('PT5S'))); - $this->assertTrue($session['Q05.duration']->equals(new Duration('PT1S'))); - $this->assertTrue($session['Q06.duration']->equals(new Duration('PT2S'))); - $this->assertTrue($session['Q07.1.duration']->equals(new Duration('PT10S'))); + $this->assertTrue($session['itemsubset.duration']->equals(new QtiDuration('PT38S'))); + $this->assertTrue($session['P01.duration']->equals(new QtiDuration('PT38S'))); + $this->assertTrue($session['S01.duration']->equals(new QtiDuration('PT14S'))); + $this->assertTrue($session['S02.duration']->equals(new QtiDuration('PT12S'))); + $this->assertTrue($session['S03.duration']->equals(new QtiDuration('PT12S'))); + $this->assertTrue($session['Q01.duration']->equals(new QtiDuration('PT1S'))); + $this->assertTrue($session['Q02.duration']->equals(new QtiDuration('PT2S'))); + $this->assertTrue($session['Q03.duration']->equals(new QtiDuration('PT10S'))); + $this->assertTrue($session['Q04.duration']->equals(new QtiDuration('PT5S'))); + $this->assertTrue($session['Q05.duration']->equals(new QtiDuration('PT1S'))); + $this->assertTrue($session['Q06.duration']->equals(new QtiDuration('PT2S'))); + $this->assertTrue($session['Q07.1.duration']->equals(new QtiDuration('PT10S'))); $session->moveNext(); @@ -315,21 +315,21 @@ public function testTemporaryQtiBinaryStorage() { // The candidate spends a whole minute on Q07.2. $session->setTime(new DateTime('2014-07-14T13:01:38+00:00', new DateTimeZone('UTC'))); - $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::POINT, new Point(200, 200))))); - - $this->assertTrue($session['itemsubset.duration']->equals(new Duration('PT98S'))); // NO FEAR! - $this->assertTrue($session['P01.duration']->equals(new Duration('PT1M38S'))); - $this->assertTrue($session['S01.duration']->equals(new Duration('PT14S'))); - $this->assertTrue($session['S02.duration']->equals(new Duration('PT12S'))); - $this->assertTrue($session['S03.duration']->equals(new Duration('PT1M12S'))); - $this->assertTrue($session['Q01.duration']->equals(new Duration('PT1S'))); - $this->assertTrue($session['Q02.duration']->equals(new Duration('PT2S'))); - $this->assertTrue($session['Q03.duration']->equals(new Duration('PT10S'))); - $this->assertTrue($session['Q04.duration']->equals(new Duration('PT5S'))); - $this->assertTrue($session['Q05.duration']->equals(new Duration('PT1S'))); - $this->assertTrue($session['Q06.duration']->equals(new Duration('PT2S'))); - $this->assertTrue($session['Q07.1.duration']->equals(new Duration('PT10S'))); - $this->assertTrue($session['Q07.2.duration']->equals(new Duration('PT1M'))); + $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::POINT, new QtiPoint(200, 200))))); + + $this->assertTrue($session['itemsubset.duration']->equals(new QtiDuration('PT98S'))); // NO FEAR! + $this->assertTrue($session['P01.duration']->equals(new QtiDuration('PT1M38S'))); + $this->assertTrue($session['S01.duration']->equals(new QtiDuration('PT14S'))); + $this->assertTrue($session['S02.duration']->equals(new QtiDuration('PT12S'))); + $this->assertTrue($session['S03.duration']->equals(new QtiDuration('PT1M12S'))); + $this->assertTrue($session['Q01.duration']->equals(new QtiDuration('PT1S'))); + $this->assertTrue($session['Q02.duration']->equals(new QtiDuration('PT2S'))); + $this->assertTrue($session['Q03.duration']->equals(new QtiDuration('PT10S'))); + $this->assertTrue($session['Q04.duration']->equals(new QtiDuration('PT5S'))); + $this->assertTrue($session['Q05.duration']->equals(new QtiDuration('PT1S'))); + $this->assertTrue($session['Q06.duration']->equals(new QtiDuration('PT2S'))); + $this->assertTrue($session['Q07.1.duration']->equals(new QtiDuration('PT10S'))); + $this->assertTrue($session['Q07.2.duration']->equals(new QtiDuration('PT1M'))); $session->moveNext(); @@ -354,7 +354,7 @@ public function testTemporaryQtiBinaryStorage() { // The candidate takes an hour (yes, an hour) to respond on Q07.3. $session->setTime(new DateTime('2014-07-14T14:01:39+00:00', new DateTimeZone('UTC'))); - $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::POINT, new Point(102, 113))))); + $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::POINT, new QtiPoint(102, 113))))); $session->moveNext(); // -- End of test, outcome processing performed correctly? @@ -363,34 +363,34 @@ public function testTemporaryQtiBinaryStorage() { $session = $storage->retrieve($test, $sessionId); $this->assertEquals(AssessmentTestSessionState::CLOSED, $session->getState()); - $this->assertInstanceOf('qtism\\common\\datatypes\\Integer', $session['NCORRECTS01']); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiInteger', $session['NCORRECTS01']); $this->assertEquals(1, $session['NCORRECTS01']->getValue()); - $this->assertInstanceOf('qtism\\common\\datatypes\\Integer', $session['NCORRECTS02']); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiInteger', $session['NCORRECTS02']); $this->assertEquals(1, $session['NCORRECTS02']->getValue()); - $this->assertInstanceOf('qtism\\common\\datatypes\\Integer', $session['NCORRECTS03']); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiInteger', $session['NCORRECTS03']); $this->assertEquals(1, $session['NCORRECTS03']->getValue()); $this->assertEquals(6, $session['NINCORRECT']->getValue()); $this->assertEquals(6, $session['NRESPONSED']->getValue()); $this->assertEquals(9, $session['NPRESENTED']->getValue()); $this->assertEquals(9, $session['NSELECTED']->getValue()); - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $session['PERCENT_CORRECT']); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $session['PERCENT_CORRECT']); $this->assertEquals(round(33.33333, 3), round($session['PERCENT_CORRECT']->getValue(), 3)); // -- End of test, are durations correct? - $this->assertTrue($session['itemsubset.duration']->equals(new Duration('PT3699S'))); // NO FEAR! - $this->assertTrue($session['P01.duration']->equals(new Duration('PT1H1M39S'))); - $this->assertTrue($session['S01.duration']->equals(new Duration('PT14S'))); - $this->assertTrue($session['S02.duration']->equals(new Duration('PT12S'))); - $this->assertTrue($session['S03.duration']->equals(new Duration('PT1H1M13S'))); - $this->assertTrue($session['Q01.duration']->equals(new Duration('PT1S'))); - $this->assertTrue($session['Q02.duration']->equals(new Duration('PT2S'))); - $this->assertTrue($session['Q03.duration']->equals(new Duration('PT10S'))); - $this->assertTrue($session['Q04.duration']->equals(new Duration('PT5S'))); - $this->assertTrue($session['Q05.duration']->equals(new Duration('PT1S'))); - $this->assertTrue($session['Q06.duration']->equals(new Duration('PT2S'))); - $this->assertTrue($session['Q07.1.duration']->equals(new Duration('PT10S'))); - $this->assertTrue($session['Q07.2.duration']->equals(new Duration('PT1M'))); - $this->assertTrue($session['Q07.3.duration']->equals(new Duration('PT1H'))); + $this->assertTrue($session['itemsubset.duration']->equals(new QtiDuration('PT3699S'))); // NO FEAR! + $this->assertTrue($session['P01.duration']->equals(new QtiDuration('PT1H1M39S'))); + $this->assertTrue($session['S01.duration']->equals(new QtiDuration('PT14S'))); + $this->assertTrue($session['S02.duration']->equals(new QtiDuration('PT12S'))); + $this->assertTrue($session['S03.duration']->equals(new QtiDuration('PT1H1M13S'))); + $this->assertTrue($session['Q01.duration']->equals(new QtiDuration('PT1S'))); + $this->assertTrue($session['Q02.duration']->equals(new QtiDuration('PT2S'))); + $this->assertTrue($session['Q03.duration']->equals(new QtiDuration('PT10S'))); + $this->assertTrue($session['Q04.duration']->equals(new QtiDuration('PT5S'))); + $this->assertTrue($session['Q05.duration']->equals(new QtiDuration('PT1S'))); + $this->assertTrue($session['Q06.duration']->equals(new QtiDuration('PT2S'))); + $this->assertTrue($session['Q07.1.duration']->equals(new QtiDuration('PT10S'))); + $this->assertTrue($session['Q07.2.duration']->equals(new QtiDuration('PT1M'))); + $this->assertTrue($session['Q07.3.duration']->equals(new QtiDuration('PT1H'))); } public function testLinearNavigationSimultaneousSubmission() { @@ -410,7 +410,7 @@ public function testLinearNavigationSimultaneousSubmission() { // Q01 - Correct $session->beginAttempt(); - $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('ChoiceA'))))); + $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('ChoiceA'))))); $session->moveNext(); $storage->persist($session); @@ -421,7 +421,7 @@ public function testLinearNavigationSimultaneousSubmission() { // Q02 - Correct $session->beginAttempt(); - $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::MULTIPLE, BaseType::PAIR, new MultipleContainer(BaseType::PAIR, array(new Pair('A', 'P'), new Pair('C', 'M'), new Pair('D', 'L'))))))); + $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::MULTIPLE, BaseType::PAIR, new MultipleContainer(BaseType::PAIR, array(new QtiPair('A', 'P'), new QtiPair('C', 'M'), new QtiPair('D', 'L'))))))); $session->moveNext(); $storage->persist($session); @@ -468,7 +468,7 @@ public function testLinearNavigationSimultaneousSubmission() { // Q07.1 - Correct $session->beginAttempt(); - $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::POINT, new Point(102, 113))))); + $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::POINT, new QtiPoint(102, 113))))); $session->moveNext(); $storage->persist($session); @@ -479,7 +479,7 @@ public function testLinearNavigationSimultaneousSubmission() { // Q07.2 - Incorrect but in the circle $session->beginAttempt(); - $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::POINT, new Point(103, 114))))); + $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::POINT, new QtiPoint(103, 114))))); $session->moveNext(); $storage->persist($session); @@ -490,7 +490,7 @@ public function testLinearNavigationSimultaneousSubmission() { // Q07.3 - Incorrect and out of the circle $session->beginAttempt(); - $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::POINT, new Point(30, 13))))); + $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::POINT, new QtiPoint(30, 13))))); $this->assertSame(null, $session['Q07.3.RESPONSE']); $session->moveNext(); @@ -505,34 +505,34 @@ public function testLinearNavigationSimultaneousSubmission() { $session = $storage->retrieve($test, $sessionId); // Let's check the overall Assessment Test Session state. - $this->assertInstanceOf('qtism\\common\\datatypes\\Identifier', $session['Q01.RESPONSE']); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiIdentifier', $session['Q01.RESPONSE']); $this->assertEquals('ChoiceA', $session['Q01.RESPONSE']->getValue()); - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $session['Q01.scoring']); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $session['Q01.scoring']); $this->assertEquals(1.0, $session['Q01.scoring']->getValue()); - $this->assertTrue($session['Q02.RESPONSE']->equals(new MultipleContainer(BaseType::PAIR, array(new Pair('A', 'P'), new Pair('C', 'M'), new Pair('D', 'L'))))); + $this->assertTrue($session['Q02.RESPONSE']->equals(new MultipleContainer(BaseType::PAIR, array(new QtiPair('A', 'P'), new QtiPair('C', 'M'), new QtiPair('D', 'L'))))); $this->assertEquals(4.0, $session['Q02.SCORE']->getValue()); - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $session['Q03.SCORE']); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $session['Q03.SCORE']); $this->assertEquals(0.0, $session['Q03.SCORE']->getValue()); - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $session['Q04.SCORE']); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $session['Q04.SCORE']); $this->assertEquals(0.0, $session['Q04.SCORE']->getValue()); - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $session['Q05.SCORE']); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $session['Q05.SCORE']); $this->assertEquals(0.0, $session['Q05.SCORE']->getValue()); - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $session['Q06.mySc0r3']); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $session['Q06.mySc0r3']); $this->assertEquals(0.0, $session['Q06.mySc0r3']->getValue()); - $this->assertTrue($session['Q07.1.RESPONSE']->equals(new Point(102, 113))); + $this->assertTrue($session['Q07.1.RESPONSE']->equals(new QtiPoint(102, 113))); $this->assertEquals(1.0, $session['Q07.1.SCORE']->getValue()); - $this->assertTrue($session['Q07.2.RESPONSE']->equals(new Point(103, 114))); + $this->assertTrue($session['Q07.2.RESPONSE']->equals(new QtiPoint(103, 114))); $this->assertEquals(1.0, $session['Q07.2.SCORE']->getValue()); - $this->assertTrue($session['Q07.3.RESPONSE']->equals(new Point(30, 13))); - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $session['Q07.3.SCORE']); + $this->assertTrue($session['Q07.3.RESPONSE']->equals(new QtiPoint(30, 13))); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $session['Q07.3.SCORE']); $this->assertEquals(0.0, $session['Q07.3.SCORE']->getValue()); $this->assertEquals(2, $session['NCORRECTS01']->getValue()); @@ -576,7 +576,7 @@ public function testFiles() { $filepath = self::samplesDir() . 'datatypes/file/files_1.txt'; $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::FILE, FileSystemFile::retrieveFile($filepath))))); $session->moveNext(); - $this->assertInstanceOf('qtism\\common\\datatypes\\File', $session['Q01.RESPONSE']); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFile', $session['Q01.RESPONSE']); $this->assertEquals('text.txt', $session['Q01.RESPONSE']->getFilename()); $this->assertEquals('text/plain', $session['Q01.RESPONSE']->getMimeType()); $this->assertEquals('Some text...', $session['Q01.RESPONSE']->getData()); @@ -585,7 +585,7 @@ public function testFiles() { $storage->persist($session); unset($session); $session = $storage->retrieve($test, $sessionId); - $this->assertInstanceOf('qtism\\common\\datatypes\\File', $session['Q01.RESPONSE']); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFile', $session['Q01.RESPONSE']); $this->assertEquals('text.txt', $session['Q01.RESPONSE']->getFilename()); $this->assertEquals('text/plain', $session['Q01.RESPONSE']->getMimeType()); $this->assertEquals('Some text...', $session['Q01.RESPONSE']->getData()); @@ -595,7 +595,7 @@ public function testFiles() { $filepath = self::samplesDir() . 'datatypes/file/files_2.txt'; $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::FILE, FileSystemFile::retrieveFile($filepath))))); $session->moveNext(); - $this->assertInstanceOf('qtism\\common\\datatypes\\File', $session['Q02.RESPONSE']); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFile', $session['Q02.RESPONSE']); $this->assertEquals('', $session['Q02.RESPONSE']->getFilename()); $this->assertEquals('text/html', $session['Q02.RESPONSE']->getMimeType()); $this->assertEquals('', $session['Q02.RESPONSE']->getData()); @@ -606,12 +606,12 @@ public function testFiles() { $session = $storage->retrieve($test, $sessionId); // We now test all the collected variables. - $this->assertInstanceOf('qtism\\common\\datatypes\\File', $session['Q01.RESPONSE']); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFile', $session['Q01.RESPONSE']); $this->assertEquals('text.txt', $session['Q01.RESPONSE']->getFilename()); $this->assertEquals('text/plain', $session['Q01.RESPONSE']->getMimeType()); $this->assertEquals('Some text...', $session['Q01.RESPONSE']->getData()); - $this->assertInstanceOf('qtism\\common\\datatypes\\File', $session['Q02.RESPONSE']); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFile', $session['Q02.RESPONSE']); $this->assertEquals('', $session['Q02.RESPONSE']->getFilename()); $this->assertEquals('text/html', $session['Q02.RESPONSE']->getMimeType()); $this->assertEquals('', $session['Q02.RESPONSE']->getData()); @@ -622,7 +622,7 @@ public function testFiles() { $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::FILE, FileSystemFile::retrieveFile($filepath))))); $session->moveNext(); $this->assertFalse($session->isRunning()); - $this->assertInstanceOf('qtism\\common\\datatypes\\File', $session['Q02.RESPONSE']); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFile', $session['Q02.RESPONSE']); $this->assertEquals('empty.txt', $session['Q03.RESPONSE']->getFilename()); $this->assertEquals('text/plain', $session['Q03.RESPONSE']->getMimeType()); $this->assertEquals('', $session['Q03.RESPONSE']->getData()); @@ -632,17 +632,17 @@ public function testFiles() { $session = $storage->retrieve($test, $sessionId); // Final big check. - $this->assertInstanceOf('qtism\\common\\datatypes\\File', $session['Q01.RESPONSE']); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFile', $session['Q01.RESPONSE']); $this->assertEquals('text.txt', $session['Q01.RESPONSE']->getFilename()); $this->assertEquals('text/plain', $session['Q01.RESPONSE']->getMimeType()); $this->assertEquals('Some text...', $session['Q01.RESPONSE']->getData()); - $this->assertInstanceOf('qtism\\common\\datatypes\\File', $session['Q02.RESPONSE']); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFile', $session['Q02.RESPONSE']); $this->assertEquals('', $session['Q02.RESPONSE']->getFilename()); $this->assertEquals('text/html', $session['Q02.RESPONSE']->getMimeType()); $this->assertEquals('', $session['Q02.RESPONSE']->getData()); - $this->assertInstanceOf('qtism\\common\\datatypes\\File', $session['Q02.RESPONSE']); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFile', $session['Q02.RESPONSE']); $this->assertEquals('empty.txt', $session['Q03.RESPONSE']->getFilename()); $this->assertEquals('text/plain', $session['Q03.RESPONSE']->getMimeType()); $this->assertEquals('', $session['Q03.RESPONSE']->getData()); @@ -736,7 +736,7 @@ public function testTemplateProcessingBasic1() { $this->assertEquals('ChoiceB', $session['QTPL1.RESPONSE']->getValue()); // -- TPL1 - Correct response. - $candidateResponses = new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('ChoiceA')))); + $candidateResponses = new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('ChoiceA')))); $session->endAttempt($candidateResponses); $this->assertEquals(1.0, $session['QTPL1.SCORE']->getValue()); @@ -772,7 +772,7 @@ public function testTemplateProcessingBasic1() { $this->assertEquals('ChoiceA', $session['QTPL2.RESPONSE']->getValue()); // -- TPL2 - Incorrect response. - $candidateResponses = new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('ChoiceC')))); + $candidateResponses = new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('ChoiceC')))); $session->endAttempt($candidateResponses); $this->assertEquals(-1.0, $session['QTPL2.SCORE']->getValue()); @@ -887,7 +887,7 @@ public function testTemplateDefault1() { $this->assertEquals(null, $session['QTPL1.RESPONSE']); // -- TPL1 - Correct response. - $candidateResponses = new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('ChoiceA')))); + $candidateResponses = new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('ChoiceA')))); $session->endAttempt($candidateResponses); $this->assertEquals(1.0, $session['QTPL1.SCORE']->getValue()); @@ -923,7 +923,7 @@ public function testTemplateDefault1() { $this->assertEquals(null, $session['QTPL2.RESPONSE']); // -- TPL2 - Incorrect response. - $candidateResponses = new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('ChoiceC')))); + $candidateResponses = new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('ChoiceC')))); $session->endAttempt($candidateResponses); $this->assertEquals(-1.0, $session['QTPL2.SCORE']->getValue()); diff --git a/test/qtismtest/runtime/tests/AssessmentItemSessionTemplateTest.php b/test/qtismtest/runtime/tests/AssessmentItemSessionTemplateTest.php index 872fd0a5e..f49d95dc8 100644 --- a/test/qtismtest/runtime/tests/AssessmentItemSessionTemplateTest.php +++ b/test/qtismtest/runtime/tests/AssessmentItemSessionTemplateTest.php @@ -2,7 +2,7 @@ namespace qtismtest\runtime\tests; use qtismtest\QtiSmAssessmentItemTestCase; -use qtism\common\datatypes\Identifier; +use qtism\common\datatypes\QtiIdentifier; use qtism\common\enums\BaseType; use qtism\common\enums\Cardinality; use qtism\data\storage\xml\XmlDocument; @@ -33,7 +33,7 @@ public function testAssigningScoresAndCorrectResponses() { // With a correct response. $session->beginAttempt(); $responses = new State( - array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('ChoiceA'))) + array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('ChoiceA'))) ); $session->endAttempt($responses); $this->assertEquals(1.0, $session['SCORE']->getValue()); @@ -41,7 +41,7 @@ public function testAssigningScoresAndCorrectResponses() { // With an incorrect response. $session->beginAttempt(); $responses = new State( - array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('ChoiceB'))) + array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('ChoiceB'))) ); $session->endAttempt($responses); $this->assertEquals(0.0, $session['SCORE']->getValue()); diff --git a/test/qtismtest/runtime/tests/AssessmentItemSessionTest.php b/test/qtismtest/runtime/tests/AssessmentItemSessionTest.php index fcb9d3a74..0f76d5b2d 100644 --- a/test/qtismtest/runtime/tests/AssessmentItemSessionTest.php +++ b/test/qtismtest/runtime/tests/AssessmentItemSessionTest.php @@ -1,13 +1,13 @@ assertInstanceOf('qtism\\runtime\\common\\OutcomeVariable', $itemSession->getVariable('SCORE')); - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $itemSession['SCORE']); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $itemSession['SCORE']); $this->assertEquals(0.0, $itemSession['SCORE']->getValue()); // Built-in variables instantiated and values initialized correctly? $this->assertInstanceOf('qtism\\runtime\\common\\ResponseVariable', $itemSession->getVariable('numAttempts')); - $this->assertInstanceOf('qtism\\common\\datatypes\\Integer', $itemSession['numAttempts']); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiInteger', $itemSession['numAttempts']); $this->assertEquals(0, $itemSession['numAttempts']->getValue()); $this->assertInstanceOf('qtism\\runtime\\common\\ResponseVariable', $itemSession->getVariable('duration')); - $this->assertInstanceOf('qtism\\common\\datatypes\\Duration', $itemSession['duration']); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiDuration', $itemSession['duration']); $this->assertEquals('PT0S', $itemSession['duration']->__toString()); $this->assertInstanceOf('qtism\\runtime\\common\\OutcomeVariable', $itemSession->getVariable('completionStatus')); - $this->assertInstanceOf('qtism\\common\\datatypes\\String', $itemSession['completionStatus']); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiString', $itemSession['completionStatus']); $this->assertEquals('not_attempted', $itemSession['completionStatus']->getValue()); $this->assertEquals(BaseType::IDENTIFIER, $itemSession->getVariable('completionStatus')->getBaseType()); @@ -96,7 +96,7 @@ public function testEvolutionBasic() { // Note: here we provide a State object for the responses, but the value of the 'RESPONSE' // variable can also be set manually on the item session prior calling endAttempt(). This // is a matter of choice. - $resp = new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('ChoiceB')); + $resp = new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('ChoiceB')); $itemSession->endAttempt(new State(array($resp))); $this->assertTrue($itemSession->isResponded()); @@ -167,20 +167,20 @@ public function testEvolutionAdaptiveItem() { $this->assertEquals(-1, $itemSession->getRemainingAttempts()); $itemSession->beginAttempt(); $this->assertEquals(-1, $itemSession->getRemainingAttempts()); - $itemSession->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('ChoiceE'))))); + $itemSession->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('ChoiceE'))))); $this->assertEquals(-1, $itemSession->getRemainingAttempts()); $this->assertEquals(1, $itemSession['numAttempts']->getValue()); $this->assertEquals('incomplete', $itemSession['completionStatus']->getValue()); - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $itemSession['SCORE']); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $itemSession['SCORE']); $this->assertEquals(0.0, $itemSession['SCORE']->getValue()); $itemSession->beginAttempt(); // Second attempt, give the correct answer to be allowed to go to the next item. - $itemSession->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('ChoiceB'))))); + $itemSession->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('ChoiceB'))))); $this->assertEquals(0, $itemSession->getRemainingAttempts()); $this->assertEquals('completed', $itemSession['completionStatus']->getValue()); - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $itemSession['SCORE']); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $itemSession['SCORE']); $this->assertEquals(1.0, $itemSession['SCORE']->getValue()); // If you now try to attempt again, exception because already completed. @@ -234,7 +234,7 @@ public function testValidResponsesInForceValid() { $itemSession->beginAttempt(); $responses = new State(); - $responses->setVariable(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('ChoiceD'))); + $responses->setVariable(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('ChoiceD'))); $itemSession->endAttempt($responses); } @@ -252,14 +252,14 @@ public function testIsCorrect() { $this->assertFalse($itemSession->isCorrect()); $state = new State(); - $state->setVariable(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('ChoiceA'))); + $state->setVariable(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('ChoiceA'))); $itemSession->endAttempt($state); // Wrong answer ('ChoiceB' is the correct one), the session is not correct. $this->assertEquals('incomplete', $itemSession['completionStatus']->getValue()); $this->assertFalse($itemSession->isCorrect()); - $state['RESPONSE'] = new Identifier('ChoiceB'); + $state['RESPONSE'] = new QtiIdentifier('ChoiceB'); $itemSession->beginAttempt(); $itemSession->endAttempt($state); @@ -275,9 +275,9 @@ public function testStandaloneItemSession() { $itemSession = new AssessmentItemSession($doc->getDocumentComponent()); $itemSession->beginItemSession(); $itemSession->beginAttempt(); - $responses = new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('A')))); + $responses = new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('A')))); $itemSession->endAttempt($responses); - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $itemSession['SCORE']); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $itemSession['SCORE']); $this->assertEquals(1.0, $itemSession['SCORE']->getValue()); } @@ -288,10 +288,10 @@ public function testStandaloneMultipleInteractions() { $itemSession = new AssessmentItemSession($doc->getDocumentComponent()); $itemSession->beginItemSession(); $itemSession->beginAttempt(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $itemSession['SCORE']); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $itemSession['SCORE']); $this->assertEquals(0.0, $itemSession['SCORE']->getValue()); - $responses = new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('Choice_3')))); + $responses = new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('Choice_3')))); $itemSession->endAttempt($responses); $this->assertEquals(6.0, $itemSession['SCORE']->getValue()); } @@ -307,7 +307,7 @@ public function testModalFeedback() { $itemSession->setItemSessionControl($itemSessionControl); $itemSession->beginItemSession(); - $responses = new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('true')))); + $responses = new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('true')))); $itemSession->beginAttempt(); $itemSession->endAttempt($responses); @@ -315,7 +315,7 @@ public function testModalFeedback() { $this->assertEquals(AssessmentItemSessionState::MODAL_FEEDBACK, $itemSession->getState()); // new attempt! - $responses = new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('false')))); + $responses = new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('false')))); $itemSession->beginAttempt(); $itemSession->endAttempt($responses); @@ -340,17 +340,17 @@ public function testTemplateVariableDefault() { $itemSession->setItemSessionControl($itemSessionControl); $itemSession->beginItemSession(); - $this->assertTrue($itemSession['WRONGSCORE']->equals(new Float(0.0))); - $this->assertTrue($itemSession['GOODSCORE']->equals(new Float(1.0))); + $this->assertTrue($itemSession['WRONGSCORE']->equals(new QtiFloat(0.0))); + $this->assertTrue($itemSession['GOODSCORE']->equals(new QtiFloat(1.0))); // 1st attempt to get 'GOODSCORE' as 'SCORE'. - $responses = new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('ChoiceA')))); + $responses = new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('ChoiceA')))); $itemSession->beginAttempt(); $itemSession->endAttempt($responses); $this->assertTrue($itemSession['SCORE']->equals($itemSession['GOODSCORE'])); // 2nd attempt to get 'WRONGSCORE' as 'SCORE'. - $responses = new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('ChoiceB')))); + $responses = new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('ChoiceB')))); $itemSession->beginAttempt(); $itemSession->endAttempt($responses); $this->assertTrue($itemSession['SCORE']->equals($itemSession['WRONGSCORE'])); diff --git a/test/qtismtest/runtime/tests/AssessmentItemSessionTimingTest.php b/test/qtismtest/runtime/tests/AssessmentItemSessionTimingTest.php index a6f0b6ab6..42be98203 100644 --- a/test/qtismtest/runtime/tests/AssessmentItemSessionTimingTest.php +++ b/test/qtismtest/runtime/tests/AssessmentItemSessionTimingTest.php @@ -2,13 +2,13 @@ namespace qtismtest\runtime\tests; use qtismtest\QtiSmAssessmentItemTestCase; -use qtism\common\datatypes\Float; -use qtism\common\datatypes\Identifier; +use qtism\common\datatypes\QtiFloat; +use qtism\common\datatypes\QtiIdentifier; use qtism\common\enums\BaseType; use qtism\common\enums\Cardinality; use qtism\runtime\common\State; use qtism\runtime\common\ResponseVariable; -use qtism\common\datatypes\Duration; +use qtism\common\datatypes\QtiDuration; use qtism\runtime\tests\AssessmentItemSessionState; use qtism\runtime\tests\AssessmentItemSessionException; use qtism\data\TimeLimits; @@ -20,14 +20,14 @@ class AssessmentItemSessionTimingTest extends QtiSmAssessmentItemTestCase { public function testBeginItemSession() { $session = self::instantiateBasicAssessmentItemSession(); - $timeLimits = new TimeLimits(null, new Duration('PT30S')); + $timeLimits = new TimeLimits(null, new QtiDuration('PT30S')); // The session is time-tracked and begins 2014-07-14 at 1 PM. $session->setTime(self::createDate('2014-07-14 13:00:00')); $session->beginItemSession(); // The session duration must remain the PT0S, because we are not interacting yet. - $this->assertTrue($session['duration']->equals(new Duration('PT0S'))); + $this->assertTrue($session['duration']->equals(new QtiDuration('PT0S'))); // The time reference must remain the same as the one provided at item session beginning time. $this->assertEquals('2014-07-14@13:00:00@UTC', $session->getTimeReference()->format('Y-m-d@H:i:s@T')); @@ -38,7 +38,7 @@ public function testBeginItemSession() { */ public function testBeginFirstAttempt() { $session = self::instantiateBasicAssessmentItemSession(); - $timeLimits = new TimeLimits(null, new Duration('PT30S')); + $timeLimits = new TimeLimits(null, new QtiDuration('PT30S')); // The session is time-tracked and begins 2014-07-14 at 1 PM. $session->setTime(self::createDate('2014-07-14 13:00:00')); @@ -49,7 +49,7 @@ public function testBeginFirstAttempt() { $session->beginAttempt(); // Remember that time-tracking is not enabled in the INITIAL state. - $this->assertTrue($session['duration']->equals(new Duration('PT0S'))); + $this->assertTrue($session['duration']->equals(new QtiDuration('PT0S'))); $this->assertEquals('2014-07-14@13:00:03@UTC', $session->getTimeReference()->format('Y-m-d@H:i:s@T')); } @@ -58,7 +58,7 @@ public function testBeginFirstAttempt() { */ public function testEndAttempt() { $session = self::instantiateBasicAssessmentItemSession(); - $timeLimits = new TimeLimits(null, new Duration('PT30S')); + $timeLimits = new TimeLimits(null, new QtiDuration('PT30S')); // The session is time-tracked and begins 2014-07-14 at 1 PM. $session->setTime(self::createDate('2014-07-14 13:00:00')); @@ -70,10 +70,10 @@ public function testEndAttempt() { // The candidate spent 15 seconds to end his first attempt. $session->setTime(self::createDate('2014-07-14 13:00:17')); - $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('ChoiceB'))))); + $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('ChoiceB'))))); // Duration should be 15S. - $this->assertTrue($session['duration']->equals(new Duration('PT15S'))); + $this->assertTrue($session['duration']->equals(new QtiDuration('PT15S'))); // Only 1 attempt, so that the session must be closed. $this->assertEquals(AssessmentItemSessionState::CLOSED, $session->getState()); @@ -84,7 +84,7 @@ public function testEndAttempt() { */ public function testEndItemSession() { $session = self::instantiateBasicAssessmentItemSession(); - $timeLimits = new TimeLimits(null, new Duration('PT30S')); + $timeLimits = new TimeLimits(null, new QtiDuration('PT30S')); // Give infinite attempts. $itemSessionControl = new ItemSessionControl(); @@ -101,14 +101,14 @@ public function testEndItemSession() { // The candidate spent 15 seconds to end his first attempt. $session->setTime(self::createDate('2014-07-14 13:00:17')); - $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('ChoiceB'))))); + $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('ChoiceB'))))); // Infinite number of attempts, so the session is not closed. $this->assertEquals(AssessmentItemSessionState::SUSPENDED, $session->getState()); // Close the session. The duration remains the same. $session->endItemSession(); - $this->assertTrue($session['duration']->equals(new Duration('PT15S'))); + $this->assertTrue($session['duration']->equals(new QtiDuration('PT15S'))); } /** @@ -117,7 +117,7 @@ public function testEndItemSession() { public function testEndItemSessionBrutal() { // -- We will close the session during an attempt. $session = self::instantiateBasicAssessmentItemSession(); - $timeLimits = new TimeLimits(null, new Duration('PT30S')); + $timeLimits = new TimeLimits(null, new QtiDuration('PT30S')); // The session is time-tracked and begins 2014-07-14 at 1 PM. $session->setTime(self::createDate('2014-07-14 13:00:00')); @@ -130,7 +130,7 @@ public function testEndItemSessionBrutal() { // Close the session while the candidate spent 10 seconds on the attempt, but without ending it. $session->setTime(self::createDate('2014-07-14 13:00:12')); $session->endItemSession(); - $this->assertTrue($session['duration']->equals(new Duration('PT10S'))); + $this->assertTrue($session['duration']->equals(new QtiDuration('PT10S'))); } /** @@ -140,7 +140,7 @@ public function testGetStateTimeOverflow() { // -- We test if after a setTime that overflows maxTime, // the session is indeed closed. $session = self::instantiateBasicAssessmentItemSession(); - $timeLimits = new TimeLimits(null, new Duration('PT30S')); + $timeLimits = new TimeLimits(null, new QtiDuration('PT30S')); $session->setTimeLimits($timeLimits); // The session is time-tracked and begins 2014-07-14 at 1 PM. @@ -162,7 +162,7 @@ public function testGetStateTimeOverflow() { public function testEndAttemptTimeOverflowNoLateSubmission() { $session = self::instantiateBasicAssessmentItemSession(); - $timeLimits = new TimeLimits(null, new Duration('PT30S')); + $timeLimits = new TimeLimits(null, new QtiDuration('PT30S')); $session->setTimeLimits($timeLimits); // The session is time-tracked and begins 2014-07-14 at 1 PM. @@ -176,7 +176,7 @@ public function testEndAttemptTimeOverflowNoLateSubmission() { // The candidate spent 60 seconds on the attempt. $session->setTime(new DateTime('2014-07-14T13:01:02+00:00', new DateTimeZone('UTC'))); // Extra check: make sure that duration cannot be longer than maxTime. - $this->assertTrue($session['duration']->equals(new Duration('PT30S'))); + $this->assertTrue($session['duration']->equals(new QtiDuration('PT30S'))); $this->setExpectedException( 'qtism\\runtime\\tests\\AssessmentItemSessionException', @@ -184,7 +184,7 @@ public function testEndAttemptTimeOverflowNoLateSubmission() { AssessmentItemSessionException::DURATION_OVERFLOW ); - $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('ChoiceB'))))); + $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('ChoiceB'))))); } /** @@ -194,7 +194,7 @@ public function testEndAttemptTimeOverflowWithLateSubmission() { $session = self::instantiateBasicAssessmentItemSession(); - $timeLimits = new TimeLimits(null, new Duration('PT30S')); + $timeLimits = new TimeLimits(null, new QtiDuration('PT30S')); $timeLimits->setAllowLateSubmission(true); $session->setTimeLimits($timeLimits); @@ -208,7 +208,7 @@ public function testEndAttemptTimeOverflowWithLateSubmission() { // The candidate spent 60 seconds on the attempt. $session->setTime(self::createDate('2014-07-14 13:01:02')); - $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('ChoiceB'))))); + $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('ChoiceB'))))); // The attempt is taken into account because allowLateSubmission = true. $this->assertEquals(1, $session['numAttempts']->getValue()); @@ -226,7 +226,7 @@ public function testEvolutionBasicTimeLimitsUnderflowOverflow() { $itemSession->setItemSessionControl($itemSessionControl); // No late submission allowed. - $timeLimits = new TimeLimits(new Duration('PT1S'), new Duration('PT2S')); + $timeLimits = new TimeLimits(new QtiDuration('PT1S'), new QtiDuration('PT2S')); $itemSession->setTimeLimits($timeLimits); $itemSession->setTime(self::createDate('2014-07-14 13:00:00')); @@ -267,15 +267,15 @@ public function testEvolutionBasicTimeLimitsUnderflowOverflow() { $this->assertEquals(2, $itemSession['numAttempts']->getValue()); $this->assertEquals(AssessmentItemSessionState::CLOSED, $itemSession->getState()); - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $itemSession['SCORE']); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $itemSession['SCORE']); $this->assertEquals(0.0, $itemSession['SCORE']->getValue()); } public function testEvolutionBasicMultipleAttempts() { $count = 5; - $attempts = array(new Identifier('ChoiceA'), new Identifier('ChoiceB'), new Identifier('ChoiceC'), new Identifier('ChoiceD'), new Identifier('ChoiceE')); - $expected = array(new Float(0.0), new Float(1.0), new Float(0.0), new Float(0.0), new Float(0.0)); + $attempts = array(new QtiIdentifier('ChoiceA'), new QtiIdentifier('ChoiceB'), new QtiIdentifier('ChoiceC'), new QtiIdentifier('ChoiceD'), new QtiIdentifier('ChoiceE')); + $expected = array(new QtiFloat(0.0), new QtiFloat(1.0), new QtiFloat(0.0), new QtiFloat(0.0), new QtiFloat(0.0)); $itemSession = self::instantiateBasicAssessmentItemSession(); $itemSessionControl = new ItemSessionControl(); @@ -296,7 +296,7 @@ public function testEvolutionBasicMultipleAttempts() { $itemSession['RESPONSE'] = $attempts[$i]; $itemSession->endAttempt(); - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $itemSession['SCORE']); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $itemSession['SCORE']); $this->assertTrue($expected[$i]->equals($itemSession['SCORE'])); $this->assertEquals($t, $itemSession['numAttempts']->getValue()); } @@ -318,14 +318,14 @@ public function testEvolutionBasicMultipleAttempts() { public function testAllowLateSubmissionNonAdaptive() { $itemSession = self::instantiateBasicAssessmentItemSession(); - $timeLimits = new TimeLimits(null, new Duration('PT1S'), true); + $timeLimits = new TimeLimits(null, new QtiDuration('PT1S'), true); $itemSession->setTimeLimits($timeLimits); $itemSession->setTime(self::createDate('2014-07-14 13:00:00')); $itemSession->beginItemSession(); $itemSession->beginAttempt(); - $itemSession['RESPONSE'] = new Identifier('ChoiceB'); + $itemSession['RESPONSE'] = new QtiIdentifier('ChoiceB'); // No exception because late submission is allowed. $itemSession->setTime(self::createDate('2014-07-14 13:00:05')); @@ -355,29 +355,29 @@ public function testRemainingTimeOne() { $itemSession = self::instantiateBasicAssessmentItemSession(); $this->assertFalse($itemSession->getRemainingTime()); $timeLimits = new TimeLimits(); - $timeLimits->setMaxTime(new Duration('PT3S')); + $timeLimits->setMaxTime(new QtiDuration('PT3S')); $itemSession->setTimeLimits($timeLimits); $itemSession->setTime(self::createDate('2014-07-14 13:00:00')); $itemSession->beginItemSession(); $this->assertEquals(1, $itemSession->getRemainingAttempts()); - $this->assertTrue($itemSession->getRemainingTime()->equals(new Duration('PT3S'))); + $this->assertTrue($itemSession->getRemainingTime()->equals(new QtiDuration('PT3S'))); $itemSession->beginAttempt(); $itemSession->setTime(self::createDate('2014-07-14 13:00:02')); - $this->assertTrue($itemSession->getRemainingTime()->equals(new Duration('PT1S'))); + $this->assertTrue($itemSession->getRemainingTime()->equals(new QtiDuration('PT1S'))); $itemSession->setTime(self::createDate('2014-07-14 13:00:03')); - $this->assertTrue($itemSession->getRemainingTime()->equals(new Duration('PT0S'))); + $this->assertTrue($itemSession->getRemainingTime()->equals(new QtiDuration('PT0S'))); try { - $itemSession->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('ChoiceB'))))); + $itemSession->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('ChoiceB'))))); // Must be rejected, no more time remaining!!! $this->assertFalse(true); } catch (AssessmentItemSessionException $e) { $this->assertEquals(AssessmentItemSessionException::DURATION_OVERFLOW, $e->getCode()); - $this->assertTrue($itemSession->getRemainingTime()->equals(new Duration('PT0S'))); + $this->assertTrue($itemSession->getRemainingTime()->equals(new QtiDuration('PT0S'))); } } @@ -391,12 +391,12 @@ public function testRemainingTimeTwo() { $itemSession->beginAttempt(); $this->assertFalse($itemSession->getRemainingTime()); - $itemSession->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('ChoiceA'))))); + $itemSession->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('ChoiceA'))))); $this->assertEquals('incomplete', $itemSession['completionStatus']->getValue()); $this->assertFalse($itemSession->getRemainingTime()); $itemSession->beginAttempt(); - $itemSession->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('ChoiceB'))))); + $itemSession->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('ChoiceB'))))); $this->assertEquals('completed', $itemSession['completionStatus']->getValue()); $this->assertFalse($itemSession->getRemainingTime()); } diff --git a/test/qtismtest/runtime/tests/AssessmentTestSessionAttemptsTest.php b/test/qtismtest/runtime/tests/AssessmentTestSessionAttemptsTest.php index 7967c03c3..e04a7d9ef 100644 --- a/test/qtismtest/runtime/tests/AssessmentTestSessionAttemptsTest.php +++ b/test/qtismtest/runtime/tests/AssessmentTestSessionAttemptsTest.php @@ -3,7 +3,7 @@ use qtismtest\QtiSmAssessmentTestSessionTestCase; use qtism\runtime\tests\AssessmentItemSession; -use qtism\common\datatypes\Identifier; +use qtism\common\datatypes\QtiIdentifier; use qtism\common\enums\BaseType; use qtism\common\enums\Cardinality; use qtism\runtime\common\ResponseVariable; @@ -17,19 +17,19 @@ public function testMultipleAttempts() { // Q01 - first attempt. $session->beginAttempt(); - $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('ChoiceA'))))); + $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('ChoiceA'))))); $this->assertEquals(AssessmentItemSession::COMPLETION_STATUS_COMPLETED, $session['Q01.completionStatus']); // Q02 - second attempt. $session->beginAttempt(); - $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('ChoiceC'))))); + $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('ChoiceC'))))); $this->assertEquals(AssessmentItemSession::COMPLETION_STATUS_COMPLETED, $session['Q01.completionStatus']); // Q03 - third attempt. The completion status is now completed. $session->beginAttempt(); - $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('ChoiceA'))))); + $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('ChoiceA'))))); $this->assertEquals(AssessmentItemSession::COMPLETION_STATUS_COMPLETED, $session['Q01.completionStatus']); } diff --git a/test/qtismtest/runtime/tests/AssessmentTestSessionBranchingsTest.php b/test/qtismtest/runtime/tests/AssessmentTestSessionBranchingsTest.php index d5f7ae7ce..c8e1674ef 100644 --- a/test/qtismtest/runtime/tests/AssessmentTestSessionBranchingsTest.php +++ b/test/qtismtest/runtime/tests/AssessmentTestSessionBranchingsTest.php @@ -2,7 +2,7 @@ namespace qtismtest\runtime\tests; use qtismtest\QtiSmAssessmentTestSessionTestCase; -use qtism\common\datatypes\Identifier; +use qtism\common\datatypes\QtiIdentifier; use qtism\runtime\tests\AssessmentTestSessionState; use qtism\common\enums\BaseType; use qtism\common\enums\Cardinality; @@ -57,7 +57,7 @@ public function testBranchingSingleSectionLinear1() { // Q01 - We answer correct to bypass Q02. $testSession->beginAttempt(); - $responses = new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('ChoiceA')))); + $responses = new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('ChoiceA')))); $testSession->endAttempt($responses); // Correct? Then we should go to Q03. @@ -67,14 +67,14 @@ public function testBranchingSingleSectionLinear1() { // Q03 - Are we there? We answer incorrect to take Q04. $this->assertEquals('Q03', $testSession->getCurrentAssessmentItemRef()->getIdentifier()); $testSession->beginAttempt(); - $responses = new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('ChoiceZ')))); + $responses = new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('ChoiceZ')))); $testSession->endAttempt($responses); $testSession->moveNext(); // Q04 - Last item, nothing special. $this->assertEquals('Q04', $testSession->getCurrentAssessmentItemRef()->getIdentifier()); $testSession->beginAttempt(); - $responses = new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('ChoiceD')))); + $responses = new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('ChoiceD')))); $testSession->endAttempt($responses); $testSession->moveNext(); @@ -97,13 +97,13 @@ public function testBranchingSingleSectionLinear2() { // Q01 - We answer correct to move to Q03. $testSession->beginAttempt(); - $responses = new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('ChoiceA')))); + $responses = new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('ChoiceA')))); $testSession->endAttempt($responses); $testSession->moveNext(); // Q03 - We want to reach the EXIT_TEST target. $testSession->beginAttempt(); - $responses = new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('ChoiceC')))); + $responses = new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('ChoiceC')))); $testSession->endAttempt($responses); $testSession->moveNext(); @@ -130,7 +130,7 @@ public function testBranchingSingleSectionNonLinear1() { $testSession->beginTestSession(); $testSession->beginAttempt(); - $responses = new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('ChoiceA')))); + $responses = new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('ChoiceA')))); $testSession->endAttempt($responses); $testSession->moveNext(); @@ -167,9 +167,9 @@ public function testBranchingMultipleOccurences($response, $expectedTarget, $occ public function branchingMultipleOccurencesProvider() { return array( - array(new Identifier('goto21'), 'Q02', 0), - array(new Identifier('goto22'), 'Q02', 1), - array(new Identifier('goto23'), 'Q02', 2), + array(new QtiIdentifier('goto21'), 'Q02', 0), + array(new QtiIdentifier('goto22'), 'Q02', 1), + array(new QtiIdentifier('goto23'), 'Q02', 2), array(null, 'Q02', 3) ); } @@ -186,14 +186,14 @@ public function testBranchingOnPreconditon() { // Q01 - Incorrect $session->beginAttempt(); - $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('ChoiceB'))))); + $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('ChoiceB'))))); $session->moveNext(); // Q04 - We should be at Q04. // -> because Q03 has a precondition which returns false. $this->assertEquals('Q04', $session->getCurrentAssessmentItemRef()->getIdentifier()); $session->beginAttempt(); - $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('ChoiceD'))))); + $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('ChoiceD'))))); $session->moveNext(); // Only item sessions related to Q01 and Q04 should be instantiated. diff --git a/test/qtismtest/runtime/tests/AssessmentTestSessionCompletionTest.php b/test/qtismtest/runtime/tests/AssessmentTestSessionCompletionTest.php index d26d583fb..ac8682292 100644 --- a/test/qtismtest/runtime/tests/AssessmentTestSessionCompletionTest.php +++ b/test/qtismtest/runtime/tests/AssessmentTestSessionCompletionTest.php @@ -2,7 +2,7 @@ namespace qtismtest\runtime\tests; use qtismtest\QtiSmAssessmentTestSessionTestCase; -use qtism\common\datatypes\Identifier; +use qtism\common\datatypes\QtiIdentifier; use qtism\common\enums\BaseType; use qtism\common\enums\Cardinality; use qtism\runtime\common\ResponseVariable; @@ -54,7 +54,7 @@ public function testCompletion($testFile, $identifiers, $finalNumberCompleted) { $movedNext++; } else { - $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier($identifier))))); + $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier($identifier))))); } $this->assertSame($i - $movedNext, $session->numberCompleted()); diff --git a/test/qtismtest/runtime/tests/AssessmentTestSessionEndAttemptInteractionTest.php b/test/qtismtest/runtime/tests/AssessmentTestSessionEndAttemptInteractionTest.php index b789550f9..b4be90fcc 100644 --- a/test/qtismtest/runtime/tests/AssessmentTestSessionEndAttemptInteractionTest.php +++ b/test/qtismtest/runtime/tests/AssessmentTestSessionEndAttemptInteractionTest.php @@ -3,9 +3,9 @@ use qtism\runtime\tests\AssessmentTestSessionState; -use qtism\common\datatypes\Boolean; +use qtism\common\datatypes\QtiBoolean; use qtismtest\QtiSmAssessmentTestSessionTestCase; -use qtism\common\datatypes\Identifier; +use qtism\common\datatypes\QtiIdentifier; use qtism\common\enums\BaseType; use qtism\common\enums\Cardinality; use qtism\runtime\common\ResponseVariable; @@ -36,7 +36,7 @@ public function testEndAttemptInteraction() { $this->assertFalse($session['Q01.SHOWHINT']->getValue()); // End of attempt using endAttemptInteraction 'HINT'. - $session->endAttempt(new State(array(new ResponseVariable('HINT', Cardinality::SINGLE, BaseType::BOOLEAN, new Boolean(true))))); + $session->endAttempt(new State(array(new ResponseVariable('HINT', Cardinality::SINGLE, BaseType::BOOLEAN, new QtiBoolean(true))))); $this->assertTrue($session['Q01.HINT']->getValue()); $this->assertTrue($session['Q01.SHOWHINT']->getValue()); @@ -53,8 +53,8 @@ public function testEndAttemptInteraction() { $session->endAttempt( new State( array( - new ResponseVariable('HINT', Cardinality::SINGLE, BaseType::BOOLEAN, new Boolean(false)), - new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('ChoiceA')) + new ResponseVariable('HINT', Cardinality::SINGLE, BaseType::BOOLEAN, new QtiBoolean(false)), + new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('ChoiceA')) ) ) ); @@ -67,7 +67,7 @@ public function testEndAttemptInteraction() { // Q02 - No endAttemptInteraction. $session->beginAttempt(); - $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('ChoiceB'))))); + $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('ChoiceB'))))); $this->assertEquals(1.0, $session['Q02.SCORE']->getValue()); @@ -85,8 +85,8 @@ public function testEndAttemptInteraction() { $session->endAttempt( new State( array( - new ResponseVariable('HINT1', Cardinality::SINGLE, BaseType::BOOLEAN, new Boolean(true)), - new ResponseVariable('HINT2', Cardinality::SINGLE, BaseType::BOOLEAN, new Boolean(false)) + new ResponseVariable('HINT1', Cardinality::SINGLE, BaseType::BOOLEAN, new QtiBoolean(true)), + new ResponseVariable('HINT2', Cardinality::SINGLE, BaseType::BOOLEAN, new QtiBoolean(false)) ) ) ); @@ -109,9 +109,9 @@ public function testEndAttemptInteraction() { $session->endAttempt( new State( array( - new ResponseVariable('HINT1', Cardinality::SINGLE, BaseType::BOOLEAN, new Boolean(false)), - new ResponseVariable('HINT2', Cardinality::SINGLE, BaseType::BOOLEAN, new Boolean(false)), - new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('ChoiceE')) + new ResponseVariable('HINT1', Cardinality::SINGLE, BaseType::BOOLEAN, new QtiBoolean(false)), + new ResponseVariable('HINT2', Cardinality::SINGLE, BaseType::BOOLEAN, new QtiBoolean(false)), + new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('ChoiceE')) ) ) ); @@ -127,8 +127,8 @@ public function testEndAttemptInteraction() { $session->endAttempt( new State( array( - new ResponseVariable('HINT1', Cardinality::SINGLE, BaseType::BOOLEAN, new Boolean(false)), - new ResponseVariable('HINT2', Cardinality::SINGLE, BaseType::BOOLEAN, new Boolean(true)) + new ResponseVariable('HINT1', Cardinality::SINGLE, BaseType::BOOLEAN, new QtiBoolean(false)), + new ResponseVariable('HINT2', Cardinality::SINGLE, BaseType::BOOLEAN, new QtiBoolean(true)) ) ) ); @@ -143,9 +143,9 @@ public function testEndAttemptInteraction() { $session->beginAttempt(); $session->endAttempt(new State( array( - new ResponseVariable('HINT1', Cardinality::SINGLE, BaseType::BOOLEAN, new Boolean(false)), - new ResponseVariable('HINT2', Cardinality::SINGLE, BaseType::BOOLEAN, new Boolean(false)), - new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('ChoiceC')) + new ResponseVariable('HINT1', Cardinality::SINGLE, BaseType::BOOLEAN, new QtiBoolean(false)), + new ResponseVariable('HINT2', Cardinality::SINGLE, BaseType::BOOLEAN, new QtiBoolean(false)), + new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('ChoiceC')) ) )); diff --git a/test/qtismtest/runtime/tests/AssessmentTestSessionExitTest.php b/test/qtismtest/runtime/tests/AssessmentTestSessionExitTest.php index 8199baf31..c642d14be 100644 --- a/test/qtismtest/runtime/tests/AssessmentTestSessionExitTest.php +++ b/test/qtismtest/runtime/tests/AssessmentTestSessionExitTest.php @@ -2,7 +2,7 @@ namespace qtismtest\runtime\tests; use qtismtest\QtiSmAssessmentTestSessionTestCase; -use qtism\common\datatypes\Identifier; +use qtism\common\datatypes\QtiIdentifier; use qtism\common\enums\BaseType; use qtism\common\enums\Cardinality; use qtism\runtime\common\ResponseVariable; @@ -21,7 +21,7 @@ public function testExitSection() { // If we get correct to the first question, we should EXIT_SECTION. We should // then be redirected to S02. $testSession->beginAttempt(); - $testSession->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('ChoiceA'))))); + $testSession->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('ChoiceA'))))); // We should arrive at section 2. $testSession->moveNext(); @@ -38,7 +38,7 @@ public function testExitSectionEndOfTest() { // be then redirected to the end of the test, because S01 is the unique section // of the test. $testSession->beginAttempt(); - $testSession->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('ChoiceA'))))); + $testSession->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('ChoiceA'))))); // We should be at the end of the test. $testSession->moveNext(); @@ -65,7 +65,7 @@ public function testExitSectionPreconditionsEndOfTest() { // be then redirected to the end of the test, because Q03 has a precondition // which is never satisfied (return always false). $testSession->beginAttempt(); - $testSession->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('ChoiceA'))))); + $testSession->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('ChoiceA'))))); // We should be at the end of the test. $testSession->moveNext(); @@ -95,7 +95,7 @@ public function testExitTestPart() { // If we get correct to the first question, we should EXIT_TESTPART. We should // then be redirected to P02. $testSession->beginAttempt(); - $testSession->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('ChoiceA'))))); + $testSession->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('ChoiceA'))))); // We should arrive at testPart 2 $testSession->moveNext(); @@ -112,7 +112,7 @@ public function testExitTestPartEndOfTest() { // be then redirected to the end of the test, because T01 is the unique testPart // of the test. $testSession->beginAttempt(); - $testSession->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('ChoiceA'))))); + $testSession->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('ChoiceA'))))); // We should be at the end of the test. $testSession->moveNext(); @@ -139,7 +139,7 @@ public function testExitTestPartPreconditionsEndOfTest() { // be then redirected to the end of the test, because Q03 has a precondition // which is never satisfied (return always false). $testSession->beginAttempt(); - $testSession->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('ChoiceA'))))); + $testSession->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('ChoiceA'))))); // We should be at the end of the test. $testSession->moveNext(); @@ -169,7 +169,7 @@ public function testExitTest() { // If we get correct to the first question, we should EXIT_TEST. We should // then be redirected to end of the test. $testSession->beginAttempt(); - $testSession->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('ChoiceA'))))); + $testSession->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('ChoiceA'))))); // We should arrive at section 2. $testSession->moveNext(); diff --git a/test/qtismtest/runtime/tests/AssessmentTestSessionFeedbackTest.php b/test/qtismtest/runtime/tests/AssessmentTestSessionFeedbackTest.php index eec571e10..1c55ba40d 100644 --- a/test/qtismtest/runtime/tests/AssessmentTestSessionFeedbackTest.php +++ b/test/qtismtest/runtime/tests/AssessmentTestSessionFeedbackTest.php @@ -2,7 +2,7 @@ namespace qtismtest\runtime\tests; use qtismtest\QtiSmAssessmentTestSessionTestCase; -use qtism\common\datatypes\Identifier; +use qtism\common\datatypes\QtiIdentifier; use qtism\common\enums\BaseType; use qtism\common\enums\Cardinality; use qtism\runtime\common\ResponseVariable; @@ -20,7 +20,7 @@ public function testLinearAssessmentTestDuring() { // Attempt on Q01. $testSession->beginAttempt(); - $testSession->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('ChoiceA'))))); + $testSession->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('ChoiceA'))))); $current = $testSession->getRoute()->current(); // The call to moveNext must put the state of the session into MODAL_FEEDBACK. Be carefull, @@ -36,7 +36,7 @@ public function testLinearAssessmentTestDuring() { // Attempt on Q02. $testSession->beginAttempt(); - $testSession->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('ChoiceB'))))); + $testSession->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('ChoiceB'))))); // The call to moveNext must again put the state of the session into MODAL_FEEDBACK without // moving to the next item. @@ -58,7 +58,7 @@ public function testLinearAssessmentTestAtEndShow() { // Attempt on Q01. Correct response. $testSession->beginAttempt(); - $testSession->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('ChoiceA'))))); + $testSession->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('ChoiceA'))))); $testSession->moveNext(); // No feedback must be shown because we are not at the end of test. @@ -68,7 +68,7 @@ public function testLinearAssessmentTestAtEndShow() { // Attempt on Q02. Correct response. $testSession->beginAttempt(); - $testSession->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('ChoiceB'))))); + $testSession->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('ChoiceB'))))); $testSession->moveNext(); // Because it is the end of the test, and the two responses are correct, the feedback must be shown. @@ -91,12 +91,12 @@ public function testLinearAssessmentTestAtEndNoShow() { // Attempt on Q01. Correct response. $testSession->beginAttempt(); - $testSession->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('ChoiceA'))))); + $testSession->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('ChoiceA'))))); $testSession->moveNext(); // Attempt on Q02. Incorrect response. $testSession->beginAttempt(); - $testSession->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('ChoiceD'))))); + $testSession->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('ChoiceD'))))); $testSession->moveNext(); // Because it is the end of the test, and the two responses are not correct, the feedback must not be shown. @@ -113,7 +113,7 @@ public function testLinearTestPartAtEndShow() { // Entering testPart P01... // Attempt on Q01. Correct response. $testSession->beginAttempt(); - $testSession->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('ChoiceA'))))); + $testSession->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('ChoiceA'))))); $testSession->moveNext(); // No feedback must be shown because we are not at the end of the testPart. @@ -123,7 +123,7 @@ public function testLinearTestPartAtEndShow() { // Attempt on Q02. Correct response. $testSession->beginAttempt(); - $testSession->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('ChoiceB'))))); + $testSession->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('ChoiceB'))))); $testSession->moveNext(); // Because it is the end of the testPart, and the two responses of this testPart are correct, the feedback must be shown. @@ -136,7 +136,7 @@ public function testLinearTestPartAtEndShow() { // Attempt on Q03. Correct response. $testSession->beginAttempt(); - $testSession->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('ChoiceC'))))); + $testSession->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('ChoiceC'))))); $testSession->moveNext(); // No feedback must be shown because we are not at the end of the testPart. @@ -146,7 +146,7 @@ public function testLinearTestPartAtEndShow() { // Attempt on Q04. Correct response. $testSession->beginAttempt(); - $testSession->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('ChoiceD'))))); + $testSession->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('ChoiceD'))))); $testSession->moveNext(); // Because it is the end of the testPart, and the two responses of this testPart are correct, the feedback must be shown. diff --git a/test/qtismtest/runtime/tests/AssessmentTestSessionNumberXTest.php b/test/qtismtest/runtime/tests/AssessmentTestSessionNumberXTest.php index beb73b57f..fd962fea6 100644 --- a/test/qtismtest/runtime/tests/AssessmentTestSessionNumberXTest.php +++ b/test/qtismtest/runtime/tests/AssessmentTestSessionNumberXTest.php @@ -2,7 +2,7 @@ namespace qtismtest\runtime\tests; use qtismtest\QtiSmAssessmentTestSessionTestCase; -use qtism\common\datatypes\Identifier; +use qtism\common\datatypes\QtiIdentifier; use qtism\common\enums\BaseType; use qtism\common\enums\Cardinality; use qtism\runtime\common\ResponseVariable; @@ -75,7 +75,7 @@ public function testNumberXRunning() { // -- Correct answer to Q01. $session->beginAttempt(); - $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('ChoiceA'))))); + $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('ChoiceA'))))); $session->moveNext(); $this->assertEquals(1, $session->numberCorrect()); @@ -110,7 +110,7 @@ public function testNumberXRunning() { // -- Incorrect answer to Q02. $session->beginAttempt(); - $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('ChoiceA'))))); + $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('ChoiceA'))))); $session->moveNext(); $this->assertEquals(1, $session->numberCorrect()); @@ -180,7 +180,7 @@ public function testNumberXRunning() { // -- Incorrect answer to Q04.1 $session->beginAttempt(); - $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('ChoiceZ'))))); + $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('ChoiceZ'))))); $session->moveNext(); $this->assertEquals(1, $session->numberCorrect()); @@ -215,7 +215,7 @@ public function testNumberXRunning() { // -- Correct answer to Q04.2 $session->beginAttempt(); - $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('ChoiceD'))))); + $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('ChoiceD'))))); $session->moveNext(); $this->assertEquals(2, $session->numberCorrect()); @@ -285,7 +285,7 @@ public function testNumberXRunning() { // Correct answer to Q05. $session->beginAttempt(); - $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('ChoiceE'))))); + $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('ChoiceE'))))); $session->moveNext(); $this->assertEquals(3, $session->numberCorrect()); diff --git a/test/qtismtest/runtime/tests/AssessmentTestSessionPreConditionsTest.php b/test/qtismtest/runtime/tests/AssessmentTestSessionPreConditionsTest.php index 700a4c5f1..9ce9ddb8f 100644 --- a/test/qtismtest/runtime/tests/AssessmentTestSessionPreConditionsTest.php +++ b/test/qtismtest/runtime/tests/AssessmentTestSessionPreConditionsTest.php @@ -2,7 +2,7 @@ namespace qtismtest\runtime\tests; use qtismtest\QtiSmAssessmentTestSessionTestCase; -use qtism\common\datatypes\Identifier; +use qtism\common\datatypes\QtiIdentifier; use qtism\common\enums\BaseType; use qtism\common\enums\Cardinality; use qtism\runtime\common\ResponseVariable; @@ -48,12 +48,12 @@ public function testSingleSectionLinear1() { // Q01 - Answer incorrect to be redirected by successive false evaluated preconditions. $testSession->beginAttempt(); - $testSession->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('ChoiceB'))))); + $testSession->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('ChoiceB'))))); $testSession->moveNext(); // Because of the autoforward, the test is finished. $this->assertFalse($testSession->isRunning()); - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $testSession['Q01.SCORE']); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $testSession['Q01.SCORE']); $this->assertEquals(0.0, $testSession['Q01.SCORE']->getValue()); $this->assertSame(null, $testSession['Q02.SCORE']); $this->assertSame(null, $testSession['Q03.SCORE']); @@ -66,12 +66,12 @@ public function testKillerTestEpicFail() { $testSession->beginTestSession(); $testSession->beginAttempt(); - $testSession->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('BadChoice'))))); + $testSession->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('BadChoice'))))); $testSession->moveNext(); // Incorrect answer = end of test. $this->assertFalse($testSession->isRunning()); - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $testSession['Q01.SCORE']); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $testSession['Q01.SCORE']); $this->assertEquals(0.0, $testSession['Q01.SCORE']->getValue()); // Other items could not be instantiated. @@ -87,31 +87,31 @@ public function testKillerTestEpicWin() { $this->assertEquals('Q01', $testSession->getCurrentAssessmentItemRef()->getIdentifier()); $testSession->beginAttempt(); - $testSession->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('GoodChoice'))))); + $testSession->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('GoodChoice'))))); $testSession->moveNext(); $this->assertEquals(1.0, $testSession['Q01.SCORE']->getValue()); $this->assertEquals('Q02', $testSession->getCurrentAssessmentItemRef()->getIdentifier()); $testSession->beginAttempt(); - $testSession->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('GoodChoice'))))); + $testSession->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('GoodChoice'))))); $testSession->moveNext(); $this->assertEquals(1.0, $testSession['Q02.SCORE']->getValue()); $this->assertEquals('Q03', $testSession->getCurrentAssessmentItemRef()->getIdentifier()); $testSession->beginAttempt(); - $testSession->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('GoodChoice'))))); + $testSession->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('GoodChoice'))))); $testSession->moveNext(); $this->assertEquals(1.0, $testSession['Q03.SCORE']->getValue()); $this->assertEquals('Q04', $testSession->getCurrentAssessmentItemRef()->getIdentifier()); $testSession->beginAttempt(); - $testSession->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('GoodChoice'))))); + $testSession->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('GoodChoice'))))); $testSession->moveNext(); $this->assertEquals(1.0, $testSession['Q04.SCORE']->getValue()); $this->assertEquals('Q05', $testSession->getCurrentAssessmentItemRef()->getIdentifier()); $testSession->beginAttempt(); - $testSession->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('GoodChoice'))))); + $testSession->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('GoodChoice'))))); $testSession->moveNext(); $this->assertEquals(1.0, $testSession['Q05.SCORE']->getValue()); diff --git a/test/qtismtest/runtime/tests/AssessmentTestSessionResultsTest.php b/test/qtismtest/runtime/tests/AssessmentTestSessionResultsTest.php index 95abe9146..e8de9e5e1 100644 --- a/test/qtismtest/runtime/tests/AssessmentTestSessionResultsTest.php +++ b/test/qtismtest/runtime/tests/AssessmentTestSessionResultsTest.php @@ -4,7 +4,7 @@ use qtismtest\QtiSmAssessmentTestSessionTestCase; use qtismtest\runtime\tests\mocks\SimpleResultsSubmittableTestSession; use qtismtest\runtime\tests\mocks\SimpleResultsSubmittableTestSessionFactory; -use qtism\common\datatypes\Identifier; +use qtism\common\datatypes\QtiIdentifier; use qtism\runtime\tests\TestResultsSubmission; use qtism\runtime\tests\AssessmentTestSessionState; use qtism\common\enums\BaseType; @@ -29,19 +29,19 @@ public function testTestResultsSubmissionNonLinearOutcomeProcessing() { // Q01 - Failure $testSession->beginAttempt(); - $testSession->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('ChoiceB'))))); + $testSession->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('ChoiceB'))))); $this->assertSame(0.0, $testSession['Q01.SCORE']->getValue()); $testSession->moveNext(); // Q02 - Success $testSession->beginAttempt(); - $testSession->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('ChoiceB'))))); + $testSession->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('ChoiceB'))))); $this->assertSame(1.0, $testSession['Q02.SCORE']->getValue()); $testSession->moveNext(); // Q03 - Success $testSession->beginAttempt(); - $testSession->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('ChoiceC'))))); + $testSession->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('ChoiceC'))))); $this->assertSame(1.0, $testSession['Q03.SCORE']->getValue()); $testSession->moveNext(); @@ -80,19 +80,19 @@ public function testTestResultsSubmissionNonLinearEnd() { // Q01 - Failure $testSession->beginAttempt(); - $testSession->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('ChoiceB'))))); + $testSession->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('ChoiceB'))))); $this->assertSame(0.0, $testSession['Q01.SCORE']->getValue()); $testSession->moveNext(); // Q02 - Success $testSession->beginAttempt(); - $testSession->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('ChoiceB'))))); + $testSession->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('ChoiceB'))))); $this->assertSame(1.0, $testSession['Q02.SCORE']->getValue()); $testSession->moveNext(); // Q03 - Success $testSession->beginAttempt(); - $testSession->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('ChoiceC'))))); + $testSession->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('ChoiceC'))))); $this->assertSame(1.0, $testSession['Q03.SCORE']->getValue()); $testSession->moveNext(); diff --git a/test/qtismtest/runtime/tests/AssessmentTestSessionTemplatesTest.php b/test/qtismtest/runtime/tests/AssessmentTestSessionTemplatesTest.php index a92651dab..5f05ed11c 100644 --- a/test/qtismtest/runtime/tests/AssessmentTestSessionTemplatesTest.php +++ b/test/qtismtest/runtime/tests/AssessmentTestSessionTemplatesTest.php @@ -3,7 +3,7 @@ use qtismtest\QtiSmAssessmentTestSessionTestCase; use qtism\runtime\tests\AssessmentItemSession; -use qtism\common\datatypes\Identifier; +use qtism\common\datatypes\QtiIdentifier; use qtism\common\enums\BaseType; use qtism\common\enums\Cardinality; use qtism\runtime\common\ResponseVariable; @@ -24,7 +24,7 @@ public function testSimpleTemplating() { // QTPL1 - correct response. $session->beginAttempt(); $responses = new State( - array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('ChoiceA'))) + array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('ChoiceA'))) ); $session->endAttempt($responses); $session->moveNext(); @@ -32,7 +32,7 @@ public function testSimpleTemplating() { // QTPL2 - correct response. $session->beginAttempt(); $responses = new State( - array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('ChoiceB'))) + array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('ChoiceB'))) ); $session->endAttempt($responses); $session->moveNext(); diff --git a/test/qtismtest/runtime/tests/AssessmentTestSessionTest.php b/test/qtismtest/runtime/tests/AssessmentTestSessionTest.php index 6c0e20cba..24a45636a 100644 --- a/test/qtismtest/runtime/tests/AssessmentTestSessionTest.php +++ b/test/qtismtest/runtime/tests/AssessmentTestSessionTest.php @@ -2,10 +2,10 @@ namespace qtismtest\runtime\tests; use qtismtest\QtiSmTestCase; -use qtism\common\datatypes\Integer; -use qtism\common\datatypes\Identifier; -use qtism\common\datatypes\Float; -use qtism\common\datatypes\String; +use qtism\common\datatypes\QtiInteger; +use qtism\common\datatypes\QtiIdentifier; +use qtism\common\datatypes\QtiFloat; +use qtism\common\datatypes\QtiString; use qtism\runtime\tests\AssessmentTestPlace; use qtism\runtime\tests\AssessmentItemSessionException; use qtism\runtime\tests\AssessmentItemSessionState; @@ -29,11 +29,11 @@ use qtism\runtime\tests\AssessmentTestSession; use qtism\runtime\tests\AssessmentTestSessionState; use qtism\runtime\tests\AssessmentTestSessionException; -use qtism\common\datatypes\Point; -use qtism\common\datatypes\DirectedPair; -use qtism\common\datatypes\Pair; +use qtism\common\datatypes\QtiPoint; +use qtism\common\datatypes\QtiDirectedPair; +use qtism\common\datatypes\QtiPair; use qtism\runtime\common\MultipleContainer; -use qtism\common\datatypes\Duration; +use qtism\common\datatypes\QtiDuration; use \OutOfBoundsException; use \InvalidArgumentException; @@ -49,7 +49,7 @@ public function setUp() { $sessionManager = new SessionManager(); $this->state = $sessionManager->createAssessmentTestSession($xml->getDocumentComponent()); - $this->state['OUTCOME1'] = new String('String!'); + $this->state['OUTCOME1'] = new QtiString('String!'); } public function tearDown() { @@ -94,7 +94,7 @@ public function testInstantiateOne() { // test-level outcome variables should be initialized // with their default values. - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $assessmentTestSession['SCORE']); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $assessmentTestSession['SCORE']); $this->assertEquals(0.0, $assessmentTestSession['SCORE']->getValue()); // No session ID should be set, this is the role of AssessmentTestSession Storage Services. @@ -112,7 +112,7 @@ public function testInstantiateTwo() { for ($i = 1; $i <= 3; $i++) { $score = $assessmentTestSession["Q01.${i}.SCORE"]; $response = $assessmentTestSession["Q01.${i}.RESPONSE"]; - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $score); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $score); $this->assertEquals(0.0, $score->getValue()); $this->assertSame(null, $response); } @@ -128,13 +128,13 @@ public function testSetVariableValuesAfterInstantiationOne() { // Change the value of the global SCORE. $this->assertEquals(0.0, $assessmentTestSession['SCORE']->getValue()); - $assessmentTestSession['SCORE'] = new Float(20.0); + $assessmentTestSession['SCORE'] = new QtiFloat(20.0); $this->assertEquals(20.0, $assessmentTestSession['SCORE']->getValue()); // the assessment test session has no variable MAXSCORE. $this->assertSame(null, $assessmentTestSession['MAXSCORE']); try { - $assessmentTestSession['MAXSCORE'] = new Float(20.0); + $assessmentTestSession['MAXSCORE'] = new QtiFloat(20.0); // An exception must be thrown in this case! $this->assertTrue(false); } @@ -144,13 +144,13 @@ public function testSetVariableValuesAfterInstantiationOne() { // Change the value of Q01.SCORE. $this->assertEquals(0.0, $assessmentTestSession['Q01.SCORE']->getValue()); - $assessmentTestSession['Q01.SCORE'] = new Float(1.0); + $assessmentTestSession['Q01.SCORE'] = new QtiFloat(1.0); $this->assertEquals(1.0, $assessmentTestSession['Q01.SCORE']->getValue()); // Q01 has no 'MAXSCORE' variable. $this->assertSame(null, $assessmentTestSession['Q01.MAXSCORE']); try { - $assessmentTestSession['Q01.MAXSCORE'] = new Float(1.0); + $assessmentTestSession['Q01.MAXSCORE'] = new QtiFloat(1.0); // An exception must be thrown ! $this->assertTrue(false); } @@ -161,7 +161,7 @@ public function testSetVariableValuesAfterInstantiationOne() { // No item Q04. $this->assertSame(null, $assessmentTestSession['Q04.SCORE']); try { - $assessmentTestSession['Q04.SCORE'] = new Float(1.0); + $assessmentTestSession['Q04.SCORE'] = new QtiFloat(1.0); // Because no such item, outofbounds. $this->assertTrue(false); } @@ -225,7 +225,7 @@ public function testLinearAnswerAll() { $assessmentTestSession->beginAttempt(); $this->assertTrue($assessmentTestSession->isCurrentAssessmentItemInteracting()); $responses = new State(); - $responses->setVariable(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('ChoiceA'))); + $responses->setVariable(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('ChoiceA'))); $assessmentTestSession->endAttempt($responses); $assessmentTestSession->moveNext(); $this->assertFalse($assessmentTestSession->isCurrentAssessmentItemInteracting()); @@ -234,7 +234,7 @@ public function testLinearAnswerAll() { $this->assertEquals('Q02', $assessmentTestSession->getCurrentAssessmentItemRef()->getIdentifier()); $assessmentTestSession->beginAttempt(); $responses = new State(); - $responses->setVariable(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('ChoiceC'))); // -> incorrect x) + $responses->setVariable(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('ChoiceC'))); // -> incorrect x) $assessmentTestSession->endAttempt($responses); $assessmentTestSession->moveNext(); @@ -242,30 +242,30 @@ public function testLinearAnswerAll() { $this->assertEquals('Q03', $assessmentTestSession->getCurrentAssessmentItemRef()->getIdentifier()); $assessmentTestSession->beginAttempt(); $responses = new State(); - $responses->setVariable(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('ChoiceC'))); + $responses->setVariable(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('ChoiceC'))); $assessmentTestSession->endAttempt($responses); $assessmentTestSession->moveNext(); // Check the final state of the test session. // - Q01 $this->assertEquals('ChoiceA', $assessmentTestSession['Q01.RESPONSE']->getValue()); - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $assessmentTestSession['Q01.SCORE']); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $assessmentTestSession['Q01.SCORE']); $this->assertEquals(1.0, $assessmentTestSession['Q01.SCORE']->getValue()); - $this->assertInstanceOf('qtism\\common\\datatypes\\Integer', $assessmentTestSession['Q01.numAttempts']); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiInteger', $assessmentTestSession['Q01.numAttempts']); $this->assertEquals(1, $assessmentTestSession['Q01.numAttempts']->getValue()); // - Q02 $this->assertEquals('ChoiceC', $assessmentTestSession['Q02.RESPONSE']->getValue()); - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $assessmentTestSession['Q02.SCORE']); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $assessmentTestSession['Q02.SCORE']); $this->assertEquals(0.0, $assessmentTestSession['Q02.SCORE']->getValue()); - $this->assertInstanceOf('qtism\\common\\datatypes\\Integer', $assessmentTestSession['Q02.numAttempts']); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiInteger', $assessmentTestSession['Q02.numAttempts']); $this->assertEquals(1, $assessmentTestSession['Q02.numAttempts']->getValue()); // - Q03 $this->assertEquals('ChoiceC', $assessmentTestSession['Q03.RESPONSE']->getValue()); - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $assessmentTestSession['Q03.SCORE']); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $assessmentTestSession['Q03.SCORE']); $this->assertEquals(1.0, $assessmentTestSession['Q03.SCORE']->getValue()); - $this->assertInstanceOf('qtism\\common\\datatypes\\Integer', $assessmentTestSession['Q03.numAttempts']); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiInteger', $assessmentTestSession['Q03.numAttempts']); $this->assertEquals(1, $assessmentTestSession['Q03.numAttempts']->getValue()); $this->assertEquals(AssessmentTestSessionState::CLOSED, $assessmentTestSession->getState()); @@ -281,7 +281,7 @@ public function testLinearSimultaneousSubmission() { // Q01 - Correct. $session->beginAttempt(); - $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('ChoiceA'))))); + $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('ChoiceA'))))); // The session must be suspended until the end of the test part. $this->assertEquals(AssessmentItemSessionState::SUSPENDED, $session->getCurrentAssessmentItemSession()->getState()); // !!! The Response must be stored in the session, but no score must be computed. @@ -293,7 +293,7 @@ public function testLinearSimultaneousSubmission() { // Q02 - Incorrect (but SCORE = 3) $session->beginAttempt(); - $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::MULTIPLE, BaseType::PAIR, new MultipleContainer(BaseType::PAIR, array(new Pair('A', 'P'), new Pair('C', 'M'))))))); + $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::MULTIPLE, BaseType::PAIR, new MultipleContainer(BaseType::PAIR, array(new QtiPair('A', 'P'), new QtiPair('C', 'M'))))))); $this->assertEquals(AssessmentItemSessionState::SUSPENDED, $session->getCurrentAssessmentItemSession()->getState()); $this->assertSame(null, $session['Q02.RESPONSE']); $this->assertEquals(0.0, $session['Q02.SCORE']->getValue()); @@ -330,17 +330,17 @@ public function testLinearSimultaneousSubmission() { // Q07.1 - Correct. $session->beginAttempt(); - $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::POINT, new Point(102, 113))))); + $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::POINT, new QtiPoint(102, 113))))); $this->assertEquals(AssessmentItemSessionState::SUSPENDED, $session->getCurrentAssessmentItemSession()->getState()); $this->assertSame(null, $session['Q07.1.RESPONSE']); - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $session['Q07.1.SCORE']); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $session['Q07.1.SCORE']); $this->assertEquals(0.0, $session['Q07.1.SCORE']->getValue()); $this->assertEquals(7, count($session->getPendingResponses())); $session->moveNext(); // Q07.2 - Incorrect (but SCORE = 1). $session->beginAttempt(); - $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::POINT, new Point(103, 113))))); + $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::POINT, new QtiPoint(103, 113))))); $this->assertEquals(AssessmentItemSessionState::SUSPENDED, $session->getCurrentAssessmentItemSession()->getState()); $this->assertSame(null, $session['Q07.2.RESPONSE']); $this->assertEquals(0.0, $session['Q07.2.SCORE']->getValue()); @@ -349,7 +349,7 @@ public function testLinearSimultaneousSubmission() { // Q07.3 - Incorrect (and SCORE = 0). $session->beginAttempt(); - $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::POINT, new Point(50, 60))))); + $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::POINT, new QtiPoint(50, 60))))); $this->assertEquals(AssessmentItemSessionState::SUSPENDED, $session->getCurrentAssessmentItemSession()->getState()); $this->assertSame(null, $session['Q07.3.RESPONSE']); $this->assertEquals(0.0, $session['Q07.3.SCORE']->getValue()); @@ -366,7 +366,7 @@ public function testLinearSimultaneousSubmission() { $this->assertEquals('ChoiceA', $session['Q01.RESPONSE']->getValue()); $this->assertEquals(1.0, $session['Q01.scoring']->getValue()); - $this->assertTrue($session['Q02.RESPONSE']->equals(new MultipleContainer(BaseType::PAIR, array(new Pair('A', 'P'), new Pair('C', 'M'))))); + $this->assertTrue($session['Q02.RESPONSE']->equals(new MultipleContainer(BaseType::PAIR, array(new QtiPair('A', 'P'), new QtiPair('C', 'M'))))); $this->assertEquals(3.0, $session['Q02.SCORE']->getValue()); @@ -375,9 +375,9 @@ public function testLinearSimultaneousSubmission() { $this->assertEquals(0.0, $session['Q05.SCORE']->getValue()); $this->assertEquals(0.0, $session['Q06.mySc0r3']->getValue()); - $this->assertTrue($session['Q07.1.RESPONSE']->equals(new Point(102, 113))); - $this->assertTrue($session['Q07.2.RESPONSE']->equals(new Point(103, 113))); - $this->assertTrue($session['Q07.3.RESPONSE']->equals(new Point(50, 60))); + $this->assertTrue($session['Q07.1.RESPONSE']->equals(new QtiPoint(102, 113))); + $this->assertTrue($session['Q07.2.RESPONSE']->equals(new QtiPoint(103, 113))); + $this->assertTrue($session['Q07.3.RESPONSE']->equals(new QtiPoint(50, 60))); // Did the test-level outcome processing take place? $this->assertEquals(9, $session['NPRESENTED']->getValue()); @@ -424,7 +424,7 @@ public function testLinearOutcomeProcessing(array $responses, array $outcomes) { $this->assertEquals(AssessmentTestSessionState::CLOSED, $assessmentTestSession->getState()); foreach ($outcomes as $outcomeIdentifier => $outcomeValue) { - $this->assertInstanceOf(($outcomeValue instanceof Integer) ? 'qtism\\common\\datatypes\\Integer' : 'qtism\\common\\datatypes\\Float', $assessmentTestSession[$outcomeIdentifier]); + $this->assertInstanceOf(($outcomeValue instanceof QtiInteger) ? 'qtism\\common\\datatypes\\QtiInteger' : 'qtism\\common\\datatypes\\QtiFloat', $assessmentTestSession[$outcomeIdentifier]); if ($outcomeIdentifier !== 'PERCENT_CORRECT') { $this->assertEquals($outcomeValue->getValue(), $assessmentTestSession[$outcomeIdentifier]->getValue()); @@ -439,33 +439,33 @@ public function linearOutcomeProcessingProvider() { $returnValue = array(); // Test 1. - $outcomes = array('NCORRECTS01' => new Integer(2), 'NCORRECTS02' => new Integer(1), 'NCORRECTS03' => new Integer(1), 'NINCORRECT' => new Integer(5), 'NRESPONSED' => new Integer(9), 'NPRESENTED' => new Integer(9), 'NSELECTED' => new Integer(9), 'PERCENT_CORRECT' => new Float(44.44)); + $outcomes = array('NCORRECTS01' => new QtiInteger(2), 'NCORRECTS02' => new QtiInteger(1), 'NCORRECTS03' => new QtiInteger(1), 'NINCORRECT' => new QtiInteger(5), 'NRESPONSED' => new QtiInteger(9), 'NPRESENTED' => new QtiInteger(9), 'NSELECTED' => new QtiInteger(9), 'PERCENT_CORRECT' => new QtiFloat(44.44)); $responses = array(); - $responses['Q01'] = new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('ChoiceA')))); // SCORE = 1 - Correct - $responses['Q02'] = new State(array(new ResponseVariable('RESPONSE', Cardinality::MULTIPLE, BaseType::PAIR, new MultipleContainer(BaseType::PAIR, array(new Pair('A', 'P'), new Pair('D', 'L')))))); // SCORE = 3 - Incorrect - $responses['Q03'] = new State(array(new ResponseVariable('RESPONSE', Cardinality::MULTIPLE, BaseType::IDENTIFIER, new MultipleContainer(BaseType::IDENTIFIER, array(new Identifier('H'), new Identifier('O')))))); // SCORE = 2 - Correct - $responses['Q04'] = new State(array(new ResponseVariable('RESPONSE', Cardinality::MULTIPLE, BaseType::DIRECTED_PAIR, new MultipleContainer(BaseType::DIRECTED_PAIR, array(new DirectedPair('W', 'Sp'), new DirectedPair('G2', 'Su')))))); // SCORE = 0 - Incorrect - $responses['Q05'] = new State(array(new ResponseVariable('RESPONSE', Cardinality::MULTIPLE, BaseType::PAIR, new MultipleContainer(BaseType::PAIR, array(new Pair('C', 'B'), new Pair('C', 'D'), new Pair('B', 'D')))))); // SCORE = 1 - Incorrect - $responses['Q06'] = new State(array(new ResponseVariable('answer', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('A')))); // SCORE = 1 - Correct - $responses['Q07.1'] = new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::POINT, new Point(105, 105)))); // SCORE = 1 - Incorrect - $responses['Q07.2'] = new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::POINT, new Point(102, 113)))); // SCORE = 1 - Correct - $responses['Q07.3'] = new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::POINT, new Point(13, 37)))); // SCORE = 0 - Incorrect + $responses['Q01'] = new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('ChoiceA')))); // SCORE = 1 - Correct + $responses['Q02'] = new State(array(new ResponseVariable('RESPONSE', Cardinality::MULTIPLE, BaseType::PAIR, new MultipleContainer(BaseType::PAIR, array(new QtiPair('A', 'P'), new QtiPair('D', 'L')))))); // SCORE = 3 - Incorrect + $responses['Q03'] = new State(array(new ResponseVariable('RESPONSE', Cardinality::MULTIPLE, BaseType::IDENTIFIER, new MultipleContainer(BaseType::IDENTIFIER, array(new QtiIdentifier('H'), new QtiIdentifier('O')))))); // SCORE = 2 - Correct + $responses['Q04'] = new State(array(new ResponseVariable('RESPONSE', Cardinality::MULTIPLE, BaseType::DIRECTED_PAIR, new MultipleContainer(BaseType::DIRECTED_PAIR, array(new QtiDirectedPair('W', 'Sp'), new QtiDirectedPair('G2', 'Su')))))); // SCORE = 0 - Incorrect + $responses['Q05'] = new State(array(new ResponseVariable('RESPONSE', Cardinality::MULTIPLE, BaseType::PAIR, new MultipleContainer(BaseType::PAIR, array(new QtiPair('C', 'B'), new QtiPair('C', 'D'), new QtiPair('B', 'D')))))); // SCORE = 1 - Incorrect + $responses['Q06'] = new State(array(new ResponseVariable('answer', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('A')))); // SCORE = 1 - Correct + $responses['Q07.1'] = new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::POINT, new QtiPoint(105, 105)))); // SCORE = 1 - Incorrect + $responses['Q07.2'] = new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::POINT, new QtiPoint(102, 113)))); // SCORE = 1 - Correct + $responses['Q07.3'] = new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::POINT, new QtiPoint(13, 37)))); // SCORE = 0 - Incorrect $test = array($responses, $outcomes); $returnValue[] = $test; // Test 2 (full correct). - $outcomes = array('NCORRECTS01' => new Integer(3), 'NCORRECTS02' => new Integer(3), 'NCORRECTS03' => new Integer(3), 'NINCORRECT' => new Integer(0), 'NRESPONSED' => new Integer(9), 'NPRESENTED' => new Integer(9), 'NSELECTED' => new Integer(9), 'PERCENT_CORRECT' => new Float(100.00)); + $outcomes = array('NCORRECTS01' => new QtiInteger(3), 'NCORRECTS02' => new QtiInteger(3), 'NCORRECTS03' => new QtiInteger(3), 'NINCORRECT' => new QtiInteger(0), 'NRESPONSED' => new QtiInteger(9), 'NPRESENTED' => new QtiInteger(9), 'NSELECTED' => new QtiInteger(9), 'PERCENT_CORRECT' => new QtiFloat(100.00)); $responses = array(); - $responses['Q01'] = new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('ChoiceA')))); // SCORE = 1 - Correct - $responses['Q02'] = new State(array(new ResponseVariable('RESPONSE', Cardinality::MULTIPLE, BaseType::PAIR, new MultipleContainer(BaseType::PAIR, array(new Pair('A', 'P'), new Pair('C', 'M'), new Pair('D', 'L')))))); // SCORE = 4 - Correct - $responses['Q03'] = new State(array(new ResponseVariable('RESPONSE', Cardinality::MULTIPLE, BaseType::IDENTIFIER, new MultipleContainer(BaseType::IDENTIFIER, array(new Identifier('H'), new Identifier('O')))))); // SCORE = 2 - Correct - $responses['Q04'] = new State(array(new ResponseVariable('RESPONSE', Cardinality::MULTIPLE, BaseType::DIRECTED_PAIR, new MultipleContainer(BaseType::DIRECTED_PAIR, array(new DirectedPair('W', 'G1'), new DirectedPair('Su', 'G2')))))); // SCORE = 3 - Correct - $responses['Q05'] = new State(array(new ResponseVariable('RESPONSE', Cardinality::MULTIPLE, BaseType::PAIR, new MultipleContainer(BaseType::PAIR, array(new Pair('C', 'B'), new Pair('C', 'D')))))); // SCORE = 2 - Correct - $responses['Q06'] = new State(array(new ResponseVariable('answer', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('A')))); // SCORE = 1 - Correct - $responses['Q07.1'] = new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::POINT, new Point(102, 113)))); // SCORE = 1 - Correct - $responses['Q07.2'] = new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::POINT, new Point(102, 113)))); // SCORE = 1 - Correct - $responses['Q07.3'] = new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::POINT, new Point(102, 113)))); // SCORE = 0 - Correct + $responses['Q01'] = new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('ChoiceA')))); // SCORE = 1 - Correct + $responses['Q02'] = new State(array(new ResponseVariable('RESPONSE', Cardinality::MULTIPLE, BaseType::PAIR, new MultipleContainer(BaseType::PAIR, array(new QtiPair('A', 'P'), new QtiPair('C', 'M'), new QtiPair('D', 'L')))))); // SCORE = 4 - Correct + $responses['Q03'] = new State(array(new ResponseVariable('RESPONSE', Cardinality::MULTIPLE, BaseType::IDENTIFIER, new MultipleContainer(BaseType::IDENTIFIER, array(new QtiIdentifier('H'), new QtiIdentifier('O')))))); // SCORE = 2 - Correct + $responses['Q04'] = new State(array(new ResponseVariable('RESPONSE', Cardinality::MULTIPLE, BaseType::DIRECTED_PAIR, new MultipleContainer(BaseType::DIRECTED_PAIR, array(new QtiDirectedPair('W', 'G1'), new QtiDirectedPair('Su', 'G2')))))); // SCORE = 3 - Correct + $responses['Q05'] = new State(array(new ResponseVariable('RESPONSE', Cardinality::MULTIPLE, BaseType::PAIR, new MultipleContainer(BaseType::PAIR, array(new QtiPair('C', 'B'), new QtiPair('C', 'D')))))); // SCORE = 2 - Correct + $responses['Q06'] = new State(array(new ResponseVariable('answer', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('A')))); // SCORE = 1 - Correct + $responses['Q07.1'] = new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::POINT, new QtiPoint(102, 113)))); // SCORE = 1 - Correct + $responses['Q07.2'] = new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::POINT, new QtiPoint(102, 113)))); // SCORE = 1 - Correct + $responses['Q07.3'] = new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::POINT, new QtiPoint(102, 113)))); // SCORE = 0 - Correct $test = array($responses, $outcomes); $returnValue[] = $test; @@ -483,7 +483,7 @@ public function testWichLastOccurenceUpdate() { $this->assertFalse($assessmentTestSession->whichLastOccurenceUpdate($doc->getDocumentComponent()->getComponentByIdentifier('Q01'))); - $responses = new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('ChoiceA')))); + $responses = new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('ChoiceA')))); $assessmentTestSession->beginAttempt(); $assessmentTestSession->endAttempt($responses); $assessmentTestSession->moveNext(); @@ -648,7 +648,7 @@ public function testJumps() { $this->assertEquals('Q03', $session->getCurrentAssessmentItemRef()->getIdentifier()); $session->beginAttempt(); - $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::MULTIPLE, BaseType::IDENTIFIER, new MultipleContainer(BaseType::IDENTIFIER, array(new Identifier('H'), new Identifier('O'))))))); + $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::MULTIPLE, BaseType::IDENTIFIER, new MultipleContainer(BaseType::IDENTIFIER, array(new QtiIdentifier('H'), new QtiIdentifier('O'))))))); $this->assertEquals(AssessmentItemSessionState::CLOSED, $session->getCurrentAssessmentItemSession()->getState()); $session->moveNext(); @@ -657,14 +657,14 @@ public function testJumps() { // Come back at Q01. $session->jumpTo(0); $this->assertEquals('Q01', $session->getCurrentAssessmentItemRef()->getIdentifier()); - $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('ChoiceA'))))); + $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('ChoiceA'))))); $session->moveNext(); $this->assertEquals(1.0, $session['Q01.scoring']->getValue()); // Wwe are at Q02. $this->assertEquals('Q02', $session->getCurrentAssessmentItemRef()->getIdentifier()); $session->beginAttempt(); - $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::MULTIPLE, BaseType::PAIR, new MultipleContainer(BaseType::PAIR, array(new Pair('A', 'P'))))))); + $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::MULTIPLE, BaseType::PAIR, new MultipleContainer(BaseType::PAIR, array(new QtiPair('A', 'P'))))))); $session->moveNext(); $this->assertEquals(2.0, $session['Q02.SCORE']->getValue()); @@ -685,7 +685,7 @@ public function testJumps() { $this->assertEquals('Q07', $session->getCurrentAssessmentItemRef()->getIdentifier()); $this->assertEquals(1, $session->getCurrentAssessmentItemRefOccurence()); $session->beginAttempt(); - $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::POINT, new Point(102, 102))))); + $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::POINT, new QtiPoint(102, 102))))); $session->moveNext(); $this->assertEquals(1.0, $session['Q07.2.SCORE']->getValue()); @@ -697,15 +697,15 @@ public function testJumps() { $session->moveNext(); // End of test, everything ok? - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $session['Q01.scoring']); - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $session['Q02.SCORE']); - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $session['Q03.SCORE']); - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $session['Q04.SCORE']); // Because auto forward = true, Q04 was selected as eligible after Q03's endAttempt. However, it was never attempted. + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $session['Q01.scoring']); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $session['Q02.SCORE']); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $session['Q03.SCORE']); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $session['Q04.SCORE']); // Because auto forward = true, Q04 was selected as eligible after Q03's endAttempt. However, it was never attempted. $this->assertSame(0.0, $session['Q05.SCORE']->getValue()); $this->assertSame(0.0, $session['Q06.mySc0r3']->getValue()); $this->assertSame(0.0, $session['Q07.1.SCORE']->getValue()); - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $session['Q07.2.SCORE']); - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $session['Q07.3.SCORE']); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $session['Q07.2.SCORE']); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $session['Q07.3.SCORE']); $this->assertEquals(5, $session['NPRESENTED']->getValue()); $this->assertEquals(9, $session['NSELECTED']->getValue()); @@ -727,20 +727,20 @@ public function testJumpsSimultaneous() { $session->jumpTo(2); $this->assertEquals('Q03', $session->getCurrentAssessmentItemRef()->getIdentifier()); $session->beginAttempt(); - $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::MULTIPLE, BaseType::IDENTIFIER, new MultipleContainer(BaseType::IDENTIFIER, array(new Identifier('H'), new Identifier('O'))))))); + $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::MULTIPLE, BaseType::IDENTIFIER, new MultipleContainer(BaseType::IDENTIFIER, array(new QtiIdentifier('H'), new QtiIdentifier('O'))))))); $this->assertEquals(AssessmentItemSessionState::SUSPENDED, $session->getCurrentAssessmentItemSession()->getState()); $session->moveNext(); // Come back at Q01. $session->jumpTo(0); $this->assertEquals('Q01', $session->getCurrentAssessmentItemRef()->getIdentifier()); - $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('ChoiceA'))))); + $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('ChoiceA'))))); $session->moveNext(); // We are at Q02. $this->assertEquals('Q02', $session->getCurrentAssessmentItemRef()->getIdentifier()); $session->beginAttempt(); - $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::MULTIPLE, BaseType::PAIR, new MultipleContainer(BaseType::PAIR, array(new Pair('A', 'P'))))))); + $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::MULTIPLE, BaseType::PAIR, new MultipleContainer(BaseType::PAIR, array(new QtiPair('A', 'P'))))))); $session->moveNext(); // We are at Q03. @@ -875,7 +875,7 @@ public function testMoveNextAndBackNonLinearIndividual() { $session->moveNext(); // OutcomeProcessing? - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $session['PERCENT_CORRECT']); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $session['PERCENT_CORRECT']); $this->assertEquals(0.0, $session['PERCENT_CORRECT']->getValue()); $this->assertEquals(9, $session['NSELECTED']->getValue()); } @@ -893,17 +893,17 @@ public function testMoveNextAndBackNonLinearSimultaneous() { // Q01. $session->beginAttempt(); - $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('ChoiceA'))))); + $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('ChoiceA'))))); $session->moveNext(); // Q02. $session->beginAttempt(); - $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::MULTIPLE, BaseType::PAIR, new MultipleContainer(BaseType::PAIR, array(new Pair('A', 'P'))))))); + $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::MULTIPLE, BaseType::PAIR, new MultipleContainer(BaseType::PAIR, array(new QtiPair('A', 'P'))))))); $session->moveNext(); // Q03. $session->beginAttempt(); - $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::MULTIPLE, BaseType::IDENTIFIER, new MultipleContainer(BaseType::IDENTIFIER, array(new Identifier('O'))))))); + $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::MULTIPLE, BaseType::IDENTIFIER, new MultipleContainer(BaseType::IDENTIFIER, array(new QtiIdentifier('O'))))))); $session->moveNext(); // Q04. @@ -943,7 +943,7 @@ public function testUnlimitedAttempts() { $session->beginAttempt(); $this->assertEquals(-1, $session->getCurrentRemainingAttempts()); - $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('ChoiceB'))))); + $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('ChoiceB'))))); $this->assertEquals(-1, $session->getCurrentRemainingAttempts()); $session->moveNext(); @@ -975,7 +975,7 @@ public function testSuspendInteractItemSession() { $this->assertEquals(AssessmentItemSessionState::INTERACTING, $session->getCurrentAssessmentItemSession()->getState()); // Finally answer the question :) ! - $responses = new State(array(new ResponseVariable('RESPONSE', BaseType::IDENTIFIER, Cardinality::SINGLE, new Identifier('ChoiceA')))); + $responses = new State(array(new ResponseVariable('RESPONSE', BaseType::IDENTIFIER, Cardinality::SINGLE, new QtiIdentifier('ChoiceA')))); $session->endAttempt($responses); $session->moveNext(); $this->assertEquals(1.0, $session['Q01.scoring']->getValue()); @@ -1388,7 +1388,7 @@ public function testItemModalFeedbacks() { // -- Q01. $session->beginAttempt(); - $responses = new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('true')))); + $responses = new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('true')))); $session->endAttempt($responses); $this->assertEquals(AssessmentItemSessionState::MODAL_FEEDBACK, $session->getCurrentAssessmentItemSession()->getState()); @@ -1404,13 +1404,13 @@ public function testItemModalFeedbacks() { // Here, the maxAttempts is 0 i.e. no limit. Moreover, feedback is shown only if the answer // is wrong. $session->beginAttempt(); - $responses = new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('false')))); + $responses = new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('false')))); $session->endAttempt($responses); $this->assertEquals(AssessmentItemSessionState::MODAL_FEEDBACK, $session->getCurrentAssessmentItemSession()->getState()); // Brutal new attempt! $session->beginAttempt(); - $responses = new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('true')))); + $responses = new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('true')))); $session->endAttempt($responses); $this->assertEquals(AssessmentItemSessionState::SUSPENDED, $session->getCurrentAssessmentItemSession()->getState()); @@ -1437,35 +1437,35 @@ public function testIsTimeout() { // Q01. $session->beginAttempt(); $this->assertSame(0, $session->isTimeout()); - $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('ChoiceA'))))); + $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('ChoiceA'))))); $this->assertSame(0, $session->isTimeout()); $session->moveNext(); // Q02. $session->beginAttempt(); $this->assertSame(0, $session->isTimeout()); - $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('ChoiceB'))))); + $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('ChoiceB'))))); $this->assertSame(0, $session->isTimeout()); $session->moveNext(); // Q03. $session->beginAttempt(); $this->assertSame(0, $session->isTimeout()); - $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('ChoiceC'))))); + $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('ChoiceC'))))); $this->assertSame(0, $session->isTimeout()); $session->moveNext(); // Q04. $session->beginAttempt(); $this->assertSame(0, $session->isTimeout()); - $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('ChoiceD'))))); + $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('ChoiceD'))))); $this->assertSame(0, $session->isTimeout()); $session->moveNext(); // Q05. $session->beginAttempt(); $this->assertSame(0, $session->isTimeout()); - $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('ChoiceE'))))); + $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('ChoiceE'))))); $this->assertSame(0, $session->isTimeout()); $session->moveNext(); diff --git a/test/qtismtest/runtime/tests/AssessmentTestSessionTimingTest.php b/test/qtismtest/runtime/tests/AssessmentTestSessionTimingTest.php index 4453c7920..19a7a0af3 100644 --- a/test/qtismtest/runtime/tests/AssessmentTestSessionTimingTest.php +++ b/test/qtismtest/runtime/tests/AssessmentTestSessionTimingTest.php @@ -5,18 +5,18 @@ use qtismtest\QtiSmAssessmentTestSessionTestCase; use qtism\runtime\tests\AssessmentItemSessionState; -use qtism\common\datatypes\Identifier; +use qtism\common\datatypes\QtiIdentifier; use qtism\data\storage\xml\XmlDocument; use qtism\runtime\tests\AssessmentTestPlace; use qtism\runtime\tests\AssessmentItemSessionException; -use qtism\common\datatypes\Point; +use qtism\common\datatypes\QtiPoint; use qtism\runtime\common\State; use qtism\runtime\tests\AssessmentTestSessionState; use qtism\runtime\tests\AssessmentTestSessionException; use qtism\runtime\common\MultipleContainer; use qtism\common\enums\BaseType; use qtism\common\enums\Cardinality; -use qtism\common\datatypes\Duration; +use qtism\common\datatypes\QtiDuration; use qtism\runtime\common\ResponseVariable; use qtism\runtime\tests\AssessmentTestSession; use qtism\runtime\tests\AssessmentTestSessionFactory; @@ -36,9 +36,9 @@ public function testTestPartAssessmentSectionsDurations() { // The candidate begins the test session at 13:00:00. $session->setTime(self::createDate('2014-07-14 13:00:00')); $session->beginTestSession(); - $this->assertTrue($session['P01.duration']->equals(new Duration('PT0S'))); - $this->assertTrue($session['S01.duration']->equals(new Duration('PT0S'))); - $this->assertTrue($session['itemsubset.duration']->equals(new Duration('PT0S'))); + $this->assertTrue($session['P01.duration']->equals(new QtiDuration('PT0S'))); + $this->assertTrue($session['S01.duration']->equals(new QtiDuration('PT0S'))); + $this->assertTrue($session['itemsubset.duration']->equals(new QtiDuration('PT0S'))); // Q01. // The candidate begins an attempt on Q01 at 13:00:02 @@ -47,10 +47,10 @@ public function testTestPartAssessmentSectionsDurations() { // The candidate spends 1 second on item Q01. $session->setTime(self::createDate('2014-07-14 13:00:03')); - $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('ChoiceA'))))); - $this->assertTrue($session['P01.duration']->equals(new Duration('PT3S'))); - $this->assertTrue($session['S01.duration']->equals(new Duration('PT3S'))); - $this->assertTrue($session['itemsubset.duration']->equals(new Duration('PT3S'))); + $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('ChoiceA'))))); + $this->assertTrue($session['P01.duration']->equals(new QtiDuration('PT3S'))); + $this->assertTrue($session['S01.duration']->equals(new QtiDuration('PT3S'))); + $this->assertTrue($session['itemsubset.duration']->equals(new QtiDuration('PT3S'))); $session->moveNext(); // Q02. @@ -61,9 +61,9 @@ public function testTestPartAssessmentSectionsDurations() { // The candidate spends 3 second on the item. $session->setTime(self::createDate('2014-07-14 13:00:07')); $session->skip(); - $this->assertTrue($session['P01.duration']->equals(new Duration('PT7S'))); - $this->assertTrue($session['S01.duration']->equals(new Duration('PT7S'))); - $this->assertTrue($session['itemsubset.duration']->equals(new Duration('PT7S'))); + $this->assertTrue($session['P01.duration']->equals(new QtiDuration('PT7S'))); + $this->assertTrue($session['S01.duration']->equals(new QtiDuration('PT7S'))); + $this->assertTrue($session['itemsubset.duration']->equals(new QtiDuration('PT7S'))); $session->moveNext(); // Try to get a duration that does not exist. @@ -72,11 +72,11 @@ public function testTestPartAssessmentSectionsDurations() { // Brutal end... $session->endTestSession(); $this->assertEquals(AssessmentTestSessionState::CLOSED, $session->getState()); - $this->assertTrue($session['P01.duration']->equals(new Duration('PT7S'))); - $this->assertTrue($session['S01.duration']->equals(new Duration('PT7S'))); - $this->assertTrue($session['itemsubset.duration']->equals(new Duration('PT7S'))); - $this->assertTrue($session['Q01.duration']->equals(new Duration('PT1S'))); - $this->assertTrue($session['Q02.duration']->equals(new Duration('PT3S'))); + $this->assertTrue($session['P01.duration']->equals(new QtiDuration('PT7S'))); + $this->assertTrue($session['S01.duration']->equals(new QtiDuration('PT7S'))); + $this->assertTrue($session['itemsubset.duration']->equals(new QtiDuration('PT7S'))); + $this->assertTrue($session['Q01.duration']->equals(new QtiDuration('PT1S'))); + $this->assertTrue($session['Q02.duration']->equals(new QtiDuration('PT3S'))); } public function testTestPartTimeLimitsLinear() { @@ -93,12 +93,12 @@ public function testTestPartTimeLimitsLinear() { // The candidate spends 2 seconds on the item (maxTime = 5). $session->setTime(self::createDate('2014-07-14 13:00:02')); - $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('ChoiceA'))))); + $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('ChoiceA'))))); $session->moveNext(); // Check if the maximum remaining time for the test part is indeed 3 seconds (2 seconds spent on Q01). $timeConstraints = $session->getTimeConstraints(AssessmentTestPlace::TEST_PART); - $this->assertTrue($timeConstraints[0]->getMaximumRemainingTime()->equals(new Duration('PT3S'))); + $this->assertTrue($timeConstraints[0]->getMaximumRemainingTime()->equals(new QtiDuration('PT3S'))); // Q02. // The candidate begins an attempt on Q02 at 13:00:02. @@ -112,7 +112,7 @@ public function testTestPartTimeLimitsLinear() { // Check if the maximum remaining time for the test part is indeed 1 second (2 seconds on Q01 + 2 seconds on Q02). $timeConstraints = $session->getTimeConstraints(AssessmentTestPlace::TEST_PART); - $this->assertTrue($timeConstraints[0]->getMaximumRemainingTime()->equals(new Duration('PT1S'))); + $this->assertTrue($timeConstraints[0]->getMaximumRemainingTime()->equals(new QtiDuration('PT1S'))); // Q03. @@ -124,7 +124,7 @@ public function testTestPartTimeLimitsLinear() { // The candidate spends 2 seconds on the item. // P01.duration = 6 > maxTime -> exception ! $session->setTime(self::createDate('2014-07-14 13:00:06')); - $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::MULTIPLE, BaseType::IDENTIFIER, new MultipleContainer(BaseType::IDENTIFIER, array(new Identifier('H'), new Identifier('O'))))))); + $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::MULTIPLE, BaseType::IDENTIFIER, new MultipleContainer(BaseType::IDENTIFIER, array(new QtiIdentifier('H'), new QtiIdentifier('O'))))))); $this->assertFalse(true); } catch (AssessmentTestSessionException $e) { @@ -139,7 +139,7 @@ public function testTestPartTimeLimitsLinear() { // Check if P02 time constraint is there (maxtime = 1). $timeConstraints = $session->getTimeConstraints(AssessmentTestPlace::TEST_PART); - $this->assertTrue($timeConstraints[0]->getMaximumRemainingTime()->equals(new Duration('PT1S'))); + $this->assertTrue($timeConstraints[0]->getMaximumRemainingTime()->equals(new QtiDuration('PT1S'))); // Q04.1 // The candidate begins an attempt on Q04 at 13:00:06. @@ -149,7 +149,7 @@ public function testTestPartTimeLimitsLinear() { try { // The candidate spends 2 seconds on Q04. $session->setTime(self::createDate('2014-07-14 13:00:08')); - $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::POINT, new Point(102, 113))))); + $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::POINT, new QtiPoint(102, 113))))); $this->assertTrue(false); } catch (AssessmentTestSessionException $e) { @@ -190,12 +190,12 @@ public function testForceLateSubmission($forceLateSubmission = true) { try { // The candidate ends the attempt on Q02 at 13:00:04. He spent 2 seconds (maxtime = 1) on the item. $session->setTime(self::createDate('2014-07-14 13:00:04')); - $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', BaseType::IDENTIFIER, Cardinality::SINGLE, new Identifier('ChoiceA')))), $forceLateSubmission); + $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', BaseType::IDENTIFIER, Cardinality::SINGLE, new QtiIdentifier('ChoiceA')))), $forceLateSubmission); $session->moveNext(); // If $forceLateSubmission = true, an exception is thrown and we go the catch block. $this->assertTrue($forceLateSubmission, '$forceLateSubmission is false but the attempt dit not raised an exception.'); - $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $session['Q01.SCORE']); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiFloat', $session['Q01.SCORE']); $this->assertEquals(1.0, $session['Q01.SCORE']->getValue()); $this->assertFalse($session->isRunning()); @@ -255,7 +255,7 @@ public function testTimeConstraints() { // The candidate ends an attempt on Q01 at 13:00:04 (time elapsed on item is 2 seconds). $session->setTime(self::createDate('2014-07-14 13:00:04', 'Europe/Luxembourg')); - $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('ChoiceA'))))); + $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('ChoiceA'))))); $timeConstraints = $session->getTimeConstraints(AssessmentTestPlace::ASSESSMENT_ITEM); $this->assertEquals(1, count($timeConstraints)); @@ -271,7 +271,7 @@ public function testTimeConstraints() { // The candidate ends an attempt on Q02 at 13:00:08. $session->setTime(self::createDate('2014-07-14 13:00:08', 'Europe/Luxembourg')); - $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('ChoiceB'))))); + $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('ChoiceB'))))); $timeConstraints = $session->getTimeConstraints(); $this->assertFalse($timeConstraints[3]->getMinimumRemainingTime()); $this->assertEquals('PT0S', $timeConstraints[3]->getMaximumRemainingTime()->__toString()); @@ -299,7 +299,7 @@ public function testTimeConstraintsTwo() { $session->beginAttempt(); $session->setTime(self::createDate('2014-07-14 13:00:00')); - $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('ChoiceB'))))); + $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('ChoiceB'))))); $this->fail("An exception should be thrown because minTime must be considered now on Q01."); } catch (AssessmentTestSessionException $e) { @@ -334,7 +334,7 @@ public function testDurationBetweenItems() { $this->assertEquals(1, $session['duration']->getSeconds(true)); $session->setTime(self::createDate('2014-07-14 13:00:02')); - $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('ChoiceA'))))); + $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('ChoiceA'))))); // We are now between Q01 and Q02, the duration of items must not increase // but the test related timing increase. @@ -353,7 +353,7 @@ public function testDurationBetweenItems() { // The candidate thinks for 4 seconds and ends the attempt. $session->setTime(self::createDate('2014-07-14 13:00:16')); - $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('ChoiceA'))))); + $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('ChoiceA'))))); $this->assertEquals(1, $session['Q01.duration']->getSeconds(true)); $this->assertEquals(4, $session['Q02.duration']->getSeconds(true)); @@ -437,7 +437,7 @@ public function testIsTimeout1() { // Spend 25 seconds... $session->setTime(self::createDate('2015-02-02 11:54:25')); - $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('ChoiceA'))))); + $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('ChoiceA'))))); $this->assertSame(0, $session->isTimeout()); // -- Q01 (2nd attempt) @@ -449,37 +449,37 @@ public function testIsTimeout1() { $this->assertSame(AssessmentTestPlace::ASSESSMENT_ITEM, $session->isTimeout()); // Check max time reached for item... (item maxTime = 30S) - $this->assertTrue($session['Q01.duration']->equals(new Duration('PT30S'))); + $this->assertTrue($session['Q01.duration']->equals(new QtiDuration('PT30S'))); // Check current time for the overall session... - $this->assertTrue($session['S01.duration']->equals(new Duration('PT35S'))); - $this->assertTrue($session['P01.duration']->equals(new Duration('PT35S'))); - $this->assertTrue($session['istimeout.duration']->equals(new Duration('PT35S'))); + $this->assertTrue($session['S01.duration']->equals(new QtiDuration('PT35S'))); + $this->assertTrue($session['P01.duration']->equals(new QtiDuration('PT35S'))); + $this->assertTrue($session['istimeout.duration']->equals(new QtiDuration('PT35S'))); // Spend 20 seconds here... $session->setTime(self::createDate('2015-02-02 11:54:55')); $this->assertSame(AssessmentTestPlace::ASSESSMENT_SECTION, $session->isTimeout()); // Check current time for the overall session... (session maxTime = 45S) - $this->assertTrue($session['Q01.duration']->equals(new Duration('PT30S'))); - $this->assertTrue($session['S01.duration']->equals(new Duration('PT45S'))); - $this->assertTrue($session['P01.duration']->equals(new Duration('PT55S'))); - $this->assertTrue($session['istimeout.duration']->equals(new Duration('PT55S'))); + $this->assertTrue($session['Q01.duration']->equals(new QtiDuration('PT30S'))); + $this->assertTrue($session['S01.duration']->equals(new QtiDuration('PT45S'))); + $this->assertTrue($session['P01.duration']->equals(new QtiDuration('PT55S'))); + $this->assertTrue($session['istimeout.duration']->equals(new QtiDuration('PT55S'))); // Spend 10 more seconds here to outreach P01's maxTime. $session->setTime(self::createDate('2015-02-02 11:55:05')); $this->assertSame(AssessmentTestPlace::TEST_PART, $session->isTimeout()); - $this->assertTrue($session['P01.duration']->equals(new Duration('PT1M'))); - $this->assertTrue($session['istimeout.duration']->equals(new Duration('PT1M5S'))); + $this->assertTrue($session['P01.duration']->equals(new QtiDuration('PT1M'))); + $this->assertTrue($session['istimeout.duration']->equals(new QtiDuration('PT1M5S'))); // Spend 30 more seconds here to outreach istimeout's maxTime. The test session must close. $session->setTime(self::createDate('2015-02-02 11:55:35')); $this->assertSame(AssessmentTestSessionState::CLOSED, $session->getState()); - $this->assertTrue($session['Q01.duration']->equals(new Duration('PT30S'))); - $this->assertTrue($session['S01.duration']->equals(new Duration('PT45S'))); - $this->assertTrue($session['P01.duration']->equals(new Duration('PT1M'))); - $this->assertTrue($session['istimeout.duration']->equals(new Duration('PT1M30S'))); + $this->assertTrue($session['Q01.duration']->equals(new QtiDuration('PT30S'))); + $this->assertTrue($session['S01.duration']->equals(new QtiDuration('PT45S'))); + $this->assertTrue($session['P01.duration']->equals(new QtiDuration('PT1M'))); + $this->assertTrue($session['istimeout.duration']->equals(new QtiDuration('PT1M30S'))); } public function testItemSessionsAreClosed1() { @@ -505,7 +505,7 @@ public function testItemSessionsAreClosed1() { $session->beginAttempt(); // Spend 8 seconds ... $session->setTime(self::createDate('2015-02-02 14:25:18')); - $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('ChoiceA'))))); + $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('ChoiceA'))))); $session->moveNext(); // -- Q02 attempt. @@ -523,13 +523,13 @@ public function testItemSessionsAreClosed1() { $session->moveNext(); // Let's check durations... - $this->assertTrue($session['istimeout.duration']->equals(new Duration('PT33S'))); - $this->assertTrue($session['P01.duration']->equals(new Duration('PT33S'))); - $this->assertTrue($session['S01.duration']->equals(new Duration('PT33S'))); - $this->assertTrue($session['S01A.duration']->equals(new Duration('PT30S'))); - $this->assertTrue($session['S01B.duration']->equals(new Duration('PT0S'))); - $this->assertTrue($session['Q01.duration']->equals(new Duration('PT8S'))); - $this->assertTrue($session['Q02.duration']->equals(new Duration('PT10S'))); + $this->assertTrue($session['istimeout.duration']->equals(new QtiDuration('PT33S'))); + $this->assertTrue($session['P01.duration']->equals(new QtiDuration('PT33S'))); + $this->assertTrue($session['S01.duration']->equals(new QtiDuration('PT33S'))); + $this->assertTrue($session['S01A.duration']->equals(new QtiDuration('PT30S'))); + $this->assertTrue($session['S01B.duration']->equals(new QtiDuration('PT0S'))); + $this->assertTrue($session['Q01.duration']->equals(new QtiDuration('PT8S'))); + $this->assertTrue($session['Q02.duration']->equals(new QtiDuration('PT10S'))); // -- Let's dive into S01B and make it timeout. $q03Sessions = $session->getAssessmentItemSessions('Q03'); @@ -545,15 +545,15 @@ public function testItemSessionsAreClosed1() { $this->assertEquals(AssessmentItemSessionState::CLOSED, $q04Sessions[0]->getState()); // Let's check durations... - $this->assertTrue($session['istimeout.duration']->equals(new Duration('PT1M2S'))); - $this->assertTrue($session['P01.duration']->equals(new Duration('PT1M2S'))); - $this->assertTrue($session['S01.duration']->equals(new Duration('PT1M'))); - $this->assertTrue($session['S01A.duration']->equals(new Duration('PT30S'))); - $this->assertTrue($session['S01B.duration']->equals(new Duration('PT29S'))); - $this->assertTrue($session['Q01.duration']->equals(new Duration('PT8S'))); - $this->assertTrue($session['Q02.duration']->equals(new Duration('PT10S'))); - $this->assertTrue($session['Q03.duration']->equals(new Duration('PT0S'))); - $this->assertTrue($session['Q04.duration']->equals(new Duration('PT0S'))); + $this->assertTrue($session['istimeout.duration']->equals(new QtiDuration('PT1M2S'))); + $this->assertTrue($session['P01.duration']->equals(new QtiDuration('PT1M2S'))); + $this->assertTrue($session['S01.duration']->equals(new QtiDuration('PT1M'))); + $this->assertTrue($session['S01A.duration']->equals(new QtiDuration('PT30S'))); + $this->assertTrue($session['S01B.duration']->equals(new QtiDuration('PT29S'))); + $this->assertTrue($session['Q01.duration']->equals(new QtiDuration('PT8S'))); + $this->assertTrue($session['Q02.duration']->equals(new QtiDuration('PT10S'))); + $this->assertTrue($session['Q03.duration']->equals(new QtiDuration('PT0S'))); + $this->assertTrue($session['Q04.duration']->equals(new QtiDuration('PT0S'))); // Even if all item sessions are closed, we consider the test is still running // We can imagine a test taker navigating through the item flow searching @@ -565,15 +565,15 @@ public function testItemSessionsAreClosed1() { $session->setTime(self::createDate('2015-02-02 14:26:32')); // Let's check durations... - $this->assertTrue($session['istimeout.duration']->equals(new Duration('PT1M32S'))); - $this->assertTrue($session['P01.duration']->equals(new Duration('PT1M30S'))); - $this->assertTrue($session['S01.duration']->equals(new Duration('PT1M'))); - $this->assertTrue($session['S01A.duration']->equals(new Duration('PT30S'))); - $this->assertTrue($session['S01B.duration']->equals(new Duration('PT30S'))); - $this->assertTrue($session['Q01.duration']->equals(new Duration('PT8S'))); - $this->assertTrue($session['Q02.duration']->equals(new Duration('PT10S'))); - $this->assertTrue($session['Q03.duration']->equals(new Duration('PT0S'))); - $this->assertTrue($session['Q04.duration']->equals(new Duration('PT0S'))); + $this->assertTrue($session['istimeout.duration']->equals(new QtiDuration('PT1M32S'))); + $this->assertTrue($session['P01.duration']->equals(new QtiDuration('PT1M30S'))); + $this->assertTrue($session['S01.duration']->equals(new QtiDuration('PT1M'))); + $this->assertTrue($session['S01A.duration']->equals(new QtiDuration('PT30S'))); + $this->assertTrue($session['S01B.duration']->equals(new QtiDuration('PT30S'))); + $this->assertTrue($session['Q01.duration']->equals(new QtiDuration('PT8S'))); + $this->assertTrue($session['Q02.duration']->equals(new QtiDuration('PT10S'))); + $this->assertTrue($session['Q03.duration']->equals(new QtiDuration('PT0S'))); + $this->assertTrue($session['Q04.duration']->equals(new QtiDuration('PT0S'))); // Let's spend another 28 seconds to reach the end of the test's maxTime. $session->setTime(self::createDate('2015-02-02 14:27:00')); @@ -581,15 +581,15 @@ public function testItemSessionsAreClosed1() { $this->assertEquals(AssessmentTestSessionState::CLOSED, $session->getState()); // Let's check durations... - $this->assertTrue($session['istimeout.duration']->equals(new Duration('PT2M'))); - $this->assertTrue($session['P01.duration']->equals(new Duration('PT1M30S'))); - $this->assertTrue($session['S01.duration']->equals(new Duration('PT1M'))); - $this->assertTrue($session['S01A.duration']->equals(new Duration('PT30S'))); - $this->assertTrue($session['S01B.duration']->equals(new Duration('PT30S'))); - $this->assertTrue($session['Q01.duration']->equals(new Duration('PT8S'))); - $this->assertTrue($session['Q02.duration']->equals(new Duration('PT10S'))); - $this->assertTrue($session['Q03.duration']->equals(new Duration('PT0S'))); - $this->assertTrue($session['Q04.duration']->equals(new Duration('PT0S'))); + $this->assertTrue($session['istimeout.duration']->equals(new QtiDuration('PT2M'))); + $this->assertTrue($session['P01.duration']->equals(new QtiDuration('PT1M30S'))); + $this->assertTrue($session['S01.duration']->equals(new QtiDuration('PT1M'))); + $this->assertTrue($session['S01A.duration']->equals(new QtiDuration('PT30S'))); + $this->assertTrue($session['S01B.duration']->equals(new QtiDuration('PT30S'))); + $this->assertTrue($session['Q01.duration']->equals(new QtiDuration('PT8S'))); + $this->assertTrue($session['Q02.duration']->equals(new QtiDuration('PT10S'))); + $this->assertTrue($session['Q03.duration']->equals(new QtiDuration('PT0S'))); + $this->assertTrue($session['Q04.duration']->equals(new QtiDuration('PT0S'))); // All sessions still closed? foreach ($session->getAssessmentItemSessionStore()->getAllAssessmentItemSessions() as $itemSession) { diff --git a/test/qtismtest/runtime/tests/DurationStoreTest.php b/test/qtismtest/runtime/tests/DurationStoreTest.php index 8eafd5779..8712fffb0 100644 --- a/test/qtismtest/runtime/tests/DurationStoreTest.php +++ b/test/qtismtest/runtime/tests/DurationStoreTest.php @@ -4,35 +4,35 @@ use qtismtest\QtiSmTestCase; use qtism\runtime\common\ResponseVariable; use qtism\runtime\common\MultipleContainer; -use qtism\common\datatypes\Identifier; +use qtism\common\datatypes\QtiIdentifier; use qtism\common\enums\BaseType; use qtism\common\enums\Cardinality; use qtism\runtime\common\OutcomeVariable; -use qtism\common\datatypes\Duration; +use qtism\common\datatypes\QtiDuration; use qtism\runtime\tests\DurationStore; class DurationStoreTest extends QtiSmTestCase { public function testInstantiation() { $data = array(); - $data[] = new OutcomeVariable('duration1', Cardinality::SINGLE, BaseType::DURATION, new Duration('PT0S')); - $data[] = new OutcomeVariable('duration2', Cardinality::SINGLE, BaseType::DURATION, new Duration('PT1S')); - $data[] = new OutcomeVariable('duration3', Cardinality::SINGLE, BaseType::DURATION, new Duration('PT2S')); + $data[] = new OutcomeVariable('duration1', Cardinality::SINGLE, BaseType::DURATION, new QtiDuration('PT0S')); + $data[] = new OutcomeVariable('duration2', Cardinality::SINGLE, BaseType::DURATION, new QtiDuration('PT1S')); + $data[] = new OutcomeVariable('duration3', Cardinality::SINGLE, BaseType::DURATION, new QtiDuration('PT2S')); $durations = new DurationStore($data); $this->assertInstanceOf('qtism\\runtime\\tests\\DurationStore', $durations); - $this->assertTrue($durations['duration1']->equals(new Duration('PT0S'))); - $this->assertTrue($durations['duration2']->equals(new Duration('PT1S'))); - $this->assertTrue($durations['duration3']->equals(new Duration('PT2S'))); + $this->assertTrue($durations['duration1']->equals(new QtiDuration('PT0S'))); + $this->assertTrue($durations['duration2']->equals(new QtiDuration('PT1S'))); + $this->assertTrue($durations['duration3']->equals(new QtiDuration('PT2S'))); $this->assertTrue(isset($durations['duration1'])); } public function testInstantiationWrongBaseType() { $data = array(); - $data[] = new OutcomeVariable('duration1', Cardinality::SINGLE, BaseType::DURATION, new Duration('PT0S')); - $data[] = new OutcomeVariable('duration2', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('identifier')); - $data[] = new OutcomeVariable('duration3', Cardinality::SINGLE, BaseType::DURATION, new Duration('PT2S')); + $data[] = new OutcomeVariable('duration1', Cardinality::SINGLE, BaseType::DURATION, new QtiDuration('PT0S')); + $data[] = new OutcomeVariable('duration2', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('identifier')); + $data[] = new OutcomeVariable('duration3', Cardinality::SINGLE, BaseType::DURATION, new QtiDuration('PT2S')); $this->setExpectedException('\\InvalidArgumentException', "The DurationStore only aims at storing OutcomeVariable objects with a 'duration' baseType, 'identifier' baseType given for variable 'duration2'."); $durations = new DurationStore($data); @@ -40,9 +40,9 @@ public function testInstantiationWrongBaseType() { public function testInstantiationWrongCardinality() { $data = array(); - $data[] = new OutcomeVariable('duration1', Cardinality::SINGLE, BaseType::DURATION, new Duration('PT0S')); - $data[] = new OutcomeVariable('duration2', Cardinality::SINGLE, BaseType::DURATION, new Duration('PT1S')); - $data[] = new OutcomeVariable('duration3', Cardinality::MULTIPLE, BaseType::DURATION, new MultipleContainer(BaseType::DURATION, array(new Duration('PT2S')))); + $data[] = new OutcomeVariable('duration1', Cardinality::SINGLE, BaseType::DURATION, new QtiDuration('PT0S')); + $data[] = new OutcomeVariable('duration2', Cardinality::SINGLE, BaseType::DURATION, new QtiDuration('PT1S')); + $data[] = new OutcomeVariable('duration3', Cardinality::MULTIPLE, BaseType::DURATION, new MultipleContainer(BaseType::DURATION, array(new QtiDuration('PT2S')))); $this->setExpectedException('\\InvalidArgumentException', "The DurationStore only aims at storing OutcomeVariable objects with a 'single' cardinality, 'multiple' cardinality given for variable 'duration3'."); $durations = new DurationStore($data); @@ -50,9 +50,9 @@ public function testInstantiationWrongCardinality() { public function testWrongVariableTypeInstantiation() { $data = array(); - $data[] = new OutcomeVariable('duration1', Cardinality::SINGLE, BaseType::DURATION, new Duration('PT0S')); - $data[] = new ResponseVariable('duration2', Cardinality::SINGLE, BaseType::DURATION, new Duration('PT1S')); - $data[] = new OutcomeVariable('duration3', Cardinality::SINGLE, BaseType::DURATION, new Duration('PT2S')); + $data[] = new OutcomeVariable('duration1', Cardinality::SINGLE, BaseType::DURATION, new QtiDuration('PT0S')); + $data[] = new ResponseVariable('duration2', Cardinality::SINGLE, BaseType::DURATION, new QtiDuration('PT1S')); + $data[] = new OutcomeVariable('duration3', Cardinality::SINGLE, BaseType::DURATION, new QtiDuration('PT2S')); $this->setExpectedException('\\InvalidArgumentException', 'The DurationStore only aims at storing OutcomeVariable objects, qtism\runtime\common\ResponseVariable object given.'); $durations = new DurationStore($data); @@ -60,28 +60,28 @@ public function testWrongVariableTypeInstantiation() { public function testSetVariable() { $durations = new DurationStore(); - $durations->setVariable(new OutcomeVariable('duration1', Cardinality::SINGLE, BaseType::DURATION, new Duration('PT0S'))); + $durations->setVariable(new OutcomeVariable('duration1', Cardinality::SINGLE, BaseType::DURATION, new QtiDuration('PT0S'))); $this->assertInstanceOf('qtism\\runtime\\common\\OutcomeVariable', $durations->getVariable('duration1')); - $this->assertTrue($durations['duration1']->equals(new Duration('PT0S'))); + $this->assertTrue($durations['duration1']->equals(new QtiDuration('PT0S'))); } public function testSetVariableWrongBaseType() { $durations = new DurationStore(); $this->setExpectedException('\\InvalidArgumentException', "The DurationStore only aims at storing OutcomeVariable objects with a 'duration' baseType, 'identifier' baseType given for variable 'duration1'"); - $durations->setVariable(new OutcomeVariable('duration1', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('identifier'))); + $durations->setVariable(new OutcomeVariable('duration1', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('identifier'))); } public function testSetVariableWrongCardinality() { $durations = new DurationStore(); $this->setExpectedException('\\InvalidArgumentException', "The DurationStore only aims at storing OutcomeVariable objects with a 'single' cardinality, 'multiple' cardinality given for variable 'duration1'"); - $durations->setVariable(new OutcomeVariable('duration1', Cardinality::MULTIPLE, BaseType::DURATION, new MultipleContainer(BaseType::DURATION, array(new Duration('PT0S'))))); + $durations->setVariable(new OutcomeVariable('duration1', Cardinality::MULTIPLE, BaseType::DURATION, new MultipleContainer(BaseType::DURATION, array(new QtiDuration('PT0S'))))); } public function testSetVariableWrongVariableType() { $durations = new DurationStore(); $this->setExpectedException('\\InvalidArgumentException', 'The DurationStore only aims at storing OutcomeVariable objects, qtism\runtime\common\ResponseVariable object given.'); - $durations->setVariable(new ResponseVariable('duration1', Cardinality::SINGLE, BaseType::DURATION, new Duration('PT0S'))); + $durations->setVariable(new ResponseVariable('duration1', Cardinality::SINGLE, BaseType::DURATION, new QtiDuration('PT0S'))); } } \ No newline at end of file diff --git a/test/qtismtest/runtime/tests/PendingResponsesStoreTest.php b/test/qtismtest/runtime/tests/PendingResponsesStoreTest.php index 83200b0d4..ab2be8fdc 100644 --- a/test/qtismtest/runtime/tests/PendingResponsesStoreTest.php +++ b/test/qtismtest/runtime/tests/PendingResponsesStoreTest.php @@ -2,8 +2,8 @@ namespace qtismtest\runtime\tests; use qtismtest\QtiSmTestCase; -use qtism\common\datatypes\Integer; -use qtism\common\datatypes\Boolean; +use qtism\common\datatypes\QtiInteger; +use qtism\common\datatypes\QtiBoolean; use qtism\common\enums\BaseType; use qtism\common\enums\Cardinality; use qtism\runtime\common\State; @@ -20,9 +20,9 @@ public function testPendingResponseStore() { $itemRef2 = new AssessmentItemRef('Q02', './Q02.xml'); $itemRef3 = new AssessmentItemRef('Q03', './Q02.xml'); - $state1 = new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::BOOLEAN, new Boolean(true)))); - $state2 = new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::BOOLEAN, new Boolean(false)))); - $state3 = new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::INTEGER, new Integer(1337)))); + $state1 = new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::BOOLEAN, new QtiBoolean(true)))); + $state2 = new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::BOOLEAN, new QtiBoolean(false)))); + $state3 = new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::INTEGER, new QtiInteger(1337)))); $store = new PendingResponseStore(); $store->addPendingResponses(new PendingResponses($state1, $itemRef1)); diff --git a/test/qtismtest/runtime/tests/SessionManagerTest.php b/test/qtismtest/runtime/tests/SessionManagerTest.php index 42495558d..c0b0738a8 100644 --- a/test/qtismtest/runtime/tests/SessionManagerTest.php +++ b/test/qtismtest/runtime/tests/SessionManagerTest.php @@ -2,7 +2,7 @@ namespace qtismtest\runtime\tests; use qtismtest\QtiSmTestCase; -use qtism\common\datatypes\Duration; +use qtism\common\datatypes\QtiDuration; use qtism\data\storage\xml\XmlCompactDocument; use qtism\data\AssessmentTest; use qtism\runtime\tests\SessionManager; diff --git a/test/qtismtest/runtime/tests/TimeConstraintTest.php b/test/qtismtest/runtime/tests/TimeConstraintTest.php index 324c8e2c1..93bc0503d 100644 --- a/test/qtismtest/runtime/tests/TimeConstraintTest.php +++ b/test/qtismtest/runtime/tests/TimeConstraintTest.php @@ -4,7 +4,7 @@ use qtismtest\QtiSmTestCase; use qtism\data\NavigationMode; use qtism\data\TimeLimits; -use qtism\common\datatypes\Duration; +use qtism\common\datatypes\QtiDuration; use qtism\runtime\tests\TimeConstraint; use qtism\data\AssessmentItemRef; @@ -12,15 +12,15 @@ class TimeConstraintTest extends QtiSmTestCase { public function testInstantiation() { $assessmentItemRef = new AssessmentItemRef('Q01', 'Q01.xml'); - $timeConstraint = new TimeConstraint($assessmentItemRef, new Duration('PT20S')); + $timeConstraint = new TimeConstraint($assessmentItemRef, new QtiDuration('PT20S')); $this->assertInstanceOf('qtism\\data\\AssessmentItemRef', $timeConstraint->getSource()); - $this->assertInstanceOf('qtism\\common\\datatypes\\Duration', $timeConstraint->getDuration()); + $this->assertInstanceOf('qtism\\common\\datatypes\\QtiDuration', $timeConstraint->getDuration()); } public function testNoConstraints() { $assessmentItemRef = new AssessmentItemRef('Q01', 'Q01.xml'); - $timeConstraint = new TimeConstraint($assessmentItemRef, new Duration('PT20S')); + $timeConstraint = new TimeConstraint($assessmentItemRef, new QtiDuration('PT20S')); // No timelimits in force. $this->assertFalse($timeConstraint->getMaximumRemainingTime()); @@ -31,9 +31,9 @@ public function testNoConstraints() { public function testNegativeTime() { $assessmentItemRef = new AssessmentItemRef('Q01', 'Q01.xml'); - $timeLimits = new TimeLimits(null, new Duration('PT10S')); + $timeLimits = new TimeLimits(null, new QtiDuration('PT10S')); $assessmentItemRef->setTimeLimits($timeLimits); - $timeConstraint = new TimeConstraint($assessmentItemRef, new Duration('PT20S')); + $timeConstraint = new TimeConstraint($assessmentItemRef, new QtiDuration('PT20S')); $maxRemaining = $timeConstraint->getMaximumRemainingTime(); $this->assertEquals('PT0S', $maxRemaining->__toString()); @@ -44,9 +44,9 @@ public function testNegativeTime() { public function testDoesAllowLateSubmission() { $assessmentItemRef = new AssessmentItemRef('Q01', 'Q01.xml'); - $timeLimits = new TimeLimits(null, new Duration('PT10S'), true); + $timeLimits = new TimeLimits(null, new QtiDuration('PT10S'), true); $assessmentItemRef->setTimeLimits($timeLimits); - $timeConstraint = new TimeConstraint($assessmentItemRef, new Duration('PT5S')); + $timeConstraint = new TimeConstraint($assessmentItemRef, new QtiDuration('PT5S')); $this->assertTrue($timeConstraint->allowLateSubmission()); $timeLimits->setAllowLateSubmission(false); @@ -61,7 +61,7 @@ public function testDoesAllowLateSubmission() { public function testRemainingTime() { $assessmentItemRef = new AssessmentItemRef('Q01', 'Q01.xml'); - $timeConstraint = new TimeConstraint($assessmentItemRef, new Duration('PT20S')); + $timeConstraint = new TimeConstraint($assessmentItemRef, new QtiDuration('PT20S')); $this->assertFalse($timeConstraint->maxTimeInForce()); $this->assertFalse($timeConstraint->minTimeInForce()); // There's no max remaining time nor min remaining time. @@ -74,19 +74,19 @@ public function testRemainingTime() { $this->assertFalse($timeConstraint->getMaximumRemainingTime()); $this->assertFalse($timeConstraint->getMinimumRemainingTime()); - $timeLimits->setMinTime(new Duration('PT30S')); + $timeLimits->setMinTime(new QtiDuration('PT30S')); $this->assertEquals('PT10S', $timeConstraint->getMinimumRemainingTime()->__toString()); $this->assertFalse($timeConstraint->getMaximumRemainingTime()); - $timeLimits->setMaxTime(new Duration('PT50S')); + $timeLimits->setMaxTime(new QtiDuration('PT50S')); $this->assertEquals('PT30S', $timeConstraint->getMaximumRemainingTime()->__toString()); } public function testNonLinearNavigationMode() { $assessmentItemRef = new AssessmentItemRef('Q01', 'Q01.xml'); - $timeLimits = new TimeLimits(new Duration('PT1S'), new Duration('PT2S'), false); + $timeLimits = new TimeLimits(new QtiDuration('PT1S'), new QtiDuration('PT2S'), false); $assessmentItemRef->setTimeLimits($timeLimits); - $timeConstraint = new TimeConstraint($assessmentItemRef, new Duration('PT1S'), NavigationMode::NONLINEAR); + $timeConstraint = new TimeConstraint($assessmentItemRef, new QtiDuration('PT1S'), NavigationMode::NONLINEAR); // Minimum times are applicable to assessmentSections and assessmentItems only when linear navigation // mode is in effect. @@ -96,9 +96,9 @@ public function testNonLinearNavigationMode() { public function testLinearNavigationMode() { $assessmentItemRef = new AssessmentItemRef('Q01', 'Q01.xml'); - $timeLimits = new TimeLimits(new Duration('PT1S'), new Duration('PT2S'), false); + $timeLimits = new TimeLimits(new QtiDuration('PT1S'), new QtiDuration('PT2S'), false); $assessmentItemRef->setTimeLimits($timeLimits); - $timeConstraint = new TimeConstraint($assessmentItemRef, new Duration('PT1S'), NavigationMode::LINEAR); + $timeConstraint = new TimeConstraint($assessmentItemRef, new QtiDuration('PT1S'), NavigationMode::LINEAR); // Minimum times are applicable to assessmentSections and assessmentItems only when linear navigation // mode is in effect, this is the case! diff --git a/test/samples/custom/php/php_storage_simple.php b/test/samples/custom/php/php_storage_simple.php index 6dc1005a1..1bebaf3dd 100644 --- a/test/samples/custom/php/php_storage_simple.php +++ b/test/samples/custom/php/php_storage_simple.php @@ -171,15 +171,15 @@ $outcomedeclaration_1->setLookupTable($nullvalue_12); $array_23 = array($outcomedeclaration_1); $outcomedeclarationcollection_2 = new qtism\data\state\OutcomeDeclarationCollection($array_23); -$pair_0 = new qtism\common\datatypes\Pair("A", "P"); +$pair_0 = new qtism\common\datatypes\QtiPair("A", "P"); $integer_10 = 6; $string_31 = ""; $value_2 = new qtism\data\state\Value($pair_0, $integer_10, $string_31); -$pair_1 = new qtism\common\datatypes\Pair("C", "M"); +$pair_1 = new qtism\common\datatypes\QtiPair("C", "M"); $integer_11 = 6; $string_32 = ""; $value_3 = new qtism\data\state\Value($pair_1, $integer_11, $string_32); -$pair_2 = new qtism\common\datatypes\Pair("D", "L"); +$pair_2 = new qtism\common\datatypes\QtiPair("D", "L"); $integer_12 = 6; $string_33 = ""; $value_4 = new qtism\data\state\Value($pair_2, $integer_12, $string_33); @@ -187,15 +187,15 @@ $valuecollection_2 = new qtism\data\state\ValueCollection($array_24); $string_34 = ""; $correctresponse_1 = new qtism\data\state\CorrectResponse($valuecollection_2, $string_34); -$pair_3 = new qtism\common\datatypes\Pair("A", "P"); +$pair_3 = new qtism\common\datatypes\QtiPair("A", "P"); $double_5 = 2.0; $boolean_10 = true; $mapentry_0 = new qtism\data\state\MapEntry($pair_3, $double_5, $boolean_10); -$pair_4 = new qtism\common\datatypes\Pair("C", "M"); +$pair_4 = new qtism\common\datatypes\QtiPair("C", "M"); $double_6 = 1.0; $boolean_11 = true; $mapentry_1 = new qtism\data\state\MapEntry($pair_4, $double_6, $boolean_11); -$pair_5 = new qtism\common\datatypes\Pair("D", "L"); +$pair_5 = new qtism\common\datatypes\QtiPair("D", "L"); $double_7 = 1.0; $boolean_12 = true; $mapentry_2 = new qtism\data\state\MapEntry($pair_5, $double_7, $boolean_12); diff --git a/test/samples/rendering/postrendering/templateoriented_1.xml b/test/samples/rendering/postrendering/templateoriented_1.xml index adfa21a0a..5009ae243 100644 --- a/test/samples/rendering/postrendering/templateoriented_1.xml +++ b/test/samples/rendering/postrendering/templateoriented_1.xml @@ -1,9 +1,9 @@ - + - + May I really, disappear? @@ -11,13 +11,13 @@
- + May I disappear?
- + May I pop-up?
\ No newline at end of file diff --git a/test/samples/rendering/postrendering/templateoriented_2.xml b/test/samples/rendering/postrendering/templateoriented_2.xml index 74afd3fbe..f1ee53763 100644 --- a/test/samples/rendering/postrendering/templateoriented_2.xml +++ b/test/samples/rendering/postrendering/templateoriented_2.xml @@ -8,7 +8,7 @@
  • Blue
  • - +
  • Black
  • diff --git a/test/scripts/BasicTestSessionSpeed.php b/test/scripts/BasicTestSessionSpeed.php index eaf5eb3b1..43190db9a 100644 --- a/test/scripts/BasicTestSessionSpeed.php +++ b/test/scripts/BasicTestSessionSpeed.php @@ -3,7 +3,7 @@ use qtism\runtime\tests\AssessmentTestSession; use qtism\data\storage\xml\XmlCompactDocument; use qtism\data\storage\xml\XmlDocument; -use qtism\common\datatypes\Identifier; +use qtism\common\datatypes\QtiIdentifier; use qtism\common\enums\BaseType; use qtism\common\enums\Cardinality; use qtism\runtime\common\ResponseVariable; @@ -55,7 +55,7 @@ function attempt(AssessmentTestSession $session, $identifier, array &$average = $start = microtime(); $session->beginAttempt(); - $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier($identifier))))); + $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier($identifier))))); if (is_null($average) === false) { spentTime($start, microtime(), $average); diff --git a/test/scripts/BasicTestSessionSpeed10.php b/test/scripts/BasicTestSessionSpeed10.php index 9198c3e3d..0dc6f7352 100644 --- a/test/scripts/BasicTestSessionSpeed10.php +++ b/test/scripts/BasicTestSessionSpeed10.php @@ -5,7 +5,7 @@ use qtism\runtime\tests\AssessmentTestSession; use qtism\data\storage\xml\XmlCompactDocument; use qtism\data\storage\xml\XmlDocument; -use qtism\common\datatypes\Identifier; +use qtism\common\datatypes\QtiIdentifier; use qtism\common\enums\BaseType; use qtism\common\enums\Cardinality; use qtism\runtime\common\ResponseVariable; @@ -56,7 +56,7 @@ function attempt(AssessmentTestSession $session, $identifier, array &$average = $start = microtime(); $session->beginAttempt(); - $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier($identifier))))); + $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier($identifier))))); if (is_null($average) === false) { spentTime($start, microtime(), $average); diff --git a/test/scripts/BasicTestSessionSpeed15.php b/test/scripts/BasicTestSessionSpeed15.php index da1d86bb1..32c744247 100644 --- a/test/scripts/BasicTestSessionSpeed15.php +++ b/test/scripts/BasicTestSessionSpeed15.php @@ -3,7 +3,7 @@ use qtism\runtime\tests\AssessmentTestSession; use qtism\data\storage\xml\XmlCompactDocument; use qtism\data\storage\xml\XmlDocument; -use qtism\common\datatypes\Identifier; +use qtism\common\datatypes\QtiIdentifier; use qtism\common\enums\BaseType; use qtism\common\enums\Cardinality; use qtism\runtime\common\ResponseVariable; @@ -55,7 +55,7 @@ function attempt(AssessmentTestSession $session, $identifier, array &$average = $start = microtime(); $session->beginAttempt(); - $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier($identifier))))); + $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier($identifier))))); if (is_null($average) === false) { spentTime($start, microtime(), $average); diff --git a/test/scripts/BasicTestSessionSpeed20.php b/test/scripts/BasicTestSessionSpeed20.php index 99ce3c3dd..05ed2a9ea 100644 --- a/test/scripts/BasicTestSessionSpeed20.php +++ b/test/scripts/BasicTestSessionSpeed20.php @@ -3,7 +3,7 @@ use qtism\runtime\tests\AssessmentTestSession; use qtism\data\storage\xml\XmlCompactDocument; use qtism\data\storage\xml\XmlDocument; -use qtism\common\datatypes\Identifier; +use qtism\common\datatypes\QtiIdentifier; use qtism\common\enums\BaseType; use qtism\common\enums\Cardinality; use qtism\runtime\common\ResponseVariable; @@ -55,7 +55,7 @@ function attempt(AssessmentTestSession $session, $identifier, array &$average = $start = microtime(); $session->beginAttempt(); - $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier($identifier))))); + $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier($identifier))))); if (is_null($average) === false) { spentTime($start, microtime(), $average); diff --git a/test/scripts/BasicTestSessionSpeed25.php b/test/scripts/BasicTestSessionSpeed25.php index c264557af..da0a04466 100644 --- a/test/scripts/BasicTestSessionSpeed25.php +++ b/test/scripts/BasicTestSessionSpeed25.php @@ -3,7 +3,7 @@ use qtism\runtime\tests\AssessmentTestSession; use qtism\data\storage\xml\XmlCompactDocument; use qtism\data\storage\xml\XmlDocument; -use qtism\common\datatypes\Identifier; +use qtism\common\datatypes\QtiIdentifier; use qtism\common\enums\BaseType; use qtism\common\enums\Cardinality; use qtism\runtime\common\ResponseVariable; @@ -55,7 +55,7 @@ function attempt(AssessmentTestSession $session, $identifier, array &$average = $start = microtime(); $session->beginAttempt(); - $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier($identifier))))); + $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier($identifier))))); if (is_null($average) === false) { spentTime($start, microtime(), $average); diff --git a/test/scripts/BasicTestSessionSpeed30.php b/test/scripts/BasicTestSessionSpeed30.php index 692fa9594..0645f2abf 100644 --- a/test/scripts/BasicTestSessionSpeed30.php +++ b/test/scripts/BasicTestSessionSpeed30.php @@ -3,7 +3,7 @@ use qtism\runtime\tests\AssessmentTestSession; use qtism\data\storage\xml\XmlCompactDocument; use qtism\data\storage\xml\XmlDocument; -use qtism\common\datatypes\Identifier; +use qtism\common\datatypes\QtiIdentifier; use qtism\common\enums\BaseType; use qtism\common\enums\Cardinality; use qtism\runtime\common\ResponseVariable; @@ -55,7 +55,7 @@ function attempt(AssessmentTestSession $session, $identifier, array &$average = $start = microtime(); $session->beginAttempt(); - $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier($identifier))))); + $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier($identifier))))); if (is_null($average) === false) { spentTime($start, microtime(), $average); diff --git a/test/scripts/BasicTestSessionSpeed35.php b/test/scripts/BasicTestSessionSpeed35.php index 87fff9e3e..f798d2552 100644 --- a/test/scripts/BasicTestSessionSpeed35.php +++ b/test/scripts/BasicTestSessionSpeed35.php @@ -3,7 +3,7 @@ use qtism\runtime\tests\AssessmentTestSession; use qtism\data\storage\xml\XmlCompactDocument; use qtism\data\storage\xml\XmlDocument; -use qtism\common\datatypes\Identifier; +use qtism\common\datatypes\QtiIdentifier; use qtism\common\enums\BaseType; use qtism\common\enums\Cardinality; use qtism\runtime\common\ResponseVariable; @@ -55,7 +55,7 @@ function attempt(AssessmentTestSession $session, $identifier, array &$average = $start = microtime(); $session->beginAttempt(); - $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier($identifier))))); + $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier($identifier))))); if (is_null($average) === false) { spentTime($start, microtime(), $average); diff --git a/test/scripts/BasicTestSessionSpeed40.php b/test/scripts/BasicTestSessionSpeed40.php index 33e701e76..c704481ce 100644 --- a/test/scripts/BasicTestSessionSpeed40.php +++ b/test/scripts/BasicTestSessionSpeed40.php @@ -3,7 +3,7 @@ use qtism\runtime\tests\AssessmentTestSession; use qtism\data\storage\xml\XmlCompactDocument; use qtism\data\storage\xml\XmlDocument; -use qtism\common\datatypes\Identifier; +use qtism\common\datatypes\QtiIdentifier; use qtism\common\enums\BaseType; use qtism\common\enums\Cardinality; use qtism\runtime\common\ResponseVariable; @@ -55,7 +55,7 @@ function attempt(AssessmentTestSession $session, $identifier, array &$average = $start = microtime(); $session->beginAttempt(); - $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier($identifier))))); + $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier($identifier))))); if (is_null($average) === false) { spentTime($start, microtime(), $average); diff --git a/test/scripts/BasicTestSessionSpeed5.php b/test/scripts/BasicTestSessionSpeed5.php index 9a3c1aab8..8eb535551 100644 --- a/test/scripts/BasicTestSessionSpeed5.php +++ b/test/scripts/BasicTestSessionSpeed5.php @@ -3,7 +3,7 @@ use qtism\runtime\tests\AssessmentTestSession; use qtism\data\storage\xml\XmlCompactDocument; use qtism\data\storage\xml\XmlDocument; -use qtism\common\datatypes\Identifier; +use qtism\common\datatypes\QtiIdentifier; use qtism\common\enums\BaseType; use qtism\common\enums\Cardinality; use qtism\runtime\common\ResponseVariable; @@ -55,7 +55,7 @@ function attempt(AssessmentTestSession $session, $identifier, array &$average = $start = microtime(); $session->beginAttempt(); - $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier($identifier))))); + $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier($identifier))))); if (is_null($average) === false) { spentTime($start, microtime(), $average); diff --git a/test/scripts/BasicTestSessionSpeed50.php b/test/scripts/BasicTestSessionSpeed50.php index b66ea788d..0cb401bc8 100644 --- a/test/scripts/BasicTestSessionSpeed50.php +++ b/test/scripts/BasicTestSessionSpeed50.php @@ -3,7 +3,7 @@ use qtism\runtime\tests\AssessmentTestSession; use qtism\data\storage\xml\XmlCompactDocument; use qtism\data\storage\xml\XmlDocument; -use qtism\common\datatypes\Identifier; +use qtism\common\datatypes\QtiIdentifier; use qtism\common\enums\BaseType; use qtism\common\enums\Cardinality; use qtism\runtime\common\ResponseVariable; @@ -56,7 +56,7 @@ function attempt(AssessmentTestSession $session, $identifier, array &$average = $start = microtime(); $session->beginAttempt(); - $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier($identifier))))); + $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier($identifier))))); if (is_null($average) === false) { spentTime($start, microtime(), $average); diff --git a/test/scripts/BasicTestSessionSpeed60.php b/test/scripts/BasicTestSessionSpeed60.php index 0753a33c3..18d1cadde 100644 --- a/test/scripts/BasicTestSessionSpeed60.php +++ b/test/scripts/BasicTestSessionSpeed60.php @@ -3,7 +3,7 @@ use qtism\runtime\tests\AssessmentTestSession; use qtism\data\storage\xml\XmlCompactDocument; use qtism\data\storage\xml\XmlDocument; -use qtism\common\datatypes\Identifier; +use qtism\common\datatypes\QtiIdentifier; use qtism\common\enums\BaseType; use qtism\common\enums\Cardinality; use qtism\runtime\common\ResponseVariable; @@ -56,7 +56,7 @@ function attempt(AssessmentTestSession $session, $identifier, array &$average = $start = microtime(); $session->beginAttempt(); - $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier($identifier))))); + $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier($identifier))))); if (is_null($average) === false) { spentTime($start, microtime(), $average); diff --git a/test/scripts/ChoiceInteraction1Rendering.php b/test/scripts/ChoiceInteraction1Rendering.php index 5a8c60b26..a76fc78a9 100644 --- a/test/scripts/ChoiceInteraction1Rendering.php +++ b/test/scripts/ChoiceInteraction1Rendering.php @@ -1,6 +1,6 @@ setValue(new Identifier($argv[2])); + $templateVariable->setValue(new QtiIdentifier($argv[2])); } else { - $templateVariable->setValue(new Identifier($argv[1])); + $templateVariable->setValue(new QtiIdentifier($argv[1])); } $renderer->setChoiceShowHidePolicy(AbstractMarkupRenderingEngine::CONTEXT_AWARE); diff --git a/test/scripts/ChoiceInteraction1TemplateRendering.php b/test/scripts/ChoiceInteraction1TemplateRendering.php index 8383222cb..da73abec8 100644 --- a/test/scripts/ChoiceInteraction1TemplateRendering.php +++ b/test/scripts/ChoiceInteraction1TemplateRendering.php @@ -1,6 +1,6 @@ load(dirname(__FILE__) . '/../samples/rendering/itembodywithfeedback_1.xml'); -$outcome1 = new OutcomeVariable('outcome1', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('')); -$outcome2 = new OutcomeVariable('outcome2', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('')); +$outcome1 = new OutcomeVariable('outcome1', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('')); +$outcome2 = new OutcomeVariable('outcome2', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('')); $renderer = new XhtmlRenderingEngine(); @@ -23,11 +23,11 @@ $renderer->setFeedbackShowHidePolicy(AbstractMarkupRenderingEngine::CONTEXT_AWARE); if (isset($argv[2])) { - $outcome1->setValue(new Identifier($argv[2])); + $outcome1->setValue(new QtiIdentifier($argv[2])); } if (isset($argv[3])) { - $outcome2->setValue(new Identifier($argv[3])); + $outcome2->setValue(new QtiIdentifier($argv[3])); } } diff --git a/test/scripts/ItemFeedback1Rendering.php b/test/scripts/ItemFeedback1Rendering.php index 6ac53fa51..53b2d8018 100644 --- a/test/scripts/ItemFeedback1Rendering.php +++ b/test/scripts/ItemFeedback1Rendering.php @@ -7,21 +7,21 @@ use qtism\runtime\common\OutcomeVariable; use qtism\common\enums\BaseType; use qtism\common\enums\Cardinality; -use qtism\common\datatypes\Identifier; +use qtism\common\datatypes\QtiIdentifier; require_once(dirname(__FILE__) . '/../../vendor/autoload.php'); $doc = new XmlDocument(); $doc->load(dirname(__FILE__) . '/../samples/rendering/itemfeedback_1.xml'); -$outcome1 = new OutcomeVariable('FEEDBACK', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('')); +$outcome1 = new OutcomeVariable('FEEDBACK', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('')); $renderer = new XhtmlRenderingEngine(); if (isset($argv[1]) && $argv[1] === 'CONTEXT_AWARE') { $renderer->setFeedbackShowHidePolicy(AbstractMarkupRenderingEngine::CONTEXT_AWARE); if (isset($argv[2])) { - $outcome1->setValue(new Identifier($argv[2])); + $outcome1->setValue(new QtiIdentifier($argv[2])); } } diff --git a/test/scripts/PrintedVariable1Rendering.php b/test/scripts/PrintedVariable1Rendering.php index cc680ba8d..2d8350e92 100644 --- a/test/scripts/PrintedVariable1Rendering.php +++ b/test/scripts/PrintedVariable1Rendering.php @@ -1,5 +1,5 @@ setVariable(new TemplateVariable('TPL_H', Cardinality::SINGLE, BaseType::STRING, new String('Bubble Gum'))); -$state->setVariable(new TemplateVariable('TPL_He', Cardinality::SINGLE, BaseType::STRING, new String('Bacta'))); -$state->setVariable(new TemplateVariable('TPL_C', Cardinality::SINGLE, BaseType::STRING, new String('Cola'))); -$state->setVariable(new TemplateVariable('TPL_O', Cardinality::SINGLE, BaseType::STRING, new String('Meat'))); -$state->setVariable(new TemplateVariable('TPL_N', Cardinality::SINGLE, BaseType::STRING, new String('Potatoes'))); -$state->setVariable(new TemplateVariable('TPL_Cl', Cardinality::SINGLE, BaseType::STRING, new String('Candies'))); +$state->setVariable(new TemplateVariable('TPL_H', Cardinality::SINGLE, BaseType::STRING, new QtiString('Bubble Gum'))); +$state->setVariable(new TemplateVariable('TPL_He', Cardinality::SINGLE, BaseType::STRING, new QtiString('Bacta'))); +$state->setVariable(new TemplateVariable('TPL_C', Cardinality::SINGLE, BaseType::STRING, new QtiString('Cola'))); +$state->setVariable(new TemplateVariable('TPL_O', Cardinality::SINGLE, BaseType::STRING, new QtiString('Meat'))); +$state->setVariable(new TemplateVariable('TPL_N', Cardinality::SINGLE, BaseType::STRING, new QtiString('Potatoes'))); +$state->setVariable(new TemplateVariable('TPL_Cl', Cardinality::SINGLE, BaseType::STRING, new QtiString('Candies'))); if (isset($argv[1]) && trim(strtolower($argv[1])) === 'context_aware') { $renderer->setPrintedVariablePolicy(XhtmlRenderingEngine::CONTEXT_AWARE); From 307af36ea8afb6f626bd6ab70d85430c34936a3a Mon Sep 17 00:00:00 2001 From: bugalot Date: Sun, 11 Oct 2015 03:48:43 +0200 Subject: [PATCH 2/2] add PHP7 to travis. --- .travis.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 00493f300..81750ee5a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,13 +6,14 @@ php: - 5.4 - 5.5 - 5.6 + - 7 before_script: - - composer install --no-interaction + - composer self-update && composer install --no-interaction script: - mkdir -p build/logs - ./vendor/bin/phpunit --coverage-clover build/logs/clover.xml after_script: - - ./vendor/bin/coveralls -v \ No newline at end of file + - ./vendor/bin/coveralls -v