existing_surveys_new.php 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  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
  19. * @version $Id: existing_surveys_new.php 10680 2007-01-11 21:26:23Z pcool $
  20. */
  21. /*
  22. ==============================================================================
  23. INIT SECTION
  24. ==============================================================================
  25. */
  26. // name of the language file that needs to be included
  27. $language_file = 'survey';
  28. require ('../inc/global.inc.php');
  29. require_once (api_get_path(LIBRARY_PATH)."/surveymanager.lib.php");
  30. require_once (api_get_path(LIBRARY_PATH)."/course.lib.php");
  31. /** @todo replace this with the correct code */
  32. /*
  33. $status = surveymanager::get_status();
  34. api_protect_course_script();
  35. if($status==5)
  36. {
  37. api_protect_admin_script();
  38. }
  39. */
  40. /** @todo this has to be moved to a more appropriate place (after the display_header of the code)*/
  41. if (!api_is_allowed_to_edit())
  42. {
  43. Display :: display_header();
  44. Display :: display_error_message(get_lang('NotAllowedHere'));
  45. Display :: display_footer();
  46. exit;
  47. }
  48. $table_survey = Database :: get_course_table(TABLE_SURVEY);
  49. $table_group = Database :: get_course_table(TABLE_SURVEY_GROUP);
  50. $table_survey_question = Database :: get_course_table(TABLE_SURVEY_QUESTION);
  51. $table_course_survey_rel = Database :: get_main_table(TABLE_MAIN_COURSE_SURVEY);
  52. $interbreadcrumb[] = array ("url" => "survey_list.php", "name" => get_lang('Survey'));
  53. $n='e';
  54. $tool_name = get_lang('ImportFromExisting');
  55. $tool_name1 = get_lang('SurveysOfAllCourses');
  56. $surveyid=$_GET['surveyid'];
  57. $sname = surveymanager::get_surveyname_display($surveyid);
  58. Display :: display_header($tool_name);
  59. api_display_tool_title($tool_name1);
  60. ?>
  61. <SCRIPT LANGUAGE="JavaScript">
  62. function displayTemplate(url) {
  63. window.open(url, 'popup', 'width=600,height=600,toolbar = no, status = no');
  64. }
  65. </script>
  66. <table>
  67. <tr>
  68. <td>
  69. <?php echo get_lang('SurveyName');?>&nbsp;<?php echo $sname;?>
  70. </td>
  71. </tr>
  72. <tr>
  73. <td>
  74. </td>
  75. </tr>
  76. </table>
  77. <form method="post" action="<?php echo $_SERVER['PHP_SELF'];?>">
  78. <input type="hidden" name="action" value="add_survey">
  79. <input type="hidden" name="surveyid" value="<?php echo $surveyid; ?>">
  80. <?php
  81. $surveyid=$_REQUEST['surveyid'];
  82. $nameTools=get_lang('CreateFromExistingSurveys');
  83. $table_group = Database :: get_course_table(TABLE_SURVEY_GROUP);
  84. $sql = "SELECT * FROM $table_course_survey_rel";
  85. $parameters = array ();
  86. $parameters['surveyid']=$surveyid;
  87. $parameters['newgroupid']=$groupid;
  88. $res = api_sql_query($sql,__FILE__,__LINE__);
  89. if (mysql_num_rows($res) > 0)
  90. {
  91. $surveys = array ();
  92. while ($obj = mysql_fetch_object($res))
  93. {
  94. $db_name = $obj->db_name;
  95. $course_name = $obj->course_code;
  96. $survey_id = $obj->survey_id;
  97. if($survey_id==$surveyid&&$course_name==$cidReq)
  98. {continue;}
  99. $sql_survey = "SELECT * FROM $db_name.survey WHERE survey_id = '$survey_id' AND is_shared='1'";
  100. $res_survey = api_sql_query($sql_survey,__FILE__,__LINE__);
  101. $survey = array ();
  102. while($object=mysql_fetch_object($res_survey))
  103. {
  104. //$survey[] = '<input type="checkbox" name="course[]" value="'.$obj->group_id.'">';
  105. $survey[] = $object->title;
  106. //$surveyid = $object->survey_id;
  107. //$groupid=$obj->group_id;
  108. //$surveyid=surveymanager::get_surveyid($groupid);
  109. $authorid=surveymanager::get_author($db_name,$survey_id);
  110. $author=surveymanager::get_survey_author($authorid);
  111. //$NoOfQuestion=surveymanager::no_of_question($groupid);
  112. $survey[] = $author;
  113. $survey[] = $course_name;
  114. $survey[] = $object->lang;
  115. $survey[] = $object->avail_from ;
  116. $survey[] = $object->avail_till ;
  117. $survey[] = "<a href=group_list.php?sid=$survey_id&surveyid=$surveyid&curr_dbname=$curr_dbname><img src=\"../img/info_small.gif\" border=\"0\" align=\"absmiddle\" alt=view></a>";
  118. $surveys[] = $survey;
  119. }
  120. }
  121. $table_header[] = array (get_lang('SurveyName'), true);
  122. $table_header[] = array (get_lang('Author'), true);
  123. $table_header[] = array (get_lang('CourseName'), true);
  124. $table_header[] = array (get_lang('Language'), true);
  125. $table_header[] = array (get_lang('AvailableFrom'), true);
  126. $table_header[] = array (get_lang('AvailableTill'), true);
  127. $table_header[] = array (' ', false);
  128. if(!empty($surveys))
  129. {
  130. Display :: display_sortable_table($table_header, $surveys, array (), array (), $parameters);
  131. }
  132. else
  133. {$flag=1;}
  134. ?>
  135. </form>
  136. <?php
  137. }
  138. else
  139. {
  140. echo get_lang('NoSearchResults');
  141. }
  142. if($flag=='1')
  143. {echo get_lang('SurveyNotShared');}
  144. ?>
  145. <form action="select_question_group.php?db_name=<?php echo $db_name; ?>&surveyid=<?php echo $surveyid; ?>&curr_dbname=<?php echo $curr_dbname; ?>" method="post">
  146. <input type="submit" name="back1" value="<?php echo get_lang('Back'); ?>">
  147. </form>
  148. <?php
  149. Display :: display_footer();
  150. ?>