本文整理汇总了PHP中float::equals方法的典型用法代码示例。如果您正苦于以下问题:PHP float::equals方法的具体用法?PHP float::equals怎么用?PHP float::equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类float
的用法示例。
在下文中一共展示了float::equals方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testResponseConditionMatchCorrect
/**
* @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']));
}