本文整理匯總了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']));
}