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 11 months 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]) {
$rdoCorrect->setValue(Security::remove_XSS($_POST['correct'][$i]));
} else {
$rdoCorrect->setValue($j);
$rdoCorrect->setValue($data['iid']);
}
$j++;
if (3 == $j) {

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

@ -542,11 +542,18 @@ class ExerciseShowFunctions
if (false === $hideStudentChoice) {
$content .= '<td width="5%">';
$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
if (isset($new_options[$studentChoice - 1])) {
$content .= get_lang($new_options[$studentChoice - 1]['name']);
if (isset($new_options[$studentChoice])) {
$content .= get_lang($new_options[$studentChoice]['name']);
} else {
$content .= '-';
}
@ -557,8 +564,8 @@ class ExerciseShowFunctions
if ($exercise->showExpectedChoiceColumn()) {
if (!$hide_expected_answer) {
$content .= '<td width="5%">';
if (isset($new_options[$answerCorrect - 1])) {
$content .= get_lang($new_options[$answerCorrect - 1]['name']);
if (isset($new_options[$answerCorrect])) {
$content .= get_lang($new_options[$answerCorrect]['name']);
} else {
$content .= '-';
}

Loading…
Cancel
Save