MDL-35055 question import: slight error with the Match grades option.
Even in the 'Error if grade not listed case', it was applying a small tolerance. In the case of a fuzzy match, it was returning the inexact grade from the import file, rather than the precise grade that Moodle was expecting. That causes problems when the editing form is displayed, because the value from the database does not match any of the available options, so the grade is changed to 0%.
This commit is contained in:
@@ -55,4 +55,19 @@ class questionlib_testcase extends basic_testcase {
|
||||
array(0 => 't1', 1 => 't2', 2 => 't3'));
|
||||
}
|
||||
|
||||
public function test_match_grade_options() {
|
||||
$gradeoptions = question_bank::fraction_options_full();
|
||||
|
||||
$this->assertEquals(0.3333333, match_grade_options($gradeoptions, 0.3333333, 'error'));
|
||||
$this->assertEquals(0.3333333, match_grade_options($gradeoptions, 0.333333, 'error'));
|
||||
$this->assertEquals(0.3333333, match_grade_options($gradeoptions, 0.33333, 'error'));
|
||||
$this->assertFalse(match_grade_options($gradeoptions, 0.3333, 'error'));
|
||||
|
||||
$this->assertEquals(0.3333333, match_grade_options($gradeoptions, 0.3333333, 'nearest'));
|
||||
$this->assertEquals(0.3333333, match_grade_options($gradeoptions, 0.333333, 'nearest'));
|
||||
$this->assertEquals(0.3333333, match_grade_options($gradeoptions, 0.33333, 'nearest'));
|
||||
$this->assertEquals(0.3333333, match_grade_options($gradeoptions, 0.33, 'nearest'));
|
||||
|
||||
$this->assertEquals(-0.1428571, match_grade_options($gradeoptions, -0.15, 'nearest'));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user