survey.php 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. <?php
  2. /*
  3. DOKEOS - elearning and course management software
  4. For a full list of contributors, see documentation/credits.html
  5. This program is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU General Public License
  7. as published by the Free Software Foundation; either version 2
  8. of the License, or (at your option) any later version.
  9. See "documentation/licence.html" more details.
  10. Contact:
  11. Dokeos
  12. Rue des Palais 44 Paleizenstraat
  13. B-1030 Brussels - Belgium
  14. Tel. +32 (2) 211 34 56
  15. */
  16. /**
  17. * @package dokeos.survey
  18. * @author unknown
  19. * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University: cleanup, refactoring and rewriting large parts of the code
  20. * @version $Id: survey.php 11134 2007-02-16 14:39:59Z pcool $
  21. *
  22. * @todo The ansTarget column is not done
  23. * @todo try to understand the white, blue, ... template stuff.
  24. * @todo use quickforms for the forms
  25. */
  26. // name of the language file that needs to be included
  27. $language_file = 'survey';
  28. // including the global dokeos file
  29. require ('../inc/global.inc.php');
  30. // including additional libraries
  31. //require_once (api_get_path(LIBRARY_PATH)."/survey.lib.php");
  32. require_once('survey.lib.php');
  33. require_once (api_get_path(LIBRARY_PATH)."/course.lib.php");
  34. /** @todo this has to be moved to a more appropriate place (after the display_header of the code)*/
  35. if (!api_is_allowed_to_edit())
  36. {
  37. Display :: display_header();
  38. Display :: display_error_message(get_lang('NotAllowedHere'));
  39. Display :: display_footer();
  40. exit;
  41. }
  42. // Database table definitions
  43. $table_survey = Database :: get_course_table(TABLE_SURVEY);
  44. $table_survey_question = Database :: get_course_table(TABLE_SURVEY_QUESTION);
  45. $table_survey_question_option = Database :: get_course_table(TABLE_SURVEY_QUESTION_OPTION);
  46. $table_course = Database :: get_main_table(TABLE_MAIN_COURSE);
  47. $table_user = Database :: get_main_table(TABLE_MAIN_USER);
  48. $user_info = Database :: get_main_table(TABLE_MAIN_SURVEY_REMINDER);
  49. // breadcrumbs
  50. $interbreadcrumb[] = array ("url" => "survey_list.php", "name" => get_lang('SurveyList'));
  51. $tool_name = get_lang('Survey');
  52. // Displaying the header
  53. Display::display_header($tool_name);
  54. // Action handling
  55. if (isset($_GET['action']))
  56. {
  57. if (($_GET['action'] == 'moveup' OR $_GET['action'] == 'movedown') AND isset($_GET['question_id']))
  58. {
  59. survey_manager::move_survey_question($_GET['action'], $_GET['question_id'], $_GET['survey_id']);
  60. Display::display_confirmation_message('SurveyQuestionMoved');
  61. }
  62. }
  63. // Displaying the survey information
  64. $survey_data = survey_manager::get_survey($_GET['survey_id']);
  65. echo '<strong>'.$survey_data['title'].'</strong><br />';
  66. echo $survey_data['subtitle'].'<br />';
  67. // Action links
  68. $survey_actions = '<a href="create_new_survey.php?action=edit&amp;survey_id='.$_GET['survey_id'].'">'.Display::return_icon('edit.gif').'</a>';
  69. $survey_actions .= '<a href="survey_list.php?action=delete&amp;survey_id='.$_GET['survey_id'].'">'.Display::return_icon('delete.gif').'</a>';
  70. $survey_actions .= '<a href="create_survey_in_another_language.php?id_survey='.$_GET['survey_id'].'">'.Display::return_icon('copy.gif').'</a>';
  71. $survey_actions .= '<a href="preview.php?survey_id='.$_GET['survey_id'].'">'.Display::return_icon('preview.gif').'</a>';
  72. $survey_actions .= '<a href="survey_invite.php?survey_id='.$_GET['survey_id'].'">'.Display::return_icon('survey_publish.gif').'</a>';
  73. $survey_actions .= '<a href="reporting.php?survey_id='.$_GET['survey_id'].'">'.Display::return_icon('surveyreporting.gif').'</a>';
  74. echo '<div style="float:right;">'.$survey_actions.'</div>';
  75. echo '<a href="question.php?action=add&type=yesno&amp;survey_id='.$_GET['survey_id'].'">'.get_lang('YesNo').'</a> | ';
  76. echo '<a href="question.php?action=add&type=multiplechoice&amp;survey_id='.$_GET['survey_id'].'">'.get_lang('MultipleChoice').'</a> | ';
  77. echo '<a href="question.php?action=add&type=multipleresponse&amp;survey_id='.$_GET['survey_id'].'">'.get_lang('MultipleResponse').'</a> | ';
  78. echo '<a href="question.php?action=add&type=open&amp;survey_id='.$_GET['survey_id'].'">'.get_lang('Open').'</a> | ';
  79. echo '<a href="question.php?action=add&type=dropdown&amp;survey_id='.$_GET['survey_id'].'">'.get_lang('Dropdown').'</a> | ';
  80. //echo '<a href="question.php?action=add&type=percentage&amp;survey_id='.$_GET['survey_id'].'">'.get_lang('Dropdown').'</a> | ';
  81. //echo '<a href="question.php?action=add&type=rating&amp;survey_id='.$_GET['survey_id'].'">'.get_lang('Dropdown').'</a> | ';
  82. echo '<a href="question.php?action=add&type=comment&amp;survey_id='.$_GET['survey_id'].'">'.get_lang('Comment').'</a> | ';
  83. echo '<a href="question.php?action=add&type=pagebreak&amp;survey_id='.$_GET['survey_id'].'">'.get_lang('Pagebreak').'</a>';
  84. echo '<div style="clear:both;"></div>';
  85. // Displaying the table header with all the questions
  86. echo '<table class="data_table">';
  87. echo ' <tr class="row_odd">';
  88. echo ' <th width="15">'.get_lang('QuestionNumber').'</th>';
  89. echo ' <th>'.get_lang('Title').'</th>';
  90. echo ' <th>'.get_lang('Type').'</th>';
  91. echo ' <th>'.get_lang('NumberOfOptions').'</th>';
  92. echo ' <th width="100">'.get_lang('Modify').'</th>';
  93. echo ' </tr>';
  94. // Displaying the table contents with all the questions
  95. $question_counter = 1;
  96. $sql = "SELECT survey_question.*, count(survey_question_option.question_option_id) as number_of_options
  97. FROM $table_survey_question survey_question
  98. LEFT JOIN $table_survey_question_option survey_question_option
  99. ON survey_question.question_id = survey_question_option.question_id
  100. WHERE survey_question.survey_id = '".mysql_real_escape_string($_GET['survey_id'])."'
  101. GROUP BY survey_question.question_id
  102. ORDER BY survey_question.sort ASC";
  103. $result = api_sql_query($sql, __FILE__, __LINE__);
  104. $question_counter_max = mysql_num_rows($result);
  105. while ($row = mysql_fetch_assoc($result))
  106. {
  107. echo '<tr>';
  108. echo ' <td>'.$question_counter.'</td>';
  109. echo ' <td>'.$row['survey_question'].'</td>';
  110. echo ' <td>'.$row['type'].'</td>';
  111. echo ' <td>'.$row['number_of_options'].'</td>';
  112. echo ' <td>';
  113. echo ' <a href="question.php?action=edit&amp;type='.$row['type'].'&amp;survey_id='.$_GET['survey_id'].'&amp;question_id='.$row['question_id'].'">'.Display::return_icon('edit.gif').'</a>';
  114. echo ' <a href="survey.php?action=delete&amp;survey_id='.$_GET['survey_id'].'&ampquestion_id='.$row['question_id'].'">'.Display::return_icon('delete.gif').'</a>';
  115. if ($question_counter > 1)
  116. {
  117. echo ' <a href="survey.php?action=moveup&amp;survey_id='.$_GET['survey_id'].'&amp;question_id='.$row['question_id'].'">'.Display::return_icon('up.gif').'</a>';
  118. }
  119. if ($question_counter < $question_counter_max)
  120. {
  121. echo ' <a href="survey.php?action=movedown&amp;survey_id='.$_GET['survey_id'].'&amp;question_id='.$row['question_id'].'">'.Display::return_icon('down.gif').'</a>';
  122. }
  123. echo ' </td>';
  124. $question_counter++;
  125. }
  126. echo '</table>';
  127. // Footer
  128. Display :: display_footer();
  129. ?>