MDL-27418 add unit tests for the problem case identified by Pierre.
This commit is contained in:
@@ -64,6 +64,7 @@ class qtype_numerical_question_test extends UnitTestCase {
|
||||
|
||||
public function test_grading_with_units() {
|
||||
$question = test_question_maker::make_question('numerical');
|
||||
$question->unitgradingtype = qtype_numerical::UNITOPTIONAL;
|
||||
$question->ap = new qtype_numerical_answer_processor(
|
||||
array('m' => 1, 'cm' => 100), false, '.', ',');
|
||||
|
||||
@@ -79,6 +80,28 @@ class qtype_numerical_question_test extends UnitTestCase {
|
||||
$question->grade_response(array('answer' => '314000000x10^-8m')));
|
||||
}
|
||||
|
||||
public function test_grading_with_units_graded() {
|
||||
$question = test_question_maker::make_question('numerical');
|
||||
$question->unitgradingtype = qtype_numerical::UNITGRADED;
|
||||
$question->ap = new qtype_numerical_answer_processor(
|
||||
array('m' => 1, 'cm' => 100), false, '.', ',');
|
||||
|
||||
$this->assertEqual(array(0.8, question_state::$gradedpartial),
|
||||
$question->grade_response(array('answer' => '3.14 frogs')));
|
||||
$this->assertEqual(array(0.8, question_state::$gradedpartial),
|
||||
$question->grade_response(array('answer' => '3.14')));
|
||||
$this->assertEqual(array(1, question_state::$gradedright),
|
||||
$question->grade_response(array('answer' => '3.14 m')));
|
||||
$this->assertEqual(array(1, question_state::$gradedright),
|
||||
$question->grade_response(array('answer' => '314cm')));
|
||||
$this->assertEqual(array(1, question_state::$gradedright),
|
||||
$question->grade_response(array('answer' => '314000000x10^-8m')));
|
||||
$this->assertEqual(array(0.8, question_state::$gradedpartial),
|
||||
$question->grade_response(array('answer' => '3.14 cm')));
|
||||
$this->assertEqual(array(0.8, question_state::$gradedpartial),
|
||||
$question->grade_response(array('answer' => '314 m')));
|
||||
}
|
||||
|
||||
public function test_grading_unit() {
|
||||
$question = test_question_maker::make_question('numerical', 'unit');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user