template1.php 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  1. <?php // $Id: index.php,v 1.44 2005/07/01 10:03:36 olivierb78 Exp $
  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. * Index of the admin tools
  22. *
  23. * @package dokeos.admin
  24. ==============================================================================
  25. */
  26. $langFile='survey';
  27. $cidReset=true;
  28. session_start();
  29. $lang = addslashes($_REQUEST['lang']);
  30. $_SESSION["user_language_choice"]=$lang;
  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)."/course.lib.php");
  37. require (api_get_path(LIBRARY_PATH)."/groupmanager.lib.php");
  38. require_once (api_get_path(LIBRARY_PATH)."/surveymanager.lib.php");
  39. require_once (api_get_path(LIBRARY_PATH)."/usermanager.lib.php");
  40. //$tool_name=get_lang("AdministrationTools");
  41. $surveyid = $_REQUEST['surveyid'];
  42. $uid = $_REQUEST['uid'];
  43. $uid1 = $_REQUEST['uid1'];
  44. $db_name = $_REQUEST['db_name'];
  45. $temp = $_REQUEST['temp'];
  46. $mail = $_REQUEST['mail'];
  47. $survey_user_info_table = Database :: get_main_table(MAIN_SURVEY_USER_TABLE);
  48. $user_table = Database :: get_main_table(MAIN_USER_TABLE);
  49. $sql_sname = "select * from $db_name.survey where survey_id='$surveyid'";
  50. $res_sname = api_sql_query($sql_sname,__FILE__,__LINE__);
  51. $obj_sname = mysql_fetch_object($res_sname);
  52. $surveyname = $obj_sname->title;
  53. $survey_user_info_table = Database :: get_main_table(MAIN_SURVEY_USER_TABLE);
  54. $sql_check="SELECT 1
  55. FROM $survey_user_info_table as survey_user_info
  56. INNER JOIN $db_name.survey as survey
  57. ON survey.survey_id = survey_user_info.survey_id
  58. AND survey.code = '".$obj_sname->code."'
  59. WHERE email = '$mail' AND attempted = 'yes'";
  60. $res_check=api_sql_query($sql_check);
  61. if(mysql_num_rows($res_check)>0)
  62. {
  63. if($lang=='english')
  64. $error_message="You have already attempted this survey!";
  65. else if($lang=='french')
  66. $error_message="Vous avez déjà répondu à cette enquête!";
  67. else if($lang=='dutch')
  68. $error_message="U heeft deze enquête reeds ingevuld, dank u!";
  69. Display::display_error_message($error_message);
  70. exit;
  71. }
  72. if(isset($mail))
  73. {
  74. $table_reminder = Database:: get_main_table(MAIN_SURVEY_REMINDER_TABLE);
  75. $sql_update = "UPDATE $table_reminder SET access='1' WHERE db_name='$db_name' AND sid='$surveyid' AND email='$mail'";
  76. api_sql_query($sql_update);
  77. }
  78. if(isset($_POST['Next']))
  79. {
  80. $firstname = $_REQUEST['firstname'];
  81. $lastname = $_REQUEST['lastname'];
  82. $temp = $_REQUEST['temp'];
  83. $surveyid = $_REQUEST['surveyid'];
  84. $uid = $_REQUEST['uid'];
  85. $uid1 = $_REQUEST['uid1'];
  86. $db_name = $_REQUEST['db_name'];
  87. $email = $_REQUEST['email'];
  88. $mail = $_REQUEST['mail'];
  89. $organization = $_REQUEST['organization'];
  90. $age = $_REQUEST['age'];
  91. if($uid!='')
  92. {$registered='Y';}
  93. else{$registered='N';}
  94. $user_table = Database :: get_main_table(MAIN_USER_TABLE);
  95. $survey_user_info_table = Database :: get_main_table(MAIN_SURVEY_USER_TABLE);
  96. $sql="SELECT * FROM $survey_user_info_table WHERE email = '$mail'";
  97. $result=api_sql_query($sql);
  98. $obj=mysql_fetch_object($result);
  99. $new_mail=$obj->email;
  100. $user_id=$obj->user_id;
  101. if($new_mail!='')
  102. {
  103. $uid1=$user_id;
  104. $sql_ins = "update $survey_user_info_table set user_id='$uid1', survey_id='$surveyid', db_name='$db_name', firstname='$firstname', lastname='$lastname', organization='$organization', age='$age' where user_id='$uid1'";
  105. $result=api_sql_query($sql_ins);
  106. header("location:welcome_1.php?temp=$temp&surveyid=$surveyid&uid1=$uid1&db_name=$db_name&mail=$mail&lang=$lang");
  107. exit;
  108. }
  109. else
  110. {
  111. $sql="SELECT max(user_id) FROM $survey_user_info_table";
  112. $result=api_sql_query($sql);
  113. $user_id=mysql_result($result, 0, max('user_id'));
  114. $uid1=$user_id+1;
  115. $sql_ins="INSERT INTO $survey_user_info_table(id,user_id,survey_id,db_name,firstname,lastname,email,organization,age, registered, attempted) values('','$uid1','$surveyid', '$db_name','$firstname','$lastname','$_REQUEST[mail]','$organization','$age','$registered', 'no')";
  116. $result_ins=api_sql_query($sql_ins);
  117. header("location:welcome_1.php?temp=$temp&surveyid=$surveyid&uid1=$uid1&db_name=$db_name&mail=$mail&lang=$lang");
  118. exit;
  119. }
  120. }
  121. if($uid==''){
  122. $survey_user_info_table = Database :: get_main_table(MAIN_SURVEY_USER_TABLE);
  123. $sql_u="Select * from $survey_user_info_table where user_id='$uid1' or email='$mail'";
  124. }
  125. else{
  126. $sql_u="Select * from $user_table where user_id='$uid'";
  127. }
  128. $res = api_sql_query($sql_u,__FILE__,__LINE__);
  129. $obj=@mysql_fetch_object($res);
  130. $email=$obj->email;
  131. $user_idd=$obj->user_id;
  132. $rs=mysql_query("select * from $db_name.questions");
  133. $row=mysql_num_rows($rs);
  134. $page=ceil($row/4);
  135. if(isset($_GET[num])){
  136. $num=$_GET[num];
  137. if($num>$page){
  138. header("Location:test.php");
  139. exit;
  140. }
  141. }else{
  142. $num = 1;
  143. }
  144. $lower = $num*4-4;
  145. Display::display_header($tool_name);
  146. ?><center><?api_display_tool_title($surveyname);?></center><?
  147. api_display_tool_title($tool_name);
  148. if($error_message)
  149. {
  150. Display::display_error_message($error_message);
  151. }
  152. ?>
  153. <link href="../css/survey_white.css" rel="stylesheet" type="text/css">
  154. <table width="727" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#F6F5F5">
  155. <tr>
  156. <td width="23" height="21">&nbsp;</td>
  157. <td height="21">&nbsp;</td>
  158. <td width="20" height="21">&nbsp;</td>
  159. </tr>
  160. <tr>
  161. <td>&nbsp;</td>
  162. <td valign="top">
  163. <table width="100%" height="132" border="0" cellpadding="0" cellspacing="0" bgcolor="#F6F5F5">
  164. <form method="POST" action="<?php echo $_SERVER['PHP_SELF'];?>">
  165. <!--<form method="post" action="surveytemp_white.php">-->
  166. <input type="hidden" name="uid" value="<?=$uid;?>">
  167. <input type="hidden" name="surveyid" value="<?=$surveyid;?>">
  168. <input type="hidden" name="db_name" value="<?=$db_name;?>">
  169. <input type="hidden" name="temp" value="<?=$temp;?>">
  170. <input type="hidden" name="email" value="<?=$email;?>">
  171. <input type="hidden" name="mail" value="<?=$mail;?>">
  172. <input type="hidden" name="lang" value="<?=$lang;?>">
  173. <input type="hidden" name="uid1" value="<?=$uid1;?>">
  174. <tr>
  175. <td width="32%" class="text"><?if($lang=='french')echo 'Prénom :'; else if($lang=='dutch')echo 'Voornaam :'; else echo 'First Name :' ;?></td>
  176. <td width="68%"><input type="text" name="firstname" maxlength="40" value="<? echo mysql_result($res,0,"firstname");?>"></td>
  177. </tr>
  178. <tr>
  179. <td class="text"><?if($lang=='french')echo 'Nom :'; else if($lang=='dutch')echo 'Naam :'; else echo ' Last Name :' ;?></td>
  180. <td><input name="lastname" type="text" id="lastname" maxlength="40" value="<? echo mysql_result($res,0,"lastname");?>"></td>
  181. </tr>
  182. <tr>
  183. <td class="text"><?if($lang=='french')echo 'Email :'; else if($lang=='dutch')echo 'Email :'; else echo 'EMail :' ;?></td>
  184. <td class="text"><? echo $mail;?></td>
  185. </tr>
  186. <tr>
  187. <td class="text"><?if($lang=='french')echo 'Organisation :'; else if($lang=='dutch')echo 'Organisatie :'; else echo 'Organization :' ;?></td>
  188. <td><!--<input name="organization" type="text" id="organization" maxlength="40" value="<?if($uid1){echo mysql_result($res,0,"organization");} else{echo "";}?>">-->
  189. <?
  190. if($lang=='dutch')
  191. {
  192. $fp=fopen("dutch_names.txt","r");
  193. $names=file('dutch_names.txt');
  194. }
  195. else if($lang=='french')
  196. {
  197. $fp=fopen("french_names.txt","r");
  198. $names=file('french_names.txt');
  199. }
  200. else if($lang=='english')
  201. {
  202. $fp=fopen("all_names.txt","r");
  203. $names=file('all_names.txt');
  204. }
  205. $count=count($names);
  206. ?>
  207. <select name='organization'>
  208. <?
  209. if($uid1)
  210. {
  211. echo "<option>";
  212. echo mysql_result($res,0,'organization');
  213. echo "</option>";
  214. for($i=0;$i<$count;$i++)
  215. {
  216. $name=$names[$i];
  217. ?>
  218. <option value='<?=$name;?>'>
  219. <?=$names[$i];?>
  220. </option>
  221. <?
  222. }
  223. }
  224. elseif($email)
  225. {
  226. echo "<option>";
  227. echo mysql_result($res,0,'organization');
  228. echo "</option>";
  229. for($i=0;$i<$count;$i++)
  230. {
  231. $name=$names[$i];
  232. ?>
  233. <option value='<?=$name;?>'>
  234. <?=$names[$i];?>
  235. </option>
  236. <?
  237. }
  238. }
  239. else
  240. {
  241. for($i=0;$i<$count;$i++)
  242. {
  243. $name=$names[$i];
  244. ?>
  245. <option value='<?=$name;?>'>
  246. <?=$names[$i];?>
  247. </option><?
  248. }
  249. }
  250. ?>
  251. </select></td>
  252. </tr>
  253. <tr>
  254. <td>&nbsp;</td>
  255. <?php
  256. if($user_idd)
  257. {?>
  258. <td><input type="submit" name="Next" value="<?if($lang=='french')echo 'Suivant'; else if($lang=='dutch')echo 'Volgende'; else echo 'Next' ;?>"></td>
  259. <?php
  260. }
  261. else
  262. {
  263. ?>
  264. <td><br><input type="reset" value="<?if($lang=='french')echo 'Annuler'; else if($lang=='dutch')echo 'Alles wissen'; else echo ' Reset' ;?>">&nbsp;<input type="submit" name="Next" value="<?if($lang=='french')echo 'Suivant'; else if($lang=='dutch')echo 'Volgende'; else echo 'Next' ;?>"></td>
  265. <?php
  266. }
  267. ?>
  268. </tr></form>
  269. </table>
  270. </td>
  271. <td>&nbsp;</td>
  272. </tr>
  273. <tr>
  274. <td>&nbsp;</td>
  275. <td>&nbsp;</td>
  276. <td>&nbsp;</td>
  277. </tr>
  278. </table>
  279. <?php
  280. /*
  281. ==============================================================================
  282. FOOTER
  283. ==============================================================================
  284. */
  285. Display::display_footer();
  286. ?>