mirror of
https://github.com/moodle/moodle.git
synced 2025-01-17 21:49:15 +01:00
Merge branch 'MDL-81458-main-1' of https://github.com/mihailges/moodle
This commit is contained in:
commit
0ea5aee08a
@ -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.
|
||||
|
@ -931,13 +931,13 @@ class question_type {
|
||||
if (is_array($extraanswerfields)) {
|
||||
$answerextensiontable = array_shift($extraanswerfields);
|
||||
// Use LEFT JOIN in case not every answer has extra data.
|
||||
$question->options->answers = $DB->get_records_sql("
|
||||
$answers = $DB->get_records_sql("
|
||||
SELECT qa.*, qax." . implode(', qax.', $extraanswerfields) . '
|
||||
FROM {question_answers} qa ' . "
|
||||
LEFT JOIN {{$answerextensiontable}} qax ON qa.id = qax.answerid
|
||||
WHERE qa.question = ?
|
||||
ORDER BY qa.id", array($question->id));
|
||||
if (!$question->options->answers) {
|
||||
if (!$answers) {
|
||||
echo $OUTPUT->notification('Failed to load question answers from the table ' .
|
||||
$answerextensiontable . 'for questionid ' . $question->id);
|
||||
return false;
|
||||
@ -945,9 +945,15 @@ class question_type {
|
||||
} else {
|
||||
// Don't check for success or failure because some question types do
|
||||
// not use the answers table.
|
||||
$question->options->answers = $DB->get_records('question_answers',
|
||||
$answers = $DB->get_records('question_answers',
|
||||
array('question' => $question->id), 'id ASC');
|
||||
}
|
||||
// Store the answers into the question object.
|
||||
$question->options->answers = array_map(function($answer) {
|
||||
// Some database engines return floats as strings like '1.0000000'. Cast to float for consistency.
|
||||
$answer->fraction = (float) $answer->fraction;
|
||||
return $answer;
|
||||
}, $answers);
|
||||
|
||||
$question->hints = $DB->get_records('question_hints',
|
||||
array('questionid' => $question->id), 'id ASC');
|
||||
|
Loading…
x
Reference in New Issue
Block a user