question_added.php 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. <?php
  2. /*
  3. DOKEOS - elearning and course management software
  4. For a full list of contributors, see documentation/credits.html
  5. This program is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU General Public License
  7. as published by the Free Software Foundation; either version 2
  8. of the License, or (at your option) any later version.
  9. See "documentation/licence.html" more details.
  10. Contact:
  11. Dokeos
  12. Rue des Palais 44 Paleizenstraat
  13. B-1030 Brussels - Belgium
  14. Tel. +32 (2) 211 34 56
  15. */
  16. /**
  17. * @package dokeos.survey
  18. * @author
  19. * @version $Id: question_added.php 10680 2007-01-11 21:26:23Z pcool $
  20. */
  21. /*
  22. ==============================================================================
  23. INIT SECTION
  24. ==============================================================================
  25. */
  26. // name of the language file that needs to be included
  27. $language_file = 'survey';
  28. require ('../inc/global.inc.php');
  29. api_protect_admin_script();
  30. require_once (api_get_path(LIBRARY_PATH).'/fileManage.lib.php');
  31. require_once (api_get_path(CONFIGURATION_PATH) ."/add_course.conf.php");
  32. require_once (api_get_path(LIBRARY_PATH)."/add_course.lib.inc.php");
  33. require_once (api_get_path(LIBRARY_PATH)."/surveymanager.lib.php");
  34. require_once (api_get_path(LIBRARY_PATH)."/course.lib.php");
  35. $table_survey = Database :: get_course_table(TABLE_SURVEY);
  36. $table_group = Database :: get_course_table(TABLE_SURVEY_GROUP);
  37. $table_survey_question = Database :: get_course_table(TABLE_SURVEY_QUESTION);
  38. $interbreadcrumb[] = array ("url" => "survey.php", "name" => get_lang('CreateSurvey'));
  39. $groupid=$_REQUEST['groupid'];
  40. $surveyid=$_REQUEST['surveyid'];
  41. $qdeleted=0;
  42. if (isset($_POST['addanother']))
  43. {
  44. $groupid = $_POST['groupid'];
  45. $surveyid = $_POST['surveyid'];
  46. header("Location:addanother.php?groupid=$groupid&surveyid=$surveyid");
  47. //header("Location:select_question_type.php?groupid=$groupid&surveyid=$surveyid");
  48. exit;
  49. }
  50. if (isset($_POST['addanotherg']))
  51. {
  52. $groupid = $_POST['groupid'];
  53. $surveyid = $_POST['surveyid'];
  54. header("Location:create_new_group.php?groupid=$groupid&surveyid=$surveyid");
  55. exit;
  56. }
  57. if(isset($_POST['delete']))
  58. {
  59. if(isset($_POST['qid']))
  60. {
  61. $endloop=count($_POST['qid']);
  62. $qid1=$_POST['qid'];
  63. for($i=0;$i<$endloop;$i++)
  64. {
  65. $qid2=$qid1[$i];
  66. $query="DELETE FROM $table_survey_question WHERE qid='$qid2'";
  67. api_sql_query($query);
  68. }
  69. $qdeleted=1;
  70. }
  71. }
  72. if (isset($_POST['finish']))
  73. {
  74. header("Location:survey_list.php");
  75. exit;
  76. }
  77. $query="SELECT * FROM $table_survey WHERE survey_id='$surveyid'";
  78. $result=api_sql_query($query);
  79. $survey_name=@mysql_result($result,0,'title');
  80. $author=@mysql_result($result,0,'author');
  81. $tool_name = get_lang('QuestionsAdded');
  82. Display :: display_header($tool_name);
  83. $survey_name=get_lang('SurveyName').$survey_name;
  84. $author=get_lang('Author').$author;
  85. api_display_tool_title($survey_name);
  86. api_display_tool_title($tool_name);
  87. if($qdeleted)
  88. {
  89. ?>
  90. <h2><?php echo "Question(s) Deleted";?></h2>
  91. <?php
  92. }
  93. ?>
  94. <form method="post" action="<?php echo $_SERVER['PHP_SELF'];?>">
  95. <input type="hidden" name="groupid" value="<?php echo $groupid; ?>">
  96. <input type="hidden" name="surveyid" value="<?php echo $surveyid; ?>">
  97. <?php
  98. $sql="SELECT * FROM $table_group WHERE survey_id='$surveyid'";
  99. $res = api_sql_query($sql,__FILE__,__LINE__);
  100. $num=mysql_num_rows($res);
  101. $table_header[] = array (' ', false);
  102. //$table_header[] = array (get_lang('SNo'), true);
  103. $table_header[] = array (get_lang('questions'), true);
  104. $table_header[] = array (get_lang('Group'), true);
  105. $table_header[] = array (get_lang('Type'), true);
  106. $courses = array ();
  107. for($i=0;$i<$num;$i++)
  108. {
  109. $groupid=@mysql_result($res,$i,'group_id');
  110. $gname=@mysql_result($res,$i,'groupname');
  111. $sql="SELECT * FROM $table_survey_question WHERE gid='$groupid'";
  112. $res1=api_sql_query($sql,__FILE__,__LINE__);
  113. while ($obj = mysql_fetch_object($res1))
  114. {
  115. $course = array ();
  116. $course[] = '<input type="checkbox" name="qid[]" value="'.$obj->qid.'"/>';
  117. //$course[] = $j++;//$obj->visual_code;
  118. $course[] = $obj->caption;//tab-header-questions
  119. $course[] = @mysql_result($res,$i,'groupname');//$obj->course_language;
  120. $course[] = $obj->qtype;
  121. $courses[] = $course;
  122. }
  123. }
  124. //echo '<form method="post" action="questionsadded1.php">';
  125. Display :: display_sortable_table($table_header, $courses, array (), array (), $parameters);
  126. //echo '</form>';
  127. ?>
  128. <input type="submit" name="delete" value="<?php echo get_lang('Delete');?>">
  129. <input type="submit" name="addanother" value="<?php echo get_lang('AddAnotherQuestion');?>">
  130. <input type="submit" name="addanotherg" value="<?php echo get_lang('AddAnotherGroup');?>">
  131. <input type="submit" name="finish" value="<?php echo get_lang('FinishSurvey');?>">
  132. </form>
  133. <?php
  134. /*
  135. ==============================================================================
  136. FOOTER
  137. ==============================================================================
  138. */
  139. Display :: display_footer();
  140. ?>