public function testResponseProcessingMatchCorrect()
    {
        $responseProcessing = $this->createComponentFromXml('
			<responseProcessing template="http://www.imsglobal.org/question/qti_v2p1/rptemplates/match_correct"/>
		');
        $responseDeclaration = $this->createComponentFromXml('
			<responseDeclaration identifier="RESPONSE" cardinality="single" baseType="identifier">
				<correctResponse>
					<value>ChoiceA</value>
				</correctResponse>
			</responseDeclaration>		
		');
        $outcomeDeclaration = $this->createComponentFromXml('
			<outcomeDeclaration identifier="SCORE" cardinality="single" baseType="float">
				<defaultValue>
					<value>0</value>
				</defaultValue>
			</outcomeDeclaration>
		');
        $respVar = ResponseVariable::createFromDataModel($responseDeclaration);
        $outVar = OutcomeVariable::createFromDataModel($outcomeDeclaration);
        $context = new State(array($respVar, $outVar));
        $engine = new ResponseProcessingEngine($responseProcessing, $context);
        // --> answer as a correct response.
        $context['RESPONSE'] = new Identifier('ChoiceA');
        $engine->process();
        $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $context['SCORE']);
        $this->assertEquals(1.0, $context['SCORE']->getValue());
    }
    public function testDefaultValueOnResponseSimple()
    {
        $rule = $this->createComponentFromXml('
			<setDefaultValue identifier="RESPONSE">
				<baseValue baseType="identifier">there</baseValue>
			</setDefaultValue>
		');
        $processor = new SetDefaultValueProcessor($rule);
        $response = new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER);
        $response->setDefaultValue(new Identifier('hello'));
        $state = new State(array($response));
        $processor->setState($state);
        $processor->process();
        $this->assertInstanceOf('qtism\\common\\datatypes\\Identifier', $state->getVariable('RESPONSE')->getDefaultValue());
        $this->assertEquals('there', $state->getVariable('RESPONSE')->getDefaultValue()->getValue());
    }
 /**
  * Fill the variable $variableName with a correctly transformed $clientSideValue.
  *
  * @param string $variableName The variable identifier you want to fill.
  * @param array $clientSideValue The value received from the client-side representing the value of the variable with identifier $variableName.
  * @return Variable A Variable object filled with a correctly transformed $clientSideValue.
  * @throws OutOfBoundsException If no variable with $variableName is described in the item.
  * @throws OutOfRangeException If the $clientSideValue does not fit the target variable's baseType.
  */
 public function fill($variableName, $clientSideValue)
 {
     $variableDeclaration = $this->findVariableDeclaration($variableName);
     if ($variableDeclaration === false) {
         $itemId = $this->getItemRef()->getIdentifier();
         $msg = "Variable declaration with identifier '{$variableName}' not found in item '{$itemId}'.";
         throw new OutOfBoundsException($msg);
     }
     // Create Runtime Variable from Data Model.
     $runtimeVar = $variableDeclaration instanceof ResponseDeclaration ? ResponseVariable::createFromDataModel($variableDeclaration) : OutcomeVariable::createFromDataModel($variableDeclaration);
     // Set the data into the runtime variable thanks to the PCI JSON Unmarshaller
     // from QTISM.
     try {
         $unmarshaller = new PciJsonUnmarshaller(taoQtiCommon_helpers_Utils::getFileDatatypeManager());
         $value = $unmarshaller->unmarshall($clientSideValue);
         // Dev's note:
         // The PCI JSON Representation format does make the difference between multiple and ordered containers.
         // We then have to juggle a bit if the target variable has ordered cardinality.
         if ($value !== null && $value->getCardinality() === Cardinality::MULTIPLE && $variableDeclaration->getCardinality() === Cardinality::ORDERED) {
             $value = new OrderedContainer($value->getBaseType(), $value->getArrayCopy());
         }
         $runtimeVar->setValue($value);
     } catch (PciJsonUnmarshallingException $e) {
         $strClientSideValue = mb_substr(var_export($clientSideValue, true), 0, 50, TAO_DEFAULT_ENCODING);
         $msg = "Unable to put value '{$strClientSideValue}' into variable '{$variableName}'.";
         throw new OutOfRangeException($msg, 0, $e);
     }
     return $runtimeVar;
 }
Exemplo n.º 4
0
    public function testNoDefaultValue()
    {
        $variableDeclaration = $this->createComponentFromXml('
			<responseDeclaration identifier="response1" baseType="point" cardinality="multiple"/>
		');
        $expr = $this->createComponentFromXml('<default identifier="response1"/>');
        $processor = new DefaultProcessor($expr);
        $variable = ResponseVariable::createFromDataModel($variableDeclaration);
        $processor->setState(new State(array($variable)));
        $result = $processor->process();
        $this->assertTrue($result === null);
    }
Exemplo n.º 5
0
    public function testNull()
    {
        $responseDeclaration = $this->createComponentFromXml('
			<responseDeclaration identifier="response1" baseType="integer" cardinality="single"/>
		');
        $expr = $this->createComponentFromXml('<correct identifier="response1"/>');
        $variable = ResponseVariable::createFromDataModel($responseDeclaration);
        $processor = new CorrectProcessor($expr);
        $result = $processor->process();
        // No state set.
        $this->assertTrue($result === null);
        $processor->setState(new State(array($variable)));
        $result = $processor->process();
        $this->assertTrue($result === null);
    }
    /**
     * @dataProvider responseConditionMatchCorrectProvider
     * 
     * @param string $response A QTI Identifier
     * @param float $expectedScore The expected score for a given $response
     */
    public function testResponseConditionMatchCorrect($response, $expectedScore)
    {
        $rule = $this->createComponentFromXml('
			<responseCondition>
				<responseIf>
					<match>
						<variable identifier="RESPONSE"/>
						<correct identifier="RESPONSE"/>
					</match>
					<setOutcomeValue identifier="SCORE">
						<baseValue baseType="float">1</baseValue>
						</setOutcomeValue>
				</responseIf>
				<responseElse>
					<setOutcomeValue identifier="SCORE">
						<baseValue baseType="float">0</baseValue>
					</setOutcomeValue>
				</responseElse>
			</responseCondition>
		');
        $responseVarDeclaration = $this->createComponentFromXml('
			<responseDeclaration identifier="RESPONSE" cardinality="single" baseType="identifier">
				<correctResponse>
					<value>ChoiceA</value>
				</correctResponse>
			</responseDeclaration>
		');
        $responseVar = ResponseVariable::createFromDataModel($responseVarDeclaration);
        $this->assertTrue($responseVar->getCorrectResponse()->equals(new Identifier('ChoiceA')));
        // Set 'ChoiceA' to 'RESPONSE' in order to get a score of 1.0.
        $responseVar->setValue($response);
        $outcomeVarDeclaration = $this->createComponentFromXml('
			<outcomeDeclaration identifier="SCORE" cardinality="single" baseType="float">
				<defaultValue>
					<value>0</value>
				</defaultValue>
			</outcomeDeclaration>		
		');
        $outcomeVar = OutcomeVariable::createFromDataModel($outcomeVarDeclaration);
        $this->assertEquals(0, $outcomeVar->getDefaultValue()->getValue());
        $state = new State(array($responseVar, $outcomeVar));
        $processor = new ResponseConditionProcessor($rule);
        $processor->setState($state);
        $processor->process();
        $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $state['SCORE']);
        $this->assertTrue($expectedScore->equals($state['SCORE']));
    }
 /**
  * Fille the variable $variableName with a correctly transformed
  * $clientSideValue.
  * 
  * @param string $variableName The variable identifier you want to fill.
  * @param string $clientSideValue The value received from the client-side.
  * @return Variable A Variable object filled with a correctly transformed $clientSideValue.
  * @throws OutOfBoundsException If no variable with $variableName is described in the item.
  * @throws OutOfRangeException If the $clientSideValue does not fit the target variable's baseType.
  */
 public function fill($variableName, $clientSideValue)
 {
     $variable = null;
     $outcomeDeclarations = $this->getItemRef()->getOutcomeDeclarations();
     $responseDeclarations = $this->getItemRef()->getResponseDeclarations();
     if (isset($responseDeclarations[$variableName]) === true) {
         $variable = ResponseVariable::createFromDataModel($responseDeclarations[$variableName]);
     } else {
         if (isset($outcomeDeclarations[$variableName]) === true) {
             $variable = OutcomeVariable::createFromDataModel($outcomeDeclarations[$variableName]);
         }
     }
     if (empty($variable) === true) {
         $itemId = $this->getItemRef()->getIdentifier();
         $msg = "No variable declaration '{$variableName}' found in '{$itemId}'.";
         throw new OutOfBoundsException($msg);
     }
     common_Logger::d("Filling variable '" . $variable->getIdentifier() . "'.");
     if (is_array($clientSideValue) === false) {
         $clientSideValue = array($clientSideValue);
     }
     try {
         $finalValues = array();
         foreach ($clientSideValue as $val) {
             $finalValues[] = self::transform($variable->getBaseType(), $val);
         }
         if ($variable->getCardinality() === Cardinality::SINGLE) {
             $variable->setValue($finalValues[0]);
         } else {
             if ($variable->getCardinality() === Cardinality::MULTIPLE) {
                 $variable->setValue(new MultipleContainer($variable->getBaseType(), $finalValues));
             } else {
                 // Cardinality is ORDERED.
                 $variable->setValue(new OrderedContainer($variable->getBaseType(), $finalValues));
             }
         }
         return $variable;
     } catch (InvalidArgumentException $e) {
         if (is_array($clientSideValue)) {
             $clientSideValue = implode(',', $clientSideValue);
         }
         $msg = "An error occured while filling variable '{$variableName}' with client-side value '{$clientSideValue}':" . $e->getMessage();
         throw new InvalidArgumentException($msg, 0, $e);
     }
 }
Exemplo n.º 8
0
 public function writeVariableValueProvider()
 {
     $rw_value = QtiBinaryStreamAccess::RW_VALUE;
     $rw_defaultValue = QtiBinaryStreamAccess::RW_DEFAULTVALUE;
     $rw_correctResponse = QtiBinaryStreamAccess::RW_CORRECTRESPONSE;
     $data = array();
     // -- Integers
     $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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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')));
     $data[] = array(new OutcomeVariable('VAR', Cardinality::MULTIPLE, BaseType::FILE, new MultipleContainer(BaseType::FILE, array(FileSystemFile::retrieveFile(self::samplesDir() . 'datatypes/file/text-plain_text_data.txt'), FileSystemFile::retrieveFile(self::samplesDir() . 'datatypes/file/text-plain_noname.txt')))));
     $v = new ResponseVariable('VAR', Cardinality::SINGLE, BaseType::FILE);
     $v->setDefaultValue(FileSystemFile::retrieveFile(self::samplesDir() . 'datatypes/file/text-plain_text_data.txt'));
     $data[] = array($v, $rw_defaultValue);
     $v = new ResponseVariable('VAR', Cardinality::SINGLE, BaseType::FILE);
     $v->setDefaultValue(FileSystemFile::retrieveFile(self::samplesDir() . 'datatypes/file/text-plain_text_data.txt'));
     $data[] = array($v, $rw_correctResponse);
     // 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 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 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;
 }
Exemplo n.º 9
0
 /**
  * Create a new AssessmentItemSession object. 
  * 
  * * The built-in response variables 'numAttempts' and 'duration' will be created and set up with appropriate default values, respectively Integer(0) and Duration('PT0S').
  * * The built-in outcome variable 'completionStatus' will be created and set up with an appropriate default value of  String('not_attempted').
  * * The item session is set up with a default ItemSessionControl object. If you want a specific ItemSessionControl object to rule the session, use the setItemSessionControl() method.
  * * The item session is set up with no TimeLimits object. If you want to set a a specfici TimeLimits object to rule the session, use the setTimeLimits() method.
  *
  * @param \qtism\data\IAssessmentItem $assessmentItem The description of the item that the session handles.
  * @param integer $navigationMode (optional) A value from the NavigationMode enumeration.
  * @param integer $submissionMode (optional) A value from the SubmissionMode enumeration.
  * @throws \InvalidArgumentException If $navigationMode or $submission is not a value from the NavigationMode/SubmissionMode enumeration.
  * @see \qtism\runtime\tests\AssessmentItemSession::setItemSessionControl() The setItemSessionControl() method.
  * @see \qtism\runtime\tests\AssessmentItemSession::setTimeLimits() The setTimeLimits() method.
  */
 public function __construct(IAssessmentItem $assessmentItem, $navigationMode = NavigationMode::LINEAR, $submissionMode = SubmissionMode::INDIVIDUAL)
 {
     parent::__construct();
     $this->setAssessmentItem($assessmentItem);
     $this->setItemSessionControl(new ItemSessionControl());
     $this->setNavigationMode($navigationMode);
     $this->setSubmissionMode($submissionMode);
     // -- Create the built-in response variables.
     $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 QtiIdentifier(self::COMPLETION_STATUS_NOT_ATTEMPTED)));
     // -- Create item specific outcome, response and template variables.
     foreach ($assessmentItem->getOutcomeDeclarations() as $outcomeDeclaration) {
         $outcomeVariable = OutcomeVariable::createFromDataModel($outcomeDeclaration);
         $this->setVariable($outcomeVariable);
     }
     foreach ($this->getAssessmentItem()->getResponseDeclarations() as $responseDeclaration) {
         $responseVariable = ResponseVariable::createFromDataModel($responseDeclaration);
         $this->setVariable($responseVariable);
     }
     foreach ($assessmentItem->getTemplateDeclarations() as $templateDeclaration) {
         $templateVariable = TemplateVariable::createFromDataModel($templateDeclaration);
         $this->setVariable($templateVariable);
     }
     // -- Perform choice shuffling for interactions by creating the Shuffling States for this item session.
     $shufflingStates = new ShufflingCollection();
     foreach ($assessmentItem->getShufflings() as $shuffling) {
         $shufflingStates[] = $shuffling->shuffle();
     }
     $this->setShufflingStates($shufflingStates);
 }
Exemplo n.º 10
0
    public function testMultipleCardinalityIdentifierToFloat()
    {
        $responseDeclaration = $this->createComponentFromXml('
	        <responseDeclaration identifier="RESPONSE" baseType="identifier" cardinality="multiple">
                <correctResponse>
	                <value>Choice1</value>
	                <value>Choice6</value>
	                <value>Choice7</value>
	            </correctResponse>
	            <mapping>
	                <mapEntry mapKey="Choice1" mappedValue="2"/>
	                <mapEntry mapKey="Choice6" mappedValue="20"/>
                    <mapEntry mapKey="Choice9" mappedValue="20"/>
	                <mapEntry mapKey="Choice2" mappedValue="-20"/>
	                <mapEntry mapKey="Choice3" mappedValue="-20"/>
	                <mapEntry mapKey="Choice4" mappedValue="-20"/>
	                <mapEntry mapKey="Choice5" mappedValue="-20"/>
	                <mapEntry mapKey="Choice7" mappedValue="-20" caseSensitive="false"/>
	                <!-- no mapping for choice 8 -->
	            </mapping>
	        </responseDeclaration>
	    ');
        $mapResponseExpression = new MapResponse('RESPONSE');
        $mapResponseProcessor = new MapResponseProcessor($mapResponseExpression);
        $state = new State();
        $mapResponseProcessor->setState($state);
        // State setup.
        $responseVariable = ResponseVariable::createFromDataModel($responseDeclaration);
        $state->setVariable($responseVariable);
        // RESPONSE is an empty container.
        $this->assertTrue($responseVariable->isNull());
        $result = $mapResponseProcessor->process();
        $this->assertEquals(0.0, $result->getValue());
        $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $result);
        // RESPONSE is NULL.
        $responseVariable->setValue(null);
        $result = $mapResponseProcessor->process();
        $this->assertEquals(0.0, $result->getValue());
        $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $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')));
        $result = $mapResponseProcessor->process();
        $this->assertEquals(20.0, $result->getValue());
        // Response is Choice 6, Choice 8, but the mapping's default values goes to -1.
        $mapping = $responseDeclaration->getMapping();
        $mapping->setDefaultValue(-1.0);
        $responseVariable = ResponseVariable::createFromDataModel($responseDeclaration);
        $state->setVariable($responseVariable);
        $state['RESPONSE'] = new MultipleContainer(BaseType::IDENTIFIER, array(new Identifier('Choice6'), new Identifier('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')));
        $result = $mapResponseProcessor->process();
        $this->assertEquals(-21.0, $result->getValue());
        // Empty state.
        // An exception is raised because no RESPONSE variable found.
        $state->reset();
        $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException');
        $result = $mapResponseProcessor->process();
    }
Exemplo n.º 11
0
 public function testClone()
 {
     // value, default value and correct response must be independent after cloning.
     $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());
     $this->assertNotSame($responseVariable->getDefaultValue(), $clone->getDefaultValue());
     $this->assertNotSame($responseVariable->getCorrectResponse(), $clone->getCorrectResponse());
 }
 /**
  * Start the item session. The item session is started when the related item
  * becomes eligible for the candidate.
  * 
  * * ResponseVariable objects involved in the session will be set a value of NULL.
  * * OutcomeVariable objects involved in the session will be set their default value if any. Otherwise, they are set to NULL unless their baseType is integer or float. In this case, the value is 0 or 0.0.
  * * The state of the session is set to INITIAL.
  * 
  */
 public function beginItemSession()
 {
     // We initialize the item session and its variables.
     foreach ($this->getAssessmentItem()->getOutcomeDeclarations() as $outcomeDeclaration) {
         // Outcome variables are instantiantiated as part of the item session.
         // Their values may be initialized with a default value if they have one.
         $outcomeVariable = OutcomeVariable::createFromDataModel($outcomeDeclaration);
         $outcomeVariable->initialize();
         $outcomeVariable->applyDefaultValue();
         $this->setVariable($outcomeVariable);
     }
     foreach ($this->getAssessmentItem()->getResponseDeclarations() as $responseDeclaration) {
         // Response variables are instantiated as part of the item session.
         // Their values are always initialized to NULL.
         $responseVariable = ResponseVariable::createFromDataModel($responseDeclaration);
         $responseVariable->initialize();
         $this->setVariable($responseVariable);
     }
     // The session gets the INITIAL state, ready for a first attempt.
     $this->setState(AssessmentItemSessionState::INITIAL);
     $this['duration'] = new Duration('PT0S');
     $this['numAttempts']->setValue(0);
     $this['completionStatus']->setValue(self::COMPLETION_STATUS_NOT_ATTEMPTED);
 }
 /**
  * Read a PendingResponse object from the current binary stream.
  * 
  * @param AssessmentTestSeeker $seeker An AssessmentTestSeeker object in order to know tree position for involved QTI Components.
  * @return PendingResponses A PendingResponses object.
  * @throws QtiBinaryStreamAccessException
  */
 public function readPendingResponses(AssessmentTestSeeker $seeker)
 {
     try {
         // Read the state.
         $state = new State();
         $varCount = $this->readTinyInt();
         for ($i = 0; $i < $varCount; $i++) {
             $responseDeclaration = $seeker->seekComponent('responseDeclaration', $this->readShort());
             $responseVariable = ResponseVariable::createFromDataModel($responseDeclaration);
             $this->readVariableValue($responseVariable);
             $state->setVariable($responseVariable);
         }
         // Read the assessmentItemRef.
         $itemRef = $seeker->seekComponent('assessmentItemRef', $this->readShort());
         // Read the occurence number.
         $occurence = $this->readTinyInt();
         return new PendingResponses($state, $itemRef, $occurence);
     } catch (BinaryStreamAccessException $e) {
         $msg = "An error occured while reading some pending responses.";
         throw new QtiBinaryStreamAccessException($msg, $this, QtiBinaryStreamAccessException::PENDING_RESPONSES, $e);
     } catch (OutOfBoundsException $e) {
         $msg = "A QTI component was not found in the assessmentTest tree structure.";
         throw new QtiBinaryStreamAccessException($msg, $this, QtiBinaryStreamAccessException::PENDING_RESPONSES, $e);
     }
 }
    public function testWithRecord()
    {
        $expr = $this->createComponentFromXml('<mapResponsePoint identifier="response1"/>');
        $variableDeclaration = $this->createComponentFromXml('
			<responseDeclaration identifier="response1" cardinality="record">
	            <areaMapping lowerBound="1" upperBound="5">
					<areaMapEntry shape="rect" coords="0,0,20,10" mappedValue="4"/>
					<areaMapEntry shape="circle" coords="5,5,5" mappedValue="2"/>
				</areaMapping>
	        </responseDeclaration>
		');
        $variable = ResponseVariable::createFromDataModel($variableDeclaration);
        $processor = new MapResponsePointProcessor($expr);
        $processor->setState(new State(array($variable)));
        $this->setExpectedException('qtism\\runtime\\expressions\\ExpressionProcessingException', 'The MapResponsePoint expression cannot be applied to RECORD variables.', ExpressionProcessingException::WRONG_VARIABLE_CARDINALITY);
        $result = $processor->process();
    }
    public function testUpperBoundOverflow()
    {
        $expr = $this->createComponentFromXml('<mapResponsePoint identifier="response1"/>');
        $variableDeclaration = $this->createComponentFromXml('
			<responseDeclaration identifier="response1" baseType="point" cardinality="single">
				<areaMapping lowerBound="1" upperBound="5">
					<areaMapEntry shape="rect" coords="0,0,20,10" mappedValue="4"/>
					<areaMapEntry shape="circle" coords="5,5,5" mappedValue="2"/>
				</areaMapping>
			</responseDeclaration>
		');
        $variable = ResponseVariable::createFromDataModel($variableDeclaration);
        $processor = new MapResponsePointProcessor($expr);
        $variable->setValue(new Point(3, 3));
        // inside everything.
        $processor->setState(new State(array($variable)));
        $result = $processor->process();
        $this->assertInstanceOf('qtism\\common\\datatypes\\Float', $result);
        $this->assertEquals(5, $result->getValue());
    }