mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 00:12:56 +02:00
MDL-81458 qtype_ordering: Address failing unit tests
Fixes the failing unit tests in the ordering question type by implementing the following adjustments and corrections: - Ensure the missing required files are imported in questionhint_test.php and questiontype_test.php. - Modify the expected fraction values in testexport.moodle.xml to accurately reflect the recent changes, specifically the type casting of the fraction value stored for each answer into the question object. - Reorder the items in the answers array within the failing scenario in specific_grade_detail_feedback_test.php to guarantee that, in accordance with the randomly generated subset of correct answers, the question attempt will consistently be incorrect as required. - Pass the answer codes in the order of the defined response when calling the process_submission() function in feedback_test.php to ensure the response in the current question attempt is properly set, rather than relying on random generation of the response which may result in random test failures.
This commit is contained in:
parent
72e9a1bbd9
commit
4b1dfe6a40
@ -29,37 +29,37 @@
|
||||
<text>That is not right at all.</text>
|
||||
</incorrectfeedback>
|
||||
<shownumcorrect>1</shownumcorrect>
|
||||
<answer fraction="1.0000000" format="html">
|
||||
<answer fraction="1" format="html">
|
||||
<text>Modular</text>
|
||||
<feedback format="html">
|
||||
<text>Modular is correct.</text>
|
||||
</feedback>
|
||||
</answer>
|
||||
<answer fraction="2.0000000" format="html">
|
||||
<answer fraction="2" format="html">
|
||||
<text>Object</text>
|
||||
<feedback format="html">
|
||||
<text>Object is correct.</text>
|
||||
</feedback>
|
||||
</answer>
|
||||
<answer fraction="3.0000000" format="html">
|
||||
<answer fraction="3" format="html">
|
||||
<text>Oriented</text>
|
||||
<feedback format="html">
|
||||
<text>Oriented is correct.</text>
|
||||
</feedback>
|
||||
</answer>
|
||||
<answer fraction="4.0000000" format="html">
|
||||
<answer fraction="4" format="html">
|
||||
<text>Dynamic</text>
|
||||
<feedback format="html">
|
||||
<text>Dynamic is correct.</text>
|
||||
</feedback>
|
||||
</answer>
|
||||
<answer fraction="5.0000000" format="html">
|
||||
<answer fraction="5" format="html">
|
||||
<text>Learning</text>
|
||||
<feedback format="html">
|
||||
<text>Learning is correct.</text>
|
||||
</feedback>
|
||||
</answer>
|
||||
<answer fraction="6.0000000" format="html">
|
||||
<answer fraction="6" format="html">
|
||||
<text>Environment</text>
|
||||
<feedback format="html">
|
||||
<text>Environment is correct.</text>
|
||||
|
@ -98,7 +98,8 @@ final class feedback_test extends qbehaviour_walkthrough_test_base {
|
||||
$attempt = $qa;
|
||||
} else {
|
||||
$this->start_attempt_at_question($question, 'interactive');
|
||||
$this->process_submission(array_merge(['-submit' => 1], ['answers' => array_values($answeritems)]));
|
||||
$response = qtype_ordering_test_helper::get_response($question, array_values($answeritems));
|
||||
$this->process_submission(array_merge(['-submit' => 1], $response));
|
||||
$attempt = $this->get_question_attempt();
|
||||
// Omit the numparts as we are not testing it here, and it can be a bit flaky when manually processing an attempt.
|
||||
$this->displayoptions->numpartscorrect = false;
|
||||
|
@ -197,7 +197,7 @@ final class specific_grade_detail_feedback_test extends advanced_testcase {
|
||||
qtype_ordering_question::SELECT_ALL,
|
||||
],
|
||||
'Incorrect question attempt (SELECT_RANDOM). Grading type: GRADING_ABSOLUTE_POSITION' => [
|
||||
[14 => 'Object', 16 => 'Dynamic', 13 => 'Modular', 17 => 'Learning', 18 => 'Environment', 15 => 'Oriented'],
|
||||
[16 => 'Dynamic', 14 => 'Object', 13 => 'Modular', 17 => 'Learning', 18 => 'Environment', 15 => 'Oriented'],
|
||||
qtype_ordering_question::GRADING_ABSOLUTE_POSITION,
|
||||
'vertical',
|
||||
[
|
||||
|
@ -24,6 +24,7 @@ defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
global $CFG;
|
||||
require_once($CFG->dirroot . '/question/engine/tests/helpers.php');
|
||||
require_once($CFG->dirroot . '/question/type/ordering/questiontype.php');
|
||||
|
||||
/**
|
||||
* A test class used to test question_hint_ordering.
|
||||
|
@ -39,7 +39,7 @@ require_once($CFG->dirroot . '/question/type/ordering/edit_ordering_form.php');
|
||||
require_once($CFG->libdir . '/questionlib.php');
|
||||
require_once($CFG->dirroot . '/question/format.php');
|
||||
require_once($CFG->dirroot . '/question/format/gift/format.php');
|
||||
require_once($CFG->dirroot . '/question/engine/tests/helpers.php');
|
||||
require_once($CFG->dirroot . '/question/format/xml/format.php');
|
||||
|
||||
/**
|
||||
* Unit tests for the ordering question type class.
|
||||
|
Loading…
x
Reference in New Issue
Block a user