question_list_new.php 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  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. $curr_dbname = $_REQUEST['curr_dbname'];
  44. $tool_name = get_lang('SelectQuestion');
  45. $Sname = get_lang('SurveyName');
  46. $GName = get_lang('groupname');
  47. $Author = get_lang('Author');
  48. $surveyid=$_REQUEST['surveyid'];
  49. $groupid=$_REQUEST['groupid'];
  50. $sid = $_REQUEST['sid'];
  51. //$sname =surveymanager::get_surveyname($surveyid,$db_name);
  52. $table_group = Database :: get_course_table('survey_group');
  53. $table_question = Database :: get_course_table('questions');
  54. $gide=$_POST['course'];
  55. $arraycount=0;
  56. $arraycount=count($_REQUEST['course']);
  57. if($_REQUEST['gid1'])
  58. {
  59. $gid1=explode(",",$_REQUEST['gid1']);
  60. }
  61. else
  62. {
  63. $gid1=$_REQUEST['course'];
  64. }
  65. for($r=0;$r<count($gid1);$r++)
  66. {
  67. if($r<count($gid1)-1)
  68. $str.=$gid1[$r].",";
  69. else
  70. $str.=$gid1[$r];
  71. }
  72. $arraycount=0;
  73. $arraycount=count($_REQUEST['course']);
  74. if(isset($_POST['back1']))
  75. {
  76. $db_name = $_REQUEST['db_name'];
  77. $curr_dbname = $_REQUEST['curr_dbname']; header("location:existing_surveys_new.php?cidReq=$cidReq&db_name=$db_name&surveyid=$surveyid&groupid=$groupid&curr_dbname=$curr_dbname");
  78. exit;
  79. }
  80. if(isset($_POST['view']))
  81. {
  82. if($arraycount<=0)
  83. {
  84. $pls=1;
  85. $db_name = $_REQUEST['db_name'];
  86. $curr_dbname = $_REQUEST['curr_dbname']; header("location:group_list.php?cidReq=$cidReq&surveyid=$surveyid&groupid=$groupid&pls=$pls&db_name=$db_name&sid=$sid");
  87. exit;
  88. }
  89. }
  90. if(isset($_POST['back']))
  91. {
  92. $pls=0;
  93. $sid = $_REQUEST['sid'];
  94. $db_name = $_REQUEST['db_name'];
  95. $surveyid=$_REQUEST['surveyid'];
  96. $curr_dbname = $_REQUEST['curr_dbname']; header("location:group_list.php?cidReq=$cidReq&db_name=$db_name&curr_dbname=$curr_dbname&surveyid=$surveyid&sid=$sid&pls=$pls");
  97. exit;
  98. }
  99. if(isset($_POST['import']))
  100. {
  101. if($arraycount<=0)
  102. {
  103. $pls=1;
  104. $db_name = $_REQUEST['db_name'];
  105. $curr_dbname = $_REQUEST['curr_dbname']; header("location:group_list.php?cidReq=$cidReq&surveyid=$surveyid&groupid=$groupid&pls=$pls&db_name=$db_name&sid=$sid&curr_dbname=$curr_dbname");
  106. exit;
  107. }
  108. else
  109. {
  110. $gid_arr = $_REQUEST['course'];
  111. $db_name = $_REQUEST['db_name'];
  112. $curr_dbname = $_REQUEST['curr_dbname'];
  113. $gids = implode(",",$gid_arr);
  114. $surveyid = $_POST['surveyid'];
  115. $groupid = $_POST['groupid'];
  116. //$flag = surveymanager::insert_old_groups($surveyid,$gids,$table_group,$table_question,$db_name,$cidReq);
  117. //$message_me = surveymanager::import_group($surveyid,$gids,$db_name,$curr_dbname);
  118. $flag = surveymanager::import_group($surveyid,$gids,$db_name,$curr_dbname);
  119. header("location:select_question_group.php?surveyid=$surveyid&cidReq=$cidReq&flag=$flag&curr_dbname=$curr_dbname");
  120. exit;
  121. }
  122. }
  123. if(isset($_POST['importquestion']))
  124. {
  125. $gidnext=$_POST['gid1'];
  126. $surveyid = $_POST['surveyid'];
  127. $groupid = $_POST['groupid'];
  128. $db_name = $_REQUEST['db_name'];
  129. $curr_dbname = $_REQUEST['curr_dbname'];
  130. $selectcount=count($_POST['question']);
  131. if($selectcount<=0)
  132. {
  133. $error_message=get_lang("PleaseSelectAChoice");
  134. }
  135. else
  136. {
  137. $qid_arr = $_REQUEST['question'];
  138. $qids = implode(",",$qid_arr);
  139. $message_me=surveymanager::question_import($surveyid,$qids,$db_name,$curr_dbname);
  140. if(isset($message_me) && $message_me)
  141. {
  142. header("location:select_question_group.php?surveyid=$surveyid&cidReq=$cidReq&curr_dbname=$curr_dbname&messege=$message_me");
  143. exit;
  144. }
  145. else
  146. {
  147. header("location:select_question_group.php?surveyid=$surveyid&cidReq=$cidReq&curr_dbname=$curr_dbname&messege=$message_me");
  148. exit;
  149. }
  150. }
  151. }
  152. Display :: display_header($tool_name);
  153. if( isset($error_message) )
  154. {
  155. Display::display_error_message($error_message);
  156. }
  157. ?>
  158. <SCRIPT LANGUAGE="JavaScript">
  159. function displayTemplate(url) {
  160. window.open(url, 'popup', 'width=600,height=800,scrollbars=yes,toolbar = no, status = no');
  161. }
  162. </script>
  163. <table>
  164. <tr>
  165. <td><strong><? echo get_lang('SurveyName'); ?></strong></td>
  166. <td><?echo $sname;?></td>
  167. </tr>
  168. <tr><td></td></tr>
  169. <tr><td></td></tr>
  170. </table>
  171. <?php
  172. echo get_lang('SelectQuestion');
  173. ?>
  174. <form method="post" action="<?php echo $_SERVER['PHP_SELF'];?>?cidReq=<?=$cidReq?>">
  175. <input type="hidden" name="action" value="add_survey"/>
  176. <input type="hidden" name="surveyid" value="<?=$surveyid?>">
  177. <input type="hidden" name="sid" value="<?=$sid?>">
  178. <input type="hidden" name="groupid" value="<?=$groupid?>">
  179. <input type="hidden" name="gid1" value="<?=$str?>">
  180. <input type="hidden" name="db_name" value="<?=$db_name?>">
  181. <input type="hidden" name="curr_dbname" value="<?=$curr_dbname;?>">
  182. <?
  183. $questions = array ();
  184. $cidReq=$_GET['cidReq'];
  185. $endloop=count($gid1);
  186. $datacount=0;
  187. $parameters = array ();
  188. $parameters['surveyid']=$surveyid;
  189. $parameters['sid']=$sid;
  190. $parameters['groupid']=$groupid;
  191. $parameters['cidReq']=$cidReq;
  192. $parameters['db_name']=$db_name;
  193. $parameters['curr_dbname']=$curr_dbname;
  194. $parameters['gid1']=$str;
  195. for($i=0;$i<$endloop;$i++)
  196. {
  197. $gidi=$gid1[$i];
  198. $sql = "SELECT * FROM $db_name.questions WHERE gid='$gidi' AND survey_id = '$sid'";
  199. $res = api_sql_query($sql,__FILE__,__LINE__);
  200. while ($obj = mysql_fetch_object($res))
  201. {
  202. $question = array ();
  203. $question[] = '<input type="checkbox" name="question[]" value="'.$obj->qid.'"/>';
  204. $question[] = $obj->caption;
  205. $question[] = $obj->qtype;
  206. $groupid = $obj->gid;
  207. $GName = surveymanager::get_groupname($db_name,$groupid);
  208. $question[] = $GName;
  209. $sid = surveymanager::get_surveyid($db_name,$groupid);
  210. $sname = surveymanager::get_surveyname($db_name,$sid);
  211. $question[] = $sname;
  212. /**********for displaying the 'edit' 'delete' etc. buttons***********/
  213. $url = "default.php?qid=".$obj->qid."&qtype=".$obj->qtype."&cidReq=".$cidReq."&surveyid=".$surveyid."&groupid=".$groupid."&db_name=".$db_name;
  214. $question[] = "<a href=\"#\" onClick=\"displayTemplate('".$url."')\"><img src=\"../img/info_small.gif\" border=\"0\" align=\"absmiddle\" alt=\"".get_lang('Info')."\" /></a>";
  215. $questions[] = $question;
  216. $datacount++;
  217. }
  218. }
  219. $table_header[] = array (' ', false);
  220. $table_header[] = array (get_lang('Question'), true);
  221. $table_header[] = array (get_lang('QuestionType1'), true);
  222. $table_header[] = array (get_lang('Group'),true);
  223. $table_header[] = array (get_lang('surveyname'),true);
  224. $table_header[] = array('', false);
  225. if($datacount>0)
  226. Display :: display_sortable_table($table_header, $questions, array (), array (), $parameters);
  227. else
  228. {
  229. $noquestions=get_lang("NoQuestionAvailableInThisGroup");
  230. api_display_tool_title($noquestions);
  231. }
  232. ?>
  233. <table>
  234. <tr>
  235. <td><input type="submit" name="back" value="<?echo get_lang("back");?>"></td>
  236. <td><input type="submit" name="importquestion" value="<? echo get_lang('ImportQuestion');?>"></td>
  237. </tr>
  238. </table>
  239. </form>
  240. <?php
  241. Display :: display_footer();
  242. ?>