From 1a1e2f8116158d6d49330c1f612a8b5f9c02d95d Mon Sep 17 00:00:00 2001 From: Cristian Fasanando Date: Mon, 14 Dec 2009 17:01:03 -0500 Subject: [PATCH] fixed result of exercises when you display for one answer --- main/exercice/answer.class.php | 7 ++++--- main/exercice/exercise_show.php | 11 +++++++++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/main/exercice/answer.class.php b/main/exercice/answer.class.php index d4fb7061d5..7cea53d3dd 100755 --- a/main/exercice/answer.class.php +++ b/main/exercice/answer.class.php @@ -80,8 +80,9 @@ class Answer $this->cancel(); // fills arrays - Exercise::read($_REQUEST['exerciseId']); - if($this->random_answers=='1') + $objExercise = new Exercise(); + $objExercise->read($_REQUEST['exerciseId']); + if($objExercise->random_answers=='1') { $this->readOrderedBy('rand()', '');// randomize answers } @@ -198,7 +199,7 @@ class Answer /** * returns the autoincrement id identificator * - * @author - Juan Carlos Raña + * @author - Juan Carlos Ra�a * @return - integer - answer num */ function selectAutoId($id) diff --git a/main/exercice/exercise_show.php b/main/exercice/exercise_show.php index abc5a217e9..478977d2cd 100755 --- a/main/exercice/exercise_show.php +++ b/main/exercice/exercise_show.php @@ -577,7 +577,11 @@ if ($show_results) { $ind = $row['answer']; $choice[$ind] = 1; } - $studentChoice=$choice[$answerId]; + + $numAnswer=$objAnswerTmp->selectAutoId($answerId); + + $studentChoice=$choice[$numAnswer]; + if ($studentChoice) { $questionScore+=$answerWeighting; $totalScore+=$answerWeighting; @@ -619,7 +623,10 @@ if ($show_results) { $queryans = "select answer from ".$TBL_TRACK_ATTEMPT." where exe_id = '".Database::escape_string($id)."' and question_id= '".Database::escape_string($questionId)."'"; $resultans = Database::query($queryans, __FILE__, __LINE__); $choice = Database::result($resultans,0,"answer"); - $studentChoice=($choice == $answerId)?1:0; + + $numAnswer=$objAnswerTmp->selectAutoId($answerId); + + $studentChoice=($choice == $numAnswer)?1:0; if ($studentChoice) { $questionScore+=$answerWeighting; $totalScore+=$answerWeighting;