Merge pull request #5055 from christianbeeznest/ofaj-21266-3

Exercise: Improve display and results of multiple_true_false - refs BT#21266
pull/5058/head
christianbeeznest 2 years ago committed by GitHub
commit d45f62f53b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      public/main/exercise/multiple_answer_true_false.class.php
  2. 4
      public/main/inc/lib/exercise.lib.php
  3. 17
      public/main/inc/lib/exercise_show_functions.lib.php

@ -121,7 +121,7 @@ class MultipleAnswerTrueFalse extends Question
if (isset($_POST['correct']) && isset($_POST['correct'][$i]) && $j == $_POST['correct'][$i]) { if (isset($_POST['correct']) && isset($_POST['correct'][$i]) && $j == $_POST['correct'][$i]) {
$rdoCorrect->setValue(Security::remove_XSS($_POST['correct'][$i])); $rdoCorrect->setValue(Security::remove_XSS($_POST['correct'][$i]));
} else { } else {
$rdoCorrect->setValue($j); $rdoCorrect->setValue($data['iid']);
} }
$j++; $j++;
if (3 == $j) { if (3 == $j) {

@ -634,7 +634,7 @@ class ExerciseLib
if (!empty($quizQuestionOptions)) { if (!empty($quizQuestionOptions)) {
$j = 1; $j = 1;
foreach ($quizQuestionOptions as $id => $item) { foreach ($quizQuestionOptions as $id => $item) {
if (isset($myChoice[$numAnswer]) && $j == $myChoice[$numAnswer]) { if (isset($myChoice[$numAnswer]) && $item['iid'] == $myChoice[$numAnswer]) {
$attributes = [ $attributes = [
'checked' => 1, 'checked' => 1,
'selected' => 1, 'selected' => 1,
@ -654,7 +654,7 @@ class ExerciseLib
Display::input( Display::input(
'radio', 'radio',
'choice['.$questionId.']['.$numAnswer.']', 'choice['.$questionId.']['.$numAnswer.']',
$j, $item['iid'],
$attributes $attributes
), ),
['style' => ''] ['style' => '']

@ -542,11 +542,18 @@ class ExerciseShowFunctions
if (false === $hideStudentChoice) { if (false === $hideStudentChoice) {
$content .= '<td width="5%">'; $content .= '<td width="5%">';
$course_id = api_get_course_int_id(); $course_id = api_get_course_int_id();
$new_options = Question::readQuestionOption($questionId); $new_options = [];
$originOptions = Question::readQuestionOption($questionId);
if (!empty($originOptions)) {
foreach ($originOptions as $item) {
$new_options[$item['iid']] = $item;
}
}
// Your choice // Your choice
if (isset($new_options[$studentChoice - 1])) { if (isset($new_options[$studentChoice])) {
$content .= get_lang($new_options[$studentChoice - 1]['name']); $content .= get_lang($new_options[$studentChoice]['name']);
} else { } else {
$content .= '-'; $content .= '-';
} }
@ -557,8 +564,8 @@ class ExerciseShowFunctions
if ($exercise->showExpectedChoiceColumn()) { if ($exercise->showExpectedChoiceColumn()) {
if (!$hide_expected_answer) { if (!$hide_expected_answer) {
$content .= '<td width="5%">'; $content .= '<td width="5%">';
if (isset($new_options[$answerCorrect - 1])) { if (isset($new_options[$answerCorrect])) {
$content .= get_lang($new_options[$answerCorrect - 1]['name']); $content .= get_lang($new_options[$answerCorrect]['name']);
} else { } else {
$content .= '-'; $content .= '-';
} }

Loading…
Cancel
Save