From 9c8e481f068284b9f56ee3910048d1552a9fd592 Mon Sep 17 00:00:00 2001 From: Eric Marguin Date: Fri, 15 Feb 2008 12:40:43 +0100 Subject: [PATCH] [svn r14300] fix bugs in matching question (appearing in some particular cases) FS#2228 --- main/exercice/exercise_result.php | 4 ++-- main/exercice/exercise_show.php | 25 +++++++++++++------------ 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/main/exercice/exercise_result.php b/main/exercice/exercise_result.php index 97e0d1b2a7..b7d568a956 100644 --- a/main/exercice/exercise_result.php +++ b/main/exercice/exercise_result.php @@ -25,7 +25,7 @@ * @package dokeos.exercise * @author Olivier Brouckaert, main author * @author Roan Embrechts, some refactoring -* @version $Id: exercise_result.php 13988 2007-12-14 05:05:51Z yannoo $ +* @version $Id: exercise_result.php 14300 2008-02-15 11:40:43Z elixir_inter $ * * @todo split more code up in functions, move functions to library? */ @@ -777,7 +777,7 @@ $exerciseTitle=api_parse_tex($exerciseTitle); $val = $arr1[1][0]; $val=addslashes($val); $val=strip_tags($val); - $sql = "select position from $table_ans where question_id=$questionId and answer='$val'"; + $sql = "select position from $table_ans where question_id=$questionId and answer='$val' AND correct=0"; $res = api_sql_query($sql, __FILE__, __LINE__); $answer = mysql_result($res,0,"position"); diff --git a/main/exercice/exercise_show.php b/main/exercice/exercise_show.php index a8e0a24573..601a50cb8b 100644 --- a/main/exercice/exercise_show.php +++ b/main/exercice/exercise_show.php @@ -648,21 +648,22 @@ $result =api_sql_query($query, __FILE__, __LINE__); $i_answer_correct_answer = $a_answers['correct']; $i_answer_position = $a_answers['position']; - $sql_user_answer = 'SELECT answers.answer - FROM '.$table_ans.' as answers - INNER JOIN '.$TBL_TRACK_ATTEMPT.' as track_e_attempt - ON track_e_attempt.answer=answers.position - AND track_e_attempt.position="'.$i_answer_position.'" - AND exe_id = "'.$id.'" - WHERE answers.question_id ="'.$questionId.'" - AND correct=0'; - + $sql_user_answer = + 'SELECT answers.answer + FROM '.$TBL_TRACK_ATTEMPT.' as track_e_attempt + INNER JOIN '.$table_ans.' as answers + ON answers.position = track_e_attempt.answer + AND track_e_attempt.question_id=answers.question_id + WHERE answers.correct = 0 + AND track_e_attempt.exe_id = "'.$id.'" + AND track_e_attempt.question_id = "'.$questionId.'" + AND track_e_attempt.position="'.$i_answer_position.'"'; + + $res_user_answer = api_sql_query($sql_user_answer, __FILE__, __LINE__); $s_user_answer = mysql_result($res_user_answer,0,0); - $sql_correct_answer = 'SELECT answer FROM '.$table_ans.' WHERE position = "'.$i_answer_correct_answer.'" AND question_id="'.$questionId.'"'; - $res_correct_answer = api_sql_query($sql_correct_answer, __FILE__, __LINE__); - $s_correct_answer = mysql_result($res_correct_answer,0,0); + $s_correct_answer = $s_answer_label; $i_answerWeighting=$objAnswerTmp->selectWeighting($i_answer_id);