Exercise: Consider score by answer for multiple answer dropdown - refs BT#20086

pull/4394/head
Angel Fernando Quiroz Campos 3 years ago
parent 98d479a5a2
commit 69fb4e8f84
  1. 11
      main/exercise/exercise.class.php

@ -3915,7 +3915,9 @@ class Exercise
} }
if (in_array($answerType, [MULTIPLE_ANSWER_DROPDOWN, MULTIPLE_ANSWER_DROPDOWN_GLOBAL])) { if (in_array($answerType, [MULTIPLE_ANSWER_DROPDOWN, MULTIPLE_ANSWER_DROPDOWN_GLOBAL])) {
if (MULTIPLE_ANSWER_DROPDOWN_GLOBAL == $answerType) {
$questionScore = $questionWeighting; $questionScore = $questionWeighting;
}
if ($from_database) { if ($from_database) {
$studentChoices = Database::store_result( $studentChoices = Database::store_result(
@ -3941,7 +3943,9 @@ class Exercise
$correctChoices = array_keys($correctChoices); $correctChoices = array_keys($correctChoices);
if (array_diff($studentChoices, $correctChoices) || array_diff($correctChoices, $studentChoices)) { if (MULTIPLE_ANSWER_DROPDOWN_GLOBAL == $answerType
&& (array_diff($studentChoices, $correctChoices) || array_diff($correctChoices, $studentChoices))
) {
$questionScore = 0; $questionScore = 0;
} }
@ -4103,6 +4107,7 @@ class Exercise
$totalScore = $questionScore; $totalScore = $questionScore;
break; break;
case MULTIPLE_ANSWER: case MULTIPLE_ANSWER:
case MULTIPLE_ANSWER_DROPDOWN:
if ($from_database) { if ($from_database) {
$choice = []; $choice = [];
$sql = "SELECT answer FROM $TBL_TRACK_ATTEMPT $sql = "SELECT answer FROM $TBL_TRACK_ATTEMPT
@ -4122,7 +4127,9 @@ class Exercise
$studentChoice = isset($choice[$answerAutoId]) ? $choice[$answerAutoId] : null; $studentChoice = isset($choice[$answerAutoId]) ? $choice[$answerAutoId] : null;
$real_answers[$answerId] = (bool) $studentChoice; $real_answers[$answerId] = (bool) $studentChoice;
if (isset($studentChoice)) { if (isset($studentChoice)
|| (MULTIPLE_ANSWER_DROPDOWN == $answerType && in_array($answerAutoId, $choice))
) {
$correctAnswerId[] = $answerAutoId; $correctAnswerId[] = $answerAutoId;
$questionScore += $answerWeighting; $questionScore += $answerWeighting;
} }

Loading…
Cancel
Save