survey_invitation.php 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  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 Patrick Cool <patrick.cool@UGent.be>, Ghent University: cleanup, refactoring and rewriting large parts of the code
  19. * @version $Id: survey_invite.php 10680 2007-01-11 21:26:23Z pcool $
  20. *
  21. * @todo the answered column
  22. */
  23. // name of the language file that needs to be included
  24. $language_file = 'survey';
  25. // including the global dokeos file
  26. require ('../inc/global.inc.php');
  27. // including additional libraries
  28. //require_once (api_get_path(LIBRARY_PATH)."/survey.lib.php");
  29. require_once('survey.lib.php');
  30. require_once (api_get_path(LIBRARY_PATH)."course.lib.php");
  31. require_once (api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php');
  32. require_once (api_get_path(LIBRARY_PATH)."mail.lib.inc.php");
  33. /** @todo this has to be moved to a more appropriate place (after the display_header of the code)*/
  34. if (!api_is_allowed_to_edit())
  35. {
  36. Display :: display_header();
  37. Display :: display_error_message(get_lang('NotAllowedHere'));
  38. Display :: display_footer();
  39. exit;
  40. }
  41. // Database table definitions
  42. $table_survey = Database :: get_course_table(TABLE_SURVEY);
  43. $table_survey_question = Database :: get_course_table(TABLE_SURVEY_QUESTION);
  44. $table_survey_question_option = Database :: get_course_table(TABLE_SURVEY_QUESTION_OPTION);
  45. $table_course = Database :: get_main_table(TABLE_MAIN_COURSE);
  46. $table_user = Database :: get_main_table(TABLE_MAIN_USER);
  47. $table_survey_invitation = Database :: get_course_table(TABLE_SURVEY_INVITATION);
  48. // breadcrumbs
  49. $interbreadcrumb[] = array ('url' => 'survey_list.php', 'name' => get_lang('SurveyList'));
  50. $interbreadcrumb[] = array ('url' => 'survey.php?survey_id='.$_GET['survey_id'], 'name' => get_lang('Survey'));
  51. $tool_name = get_lang('SurveyInvitations');
  52. // Displaying the header
  53. Display::display_header($tool_name);
  54. // Checking the parameters
  55. if (!is_numeric($_GET['survey_id']))
  56. {
  57. Display::display_error_message(get_lang('Error'));
  58. Display::display_footer();
  59. exit;
  60. }
  61. // Displaying the survey information
  62. $survey_data = survey_manager::get_survey($_GET['survey_id']);
  63. echo '<a href="survey.php?survey_id='.$survey_data['survey_id'].'">'.$survey_data['title'].'</a><br />';
  64. echo $survey_data['subtitle'];
  65. // Getting all the people who have filled this survey
  66. $answered_data = survey_manager::get_people_who_filled_survey($_GET['survey_id']);
  67. //
  68. echo 'view invited | view answered | view unanswered';
  69. // table header
  70. echo '<table class="data_table">';
  71. echo ' <tr>';
  72. echo ' <th>'.get_lang('User').'</th>';
  73. echo ' <th>'.get_lang('InvitationCode').'</th>';
  74. echo ' <th>'.get_lang('InvitationDate').'</th>';
  75. echo ' <th>'.get_lang('Answered').'</th>';
  76. echo ' </tr>';
  77. $sql = "SELECT survey_invitation.*, user.firstname, user.lastname, user.email FROM $table_survey_invitation survey_invitation
  78. LEFT JOIN $table_user user ON survey_invitation.user = user.user_id
  79. WHERE survey_invitation.survey_id = '".mysql_real_escape_string($_GET['survey_id'])."'";
  80. $res = api_sql_query($sql, __FILE__, __LINE__);
  81. while ($row = mysql_fetch_assoc($res))
  82. {
  83. echo '<tr>';
  84. if (is_numeric($row['user']))
  85. {
  86. echo ' <td><a href="../user/userInfo.php?editMainUserInfo='.$row['user'].'">'.$row['firstname'].' '.$row['lastname'].'</a></td>';
  87. }
  88. else
  89. {
  90. echo ' <td>'.$row['user'].'</td>';
  91. }
  92. /** @todo this is temporary to allow the developer to quickly fill a survey as a different user */
  93. // echo ' <td>'.$row['invitation_code'].'</td>';
  94. echo ' <td><a href="fillsurvey.php?course='.$_course['sysCode'].'&amp;invitationcode='.$row['invitation_code'].'">'.$row['invitation_code'].'</td>';
  95. echo ' <td>'.$row['invitation_date'].'</td>';
  96. echo ' <td>';
  97. if (in_array($row['user'], $answered_data))
  98. {
  99. echo '<a href="reporting.php?action=userreport&amp;survey_id='.$_GET['survey_id'].'&amp;user='.$row['user'].'">'.get_lang('ViewAnswers').'</a>';
  100. }
  101. else
  102. {
  103. echo '-';
  104. }
  105. echo ' </td>';
  106. echo '</tr>';
  107. }
  108. // closing the table
  109. echo '</table>';
  110. // Footer
  111. Display :: display_footer();
  112. /**
  113. * @todo add the additional parameters
  114. */
  115. /*
  116. $table = new SortableTable('survey_invitations', 'get_number_of_survey_invitations', 'get_survey_invitations_data',2);
  117. $table->set_additional_parameters($parameters);
  118. $table->set_header(0, get_lang('User'));
  119. $table->set_header(1, get_lang('InvitationCode'));
  120. $table->set_header(2, get_lang('InvitationDate'));
  121. $table->set_header(3, get_lang('Answered'));
  122. $table->set_column_filter(3, 'modify_filter');
  123. $table->display();
  124. */
  125. /**
  126. * Get all the information about the invitations of a certain survey
  127. *
  128. * @return unknown
  129. *
  130. * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
  131. * @version January 2007
  132. *
  133. * @todo use survey_id parameter instead of $_GET
  134. */
  135. function get_survey_invitations_data()
  136. {
  137. // Database table definition
  138. $table_survey_invitation = Database :: get_course_table(TABLE_SURVEY_INVITATION);
  139. $table_user = Database :: get_main_table(TABLE_MAIN_USER);
  140. $sql = "SELECT
  141. survey_invitation.user as col1,
  142. survey_invitation.invitation_code as col2,
  143. survey_invitation.invitation_date as col3,
  144. '' as col4
  145. FROM $table_survey_invitation survey_invitation
  146. LEFT JOIN $table_user user ON survey_invitation.user = user.user_id
  147. WHERE survey_invitation.survey_id = '".mysql_real_escape_string($_GET['survey_id'])."'";
  148. $res = api_sql_query($sql, __FILE__, __LINE__);
  149. while ($row = mysql_fetch_array($res))
  150. {
  151. $survey_invitation_data[] = $row;
  152. }
  153. return $survey_invitation_data;
  154. }
  155. /**
  156. * Get the total number of survey invitations for a given survey (through $_GET['survey_id'])
  157. *
  158. * @return unknown
  159. *
  160. * @todo use survey_id parameter instead of $_GET
  161. *
  162. * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
  163. * @version January 2007
  164. */
  165. function get_number_of_survey_invitations()
  166. {
  167. // Database table definition
  168. $table_survey_invitation = Database :: get_course_table(TABLE_SURVEY_INVITATION);
  169. $sql = "SELECT count(user) AS total FROM $table_survey_invitation WHERE survey_id='".mysql_real_escape_string($_GET['survey_id'])."'";
  170. $res = api_sql_query($sql, __FILE__, __LINE__);
  171. $row = mysql_fetch_assoc($res);
  172. return $row['total'];
  173. }
  174. /**
  175. * @todo use global array for answered or not
  176. *
  177. * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
  178. * @version January 2007
  179. */
  180. function modify_filter()
  181. {
  182. }
  183. ?>