From 5cd7f2cc12dfde6dd89d0fb70769b77d94936d67 Mon Sep 17 00:00:00 2001 From: Eric Marguin Date: Thu, 13 Sep 2007 11:39:21 +0200 Subject: [PATCH] [svn r13007] fix a bug when answering / previewing a survey : the options were not sorted --- main/survey/fillsurvey.php | 2 +- main/survey/preview.php | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/main/survey/fillsurvey.php b/main/survey/fillsurvey.php index 02e5e787ab..d922551013 100644 --- a/main/survey/fillsurvey.php +++ b/main/survey/fillsurvey.php @@ -252,7 +252,7 @@ if (isset($_GET['show'])) ON survey_question.question_id = survey_question_option.question_id WHERE survey_question.survey_id = '".Database::escape_string($survey_invitation['survey_id'])."' AND survey_question.question_id IN (".implode(',',$paged_questions[$_GET['show']]).") - ORDER BY survey_question.sort ASC"; + ORDER BY survey_question.sort, survey_question_option.sort ASC"; $result = api_sql_query($sql, __FILE__, __LINE__); $question_counter_max = mysql_num_rows($result); diff --git a/main/survey/preview.php b/main/survey/preview.php index 00ff07b041..a4b3101fde 100644 --- a/main/survey/preview.php +++ b/main/survey/preview.php @@ -129,7 +129,7 @@ else ON survey_question.question_id = survey_question_option.question_id WHERE survey_question.survey_id = '".Database::escape_string($_GET['survey_id'])."' AND survey_question.question_id IN (".implode(',',$paged_questions[$_GET['show']]).") - ORDER BY survey_question.sort ASC"; + ORDER BY survey_question.sort, survey_question_option.sort ASC"; $result = api_sql_query($sql, __FILE__, __LINE__); $question_counter_max = mysql_num_rows($result); @@ -146,7 +146,7 @@ else $questions[$row['sort']]['survey_question'] = $row['survey_question']; $questions[$row['sort']]['display'] = $row['display']; $questions[$row['sort']]['type'] = $row['type']; - $questions[$row['sort']]['options'][$row['option_sort']] = $row['option_text']; + $questions[$row['sort']]['options'][intval($row['option_sort'])] = $row['option_text']; $questions[$row['sort']]['maximum_score'] = $row['max_value']; } // if the type is a pagebreak we are finished loading the questions for this page @@ -158,7 +158,6 @@ else } } } - // selecting the maximum number of pages $sql = "SELECT * FROM $table_survey_question WHERE type='".Database::escape_string('pagebreak')."' AND survey_id='".Database::escape_string($_GET[survey_id])."'"; $result = api_sql_query($sql, __FILE__, __LINE__);