Exercise: Fix result for multi_answer_false

pull/4064/head
Angel Fernando Quiroz Campos 4 years ago
parent c2e44d7ff5
commit 26884d9c00
  1. 4
      main/exercise/exercise.class.php
  2. 9
      main/exercise/multiple_answer_true_false.class.php
  3. 2
      main/inc/lib/exercise.lib.php
  4. 10
      main/inc/lib/exercise_show_functions.lib.php

@ -3954,8 +3954,8 @@ class Exercise
if ($studentChoice == $answerCorrect) {
$questionScore += $true_score;
} else {
if ($quiz_question_options[$studentChoice]['name'] === "Don't know" ||
$quiz_question_options[$studentChoice]['name'] === "DoubtScore"
if ($quiz_question_options[$studentChoice - 1]['name'] === "Don't know" ||
$quiz_question_options[$studentChoice - 1]['name'] === "DoubtScore"
) {
$questionScore += $doubt_score;
} else {

@ -112,14 +112,15 @@ class MultipleAnswerTrueFalse extends Question
$answer_number->freeze();
if (is_object($answer)) {
$defaults['answer['.$i.']'] = $answer->answer[$i];
$defaults['comment['.$i.']'] = $answer->comment[$i];
$correct = $answer->correct[$i];
$defaults['answer['.$i.']'] = $answer->answer[$i] ?? '';
$defaults['comment['.$i.']'] = $answer->comment[$i] ?? '';
$correct = $answer->correct[$i] ?? 0;
$defaults['correct['.$i.']'] = $correct;
$j = 1;
if (!empty($optionData)) {
foreach ($optionData as $id => $data) {
$id++;
$rdoCorrect = $form->addElement('radio', 'correct['.$i.']', null, null, $id);
if (isset($_POST['correct']) && isset($_POST['correct'][$i]) && $id == $_POST['correct'][$i]) {
@ -298,7 +299,7 @@ class MultipleAnswerTrueFalse extends Question
if (empty($options)) {
//If this is the first time that the question is created when
// change the default values from the form 1 and 2 by the correct "option id" registered
$goodAnswer = isset($sortedByPosition[$goodAnswer]) ? $sortedByPosition[$goodAnswer]['iid'] : '';
// $goodAnswer = isset($sortedByPosition[$goodAnswer]) ? $sortedByPosition[$goodAnswer]['iid'] : '';
}
$questionWeighting += $extra_values[0]; //By default 0 has the correct answers
$objAnswer->createAnswer($answer, $goodAnswer, $comment, '', $i);

@ -754,7 +754,7 @@ class ExerciseLib
Display::input(
'radio',
'choice['.$questionId.']['.$numAnswer.']',
$id,
$id + 1,
$attributes
),
['style' => '']

@ -564,8 +564,8 @@ class ExerciseShowFunctions
$course_id = api_get_course_int_id();
$new_options = Question::readQuestionOption($questionId, $course_id);
// Your choice
if (isset($new_options[$studentChoice])) {
$content .= get_lang($new_options[$studentChoice]['name']);
if (isset($new_options[$studentChoice - 1])) {
$content .= get_lang($new_options[$studentChoice - 1]['name']);
} else {
$content .= '-';
}
@ -576,8 +576,8 @@ class ExerciseShowFunctions
if ($exercise->showExpectedChoiceColumn()) {
if (!$hide_expected_answer) {
$content .= '<td width="5%">';
if (isset($new_options[$answerCorrect])) {
$content .= get_lang($new_options[$answerCorrect]['name']);
if (isset($new_options[$answerCorrect - 1])) {
$content .= get_lang($new_options[$answerCorrect - 1]['name']);
} else {
$content .= '-';
}
@ -605,7 +605,7 @@ class ExerciseShowFunctions
if (EXERCISE_FEEDBACK_TYPE_EXAM != $feedbackType) {
$content .= '<td width="20%">';
$color = 'black';
if (isset($new_options[$studentChoice]) || in_array(
if (isset($new_options[$studentChoice - 1]) || in_array(
$exercise->results_disabled,
[
RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER,

Loading…
Cancel
Save