Fix RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER option BT#15233

pull/2864/head
Julio 7 years ago
parent f7441c566f
commit 72bb2bf70c
  1. 8
      main/exercise/MatchingDraggable.php
  2. 23
      main/exercise/exercise.class.php
  3. 17
      main/exercise/fill_blanks.class.php
  4. 3
      main/exercise/hotspot_answers.as.php
  5. 9
      main/exercise/matching.class.php
  6. 6
      main/exercise/multiple_answer.class.php
  7. 12
      main/exercise/multiple_answer_combination.class.php
  8. 8
      main/exercise/multiple_answer_true_false.class.php
  9. 7
      main/exercise/unique_answer.class.php
  10. 5
      main/exercise/unique_answer_no_option.class.php
  11. 41
      main/inc/lib/exercise_show_functions.lib.php

@ -265,13 +265,15 @@ 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->showExpectedChoice()) {
if ($exercise->results_disabled != RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER) {
$header .= '<th>'.get_lang('ElementList').'</th>';
$header .= '<th>'.get_lang('YourChoice').'</th>';
}
if ($exercise->showExpectedChoice()) {
$header .= '<th>'.get_lang('ExpectedChoice').'</th>';
$header .= '<th>'.get_lang('Status').'</th>';
} else {
$header .= '<th>'.get_lang('YourChoice').'</th>';
$header .= '<th>'.get_lang('CorrespondsTo').'</th>';
}
$header .= '</tr>';

@ -4187,6 +4187,7 @@ class Exercise
$s_answer_label = $a_answers['answer']; // your daddy - your mother
$i_answer_correct_answer = $a_answers['correct']; //1 - 2
$i_answer_id_auto = $a_answers['id_auto']; // 3 - 4
$sql = "SELECT answer FROM $TBL_TRACK_ATTEMPT
WHERE
exe_id = '$exeId' AND
@ -4201,6 +4202,7 @@ class Exercise
$i_answerWeighting = $a_answers['ponderation'];
$user_answer = '';
$status = Display::label(get_lang('Incorrect'), 'danger');
if (!empty($s_user_answer)) {
if ($answerType == DRAGGABLE) {
if ($s_user_answer == $i_answer_correct_answer) {
@ -4275,12 +4277,6 @@ class Exercise
}
}
if ($results_disabled == RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER) {
if ($s_user_answer != $i_answer_correct_answer) {
continue;
}
}
if ($show_result) {
if ($this->showExpectedChoice() == false &&
$showTotalScoreAndUserChoicesInLastAttempt === false
@ -4291,9 +4287,14 @@ class Exercise
case MATCHING:
case MATCHING_DRAGGABLE:
echo '<tr>';
if ($this->showExpectedChoice()) {
if ($this->results_disabled != RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER) {
echo '<td>'.$s_answer_label.'</td>';
echo '<td>'.$user_answer.'</td>';
} else {
$status = Display::label(get_lang('Correct'), 'success');
}
if ($this->showExpectedChoice()) {
echo '<td>';
if (in_array($answerType, [MATCHING, MATCHING_DRAGGABLE])) {
if (isset($real_list[$i_answer_correct_answer]) &&
@ -4307,8 +4308,6 @@ class Exercise
echo '</td>';
echo '<td>'.$status.'</td>';
} else {
echo '<td>'.$s_answer_label.'</td>';
echo '<td>'.$user_answer.'</td>';
echo '<td>';
if (in_array($answerType, [MATCHING, MATCHING_DRAGGABLE])) {
if (isset($real_list[$i_answer_correct_answer]) &&
@ -4330,7 +4329,11 @@ class Exercise
}
echo '<tr>';
if ($this->showExpectedChoice()) {
echo '<td>'.$user_answer.'</td>';
if ($this->results_disabled != RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER) {
echo '<td>'.$user_answer.'</td>';
} else {
$status = Display::label(get_lang('Correct'), 'success');
}
echo '<td>'.$s_answer_label.'</td>';
echo '<td>'.$status.'</td>';
} else {

@ -1231,14 +1231,9 @@ class FillBlanks extends Question
// rebuild the sentence with student answer inserted
for ($i = 0; $i < count($listStudentAnswerInfo['common_words']); $i++) {
if ($resultsDisabled == RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER) {
if (isset($listStudentAnswerInfo['student_score'][$i]) &&
$listStudentAnswerInfo['student_score'][$i] != 1) {
continue;
}
}
$result .= isset($listStudentAnswerInfo['common_words'][$i]) ? $listStudentAnswerInfo['common_words'][$i] : '';
$result .= isset($listStudentAnswerInfo['student_answer'][$i]) ? $listStudentAnswerInfo['student_answer'][$i] : '';
$studentLabel = isset($listStudentAnswerInfo['student_answer'][$i]) ? $listStudentAnswerInfo['student_answer'][$i] : '';
$result .= $studentLabel;
}
// the last common word (should be </p>)
@ -1268,7 +1263,11 @@ class FillBlanks extends Question
$showTotalScoreAndUserChoices = false
) {
$hideExpectedAnswer = false;
$hideUserSelection = false;
switch ($resultsDisabled) {
case RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER:
$hideUserSelection = true;
break;
case RESULT_DISABLE_SHOW_SCORE_ONLY:
if ($feedbackType == 0) {
$hideExpectedAnswer = true;
@ -1325,7 +1324,9 @@ class FillBlanks extends Question
}
$result = "<span class='feedback-question'>";
$result .= $iconAnswer."<span class='$style'>".$answer."</span>";
if ($hideUserSelection === false) {
$result .= $iconAnswer."<span class='$style'>".$answer."</span>";
}
$result .= "<span class='feedback-separator'>|</span>";
$result .= $correctAnswerHtml;
$result .= '</span>';

@ -168,6 +168,7 @@ if (!$hideExpectedAnswer) {
$hotSpotAnswerId = $hotSpotAnswer->getIid();
// Show only correct hotspots
/*
if ($objExercise->selectResultsDisabled() == RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER) {
$TBL_TRACK_HOTSPOT = Database::get_main_table(TABLE_STATISTIC_TRACK_E_HOTSPOT);
// Check auto id
@ -191,7 +192,7 @@ if (!$hideExpectedAnswer) {
if (!$studentChoice) {
continue;
}
}
}*/
$hotSpot = [];
$hotSpot['id'] = $hotSpotAnswerId;

@ -285,13 +285,16 @@ class Matching extends Question
$header = parent::return_header($exercise, $counter, $score);
$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>';
}
if ($exercise->showExpectedChoice()) {
$header .= '<th>'.get_lang('YourChoice').'</th>';
$header .= '<th>'.get_lang('ExpectedChoice').'</th>';
$header .= '<th>'.get_lang('Status').'</th>';
} else {
$header .= '<th>'.get_lang('YourChoice').'</th>';
$header .= '<th>'.get_lang('CorrespondsTo').'</th>';
}
$header .= '</tr>';

@ -231,7 +231,11 @@ class MultipleAnswer extends Question
{
$header = parent::return_header($exercise, $counter, $score);
$header .= '<table class="'.$this->question_table_class.'"><tr>';
$header .= '<th>'.get_lang('Choice').'</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()) {

@ -228,10 +228,14 @@ class MultipleAnswerCombination extends Question
public function return_header($exercise, $counter = null, $score = null)
{
$header = parent::return_header($exercise, $counter, $score);
$header .= '<table class="'.$this->question_table_class.'"><tr>
<th>'.get_lang('Choice').'</th>
<th>'.get_lang('ExpectedChoice').'</th>
<th>'.get_lang('Answer').'</i></th>';
$header .= '<table class="'.$this->question_table_class.'"><tr>';
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>';
}

@ -310,8 +310,12 @@ class MultipleAnswerTrueFalse extends Question
{
$header = parent::return_header($exercise, $counter, $score);
$header .= '<table class="'.$this->question_table_class.'"><tr>';
$header .= '<th>'.get_lang('Choice').'</th>
<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>
<th>'.get_lang('Answer').'</th>';
if ($exercise->showExpectedChoice()) {
$header .= '<th>'.get_lang('Status').'</th>';

@ -122,7 +122,6 @@ class UniqueAnswer extends Question
}
$temp_scenario = [];
if ($nb_answers < 1) {
$nb_answers = 1;
echo Display::return_message(
@ -416,7 +415,11 @@ class UniqueAnswer extends Question
) {
$header = parent::return_header($exercise, $counter, $score);
$header .= '<table class="'.$this->question_table_class.'"><tr>';
$header .= '<th>'.get_lang('Choice').'</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()) {

@ -401,7 +401,10 @@ class UniqueAnswerNoOption extends Question
{
$header = parent::return_header($exercise, $counter, $score);
$header .= '<table class="'.$this->question_table_class.'"><tr>';
$header .= '<th>'.get_lang('Choice').'</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()) {

@ -190,12 +190,6 @@ class ExerciseShowFunctions
echo Security::remove_XSS($answer);
}
echo '</td>';
if (!api_is_allowed_to_edit(null, true) && $feedback_type != EXERCISE_FEEDBACK_TYPE_EXAM) {
echo '<td>';
$comm = Event::get_comments($id, $questionId);
echo '</td>';
}
echo '</tr>';
}
}
@ -336,14 +330,20 @@ class ExerciseShowFunctions
$studentChoiceInt = (int) $studentChoice;
$answerCorrectChoice = (int) $answerCorrect;
$hideStudentChoice = false;
$hide_expected_answer = false;
$status = '';
if ($exercise->showExpectedChoice()) {
$status = Display::label(get_lang('Incorrect'), 'danger');
if ($studentChoiceInt === $answerCorrectChoice) {
$status = Display::label(get_lang('Correct'), 'success');
}
}
switch ($resultsDisabled) {
case RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER:
if ($studentChoiceInt !== $answerCorrectChoice) {
return '';
}
$hideStudentChoice = true;
$status = Display::label(get_lang('Correct'), 'success');
if (!$answerCorrect) {
return '';
}
@ -370,23 +370,24 @@ class ExerciseShowFunctions
$iconAnswer .= '.png';
echo '<tr>';
if ($hideStudentChoice === false) {
echo '<td width="5%">';
echo Display::return_icon($icon, null, null, ICON_SIZE_TINY);
echo '</td>';
}
echo '<td width="5%">';
echo Display::return_icon($icon, null, null, ICON_SIZE_TINY);
echo '</td><td width="5%">';
if (!$hide_expected_answer) {
echo Display::return_icon($iconAnswer, null, null, ICON_SIZE_TINY);
} else {
echo '-';
}
echo '</td><td width="40%">';
echo $answer;
echo '</td>';
if ($exercise->showExpectedChoice()) {
$status = Display::label(get_lang('Incorrect'), 'danger');
if ($studentChoiceInt === $answerCorrectChoice) {
$status = Display::label(get_lang('Correct'), 'success');
}
echo '<td width="20%">';
echo $status;
echo '</td>';
@ -413,9 +414,6 @@ class ExerciseShowFunctions
echo $comment;
}
echo '</td>';
if ($ans == 1) {
$comm = Event::get_comments($id, $questionId);
}
} else {
echo '<td>&nbsp;</td>';
}
@ -708,9 +706,6 @@ class ExerciseShowFunctions
echo '<span style="font-weight: bold; color: '.$color.';">'.nl2br($answerComment).'</span>';
}
echo '</td>';
if ($ans == 1) {
$comm = Event::get_comments($id, $questionId);
}
} else {
echo '<td>&nbsp;</td>';
}

Loading…
Cancel
Save