survey_list.php 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  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, the initial survey that did not make it in 1.8 because of bad code
  19. * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University: cleanup, refactoring and rewriting large parts of the code
  20. * @version $Id: survey_list.php 14784 2008-04-08 12:58:45Z pcool $
  21. *
  22. * @todo use quickforms for the forms
  23. */
  24. // name of the language file that needs to be included
  25. $language_file = 'survey';
  26. // including the global dokeos file
  27. require ('../inc/global.inc.php');
  28. // including additional libraries
  29. //require_once (api_get_path(LIBRARY_PATH)."/survey.lib.php");
  30. require_once('survey.lib.php');
  31. require_once (api_get_path(LIBRARY_PATH)."/course.lib.php");
  32. /** @todo this has to be moved to a more appropriate place (after the display_header of the code)*/
  33. if (!api_is_allowed_to_edit())
  34. {
  35. Display :: display_header(get_lang('SurveyList'));
  36. SurveyUtil::survey_list_user($_user['user_id']);
  37. Display :: display_footer();
  38. exit;
  39. }
  40. // Database table definitions
  41. $table_survey = Database :: get_course_table(TABLE_SURVEY);
  42. $table_survey_question = Database :: get_course_table(TABLE_SURVEY_QUESTION);
  43. $table_course = Database :: get_main_table(TABLE_MAIN_COURSE);
  44. $table_user = Database :: get_main_table(TABLE_MAIN_USER);
  45. // language variables
  46. if (isset ($_GET['search']) && $_GET['search'] == 'advanced')
  47. {
  48. $interbreadcrumb[] = array ('url' => 'survey_list.php', 'name' => get_lang('SurveyList'));
  49. $tool_name = get_lang('SearchASurvey');
  50. }
  51. else
  52. {
  53. $tool_name = get_lang('SurveyList');
  54. }
  55. // Header
  56. Display :: display_header($tool_name);
  57. //api_display_tool_title($tool_name);
  58. // Action handling: searching
  59. if (isset ($_GET['search']) AND $_GET['search'] == 'advanced')
  60. {
  61. SurveyUtil::display_survey_search_form();
  62. }
  63. // Action handling: deleting a survey
  64. if (isset($_GET['action']) AND $_GET['action'] == 'delete' AND isset($_GET['survey_id']) AND is_numeric($_GET['survey_id']))
  65. {
  66. // getting the information of the survey (used for when the survey is shared)
  67. $survey_data = survey_manager::get_survey($_GET['survey_id']);
  68. // if the survey is shared => also delete the shared content
  69. if (is_numeric($survey_data['survey_share']))
  70. {
  71. survey_manager::delete_survey($survey_data['survey_share'], true);
  72. }
  73. $return = survey_manager :: delete_survey($_GET['survey_id']);
  74. if ($return)
  75. {
  76. Display :: display_confirmation_message(get_lang('SurveyDeleted'), false);
  77. }
  78. else
  79. {
  80. Display :: display_error_message(get_lang('ErrorOccurred'), false);
  81. }
  82. }
  83. if(isset($_GET['action']) && $_GET['action'] == 'empty')
  84. {
  85. $return = survey_manager::empty_survey(intval($_GET['survey_id']));
  86. if ($return)
  87. {
  88. Display :: display_confirmation_message(get_lang('SurveyEmptied'), false);
  89. }
  90. else
  91. {
  92. Display :: display_error_message(get_lang('ErrorOccurred'), false);
  93. }
  94. }
  95. // Action handling: performing the same action on multiple surveys
  96. if ($_POST['action'])
  97. {
  98. if (is_array($_POST['id']))
  99. {
  100. foreach ($_POST['id'] as $key=>$value)
  101. {
  102. // getting the information of the survey (used for when the survey is shared)
  103. $survey_data = survey_manager::get_survey($value);
  104. // if the survey is shared => also delete the shared content
  105. if (is_numeric($survey_data['survey_share']))
  106. {
  107. survey_manager::delete_survey($survey_data['survey_share'], true);
  108. }
  109. // delete the actual survey
  110. survey_manager::delete_survey($value);
  111. }
  112. Display :: display_confirmation_message(get_lang('SurveysDeleted'), false);
  113. }
  114. else
  115. {
  116. Display :: display_error_message(get_lang('NoSurveysSelected'), false);
  117. }
  118. }
  119. // Action links
  120. echo '<a href="create_new_survey.php?'.api_get_cidreq().'&amp;action=add">'.get_lang('CreateNewSurvey').'</a> | ';
  121. //echo '<a href="survey_all_courses.php">'.get_lang('CreateExistingSurvey').'</a> | ';
  122. echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&amp;search=advanced">'.get_lang('Search').'</a>';
  123. // Main content
  124. SurveyUtil::display_survey_list();
  125. // Footer
  126. Display :: display_footer();
  127. /* Bypass functions to make direct use from SortableTable possible */
  128. function get_number_of_surveys()
  129. {
  130. return SurveyUtil::get_number_of_surveys();
  131. }
  132. function get_survey_data($from, $number_of_items, $column, $direction)
  133. {
  134. return SurveyUtil::get_survey_data($from, $number_of_items, $column, $direction);
  135. }
  136. function modify_filter($survey_id)
  137. {
  138. return SurveyUtil::modify_filter($survey_id);
  139. }
  140. function anonymous_filter($anonymous)
  141. {
  142. return SurveyUtil::anonymous_filter($anonymous);
  143. }