Fix RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER option BT#15233

pull/2864/head
Julio 7 years ago
parent c4fee51b3b
commit d0ecc6c54c
  1. 3
      main/exercise/MatchingDraggable.php
  2. 1
      main/exercise/exercise.class.php
  3. 7
      main/exercise/global_multiple_answer.class.php
  4. 4
      main/exercise/matching.class.php
  5. 2
      main/exercise/multiple_answer.class.php
  6. 2
      main/exercise/multiple_answer_combination.class.php
  7. 10
      main/exercise/multiple_answer_true_false.class.php
  8. 2
      main/exercise/unique_answer.class.php
  9. 2
      main/exercise/unique_answer_no_option.class.php
  10. 138
      main/inc/lib/exercise_show_functions.lib.php

@ -264,9 +264,8 @@ class MatchingDraggable extends Question
{
$header = parent::return_header($exercise, $counter, $score);
$header .= '<table class="matching '.$this->question_table_class.'"><tr>';
$header .= '<th>'.get_lang('ElementList').'</th>';
if ($exercise->results_disabled != RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER) {
$header .= '<th>'.get_lang('ElementList').'</th>';
$header .= '<th>'.get_lang('YourChoice').'</th>';
}

@ -4291,6 +4291,7 @@ class Exercise
echo '<td>'.$s_answer_label.'</td>';
echo '<td>'.$user_answer.'</td>';
} else {
echo '<td>'.$s_answer_label.'</td>';
$status = Display::label(get_lang('Correct'), 'success');
}

