mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 17:06:53 +02:00
MDL-27418 add unit tests for the problem case identified by Pierre.
This commit is contained in:
parent
f040d4b046
commit
c5aaf41739
1 changed files with 23 additions and 0 deletions
|
@ -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');
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue