question_added.php 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. <?php
  2. // $Id: course_list.php,v 1.15.2.1 2005/10/31 09:15:57 olivierb78 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. @author Bart Mollet
  23. * @package dokeos.admin
  24. ==============================================================================
  25. */
  26. /*
  27. ==============================================================================
  28. INIT SECTION
  29. ==============================================================================
  30. */
  31. $langFile = 'survey';
  32. require ('../inc/global.inc.php');
  33. api_protect_admin_script();
  34. require_once (api_get_path(LIBRARY_PATH).'/fileManage.lib.php');
  35. require_once (api_get_path(CONFIGURATION_PATH) ."/add_course.conf.php");
  36. require_once (api_get_path(LIBRARY_PATH)."/add_course.lib.inc.php");
  37. require_once (api_get_path(LIBRARY_PATH)."/surveymanager.lib.php");
  38. require_once (api_get_path(LIBRARY_PATH)."/course.lib.php");
  39. $cidReq=$_GET['cidReq'];
  40. $table_survey = Database :: get_course_table('survey');
  41. $table_group = Database :: get_course_table('survey_group');
  42. $table_question = Database :: get_course_table('questions');
  43. $interbredcrump[] = array ("url" => "survey.php", "name" => get_lang('CreateSurvey'));
  44. $groupid=$_REQUEST['groupid'];
  45. $surveyid=$_REQUEST['surveyid'];
  46. $qdeleted=0;
  47. //$cidReqdb = $dbNamePrefix.$_REQUEST['cidReq'];
  48. //echo "dsfgdsgfsdgdsfg".$groupid;
  49. if (isset($_POST['addanother']))
  50. {
  51. $groupid = $_POST['groupid'];
  52. $surveyid = $_POST['surveyid'];
  53. $cidReq=$_REQUEST['cidReq'];
  54. header("Location:addanother.php?groupid=$groupid&surveyid=$surveyid&cidReq=$cidReq");
  55. //header("Location:select_question_type.php?groupid=$groupid&surveyid=$surveyid&cidReq=$cidReq");
  56. exit;
  57. }
  58. if (isset($_POST['addanotherg']))
  59. {
  60. $groupid = $_POST['groupid'];
  61. $surveyid = $_POST['surveyid'];
  62. $cidReq=$_REQUEST['cidReq'];
  63. header("Location:create_new_group.php?groupid=$groupid&surveyid=$surveyid&cidReq=$cidReq");
  64. exit;
  65. }
  66. if(isset($_POST['delete']))
  67. {
  68. if(isset($_POST['qid']))
  69. {
  70. $endloop=count($_POST['qid']);
  71. $qid1=$_POST['qid'];
  72. for($i=0;$i<$endloop;$i++)
  73. {
  74. $qid2=$qid1[$i];
  75. $query="DELETE FROM $table_question WHERE qid='$qid2'";
  76. api_sql_query($query);
  77. }
  78. $qdeleted=1;
  79. }
  80. }
  81. if (isset($_POST['finish']))
  82. {
  83. $cidReq=$_REQUEST['cidReq'];
  84. header("Location:survey_list.php?cidReq=$cidReq");
  85. exit;
  86. }
  87. $query="SELECT * FROM $table_survey WHERE survey_id='$surveyid'";
  88. $result=api_sql_query($query);
  89. $survey_name=@mysql_result($result,0,'title');
  90. $author=@mysql_result($result,0,'author');
  91. $tool_name = get_lang('QuestionsAdded');
  92. Display :: display_header($tool_name);
  93. $survey_name=get_lang('SurveyName').$survey_name;
  94. $author=get_lang('author').$author;
  95. api_display_tool_title($survey_name);
  96. api_display_tool_title($tool_name);
  97. if($qdeleted)
  98. {
  99. ?>
  100. <h2><?php echo "Question(s) Deleted";?></h2>
  101. <?php
  102. }
  103. ?>
  104. <form method="post" action="<?php echo $_SERVER['PHP_SELF'];?>?cidReq=<?=$cidReq?>">
  105. <input type="hidden" name="groupid" value="<?=$groupid?>">
  106. <input type="hidden" name="surveyid" value="<?=$surveyid?>">
  107. <!--<input type="hidden" name="cidReq" value="<?=$cidReq?>">-->
  108. <?php
  109. $sql="SELECT * FROM $table_group WHERE survey_id='$surveyid'";
  110. $res = api_sql_query($sql,__FILE__,__LINE__);
  111. $num=mysql_num_rows($res);
  112. $table_header[] = array (' ', false);
  113. //$table_header[] = array (get_lang('SNo'), true);
  114. $table_header[] = array (get_lang('questions'), true);
  115. $table_header[] = array (get_lang('group'), true);
  116. $table_header[] = array (get_lang('type'), true);
  117. $courses = array ();
  118. for($i=0;$i<$num;$i++)
  119. {
  120. $groupid=@mysql_result($res,$i,'group_id');
  121. $gname=@mysql_result($res,$i,'groupname');
  122. $sql="SELECT * FROM $table_question WHERE gid='$groupid'";
  123. $res1=api_sql_query($sql,__FILE__,__LINE__);
  124. while ($obj = mysql_fetch_object($res1))
  125. {
  126. $course = array ();
  127. $course[] = '<input type="checkbox" name="qid[]" value="'.$obj->qid.'"/>';
  128. //$course[] = $j++;//$obj->visual_code;
  129. $course[] = $obj->caption;//tab-header-questions
  130. $course[] = @mysql_result($res,$i,'groupname');//$obj->course_language;
  131. $course[] = $obj->qtype;
  132. $courses[] = $course;
  133. }
  134. }
  135. //echo '<form method="post" action="questionsadded1.php">';
  136. Display :: display_sortable_table($table_header, $courses, array (), array (), $parameters);
  137. //echo '</form>';
  138. ?>
  139. <input type="submit" name="delete" value="<? echo get_lang("Delete");?>">
  140. <input type="submit" name="addanother" value="<?echo get_lang("AddAnotherQuestion");?>">
  141. <input type="submit" name="addanotherg" value="<?echo get_lang("AddAnotherGroup");?>">
  142. <input type="submit" name="finish" value="<? echo get_lang("finishsurvey");?>">
  143. </form>
  144. <?
  145. /*
  146. ==============================================================================
  147. FOOTER
  148. ==============================================================================
  149. */
  150. Display :: display_footer();
  151. ?>