addanother.php 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. <?php
  2. /*
  3. ===================================================================================
  4. Dokeos - elearning and course management software
  5. ===================================================================================
  6. For a full list of contributors, see documentation/credits.html
  7. This program is free software; you can redistribute it and/or
  8. modify it under the terms of the GNU General Public License
  9. as published by the Free Software Foundation; either version 2
  10. of the License, or (at your option) any later version.
  11. See "documentation/licence.html" more details.
  12. Contact:
  13. Dokeos
  14. Rue des Palais 44 Paleizenstraat
  15. B-1030 Brussels - Belgium
  16. Tel. +32 (2) 211 34 56
  17. ===================================================================================
  18. */
  19. /**
  20. ==============================================================================
  21. * @package dokeos.survey
  22. * @author
  23. * @version $Id: addanother.php 10680 2007-01-11 21:26:23Z pcool $
  24. ==============================================================================
  25. */
  26. /*
  27. ==============================================================================
  28. INIT SECTION
  29. ==============================================================================
  30. */
  31. // name of the language file that needs to be included
  32. $language_file = 'survey';
  33. // including the global dokeos file
  34. require_once ('../inc/global.inc.php');
  35. // including additional libraries
  36. /** @todo check if these are all needed */
  37. /** @todo check if the starting / is needed. api_get_path probably ends with an / */
  38. require_once (api_get_path(LIBRARY_PATH).'/fileManage.lib.php');
  39. require_once (api_get_path(CONFIGURATION_PATH) ."/add_course.conf.php");
  40. require_once (api_get_path(LIBRARY_PATH)."/add_course.lib.inc.php");
  41. require_once (api_get_path(LIBRARY_PATH)."/course.lib.php");
  42. require_once (api_get_path(LIBRARY_PATH)."/groupmanager.lib.php");
  43. require_once (api_get_path(LIBRARY_PATH)."/surveymanager.lib.php");
  44. require_once (api_get_path(LIBRARY_PATH)."/usermanager.lib.php");
  45. /** @todo replace this with the correct code */
  46. /*
  47. $status = surveymanager::get_status();
  48. api_protect_course_script();
  49. if($status==5)
  50. {
  51. api_protect_admin_script();
  52. }
  53. */
  54. /** @todo this has to be moved to a more appropriate place (after the display_header of the code)*/
  55. if (!api_is_allowed_to_edit())
  56. {
  57. Display :: display_header();
  58. Display :: display_error_message(get_lang('NotAllowedHere'));
  59. Display :: display_footer();
  60. exit;
  61. }
  62. // Database table definitions
  63. /** @todo use database constants for the survey tables */
  64. $table_user = Database :: get_main_table(TABLE_MAIN_USER);
  65. $table_survey = Database :: get_course_table(TABLE_SURVEY);
  66. $table_group = Database :: get_course_table(TABLE_SURVEY_GROUP);
  67. // Language variables
  68. $tool_name = get_lang('CreateNewSurvey');
  69. $tool_name1 = get_lang('AddAnotherQuestion');
  70. // breadcrumbs
  71. $interbreadcrumb[] = array ("url" => "survey_list.php", "name" => get_lang('Survey'));
  72. // Variables
  73. /** @todo use $_course array */
  74. $course_id = $_SESSION['_course']['id'];
  75. // $_GET and $_POST
  76. /** @todo replace $_REQUEST with $_GET or $_POST */
  77. $group_id = $_GET['newgroupid'];
  78. if(isset($_REQUEST['groupid']))
  79. {
  80. $groupid=$_REQUEST['groupid'];
  81. }
  82. if(isset($_REQUEST['newgroupid']))
  83. {
  84. $groupid=$_REQUEST['newgroupid'];
  85. }
  86. if(isset($_POST['back']))
  87. {
  88. header("location:select_question_group.php?add_question=$add_question&groupid=$groupid&surveyid=".$_GET['surveyid']);
  89. }
  90. if(isset($_POST['next']))
  91. {
  92. if(isset($_POST['add_question']))
  93. {
  94. if(isset($_POST['exiztinggroup']))
  95. {
  96. $groupid=$_POST['exiztinggroup'];
  97. $add_question=$_POST['add_question'];
  98. /** @todo it seems a bad idea to use language strings for switch statements and $_POST variables */
  99. switch ($_POST['add_question'])
  100. {
  101. case get_lang('YesNo'):
  102. header("location:yesno.php?add_question=$add_question&groupid=$groupid&surveyid=".$_GET['surveyid']);
  103. break;
  104. case get_lang('MultipleChoiceSingle'):
  105. header("location:mcsa.php?add_question=$add_question&groupid=$groupid&surveyid=".$_GET['surveyid']);
  106. break;
  107. case get_lang('MultipleChoiceMulti'):
  108. header("location:mcma.php?add_question=$add_question&groupid=$groupid&surveyid=".$_GET['surveyid']);
  109. break;
  110. case get_lang('Open'):
  111. header("location:open.php?add_question=$add_question&groupid=$groupid&surveyid=".$_GET['surveyid']);
  112. break;
  113. case get_lang('Numbered'):
  114. header("location:numbered.php?add_question=$add_question&groupid=$groupid&surveyid=".$_GET['surveyid']);
  115. break;
  116. default :
  117. header("location:select_question_type.php");
  118. break;
  119. }
  120. }
  121. else
  122. $error_message = get_lang('PleaseSelectGroup')."<br>";
  123. //exit;
  124. }
  125. else
  126. $error_message=get_lang('PleaseSelectQuestionAndGroup');
  127. }
  128. Display::display_header($tool_name1);
  129. $query="SELECT * FROM $table_survey WHERE survey_id='".mysql_real_escape_string($_GET['surveyid'])."'";
  130. $result=api_sql_query($query);
  131. $surveyname=mysql_result($result,0,'title');
  132. //$surveyname=get_lang('SurveyName').$surveyname;
  133. api_display_tool_title(get_lang('SurveyName')."".$surveyname);
  134. api_display_tool_title($tool_name1);
  135. if(isset($error_message))
  136. Display::display_error_message($error_message);
  137. if(isset($group_id))
  138. {
  139. $sql = "SELECT * FROM $table_group WHERE group_id='$group_id'";
  140. $res = api_sql_query($sql, __FILE__, __LINE__);
  141. $obj= mysql_fetch_object($res);
  142. ?>
  143. <div align="center"><strong><font color="#FF0000"><?php echo "Group";?>&nbsp;&nbsp;<font color="#0000CC"><u><?php echo $obj->groupname;?></u>&nbsp;&nbsp;</font><?php echo get_lang('GroupCreated');?></font></strong></div>
  144. <?php
  145. }
  146. ?>
  147. <form name="question" method="post" action="<?php echo $_SERVER['PHP_SELF'];?>">
  148. <input type="hidden" name="groupid" value="<?php echo $groupid; ?>">
  149. <input type="hidden" name="surveyid" value="<?php echo $_GET['surveyid']; ?>">
  150. <input type="hidden" name="newgroupid" value="<?php echo $group_id; ?>">
  151. <table>
  152. <tr>
  153. <td>
  154. <?php echo get_lang('SelectQuestionType');?>
  155. </td>
  156. <td>
  157. <select name="add_question" >
  158. <?php /** @todo it seems a bad idea to use language strings for switch statements and $_POST variables */ ?>
  159. <option value="<?php echo get_lang('YesNo'); ?>" ><?php echo get_lang('YesNo');?></option>
  160. <option value="<?php echo get_lang('MultipleChoiceSingle'); ?>" ><?php echo get_lang('MultipleChoiceSingle');?></option>
  161. <option value="<?php echo get_lang('MultipleChoiceMulti'); ?>" ><?php echo get_lang('MultipleChoiceMulti');?></option>
  162. <option value="<?php echo get_lang('Open');?>" ><?php echo get_lang('Open');?></option>
  163. <option value="<?php echo get_lang('Numbered');?>"><?php echo get_lang('Numbered');?></option>
  164. </select>
  165. </td>
  166. </tr>
  167. <tr></tr>
  168. <tr></tr>
  169. <tr></tr>
  170. <tr></tr>
  171. <tr>
  172. <td>
  173. <?php echo get_lang('SelectGroup');?>
  174. </td>
  175. <td>
  176. <?php
  177. echo SurveyManager::select_group_list($_GET['surveyid'], $groupid, $extra_script);
  178. ?>
  179. <!--<select name="select_group" >-->
  180. <?php
  181. /*$query="SELECT * FROM $table_group WHERE survey_id='$_GET['surveyid']'";
  182. //echo $query;
  183. $result=api_sql_query($query);
  184. $num=mysql_num_rows($result);
  185. for($i=0;$i<$num;$i++)
  186. {
  187. $groupid=mysql_result($result,$i,'group_id');
  188. $gname=mysql_result($result,$i,'groupname');
  189. */
  190. ?>
  191. <!--<option value="<?php echo $groupid;?>" ><?php echo $gname;?></option>-->
  192. <?php //}
  193. ?>
  194. <!--</select>-->
  195. </td>
  196. </tr>
  197. <tr></tr>
  198. <tr>
  199. <td>&nbsp;</td>
  200. <td>
  201. <input type="submit" name="back" value="<?php echo get_lang('Back');?>">
  202. <input type="submit" name="next" value="<?php echo get_lang('Next');?>">
  203. </tr>
  204. </table>
  205. </form>
  206. <?php
  207. // Display the footer
  208. Display :: display_footer();
  209. ?>