question_list.php 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  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. //api_protect_admin_script();
  33. require_once (api_get_path(LIBRARY_PATH)."/course.lib.php");
  34. require_once (api_get_path(LIBRARY_PATH)."/surveymanager.lib.php");
  35. $status = surveymanager::get_status();
  36. if($status==5)
  37. {
  38. api_protect_admin_script();
  39. }
  40. $interbredcrump[] = array ("url" => "survey_list.php", "name" => get_lang('Survey'));
  41. $cidReq = $_REQUEST['cidReq'];
  42. $db_name = $_REQUEST['db_name'];
  43. $tool_name = get_lang('SelectQuestion');
  44. $Sname = get_lang('SurveyName');
  45. $GName = get_lang('groupname');
  46. $Author = get_lang('Author');
  47. $surveyid=$_REQUEST['surveyid'];
  48. $groupid=$_REQUEST['groupid'];
  49. //$sname =surveymanager::get_surveyname($surveyid);
  50. $gide=$_REQUEST['course'];
  51. $gid1=explode(",",$gide);
  52. $table_question = Database :: get_course_table('questions');
  53. if($gide)
  54. {
  55. $gid1=$gid1;
  56. }
  57. else
  58. {
  59. $gid1=explode(",",$_REQUEST['gid1']);
  60. }
  61. for($r=0;$r<count($gid1);$r++)
  62. {
  63. if($r<count($gid1)-1)
  64. $str.=$gid1[$r].",";
  65. else
  66. $str.=$gid1[$r];
  67. }
  68. if(isset($_POST['back']))
  69. {
  70. $db_name = $_POST['db_name'];
  71. $cidReq=$_GET['cidReq'];
  72. header("location:create_from_existing_survey.php?cidReq=$cidReq&db_name=$db_name&surveyid=$surveyid");
  73. }
  74. if(isset($_POST['importquestion']))
  75. {
  76. $surveyid = $_POST['surveyid'];
  77. $cidReq=$_GET['cidReq'];
  78. $selectcount=count($_POST['question']);
  79. if($selectcount<=0)
  80. {
  81. $error_message=$error_message=get_lang("PleaseSelectAChoice");
  82. }
  83. else
  84. {
  85. $qid = $_POST['question'];
  86. $db_name = $_POST['db_name'];
  87. $qids = implode(",",$qid);
  88. header("location:attach_question.php?surveyid=$surveyid&qid=$qids&cidReq=$cidReq&db_name=$db_name");
  89. exit;
  90. }
  91. }
  92. Display :: display_header($tool_name);
  93. if( isset($error_message) )
  94. {
  95. Display::display_error_message($error_message);
  96. }
  97. ?>
  98. <SCRIPT LANGUAGE="JavaScript">
  99. function displayTemplate(url){
  100. window.open(url, 'popup', 'width=600,height=400,toolbar = no, status = no');
  101. }
  102. </script>
  103. <?php
  104. api_display_tool_title($tool_name);
  105. ?>
  106. <form method="post" action="<?php echo $_SERVER['PHP_SELF'];?>?cidReq=<?=$cidReq?>">
  107. <input type="hidden" name="action" value="add_survey"/>
  108. <input type="hidden" name="surveyid" value="<?=$surveyid?>">
  109. <input type="hidden" name="groupid" value="<?=$groupid?>">
  110. <input type="hidden" name="gid1" value="<?=$str?>">
  111. <input type="hidden" name="db_name" value="<?=$db_name?>">
  112. <?
  113. $questions = array ();
  114. $cidReq=$_GET['cidReq'];
  115. $endloop=count($gid1);
  116. $datacount=0;
  117. $parameters = array ();
  118. $parameters['surveyid']=$surveyid;
  119. $parameters['groupid']=$groupid;
  120. $parameters['cidReq']=$cidReq;
  121. $parameters['db_name']=$db_name;
  122. $parameters['gid1']=$str;
  123. for($i=0;$i<$endloop;$i++)
  124. {
  125. $gidi=$gid1[$i];
  126. $sql = "SELECT * FROM $db_name.questions WHERE gid='$gidi'";
  127. /*
  128. $parameters = array ('gidi' => $gidi);
  129. $parameters['surveyid']=$surveyid;
  130. $parameters['groupid']=$groupid;
  131. $parameters['cidReq']=$cidReq;
  132. $parameters['course']=$_REQUEST['course'];
  133. $parameters['db_name']=$db_name;
  134. */
  135. $res = api_sql_query($sql,__FILE__,__LINE__);
  136. while ($obj = mysql_fetch_object($res))
  137. {
  138. $question = array ();
  139. $question[] = '<input type="checkbox" name="question[]" value="'.$obj->qid.'"/>';
  140. $question[] = $obj->caption;
  141. $question[] = $obj->qtype;
  142. $groupid = $obj->gid;
  143. $GName = surveymanager::get_groupname($db_name,$groupid);
  144. $question[] = $GName;
  145. $sid = surveymanager::get_surveyid($db_name,$groupid);
  146. $sname = surveymanager::get_surveyname($db_name,$sid);
  147. $question[] = $sname;
  148. /**********for displaying the 'edit' 'delete' etc. buttons***********/
  149. $url = "default.php?qid=".$obj->qid."&qtype=".$obj->qtype."&cidReq=".$cidReq."&surveyid=".$surveyid."&groupid=".$groupid."&db_name=".$db_name;
  150. $question[] = "<a href=\"#\" onClick=\"displayTemplate('".$url."')\"><img src=\"../img/info_small.gif\" border=\"0\" align=\"absmiddle\" alt=\"".get_lang('ViewQues')."\" /></a>";
  151. $questions[] = $question;
  152. $datacount++;
  153. }
  154. }
  155. $table_header[] = array (' ', false);
  156. $table_header[] = array (get_lang('Question'), true);
  157. $table_header[] = array (get_lang('QuestionType1'), true);
  158. $table_header[] = array (get_lang('Group'),true);
  159. $table_header[] = array (get_lang('surveyname'),true);
  160. $table_header[] = array('', false);
  161. if($datacount>0)
  162. Display :: display_sortable_table($table_header, $questions, array (), array (), $parameters);
  163. else
  164. {
  165. $noquestions=get_lang("NoQuestionAvailableInThisGroup");
  166. api_display_tool_title($noquestions);
  167. }
  168. ?>
  169. <table>
  170. <tr>
  171. <td><input type="submit" name="back" value="Back"></td>
  172. <td><input type="submit" name="importquestion" value="<? echo get_lang('ImportQuestion');?>"></td>
  173. </tr>
  174. </table>
  175. </form>
  176. <?php
  177. Display :: display_footer();
  178. ?>