diff --git a/main/exercice/exercise.class.php b/main/exercice/exercise.class.php index 9d606f1eaf..9d17ddfca6 100755 --- a/main/exercice/exercise.class.php +++ b/main/exercice/exercise.class.php @@ -1779,8 +1779,7 @@ class Exercise { if ($debug) error_log('manage_answer $from_database '.$from_database); if ($debug) error_log('manage_answer $show_result '.$show_result); if ($debug) error_log('manage_answer $propagate_neg '.$propagate_neg); - if ($debug) error_log('manage_answer $$hotspot_delineation_result '.print_r($hotspot_delineation_result, 1)); - + if ($debug) error_log('manage_answer $$hotspot_delineation_result '.print_r($hotspot_delineation_result, 1)); $extra_data = array(); $html = ''; @@ -1791,7 +1790,7 @@ class Exercise { $table_ans = Database::get_course_table(TABLE_QUIZ_ANSWER); // Creates a temporary Question object - $objQuestionTmp = Question :: read($questionId); + $objQuestionTmp = Question::read($questionId); $questionName = $objQuestionTmp->selectTitle(); $questionDescription = $objQuestionTmp->selectDescription(); @@ -1803,7 +1802,7 @@ class Exercise { $next = 1; //not for now //Extra information of the question - if (!empty($extra)){ + if (!empty($extra)) { $extra = explode(':', $extra); $true_score = $extra[0]; $false_score = $extra[1]; @@ -1931,7 +1930,7 @@ class Exercise { break; case MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE: if ($from_database) { - $queryans = "SELECT answer FROM ".$TBL_TRACK_ATTEMPT." where exe_id = '".$exeId."' and question_id= '".$questionId."'"; + $queryans = "SELECT answer FROM ".$TBL_TRACK_ATTEMPT." where exe_id = ".$exeId." AND question_id= ".$questionId; $resultans = Database::query($queryans); while ($row = Database::fetch_array($resultans)) { $ind = $row['answer']; @@ -1939,11 +1938,20 @@ class Exercise { $my_answer_id = $result[0]; $option = $result[1]; $choice[$my_answer_id] = $option; - } - - $numAnswer=$objAnswerTmp->selectAutoId($answerId); - $studentChoice=$choice[$numAnswer]; - + } + $numAnswer = $objAnswerTmp->selectAutoId($answerId); + $studentChoice = $choice[$numAnswer]; + + if ($answerCorrect == $studentChoice) { + //$answerCorrect = 1; + $real_answers[$answerId] = true; + } else { + //$answerCorrect = 0; + $real_answers[$answerId] = false; + } + + + /* if ($answerCorrect == 1) { if ($studentChoice == 1) { //true value see MultipleAnswerCombinationTrueFalse class $real_answers[$answerId] = true; @@ -1960,10 +1968,19 @@ class Exercise { } else { $real_answers[$answerId] = true; } - } + }*/ } else { - $studentChoice=$choice[$numAnswer]; - if ($answerCorrect == 1) { + $studentChoice = $choice[$numAnswer]; + + if ($answerCorrect == $studentChoice) { + //$answerCorrect = 1; + $real_answers[$answerId] = true; + } else { + //$answerCorrect = 0; + $real_answers[$answerId] = false; + } + + /*if ($answerCorrect == 1) { if ($studentChoice == 1) { //true value see MultipleAnswerCombinationTrueFalse class $real_answers[$answerId] = true; } elseif ($studentChoice == 2) { //false value @@ -1979,14 +1996,15 @@ class Exercise { } else { $real_answers[$answerId] = true; } - } + } */ $final_answer = true; foreach($real_answers as $my_answer) { if (!$my_answer) { $final_answer = false; } } - } + } + break; case MULTIPLE_ANSWER_COMBINATION: if ($from_database) { diff --git a/main/exercice/exercise_show.php b/main/exercice/exercise_show.php index 473dbf1dda..515fc15e04 100755 --- a/main/exercice/exercise_show.php +++ b/main/exercice/exercise_show.php @@ -318,7 +318,7 @@ foreach ($questionList as $questionId) { $questionScore = $question_result['score']; $totalScore += $question_result['score']; } elseif ($answerType == MULTIPLE_ANSWER_COMBINATION || $answerType == MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE) { - $choice=array(); + $choice = array(); $question_result = $objExercise->manage_answer($id, $questionId, $choice,'exercise_show', array(), false, true, $show_results, $objExercise->selectPropagateNeg()); $questionScore = $question_result['score']; $totalScore += $question_result['score']; @@ -415,8 +415,7 @@ foreach ($questionList as $questionId) { if ($final_excess>100) { $final_excess = 100; - } - + } $table_resume='
| options[$studentChoice])) { echo $question->options[$studentChoice]; } else { @@ -313,18 +312,17 @@ class ExerciseShowFunctions { | options[$answerCorrect])) { echo $question->options[$answerCorrect]; } else { echo $question->options[2]; } - ?> - + ?> | @@ -332,16 +330,13 @@ class ExerciseShowFunctions { | '.nl2br(make_clickable($answerComment)).''; - } else { - echo ''.nl2br(make_clickable($answerComment)).''; - } - } else { - echo ' '; - } + + if ($studentChoice == $answerCorrect) { + echo ''.nl2br(make_clickable($answerComment)).''; + } else { + echo ''.nl2br(make_clickable($answerComment)).''; + } + ?> |