survey_all_courses.php 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. <?php
  2. /*
  3. ==============================================================================
  4. Dokeos - elearning and course management software
  5. Copyright (c) 2004 Dokeos S.A.
  6. Copyright (c) 2003 University of Ghent (UGent)
  7. Copyright (c) 2001 Universite catholique de Louvain (UCL)
  8. Copyright (c) Olivier Brouckaert
  9. For a full list of contributors, see "credits.txt".
  10. The full license can be read in "license.txt".
  11. This program is free software; you can redistribute it and/or
  12. modify it under the terms of the GNU General Public License
  13. as published by the Free Software Foundation; either version 2
  14. of the License, or (at your option) any later version.
  15. See the GNU General Public License for more details.
  16. Contact: Dokeos, 181 rue Royale, B-1000 Brussels, Belgium, info@dokeos.com
  17. ==============================================================================
  18. */
  19. /**
  20. ==============================================================================
  21. @author Bart Mollet
  22. * @package dokeos.admin
  23. ==============================================================================
  24. */
  25. /*
  26. ==============================================================================
  27. INIT SECTION
  28. ==============================================================================
  29. */
  30. $langFile = 'survey';
  31. require ('../inc/global.inc.php');
  32. require_once (api_get_path(LIBRARY_PATH)."/surveymanager.lib.php");
  33. $status = surveymanager::get_status();
  34. if($status==5)
  35. {
  36. api_protect_admin_script();
  37. }
  38. //api_protect_admin_script();
  39. require_once (api_get_path(LIBRARY_PATH)."/course.lib.php");
  40. $cidReq = $_REQUEST['cidReq'];
  41. $table_survey = Database :: get_course_table('survey');
  42. $table_group = Database :: get_course_table('survey_group');
  43. $table_question = Database :: get_course_table('questions');
  44. $table_course_survey_rel = Database :: get_main_table(MAIN_COURSE_SURVEY_TABLE);
  45. //$interbredcrump[] = array ("url" => "index.php", "name" => get_lang('AdministrationTools'));
  46. //$interbredcrump[] = array ("url" => "survey.php", "name" => get_lang('a_survey'));
  47. $interbredcrump[] = array ("url" => "survey_list.php", "name" => get_lang('Survey'));
  48. $n='e';
  49. $tool_name = get_lang('CreateFromExistingSurveys');
  50. $tool_name1 = get_lang('SurveysOfAllCourses');
  51. $surveyid=$_GET['surveyid'];
  52. Display :: display_header($tool_name);
  53. api_display_tool_title($tool_name1);
  54. ?>
  55. <SCRIPT LANGUAGE="JavaScript">
  56. function displayTemplate(url) {
  57. window.open(url, 'popup', 'width=600,height=600,toolbar = no, status = no');
  58. }
  59. </script>
  60. <table>
  61. <tr>
  62. <td>
  63. </td>
  64. </tr>
  65. </table>
  66. <form method="post" action="<?php echo $_SERVER['PHP_SELF'];?>?cidReq=<?=$cidReq?>">
  67. <input type="hidden" name="action" value="add_survey">
  68. <input type="hidden" name="surveyid" value="<?=$surveyid?>">
  69. <?php
  70. $rsDbs = mysql_list_dbs();
  71. $db_list = array();
  72. while($db = mysql_fetch_array($rsDbs)){
  73. $db_list[] = $db[0];
  74. }
  75. $nameTools=get_lang('CreateFromExistingSurveys');
  76. $table_group = Database :: get_course_table('survey_group');
  77. $sql = "SELECT course_survey.*, visual_code
  78. FROM $table_course_survey_rel as course_survey
  79. INNER JOIN ".Database::get_main_table(MAIN_COURSE_TABLE)." as course
  80. ON course_survey.course_code = course.code";
  81. $parameters = array ();
  82. $parameters['surveyid']=$surveyid;
  83. $parameters['newgroupid']=$groupid;
  84. $parameters['cidReq']=$cidReq;
  85. $res = api_sql_query($sql,__FILE__,__LINE__);
  86. if (mysql_num_rows($res) > 0)
  87. {
  88. $surveys = array ();
  89. while ($obj = mysql_fetch_object($res))
  90. {
  91. $db_name = $obj->db_name;
  92. $course_name = $obj->visual_code;
  93. $survey_id = $obj->survey_id;
  94. //echo "<pre>";
  95. if(in_array($db_name, $db_list)){
  96. $sql_survey = "SELECT * FROM $db_name.survey WHERE survey_id = '$survey_id' AND is_shared='1'";
  97. //echo "</pre>";
  98. $res_survey = api_sql_query($sql_survey,__FILE__,__LINE__);
  99. $survey = array ();
  100. while($object=mysql_fetch_object($res_survey))
  101. {
  102. //$survey[] = '<input type="checkbox" name="course[]" value="'.$obj->group_id.'">';
  103. $survey[] = $object->title;
  104. //$surveyid = $object->survey_id;
  105. //$groupid=$obj->group_id;
  106. //$surveyid=surveymanager::get_surveyid($groupid);
  107. $authorid=surveymanager::get_author($db_name,$survey_id);
  108. $author=surveymanager::get_survey_author($authorid);
  109. //$NoOfQuestion=surveymanager::no_of_question($groupid);
  110. $survey[] = $author;
  111. $survey[] = $course_name;
  112. $survey[] = $object->lang;
  113. $survey[] = $object->avail_from ;
  114. $survey[] = $object->avail_till ;
  115. $survey[] = "<a href=create_from_existing_survey.php?cidReq=$cidReq&surveyid=$survey_id&db_name=$db_name><img src=\"../img/info_small.gif\" border=\"0\" align=\"absmiddle\" alt=view></a>";
  116. $surveys[] = $survey;
  117. }
  118. }
  119. }
  120. $table_header[] = array (get_lang('SurveyName1'), true);
  121. $table_header[] = array (get_lang('author'), true);
  122. $table_header[] = array (get_lang('CourseName'), true);
  123. $table_header[] = array (get_lang('Language'), true);
  124. $table_header[] = array (get_lang('AvailableFrom'), true);
  125. $table_header[] = array (get_lang('AvailableTill'), true);
  126. $table_header[] = array (' ', false);
  127. if(!empty($surveys))
  128. {
  129. Display :: display_sortable_table($table_header, $surveys, array (), array (), $parameters);
  130. }
  131. else
  132. {$flag=1;}
  133. ?>
  134. </form>
  135. <?
  136. }
  137. else
  138. {
  139. echo get_lang('NoSearchResults');
  140. }
  141. if($flag=='1')
  142. {echo get_lang('SurveyNotShared');}
  143. ?>
  144. <form action="survey.php?cidReq=<?=$cidReq?>&db_name=<?=$db_name?>" method="post">
  145. <input type="submit" name="back1" value="<?=get_lang('back')?>">
  146. </form>
  147. <?
  148. Display :: display_footer();
  149. ?>