コード例 #1
0
    public function testSetOutcomeValueNoVariable()
    {
        $rule = $this->createComponentFromXml('
	        <setOutcomeValue identifier="SCOREXXXX">
	            <baseValue baseType="float">1337.1337</baseValue>
	        </setOutcomeValue>
	    ');
        $processor = new SetOutcomeValueProcessor($rule);
        $score = new OutcomeVariable('SCORE', Cardinality::SINGLE, BaseType::INTEGER);
        $state = new State(array($score));
        $processor->setState($state);
        $this->setExpectedException('qtism\\runtime\\rules\\RuleProcessingException', "No variable with identifier 'SCOREXXXX' to be set in the current state.", RuleProcessingException::NONEXISTENT_VARIABLE);
        $processor->process();
    }
コード例 #2
0
    public function testSetOutcomeValueModerate()
    {
        $rule = $this->createComponentFromXml('
			<setOutcomeValue identifier="myBool">
				<member>
					<baseValue baseType="string">Incredible!</baseValue>
					<multiple>
						<baseValue baseType="string">This...</baseValue>
						<baseValue baseType="string">Is...</baseValue>
						<baseValue baseType="string">Incredible!</baseValue>
					</multiple>
				</member>
			</setOutcomeValue>
		');
        $processor = new SetOutcomeValueProcessor($rule);
        $myBool = new OutcomeVariable('myBool', Cardinality::SINGLE, BaseType::BOOLEAN, new Boolean(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->assertTrue($state['myBool']->getValue());
    }