From 0acb42ab1c1c0d1f988c41c66310fbb5d169f486 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Thu, 6 Sep 2012 17:40:53 +0200 Subject: [PATCH] Fixing open question see #5392 --- main/exercice/exercise.class.php | 2 +- main/exercice/exercise_show.php | 11 +++--- main/inc/lib/events.lib.inc.php | 6 +-- main/inc/lib/exercise_show_functions.lib.php | 41 +++++++------------- 4 files changed, 24 insertions(+), 36 deletions(-) diff --git a/main/exercice/exercise.class.php b/main/exercice/exercise.class.php index dcef50bac9..b8169bae1b 100644 --- a/main/exercice/exercise.class.php +++ b/main/exercice/exercise.class.php @@ -2520,7 +2520,7 @@ class Exercise { } } elseif($answerType == FREE_ANSWER) { if($origin != 'learnpath') { - ExerciseShowFunctions::display_free_answer($choice,0,0); + ExerciseShowFunctions::display_free_answer($choice, $exeId, $questionId); } } elseif($answerType == ORAL_EXPRESSION) { // to store the details of open questions in an array to be used in mail diff --git a/main/exercice/exercise_show.php b/main/exercice/exercise_show.php index b177453bd2..c0e436314c 100644 --- a/main/exercice/exercise_show.php +++ b/main/exercice/exercise_show.php @@ -487,8 +487,8 @@ foreach ($questionList as $questionId) { } } - //if ($show_results) { - if (0) { + if ($show_results) { + //if (0) { echo ''; if ($is_allowedToEdit && $locked == false && !api_is_drh() ) { @@ -540,8 +540,7 @@ foreach ($questionList as $questionId) { echo '
'.$comnt.'
'; } echo ''; - echo Display::tag('td', nl2br(Security::remove_XSS($answer,COURSEMANAGERLOWSECURITY)), array('width'=>'55%')); - echo ''; - } - if ($feedback_type != EXERCISE_FEEDBACK_TYPE_EXAM) { - echo ''; - echo Display::tag('td', get_lang('notCorrectedYet'), array('width'=>'45%')); + static function display_free_answer($answer, $exe_id, $questionId) { + global $feedback_type; + + $comments = get_comments($exe_id, $questionId); + + if (!empty($answer)) { + echo ''; + } + + if ($feedback_type != EXERCISE_FEEDBACK_TYPE_EXAM) { + if (empty($comments)) { + echo ''; + echo Display::tag('td', Display::return_message(get_lang('notCorrectedYet')), array()); echo ''; - } else { - echo ''; } - } else { - echo ''; - if (!empty($answer)) { - echo ''; - } - if (!api_is_allowed_to_edit(null,true) && $feedback_type != EXERCISE_FEEDBACK_TYPE_EXAM) { - echo ''; - } - echo ''; } }
'; - } - + } if ($is_allowedToEdit) { if (in_array($answerType, array(FREE_ANSWER, ORAL_EXPRESSION))) { $marksname = "marksName".$questionId; @@ -558,8 +557,8 @@ foreach ($questionList as $questionId) { echo ''; echo '
'; if ($questionScore==-1 ) { - $questionScore=0; - echo '
'.get_lang('notCorrectedYet'); + $questionScore = 0; + echo Display::return_message(get_lang('notCorrectedYet')); } } else { $arrmarks[] = $questionId; diff --git a/main/inc/lib/events.lib.inc.php b/main/inc/lib/events.lib.inc.php index b74549830b..17677e55b1 100644 --- a/main/inc/lib/events.lib.inc.php +++ b/main/inc/lib/events.lib.inc.php @@ -1327,11 +1327,11 @@ function get_all_exercises_from_lp($lp_id, $course_id) { * @param int $question_id * @return str the comment */ -function get_comments($id,$question_id) { +function get_comments($exe_id, $question_id) { $table_track_attempt = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT); - $sql = "SELECT teacher_comment FROM ".$table_track_attempt." where exe_id='".Database::escape_string($id)."' and question_id = '".Database::escape_string($question_id)."' ORDER by question_id"; + $sql = "SELECT teacher_comment FROM ".$table_track_attempt." where exe_id='".Database::escape_string($exe_id)."' and question_id = '".Database::escape_string($question_id)."' ORDER by question_id"; $sqlres = Database::query($sql); - $comm = Database::result($sqlres,0,"teacher_comment"); + $comm = Database::result($sqlres, 0, "teacher_comment"); return $comm; } diff --git a/main/inc/lib/exercise_show_functions.lib.php b/main/inc/lib/exercise_show_functions.lib.php index 309b5d6542..25fccf0c58 100644 --- a/main/inc/lib/exercise_show_functions.lib.php +++ b/main/inc/lib/exercise_show_functions.lib.php @@ -55,34 +55,23 @@ class ExerciseShowFunctions { * @param int Question ID * @return void */ - static function display_free_answer($answer,$id,$questionId) { - global $feedback_type; - if (empty($id)) { - if (!empty($answer)) { - echo '
'; + echo nl2br(Security::remove_XSS($answer, COURSEMANAGERLOWSECURITY)); + echo '
 
'; - echo nl2br(Security::remove_XSS($answer,COURSEMANAGERLOWSECURITY)); - echo ''; - $comm = get_comments($id,$questionId); - echo '