@ -267,8 +267,11 @@ class GlobalMultipleAnswer extends Question
$header = parent::return_header($exercise, $counter, $score);
$header .= '<table class="'.$this->question_table_class.'"><tr>';
$header .= '<th>'.get_lang('Choice').'</th>';
$header .= '<th>'.get_lang('ExpectedChoice').'</th>';
if ($exercise->results_disabled != RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER) {
$header .= '<th>'.get_lang('Choice').'</th>';
$header .= '<th>'.get_lang('ExpectedChoice').'</th>';
}
$header .= '<th>'.get_lang('Answer').'</th>';
if ($exercise->showExpectedChoice()) {
$header .= '<th>'.get_lang('Status').'</th>';

@ -286,13 +286,13 @@ class Matching extends Question
$header .= '<table class="'.$this->question_table_class.'">';
$header .= '<tr>';
$header .= '<th>'.get_lang('ElementList').'</th>';
if ($exercise->results_disabled != RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER) {
$header .= '<th>'.get_lang('ElementList').'</th>';
$header .= '<th>'.get_lang('Choice').'</th>';
$header .= '<th>'.get_lang('ExpectedChoice').'</th>';
}
if ($exercise->showExpectedChoice()) {
$header .= '<th>'.get_lang('ExpectedChoice').'</th>';
$header .= '<th>'.get_lang('Status').'</th>';
} else {
$header .= '<th>'.get_lang('CorrespondsTo').'</th>';

@ -234,9 +234,9 @@ class MultipleAnswer extends Question
if ($exercise->results_disabled != RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER) {
$header .= '<th>'.get_lang('Choice').'</th>';
$header .= '<th>'.get_lang('ExpectedChoice').'</th>';
}
$header .= '<th>'.get_lang('ExpectedChoice').'</th>';
$header .= '<th>'.get_lang('Answer').'</th>';
if ($exercise->showExpectedChoice()) {
$header .= '<th>'.get_lang('Status').'</th>';

@ -232,9 +232,9 @@ class MultipleAnswerCombination extends Question
if ($exercise->results_disabled != RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER) {
$header .= '<th>'.get_lang('Choice').'</th>';
$header .= '<th>'.get_lang('ExpectedChoice').'</th>';
}
$header .= '<th>'.get_lang('ExpectedChoice').'</th>';
$header .= '<th>'.get_lang('Answer').'</th>';
if ($exercise->showExpectedChoice()) {
$header .= '<th>'.get_lang('Status').'</th>';

@ -313,17 +313,17 @@ class MultipleAnswerTrueFalse extends Question
if ($exercise->results_disabled != RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER) {
$header .= '<th>'.get_lang('Choice').'</th>';
$header .= '<th>'.get_lang('ExpectedChoice').'</th>';
}
$header .= '<th>'.get_lang('ExpectedChoice').'</th>
<th>'.get_lang('Answer').'</th>';
$header .= '<th>'.get_lang('Answer').'</th>';
if ($exercise->showExpectedChoice()) {
$header .= '<th>'.get_lang('Status').'</th>';
}
if ($exercise->feedback_type != EXERCISE_FEEDBACK_TYPE_EXAM) {
if ($exercise->feedback_type != EXERCISE_FEEDBACK_TYPE_EXAM ||
$exercise->results_disabled == RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER) {
$header .= '<th>'.get_lang('Comment').'</th>';
} else {
$header .= '<th>&nbsp;</th>';
}
$header .= '</tr>';

@ -418,9 +418,9 @@ class UniqueAnswer extends Question
if ($exercise->results_disabled != RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER) {
$header .= '<th>'.get_lang('Choice').'</th>';
$header .= '<th>'.get_lang('ExpectedChoice').'</th>';
}
$header .= '<th>'.get_lang('ExpectedChoice').'</th>';
$header .= '<th>'.get_lang('Answer').'</th>';
if ($exercise->showExpectedChoice()) {
$header .= '<th>'.get_lang('Status').'</th>';

@ -404,8 +404,8 @@ class UniqueAnswerNoOption extends Question
if ($exercise->results_disabled != RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER) {
$header .= '<th>'.get_lang('Choice').'</th>';
$header .= '<th>'.get_lang('ExpectedChoice').'</th>';
}
$header .= '<th>'.get_lang('ExpectedChoice').'</th>';
$header .= '<th>'.get_lang('Answer').'</th>';
if ($exercise->showExpectedChoice()) {
$header .= '<th>'.get_lang('Status').'</th>';

@ -45,10 +45,7 @@ class ExerciseShowFunctions
$resultsDisabled,
$showTotalScoreAndUserChoices
);
// ofaj
/*if (strpos($originalStudentAnswer, 'font color') !== false) {
$answerHTML = $originalStudentAnswer;
}*/
if (empty($id)) {
echo '<tr><td>';
echo Security::remove_XSS($answerHTML, COURSEMANAGERLOWSECURITY);
@ -340,10 +337,14 @@ class ExerciseShowFunctions
$status = Display::label(get_lang('Correct'), 'success');
}
}
$showComment = false;
switch ($resultsDisabled) {
case RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER:
$hideStudentChoice = true;
$hide_expected_answer = true;
$status = Display::label(get_lang('Correct'), 'success');
$showComment = true;
if (!$answerCorrect) {
return '';
}
@ -376,14 +377,13 @@ class ExerciseShowFunctions
echo '</td>';
}
echo '<td width="5%">';
if (!$hide_expected_answer) {
echo '<td width="5%">';
echo Display::return_icon($iconAnswer, null, null, ICON_SIZE_TINY);
} else {
echo '-';
echo '</td>';
}
echo '</td><td width="40%">';
echo '<td width="40%">';
echo $answer;
echo '</td>';
@ -393,30 +393,31 @@ class ExerciseShowFunctions
echo '</td>';
}
if ($feedbackType != EXERCISE_FEEDBACK_TYPE_EXAM) {
echo '<td width="20%">';
if ($studentChoice) {
$color = 'black';
if ($answerCorrect) {
$color = 'green';
}
if ($hide_expected_answer) {
$color = '';
}
$comment = '<span style="font-weight: bold; color: '.$color.';">'.
Security::remove_XSS($answerComment).
'</span>';
if ($feedbackType != EXERCISE_FEEDBACK_TYPE_EXAM && $studentChoice) {
$showComment = true;
if (!$answerCorrect && $resultsDisabled == RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER) {
$showComment = false;
}
}
if (!$answerCorrect && $resultsDisabled == RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER) {
$comment = '';
}
echo $comment;
if ($showComment) {
echo '<td width="20%">';
$color = 'black';
if ($answerCorrect) {
$color = 'green';
}
if ($hide_expected_answer) {
$color = '';
}
$comment = '<span style="font-weight: bold; color: '.$color.';">'.
Security::remove_XSS($answerComment).
'</span>';
echo $comment;
echo '</td>';
} else {
echo '<td>&nbsp;</td>';
}
echo '</tr>';
}
@ -448,7 +449,12 @@ class ExerciseShowFunctions
$showTotalScoreAndUserChoices
) {
$hide_expected_answer = false;
$hideStudentChoice = false;
switch ($resultsDisabled) {
case RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER:
$hideStudentChoice = true;
$hide_expected_answer = true;
break;
case RESULT_DISABLE_SHOW_SCORE_ONLY:
if ($feedbackType == 0) {
$hide_expected_answer = true;
@ -463,29 +469,36 @@ class ExerciseShowFunctions
break;
}
$content = '<tr><td width="5%">';
$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']);
} else {
$content .= '-';
$content = '<tr>';
if ($hideStudentChoice === false) {
$content .= '<td width="5%">';
$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']);
} else {
$content .= '-';
}
$content .= '</td>';
}
echo '</td><td width="5%">';
// Expected choice
if (!$hide_expected_answer) {
$content .= '<td width="5%">';
if (isset($new_options[$answerCorrect])) {
$content .= get_lang($new_options[$answerCorrect]['name']);
} else {
$content .= '-';
}
} else {
$content .= '-';
$content .= '</td>';
}
$content .= '</td><td width="40%">';
$content .= '<td width="40%">';
$content .= $answer;
$content .= '</td>';
if ($exercise->showExpectedChoice()) {
$status = Display::label(get_lang('Incorrect'), 'danger');
if (isset($new_options[$studentChoice])) {
@ -497,15 +510,11 @@ class ExerciseShowFunctions
$content .= $status;
$content .= '</td>';
}
if ($feedbackType != EXERCISE_FEEDBACK_TYPE_EXAM) {
if ($resultsDisabled == RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER) {
if ($studentChoice != $answerCorrect) {
return '';
}
}
$content .= '<td width="20%">';
$color = 'black';
if (isset($new_options[$studentChoice])) {
if (isset($new_options[$studentChoice]) || $resultsDisabled == RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER) {
if ($studentChoice == $answerCorrect) {
$color = 'green';
}
@ -516,8 +525,6 @@ class ExerciseShowFunctions
$content .= '<span style="font-weight: bold; color: '.$color.';">'.nl2br($answerComment).'</span>';
}
$content .= '</td>';
} else {
$content .= '<td>&nbsp;</td>';
}
$content .= '</tr>';
@ -639,7 +646,12 @@ class ExerciseShowFunctions
$showTotalScoreAndUserChoices
) {
$hide_expected_answer = false;
$hideStudentChoice = false;
switch ($resultsDisabled) {
case RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER:
$hideStudentChoice = true;
$hide_expected_answer = true;
break;
case RESULT_DISABLE_SHOW_SCORE_ONLY:
if ($feedbackType == 0) {
$hide_expected_answer = true;
@ -654,28 +666,32 @@ class ExerciseShowFunctions
break;
}
echo '<tr><td width="5%">';
// Your choice
$question = new MultipleAnswerCombinationTrueFalse();
if (isset($question->options[$studentChoice])) {
echo $question->options[$studentChoice];
} else {
echo $question->options[2];
echo '<tr>';
if ($hideStudentChoice === false) {
echo '<td width="5%">';
// Your choice
$question = new MultipleAnswerCombinationTrueFalse();
if (isset($question->options[$studentChoice])) {
echo $question->options[$studentChoice];
} else {
echo $question->options[2];
}
echo '</td>';
}
echo '</td><td width="5%">';
// Expected choice
if (!$hide_expected_answer) {
echo '<td width="5%">';
if (isset($question->options[$answerCorrect])) {
echo $question->options[$answerCorrect];
} else {
echo $question->options[2];
}
} else {
echo '-';
echo '</td>';
}
echo '</td>';
echo '<td width="40%">';
// my answer
echo $answer;
echo '</td>';
@ -695,10 +711,10 @@ class ExerciseShowFunctions
if ($feedbackType != EXERCISE_FEEDBACK_TYPE_EXAM) {
echo '<td width="20%">';
//@todo replace this harcoded value
if ($studentChoice) {
$color = "black";
if ($studentChoice || $resultsDisabled == RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER) {
$color = 'black';
if ($studentChoice == $answerCorrect) {
$color = "green";
$color = 'green';
}
if ($hide_expected_answer) {
$color = '';

Loading…
Cancel
Save