mirror of
https://github.com/moodle/moodle.git
synced 2025-03-21 16:10:15 +01:00
MDL-53137 qtype_numerical: Swap geo tolerance limits for -ve answers
This commit is contained in:
parent
178aa05227
commit
11816b9e41
@ -384,6 +384,9 @@ class qtype_numerical_answer extends question_answer {
|
||||
|
||||
case 3: case 'geometric':
|
||||
$quotient = 1 + abs($tolerance);
|
||||
if ($this->answer < 0) {
|
||||
return array($this->answer * $quotient, $this->answer / $quotient);
|
||||
}
|
||||
return array($this->answer / $quotient, $this->answer * $quotient);
|
||||
|
||||
default:
|
||||
|
@ -105,5 +105,15 @@ class answer_test extends \advanced_testcase {
|
||||
$this->assertTrue($answer->within_tolerance(7));
|
||||
$this->assertTrue($answer->within_tolerance(14));
|
||||
$this->assertFalse($answer->within_tolerance(14.01));
|
||||
|
||||
// Geometric tolerance, negative answer.
|
||||
$answer = new qtype_numerical_answer(13, -7.0, 1.0, '', FORMAT_MOODLE, 1.0);
|
||||
$answer->tolerancetype = 3;
|
||||
|
||||
$this->assertFalse($answer->within_tolerance(-3.49));
|
||||
$this->assertTrue($answer->within_tolerance(-3.5));
|
||||
$this->assertTrue($answer->within_tolerance(-7));
|
||||
$this->assertTrue($answer->within_tolerance(-14));
|
||||
$this->assertFalse($answer->within_tolerance(-14.01));
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user