Skip to content

Commit

Permalink
Fix exercise results page from ofaj_dev
Browse files Browse the repository at this point in the history
  • Loading branch information
jmontoyaa committed Aug 7, 2019
1 parent 032d063 commit 74fa0a3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 27 deletions.
12 changes: 6 additions & 6 deletions main/exercise/exercise.class.php
Expand Up @@ -3632,8 +3632,8 @@ public function manage_answer(
if ($from_database) {
$sql = "SELECT answer FROM $TBL_TRACK_ATTEMPT
WHERE
exe_id = '".$exeId."' AND
question_id= '".$questionId."'";
exe_id = $exeId AND
question_id = $questionId";
$result = Database::query($sql);
$choice = Database::result($result, 0, 'answer');

Expand Down Expand Up @@ -3829,7 +3829,7 @@ public function manage_answer(
if ($from_database) {
$choice = [];
$sql = "SELECT answer FROM $TBL_TRACK_ATTEMPT
WHERE exe_id = $exeId AND question_id= $questionId";
WHERE exe_id = $exeId AND question_id = $questionId";
$resultans = Database::query($sql);
while ($row = Database::fetch_array($resultans)) {
$choice[$row['answer']] = 1;
Expand Down Expand Up @@ -4260,7 +4260,7 @@ public function manage_answer(
FROM $TBL_TRACK_ATTEMPT
WHERE
exe_id = $exeId AND
question_id= ".intval($questionId);
question_id = $questionId";
$result = Database::query($sql);
$resultData = Database::fetch_array($result, 'ASSOC');
$answer = $resultData['answer'];
Expand Down Expand Up @@ -4460,7 +4460,7 @@ public function manage_answer(
}

if ($show_result) {
if ($this->showExpectedChoice() == false &&
if ($this->showExpectedChoice() === false &&
$showTotalScoreAndUserChoicesInLastAttempt === false
) {
$user_answer = '';
Expand Down Expand Up @@ -4585,7 +4585,7 @@ public function manage_answer(
WHERE
hotspot_exe_id = $exeId AND
hotspot_question_id= $questionId AND
hotspot_answer_id = ".intval($answerAutoId)."
hotspot_answer_id = $answerAutoId
ORDER BY hotspot_id ASC";
$result = Database::query($sql);
if (Database::num_rows($result)) {
Expand Down
34 changes: 13 additions & 21 deletions main/inc/lib/exercise_show_functions.lib.php
Expand Up @@ -339,23 +339,12 @@ public static function display_unique_or_multiple_answer(

$studentChoiceInt = (int) $studentChoice;
$answerCorrectChoice = (int) $answerCorrect;
$hideStudentChoice = false;
$hide_expected_answer = false;

$status = '';
if ($exercise->showExpectedChoice()) {
$status = Display::label(get_lang('Incorrect'), 'danger');
if ($answerCorrect || ($answerCorrect && $studentChoiceInt === $answerCorrectChoice)) {
$status = Display::label(get_lang('Correct'), 'success');
}
}

$hide_expected_answer = false;
$showComment = false;
switch ($resultsDisabled) {
case RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER:
$hideStudentChoice = false;
$hide_expected_answer = true;
$status = Display::label(get_lang('Correct'), 'success');
$showComment = true;
if (!$answerCorrect && empty($studentChoice)) {
return '';
Expand Down Expand Up @@ -397,17 +386,20 @@ public static function display_unique_or_multiple_answer(
}

echo '<tr class="'.$studentChoiceClass.'">';
if ($hideStudentChoice === false) {
echo '<td width="5%">';
echo Display::return_icon($icon, null, null, ICON_SIZE_TINY);
echo '</td>';
}

if (!$hide_expected_answer) {
if ($exercise->showExpectedChoiceColumn()) {
echo '<td width="5%">';
echo Display::return_icon($icon, null, null, ICON_SIZE_TINY);
echo '</td>';

if ($exercise->showExpectedChoiceColumn()) {
if ($hide_expected_answer === false) {
echo '<td width="5%">';
echo Display::return_icon($iconAnswer, null, null, ICON_SIZE_TINY);
echo '</td>';
} else {
echo '<td width="5%">';
echo '-';
echo '</td>';
}
}

Expand Down Expand Up @@ -514,8 +506,8 @@ public static function display_multiple_answer_true_false(
}

// Expected choice
if (!$hide_expected_answer) {
if ($exercise->showExpectedChoiceColumn()) {
if ($exercise->showExpectedChoiceColumn()) {
if (!$hide_expected_answer) {
$content .= '<td width="5%">';
if (isset($new_options[$answerCorrect])) {
$content .= get_lang($new_options[$answerCorrect]['name']);
Expand Down

0 comments on commit 74fa0a3

Please sign in to comment.