[svn r14912] Fixed complete report display (fixes to exports coming up)

skala
Yannick Warnier 18 years ago
parent c0c5db5803
commit 41093b0bae
  1. 54
      main/survey/survey.lib.php

@ -23,7 +23,7 @@ $config['survey']['debug'] = false;
/** /**
* @package dokeos.survey * @package dokeos.survey
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University: cleanup, refactoring and rewriting large parts (if not all) of the code * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University: cleanup, refactoring and rewriting large parts (if not all) of the code
* @version $Id: survey.lib.php 14911 2008-04-15 21:39:40Z yannoo $ * @version $Id: survey.lib.php 14912 2008-04-15 22:44:17Z yannoo $
* *
* @todo move this file to inc/lib * @todo move this file to inc/lib
* @todo use consistent naming for the functions (save vs store for instance) * @todo use consistent naming for the functions (save vs store for instance)
@ -2449,21 +2449,25 @@ class SurveyUtil {
//show user fields section with a big th colspan that spans over all fields //show user fields section with a big th colspan that spans over all fields
$extra_user_fields = UserManager::get_extra_fields(0,0,5,'ASC',false); $extra_user_fields = UserManager::get_extra_fields(0,0,5,'ASC',false);
$num = count($extra_user_fields); $num = count($extra_user_fields);
echo '<th '.($num>0?' colspan="'.$num.'"':'').'>'; if($num > 0)
echo '<label><input type="checkbox" name="fields_filter" value="1" checked="checked"/> '; {
echo get_lang('UserFields'); echo '<th '.($num>0?' colspan="'.$num.'"':'').'>';
echo '</label>'; echo '<label><input type="checkbox" name="fields_filter" value="1" checked="checked"/> ';
echo '</th>'; echo get_lang('UserFields');
$display_extra_user_fields = true; echo '</label>';
echo '</th>';
$display_extra_user_fields = true;
}
} }
$sql = "SELECT questions.question_id, questions.type, questions.survey_question, count(options.question_option_id) as number_of_options // Get all the questions ordered by the "sort" column
FROM $table_survey_question questions LEFT JOIN $table_survey_question_option options $sql = "SELECT q.question_id, q.type, q.survey_question, count(o.question_option_id) as number_of_options
ON questions.question_id = options.question_id FROM $table_survey_question q LEFT JOIN $table_survey_question_option o
WHERE questions.question_id = options.question_id ON q.question_id = o.question_id
AND questions.survey_id = '".Database::escape_string($_GET['survey_id'])."' WHERE q.question_id = o.question_id
GROUP BY questions.question_id AND q.survey_id = '".Database::escape_string($_GET['survey_id'])."'
ORDER BY questions.sort ASC"; GROUP BY q.question_id
ORDER BY q.sort ASC";
$result = api_sql_query($sql, __FILE__, __LINE__); $result = api_sql_query($sql, __FILE__, __LINE__);
while ($row = Database::fetch_array($result)) while ($row = Database::fetch_array($result))
{ {
@ -2487,6 +2491,7 @@ class SurveyUtil {
echo '</label>'; echo '</label>';
echo '</th>'; echo '</th>';
} }
//no column at all if it's not a question
} }
$questions[$row['question_id']] = $row; $questions[$row['question_id']] = $row;
} }
@ -2504,29 +2509,32 @@ class SurveyUtil {
} }
} }
$sql = "SELECT survey_question.question_id, survey_question.survey_id, survey_question.survey_question, survey_question.display, survey_question.sort, survey_question.type, $sql = "SELECT sq.question_id, sq.survey_id,
survey_question_option.question_option_id, survey_question_option.option_text, survey_question_option.sort as option_sort sq.survey_question, sq.display,
FROM $table_survey_question survey_question sq.sort, sq.type, sqo.question_option_id,
LEFT JOIN $table_survey_question_option survey_question_option sqo.option_text, sqo.sort as option_sort
ON survey_question.question_id = survey_question_option.question_id FROM $table_survey_question sq
WHERE survey_question.survey_id = '".Database::escape_string($_GET['survey_id'])."' LEFT JOIN $table_survey_question_option sqo
ORDER BY survey_question.sort ASC"; ON sq.question_id = sqo.question_id
WHERE sq.survey_id = '".Database::escape_string($_GET['survey_id'])."'
ORDER BY sq.sort ASC, sqo.sort ASC";
$result = api_sql_query($sql, __FILE__, __LINE__); $result = api_sql_query($sql, __FILE__, __LINE__);
while ($row = Database::fetch_array($result)) while ($row = Database::fetch_array($result))
{ {
// we show the options if // we show the options if
// 1. there is no question filter and the export button has not been clicked // 1. there is no question filter and the export button has not been clicked
// 2. there is a quesiton filter but the question is selected for display // 2. there is a question filter but the question is selected for display
if (!($_POST['submit_question_filter'] OR $_POST['export_report']) OR in_array($row['question_id'], $_POST['questions_filter'])) if (!($_POST['submit_question_filter'] OR $_POST['export_report']) OR in_array($row['question_id'], $_POST['questions_filter']))
{ {
// we do not show comment and pagebreak question types // we do not show comment and pagebreak question types
if ($row['type'] <> 'comment' AND $row['type'] <> 'pagebreak') if ($row['type'] <> 'comment' AND $row['type'] <> 'pagebreak' AND $row['type'] <> 'open')
{ {
echo ' <th>'; echo ' <th>';
echo $row['option_text']; echo $row['option_text'];
echo '</th>'; echo '</th>';
$possible_answers[$row['question_id']][$row['question_option_id']] =$row['question_option_id']; $possible_answers[$row['question_id']][$row['question_option_id']] =$row['question_option_id'];
} }
//no column at all if the question was not a question
} }
} }
echo ' </tr>'; echo ' </tr>';

Loading…
Cancel
Save