select_question_group-uploaded.php 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385
  1. <?php
  2. // $Id: course_add.php,v 1.10 2005/05/30 11:46:48 bmol Exp $
  3. /*
  4. ==============================================================================
  5. Dokeos - elearning and course management software
  6. Copyright (c) 2004 Dokeos S.A.
  7. Copyright (c) 2003 University of Ghent (UGent)
  8. Copyright (c) 2001 Universite catholique de Louvain (UCL)
  9. Copyright (c) Olivier Brouckaert
  10. For a full list of contributors, see "credits.txt".
  11. The full license can be read in "license.txt".
  12. This program is free software; you can redistribute it and/or
  13. modify it under the terms of the GNU General Public License
  14. as published by the Free Software Foundation; either version 2
  15. of the License, or (at your option) any later version.
  16. See the GNU General Public License for more details.
  17. Contact: Dokeos, 181 rue Royale, B-1000 Brussels, Belgium, info@dokeos.com
  18. ==============================================================================
  19. */
  20. /**
  21. ==============================================================================
  22. * @package dokeos.admin
  23. ==============================================================================
  24. */
  25. /*
  26. ==============================================================================
  27. INIT SECTION
  28. ==============================================================================
  29. */
  30. $langFile = 'survey';
  31. require_once ('../inc/global.inc.php');
  32. //api_protect_admin_script();
  33. require_once (api_get_path(LIBRARY_PATH).'/fileManage.lib.php');
  34. require_once (api_get_path(CONFIGURATION_PATH) ."/add_course.conf.php");
  35. require_once (api_get_path(LIBRARY_PATH)."/add_course.lib.inc.php");
  36. require_once (api_get_path(LIBRARY_PATH)."/surveymanager.lib.php");
  37. $status = surveymanager::get_status();
  38. if($status==5)
  39. {
  40. api_protect_admin_script();
  41. }
  42. /*
  43. echo "<pre>";
  44. print_r($_SESSION);
  45. echo "</pre>";
  46. */
  47. $table_survey = Database :: get_course_table('survey');
  48. $table_group = Database :: get_course_table('survey_group');
  49. $table_question = Database :: get_course_table('questions');
  50. $table_course = Database::get_main_table(MAIN_COURSE_TABLE);
  51. $cidReq = $_GET['cidReq'];
  52. $db_name = $_REQUEST['db_name'];
  53. $curr_dbname = $_REQUEST['curr_dbname'];
  54. //$table_survey = Database :: get_course_table('survey');
  55. $tool_name1 = get_lang('selectquestiongroup1');
  56. $tool_name = get_lang('selectquestiongroup');
  57. $interbredcrump[] = array ("url" => "survey_list.php", "name" => get_lang('Survey'));
  58. /*if($page = $_REQUEST['page'])
  59. {
  60. $interbredcrump[] = array ("url" => "create_new_survey.php?surveyid=$surveyid&cidReq=$cidReq&curr_dbname=$curr_dbname&page=$page", "name" => get_lang('CreateNewSurvey'));
  61. }
  62. else
  63. {
  64. $interbredcrump[] = array ("url" => "create_new_survey.php?surveyid=$surveyid&cidReq=$cidReq&curr_dbname=$curr_dbname&page=$page", "name" => get_lang('CreateFromExistingSurvey'));
  65. }*/
  66. $coursePathWeb = api_get_path(WEB_COURSE_PATH);
  67. $coursePathSys = api_get_path(SYS_COURSE_PATH);
  68. $default_group = '0';
  69. $new_group = '1';
  70. $existing_group = '2';
  71. $surveyid = $_REQUEST['surveyid'];
  72. $sname = surveymanager::pick_surveyname($surveyid);
  73. $groupid = $_REQUEST['groupid'];
  74. $newgroupid = $_REQUEST['newgroupid'];
  75. $messege = $_REQUEST['messege'];
  76. $flag = $_REQUEST['flag'];
  77. $action1 = $_REQUEST['action1'];
  78. $sort = $_REQUEST['sortby'];
  79. if(empty($page_nr)||empty($column)||empty($per_page))
  80. {
  81. $page_nr =1;
  82. $column =0;
  83. $per_page = 10;
  84. }
  85. else
  86. {
  87. $page_nr = $_REQUEST['page_nr'];
  88. $column = $_REQUEST['column'];
  89. $per_page = $_REQUEST['per_page'];
  90. }
  91. /*
  92. $sql="SELECT * FROM $curr_dbname.questions WHERE gid='$groupid' AND survey_id = '$surveyid'";
  93. $res=api_sql_query($sql,__FILE__,__LINE__);
  94. $obj=mysql_fetch_object($res);
  95. $number=mysql_num_rows($res);
  96. for($i=1;$i<=$number;$i++)
  97. {
  98. $up="up";
  99. $down="down";
  100. if(isset($_POST[$up])||isset($_POST[$down]))
  101. {
  102. $flag=0;
  103. if(isset($_POST[$up]))
  104. {
  105. $tempmutlichkboxtext=$_POST['boxtext'];
  106. if($tempradiodefault==$i)
  107. $tempradiodefault--;
  108. elseif($tempradiodefault==$i-1)
  109. $tempradiodefault++;
  110. $tempchkboxpoint=$_POST['chkboxpoint'];
  111. if($tempradiotrue==$i)
  112. $tempradiotrue--;
  113. elseif($tempradiotrue==$i-1)
  114. $tempradiotrue++;
  115. $tempm= $tempmutlichkboxtext[$i-2];
  116. $tempchkboxp=$tempchkboxpoint[$i-2];
  117. $tempmutlichkboxtext[$i-2]=$tempmutlichkboxtext[$i-1];
  118. $tempchkboxpoint[$i-2]=$tempchkboxpoint[$i-1];
  119. $tempmutlichkboxtext[$i-1]=$tempm;
  120. $tempchkboxpoint[$i-1]=$tempchkboxp;
  121. $_POST['mutlichkboxtext']=$tempmutlichkboxtext;
  122. $_POST['chkboxpoint']=$tempchkboxpoint;
  123. }
  124. if(isset($_POST[$down]))
  125. {
  126. $tempmutlichkboxtext=$_POST['mutlichkboxtext'];
  127. if($tempradiodefault==$i)
  128. $tempradiodefault++;
  129. elseif($tempradiodefault==$i+1)
  130. $tempradiodefault--;
  131. $tempchkboxpoint=$_POST['chkboxpoint'];
  132. if($tempradiotrue==$i)
  133. $tempradiotrue++;
  134. elseif($tempradiotrue==$i+1)
  135. $tempradiotrue--;
  136. $tempm= $tempmutlichkboxtext[$i];
  137. $tempchkboxp=$tempchkboxpoint[$i];
  138. $tempmutlichkboxtext[$i]=$tempmutlichkboxtext[$i-1];
  139. $tempchkboxpoint[$i]=$tempchkboxpoint[$i-1];
  140. $tempmutlichkboxtext[$i-1]=$tempm;
  141. $tempchkboxpoint[$i-1]=$tempchkboxp;
  142. $_POST['mutlichkboxtext']=$tempmutlichkboxtext;
  143. $_POST['chkboxpoint']=$tempchkboxpoint;
  144. }
  145. //echo ",while checking up/down end=".$end;
  146. $jd=0;
  147. break;
  148. }
  149. }
  150. */
  151. if ($_POST['action'] == 'selectquestion_group')
  152. {
  153. $surveyid = $_POST['newsurveyid'];
  154. $questiongroup = $_POST['question_group'];
  155. if (isset($questiongroup))
  156. {
  157. $cidReq=$_REQUEST['cidReq'];
  158. $exiztinggroup = $_POST['exiztinggroup'];
  159. $curr_dbname = $_REQUEST['curr_dbname'];
  160. header("Location:existing_surveys_new.php?cidReq=$cidReq&surveyid=$surveyid&curr_dbname=$curr_dbname");
  161. exit;
  162. }
  163. }
  164. //from question_added
  165. if (isset($_POST['back']))
  166. {
  167. $groupid = $_POST['groupid'];
  168. $surveyid = $_POST['surveyid'];
  169. $cidReq=$_REQUEST['cidReq'];
  170. $curr_dbname = $_REQUEST['curr_dbname'];
  171. $page = $_REQUEST['page'];
  172. header("Location:create_new_survey.php?surveyid=$surveyid&cidReq=$cidReq&curr_dbname=$curr_dbname&page=$page");
  173. //header("Location:select_question_type.php?groupid=$groupid&surveyid=$surveyid&cidReq=$cidReq");
  174. exit;
  175. }
  176. if (isset($_POST['addanother']))
  177. {
  178. $groupid = $_POST['groupid'];
  179. $surveyid = $_POST['surveyid'];
  180. $cidReq=$_REQUEST['cidReq'];
  181. $curr_dbname = $_REQUEST['curr_dbname'];
  182. header("Location:addanother.php?surveyid=$surveyid&cidReq=$cidReq&curr_dbname=$curr_dbname");
  183. //header("Location:select_question_type.php?groupid=$groupid&surveyid=$surveyid&cidReq=$cidReq");
  184. exit;
  185. }
  186. if (isset($_POST['addanotherg']))
  187. {
  188. //$groupid = $_POST['groupid'];
  189. $surveyid = $_POST['surveyid'];
  190. $cidReq=$_REQUEST['cidReq'];
  191. $curr_dbname = $_REQUEST['curr_dbname'];
  192. header("Location:create_new_group.php?surveyid=$surveyid&cidReq=$cidReq&curr_dbname=$curr_dbname");
  193. exit;
  194. }
  195. if(isset($_REQUEST['delete']))
  196. {
  197. $curr_dbname = $_REQUEST['curr_dbname'];
  198. if(isset($_REQUEST['qid']))
  199. {
  200. $endloop=count($_REQUEST['qid']);
  201. $qid1=$_REQUEST['qid'];
  202. for($i=0;$i<$endloop;$i++)
  203. {
  204. $qid2=$qid1[$i];
  205. $query="DELETE FROM $curr_dbname.questions WHERE qid='$qid2'";
  206. api_sql_query($query);
  207. header("Location:select_question_group.php?surveyid=$surveyid&cidReq=$cidReq&curr_dbname=$curr_dbname");
  208. exit;
  209. }
  210. }
  211. }
  212. if (isset($_POST['finish']))
  213. {
  214. $cidReq=$_REQUEST['cidReq'];
  215. header("Location:survey_list.php?cidReq=$cidReq");
  216. exit;
  217. }
  218. if(isset($action1))
  219. {
  220. $curr_dbname = $_REQUEST['curr_dbname'];
  221. $groupid = $_REQUEST['gid'];
  222. $surveyid = $_REQUEST['surveyid'];
  223. $qid = $_GET['qid'];
  224. $pre_qid = $_GET['pre_qid'];
  225. $post_qid = $_GET['post_qid'];
  226. $direction = $_GET['direction'];
  227. $pre_sort = $_GET['pre_sort'];
  228. $sort = $_GET['sortby'];
  229. $post_sort = $_GET['post_sort'];
  230. if($direction=="up")
  231. {
  232. $sql_update2="UPDATE $curr_dbname.questions SET sortby='".$sort."' WHERE qid='".$pre_qid."'";
  233. mysql_query($sql_update2);
  234. $sql_update1="UPDATE $curr_dbname.questions SET sortby='".$pre_sort."' WHERE qid='".$qid."'";
  235. mysql_query($sql_update1);
  236. }
  237. else
  238. {
  239. $sql_update2="UPDATE $curr_dbname.questions SET sortby='".$post_sort."' WHERE qid='".$qid."'";
  240. mysql_query($sql_update2);
  241. $sql_update1="UPDATE $curr_dbname.questions SET sortby='".$sort."' WHERE qid='".$post_qid."'";
  242. mysql_query($sql_update1);
  243. }
  244. //surveymanager::move_question($direction,$qid,$pre_sort,$sort,$post_sort,$curr_dbname);
  245. }
  246. Display::display_header($tool_name1);
  247. api_display_tool_title("Survey Name : ".$sname);
  248. api_display_tool_title($tool_name);
  249. if($flag==1)
  250. {
  251. ?>
  252. <div align="center"><strong><font color="#FF0000"><?echo get_lang('AlreadyImported');?></font></strong></div>
  253. <?
  254. }
  255. if(isset($messege) && $messege )
  256. {
  257. ?>
  258. <div align="center"><strong><font color="#FF0000">Already Imported !</font></strong></div>
  259. <?
  260. }
  261. ?>
  262. <form method="post" action="<?php echo $_SERVER['PHP_SELF'];?>?cidReq=<?=$cidReq?>">
  263. <input type="hidden" name="action" value="selectquestion_group">
  264. <input type="hidden" name="newsurveyid" value="<?=$surveyid;?>">
  265. <input type="hidden" name="curr_dbname" value="<?=$curr_dbname;?>">
  266. <input type="hidden" name="cidReq" value="<?=$_REQUEST['cidReq']?>">
  267. <!--<input type="hidden" name="qid" value="<?=$_REQUEST['qid']?>">
  268. <input type="hidden" name="direction" value="<?=$_REQUEST['direction']?>">-->
  269. <table>
  270. <tr>
  271. <td valign="top"></td>
  272. <td>
  273. </td></tr>
  274. <tr>
  275. <td></td>
  276. <td></td>
  277. </tr>
  278. <tr>
  279. <td></td>
  280. </tr>
  281. <tr>
  282. <td>&nbsp;</td>
  283. <td><input type="submit" name="question_group" value="<?php echo get_lang("importquestionsfromexistinggroup"); ?>"></td>
  284. </tr>
  285. </table>
  286. </form>
  287. <?php
  288. /*$query="SELECT * FROM $curr_dbname.survey WHERE survey_id='$surveyid'";
  289. $result=api_sql_query($query);*/
  290. $sql="SELECT * FROM $curr_dbname.survey_group WHERE survey_id='$surveyid'";
  291. $res = api_sql_query($sql,__FILE__,__LINE__);
  292. $num=mysql_num_rows($res);
  293. $parameters['curr_dbname']=$curr_dbname;
  294. $parameters['surveyid']=$surveyid;
  295. $parameters['cidReq']=$cidReq;
  296. //$table_header[] = array (' ', false);
  297. //$table_header[] = array (get_lang('SNo'), true);
  298. $table_header[] = array (get_lang('questions1'), true);
  299. $table_header[] = array (get_lang('ChangeOrder'), true);
  300. $table_header[] = array (get_lang('group'), true);
  301. $table_header[] = array (get_lang('type1'), true);
  302. $table_header[]=array('',true);
  303. $courses = array ();
  304. if($num){
  305. for($i=0;$i<$num;$i++)
  306. {
  307. $groupid=@mysql_result($res,$i,'group_id');
  308. $gname=@mysql_result($res,$i,'groupname');
  309. $sql="SELECT * FROM $curr_dbname.questions WHERE gid='$groupid' AND survey_id = '$surveyid' order by `sortby` asc";
  310. $res1=api_sql_query($sql,__FILE__,__LINE__);
  311. $num1=mysql_num_rows($res1);
  312. $x=1;
  313. for($k=0;$k<$num1;$k++)
  314. //while ($obj = mysql_fetch_object($res1))
  315. {
  316. $qid=mysql_result($res1,$k,'qid');//$obj->qid;
  317. $pre_qid=mysql_result($res1,$k-1,'qid');
  318. $post_qid=mysql_result($res1,$k+1,'qid');
  319. $question=mysql_result($res1,$k,'caption');//$obj->caption;
  320. $sort=mysql_result($res1,$k,'sortby');//$obj->sortby;
  321. $pre_sort=$k==0?mysql_result($res1,$k,'sortby'):mysql_result($res1,$k-1,'sortby');//$obj->sortby;
  322. $post_sort=$k==$num1?mysql_result($res1,$k,'sortby'):mysql_result($res1,$k+1,'sortby');//$obj->sortby;
  323. $course = array ();
  324. $course[] = $question;
  325. $course[] = '<a href='.$_SERVER['PHP_SELF'].'?gid='.$groupid.'&pre_sort='.$pre_sort.'&sortby='.$sort.'&post_sort='.$post_sort.'&surveyid='.$surveyid.'&pre_qid='.$pre_qid.'&qid='.$qid.'&post_qid='.$post_qid.'&curr_dbname='.$curr_dbname.'&cidReq='.$cidReq.'&page_nr='.$page_nr.'&per_page='.$per_page.'&column='.$column.'&action1=moveitem&direction=down><img src="../img/down.gif" border="0" title="lang_move_down"></a>&nbsp;'.$sort.'&nbsp;&nbsp;'.'<a href='.$_SERVER['PHP_SELF'].'?gid='.$groupid.'&pre_sort='.$pre_sort.'&sortby='.$sort.'&post_sort='.$post_sort.'&surveyid='.$surveyid.'&pre_qid='.$pre_qid.'&qid='.$qid.'&post_qid='.$post_qid.'&curr_dbname='.$curr_dbname.'&cidReq='.$cidReq.'&page_nr='.$page_nr.'&per_page='.$per_page.'&column='.$column.'&action1=moveitem&direction=up><img src="../img/up.gif" border="0" title="lang_move_up"></a>';
  326. $course[] = @mysql_result($res,$i,'groupname');
  327. $course[] = mysql_result($res1,$k,'qtype');//$obj->qtype;
  328. /*$course[]='<a href="question_edit.php?qid='.$obj->qid.'&cidReq='.$cidReq.'&curr_dbname='.$curr_dbname.'&qtype='.$obj->qtype.'&groupid='.$groupid.'&surveyid='.$surveyid.'"><img src="../img/edit.gif" border="0" align="absmiddle" alt="'.get_lang('Edit').'"/></a>'.'<a href="select_question_group.php?delete=1&qid[]='.$obj->qid.'&cidReq='.$cidReq.'&curr_dbname='.$curr_dbname.'&qtype='.$obj->qtype.'&groupid='.$groupid.'&surveyid='.$surveyid.'" onclick="javascript:if(!confirm('."'".addslashes(htmlentities(get_lang("ConfirmYourChoice")))."'".')) return false;"><img src="../img/delete.gif" border="0" align="absmiddle" alt="'.get_lang('Delete').'"/></a>';
  329. */
  330. $courses[] = $course;
  331. $x++;
  332. }
  333. }
  334. }
  335. ?>
  336. <form method="post" action="<?php echo $_SERVER['PHP_SELF'];?>?cidReq=<?=$cidReq?>">
  337. <input type="hidden" name="groupid" value="<?=$groupid?>">
  338. <input type="hidden" name="surveyid" value="<?=$surveyid?>">
  339. <input type="hidden" name="curr_dbname" value="<?=$curr_dbname;?>">
  340. <input type="hidden" name="page" value="<?=$page;?>">
  341. <?
  342. if(!empty($courses))
  343. {
  344. SurveyManager :: display_sortable_table($groupid,$surveyid,$curr_dbname,$table_header, $courses, array (), array (), $parameters);
  345. ?>
  346. <!--<input type="submit" name="delete" value="<? echo get_lang("Delete");?>">-->
  347. <!--<input type=button value="Back" onClick="history.go(-1)">-->
  348. <input type="submit" name="addanother" value="<?echo get_lang("AddAnotherQuestion");?>">
  349. <input type="submit" name="addanotherg" value="<?echo get_lang("AddNewGroup");?>">
  350. <input type="submit" name="finish" value="<? echo get_lang("finishsurvey");?>">
  351. <?
  352. }
  353. else
  354. {
  355. ?>
  356. <input type="submit" name="back" value="<?echo get_lang("back");?>">
  357. <input type="submit" name="addanother" value="<?echo get_lang("AddAnotherQuestion");?>">
  358. <input type="submit" name="addanotherg" value="<?echo get_lang("AddNewGroup");?>">
  359. <?
  360. }
  361. ?>
  362. </form>
  363. <!-- question_added-->
  364. <?php
  365. /*
  366. ==============================================================================
  367. FOOTER
  368. ==============================================================================
  369. */
  370. Display :: display_footer();
  371. ?>