attach_question.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367
  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)."/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. $status = surveymanager::get_status();
  40. if($status==5)
  41. {
  42. api_protect_admin_script();
  43. }
  44. require_once (api_get_path(LIBRARY_PATH)."/usermanager.lib.php");
  45. $MonthsLong = array(get_lang("JanuaryLong"), get_lang("FebruaryLong"), get_lang("MarchLong"), get_lang("AprilLong"), get_lang("MayLong"), get_lang("JuneLong"), get_lang("JulyLong"), get_lang("AugustLong"), get_lang("SeptemberLong"), get_lang("OctoberLong"), get_lang("NovemberLong"), get_lang("DecemberLong"));
  46. $arr_date = explode("-",date("Y-m-d"));
  47. $curr_year = $arr_date[0];
  48. $curr_month = $arr_date[1];
  49. $curr_day = $arr_date[2];
  50. $coursePathWeb = api_get_path(WEB_COURSE_PATH);
  51. $coursePathSys = api_get_path(SYS_COURSE_PATH);
  52. $table_user = Database :: get_main_table(MAIN_USER_TABLE);
  53. $cidReq = $_REQUEST['cidReq'];
  54. $db_name = $_REQUEST['db_name'];
  55. $table_survey = Database :: get_course_table('survey');
  56. $table_group = Database :: get_course_table('survey_group');
  57. $table_question = Database :: get_course_table('questions');
  58. $table_course = Database :: get_main_table(MAIN_COURSE_TABLE);
  59. $table_course_survey_rel = Database :: get_main_table(MAIN_COURSE_SURVEY_TABLE);
  60. $tool_name = get_lang('New_survey');
  61. $tool_name1 = get_lang('Newsurvey');
  62. $interbredcrump[] = array ("url" => "survey_list.php", "name" => get_lang('Survey'));
  63. $course_id = $_SESSION['_course']['id'];
  64. $oldsurveyid = $_REQUEST['surveyid'];
  65. $survey_name = surveymanager::get_surveyname($db_name,$oldsurveyid);
  66. $qids=$_REQUEST['qid'];
  67. $groupid=$_REQUEST['groupid'];
  68. if ($_POST['action'] == 'add_survey')
  69. {
  70. $surveycode=$_POST['survey_code'];
  71. $surveytitle = $_POST['survey_title'];
  72. $surveysubtitle = $_POST['survey_subtitle'];
  73. //$cidReq = $dbNamePrefix.$_POST['cidReq'];
  74. $author = $_POST['author'];
  75. $survey_language = $_POST['survey_language'];
  76. $availablefrom = $_POST['fyear']."-".$_POST['fmonth']."-".$_POST['fday'];
  77. $availabletill = $_POST['end_fyear']."-".$_POST['end_fmonth']."-".$_POST['end_fday'];
  78. $isshare = $_POST['isshare'];
  79. $surveytemplate = $_POST['template'];
  80. $surveyintroduction = $_POST['content'];
  81. $surveythanks = $_POST['thanks'];
  82. $savailablefrom=mktime(0,0,0,$_POST['fmonth'],$_POST['fday'], $_POST['fyear']);
  83. $savailabletill=mktime(0,0,0,$_POST['end_fmonth'],$_POST['end_fday'], $_POST['end_fyear']);
  84. $cidReq=$_REQUEST['cidReq'];
  85. $qids=$_REQUEST['qids'];
  86. $db_name = $_REQUEST['db_name'];
  87. $surveyid = $_REQUEST['surveyid'];
  88. if(isset($_POST['back']))
  89. {
  90. $cidReq = $_REQUEST['cidReq'];
  91. $surveyid = $_REQUEST['surveyid'];
  92. $db_name = $_REQUEST['db_name'];
  93. header("location:create_from_existing_survey.php?cidReq=$cidReq&surveyid=$surveyid&db_name=$db_name");
  94. }
  95. $surveytitle=trim($surveytitle);
  96. $surveycode=trim($surveycode);
  97. if(empty ($surveytitle))
  98. {
  99. $error_message = get_lang('PleaseEnterSurveyTitle');
  100. }
  101. elseif ($savailabletill<=$savailablefrom){
  102. $error_message = get_lang('PleaseEnterValidDate');
  103. }
  104. elseif (empty ($surveycode)){
  105. $error_message = get_lang('PleaseEnterValidCode');
  106. }
  107. else
  108. {
  109. $result=SurveyManager::get_survey_code($table_survey,$surveycode);
  110. if(!empty($result))
  111. {
  112. $error_message=get_lang('thiscodealradyexist');
  113. }
  114. else
  115. {
  116. $survey_id = SurveyManager::create_survey($surveycode, $surveytitle, $surveysubtitle, $author, $survey_language, $availablefrom, $availabletill, $isshare, $surveytemplate, $surveyintroduction, $surveythanks, $table_survey, $table_group);
  117. $cidReq=$_GET['cidReq'];
  118. $curr_dbname=SurveyManager::create_course_survey_rel($cidReq,$survey_id,$table_course,$table_course_survey_rel);
  119. $qids=$_REQUEST['qids'];
  120. //surveymanager::import_existing_question($survey_id,$qids,$table_group,$table_question,"no");
  121. $db_name = $_REQUEST['db_name'];
  122. $message_me=surveymanager::question_import($survey_id,$qids,$db_name,$curr_dbname);
  123. if (isset($_POST['next']))
  124. {
  125. if(isset($message_me) && $message_me)
  126. {
  127. header("location:select_question_group.php?surveyid=$survey_id&cidReq=$cidReq&curr_dbname=$curr_dbname&message=$message_me");
  128. exit;
  129. }
  130. else
  131. {
  132. header("location:select_question_group.php?surveyid=$survey_id&cidReq=$cidReq&curr_dbname=$curr_dbname&message=$message_me");
  133. exit;
  134. }
  135. }
  136. else
  137. {
  138. $cidReq=$_GET['cidReq'];
  139. header("location:survey_list.php?&cidReq=$cidReq");
  140. exit;
  141. }
  142. }
  143. }
  144. }
  145. Display::display_header($tool_name);
  146. api_display_tool_title($tool_name1);
  147. //echo "<pre>";
  148. //print_r($_SESSION);
  149. //echo "</pre>";
  150. if( isset($error_message) )
  151. {
  152. Display::display_error_message($error_message);
  153. }
  154. ?>
  155. <SCRIPT LANGUAGE="JavaScript">
  156. <!-- Begin
  157. function displayTemplate(form) {
  158. var inf = form.template.value;
  159. if(inf=="")
  160. {
  161. alert("Please Select a Template");
  162. }
  163. else
  164. {
  165. window.open(inf+".htm", 'popup', 'width=900,height=800,toolbar = no, status = no');
  166. }
  167. //window.open(inf+".htm");
  168. //win.document.write("" + inf + "");
  169. }
  170. // End -->
  171. </script>
  172. <script src=tbl_change.js type="text/javascript" language="javascript"></script>
  173. <form name="new_calendar_item" method="post" action="<?php echo $_SERVER['PHP_SELF'];?>?cidReq=<?=$cidReq?>">
  174. <input type="hidden" name="action" value="add_survey">
  175. <input type="hidden" name="qids" value="<?=$qids?>">
  176. <input type="hidden" name="db_name" value="<?=$db_name?>">
  177. <input type="hidden" name="groupid" value="<?=$groupid?>">
  178. <input type="hidden" name="surveyid" value="<?=$oldsurveyid?>">
  179. <table>
  180. <tr>
  181. <td><?php echo get_lang('surveycode'); ?></td>
  182. <td><input type="text" name="survey_code" size="20" maxlength="39" value="<?php echo $surveycode; ?>"></td>
  183. </tr>
  184. <tr>
  185. <td><?php echo get_lang('surveytitle'); ?></td>
  186. <td><input type="text" name="survey_title" size="40" maxlength="79" value="<?php echo $surveytitle ?>"></td>
  187. </tr>
  188. <tr>
  189. <td><?php echo get_lang('surveysubtitle'); ?></td>
  190. <td><input type="text" name="survey_subtitle" size="40" maxlength="79" value="<?php echo $surveysubtitle ?>"></td>
  191. </tr>
  192. <tr>
  193. <?php
  194. if($_SESSION['is_platformAdmin']=='1'||$_SESSION['is_courseAdmin'])
  195. {
  196. echo "<td>";
  197. echo get_lang('author');
  198. echo "</td>";
  199. echo "<td>";
  200. UserManager::get_teacher_list($course_id, $author_id);
  201. echo "</td>";
  202. }
  203. ?>
  204. </tr>
  205. <tr>
  206. <td><?php echo get_lang('surveylanguage'); ?>&nbsp;</td>
  207. <td>
  208. <select name="survey_language">
  209. <option value="english" selected="selected">English</option>
  210. <option value="french" >Fran&ccedil;ais</option>
  211. <option value="dutch" >Nederlands</option>
  212. </select>
  213. </td>
  214. </tr>
  215. <tr id="subtitle">
  216. <td><?php echo get_lang('availablefrom'); ?>&nbsp;</td>
  217. <td>
  218. <select name="fday">
  219. <?
  220. for($i=1;$i<=31;$i++){
  221. if($i<=9) $val = "0".$i;
  222. else $val = $i;
  223. if ($val==$curr_day) $selected = "selected";
  224. else $selected = "";
  225. echo "<option value=\"$val\" $selected>$i</option>";
  226. }
  227. ?>
  228. </select>
  229. <!-- month: january ->
  230. december -->
  231. <select name="fmonth">
  232. <?
  233. for($i=1;$i<count($MonthsLong);$i++)
  234. {
  235. if($i<=9)
  236. $val = "0".$i;
  237. else
  238. $val = $i;
  239. if($val == $curr_month)
  240. echo "<option value=\"$val\" selected>".$MonthsLong[$i-1]."</option>\n";
  241. else
  242. echo "<option value=\"$val\">".$MonthsLong[$i-1]."</option>\n";
  243. }
  244. ?>
  245. </select>
  246. <select name="fyear">
  247. <?
  248. for($i=$curr_year;$i<=$curr_year+10;$i++){
  249. if($i == $curr_year)
  250. echo "<option value=\"$i\" selected>$i</option>\n";
  251. else
  252. echo "<option value=\"$i\">$i</option>\n";
  253. }
  254. ?>
  255. </select>
  256. <a title="Calendar" href="javascript:openCalendar('new_calendar_item', 'f')"><img src="../img/calendar_select.gif" border="0" align="absmiddle"/></a></td>
  257. </tr>
  258. <tr id="subtitle">
  259. <td><?php echo get_lang('availabletill'); ?>&nbsp;</td>
  260. <td>
  261. <select name="end_fday">
  262. <? for($i=1;$i<=31;$i++){
  263. if($i<=9)
  264. $val = "0".$i;
  265. else
  266. $val = $i;
  267. if ($val==$curr_day) $selected = "selected";
  268. else $selected = "";
  269. echo "<option value=\"$val\" $selected>$i</option>";
  270. }
  271. ?>
  272. </select>
  273. <!-- month: january ->
  274. december -->
  275. <select name="end_fmonth">
  276. <?
  277. for($i=1;$i<count($MonthsLong);$i++)
  278. {
  279. if($i<=9)
  280. $val = "0".$i;
  281. else
  282. $val = $i;
  283. if($val == $curr_month)
  284. echo "<option value=\"$val\" selected>".$MonthsLong[$i-1]."</option>\n";
  285. else
  286. echo "<option value=\"$val\">".$MonthsLong[$i-1]."</option>\n";
  287. }
  288. ?>
  289. </select>
  290. <select name="end_fyear">
  291. <?
  292. for($i=$curr_year;$i<=$curr_year+10;$i++){
  293. if($i == $curr_year+1)
  294. echo "<option value=\"$i\" selected>$i</option>\n";
  295. else
  296. echo "<option value=\"$i\">$i</option>\n";
  297. }
  298. ?>
  299. </select>
  300. <a title="Calendar" href="javascript:openCalendar('new_calendar_item', 'end_f')"><img src="../img/calendar_select.gif" border="0" align="absmiddle"/></a></td>
  301. </tr>
  302. <tr>
  303. <td valign="top"><?php echo get_lang('IsShareSurvey'); ?>&nbsp;</td>
  304. <td>
  305. <input type="radio" name="isshare" value="1">Yes&nbsp;<input type="radio" name="isshare" value="0" checked>No
  306. </td>
  307. </tr>
  308. <tr>
  309. <td><?php echo get_lang('surveytemplate'); ?>&nbsp;</td>
  310. <td>
  311. <select name="template">
  312. <option value="template1">OFO_nl</option>
  313. <option value="template2">IFA_fr</option>
  314. <option value="template3">SPF P&O_FR</option>
  315. <option value="template4">FOD P&O_NL</option>
  316. <option value="template5">Blank</option>
  317. </select>
  318. <input type="button" value="<?php echo get_lang('preview');?>" onClick="displayTemplate(new_calendar_item)">
  319. </td>
  320. </tr>
  321. <tr><td valign="top"><?php echo get_lang('surveyintroduction'); ?>&nbsp;</td>
  322. <td>
  323. <?php
  324. api_disp_html_area('content',$content,'300px');
  325. /*$oFCKeditor = new FCKeditor('content') ;
  326. $oFCKeditor->BasePath = 'FCKeditor/';
  327. $oFCKeditor->Value = 'Enter your introduction text here';
  328. $oFCKeditor->Width = '600' ;
  329. $oFCKeditor->Height = '400' ;
  330. $oFCKeditor->Create();
  331. */
  332. ?>
  333. <br>
  334. </td>
  335. </tr>
  336. <tr><td valign="top"><?php echo get_lang('Thanks'); ?>&nbsp;</td>
  337. <td>
  338. <?php
  339. api_disp_html_area('thanks',$thanks,'200px');
  340. ?>
  341. <br>
  342. </td>
  343. </tr>
  344. <tr>
  345. <td><?php echo get_lang('surveyattached');?>&nbsp;&nbsp;<?php echo $survey_name;?></td>
  346. </tr>
  347. </table>
  348. <tr>
  349. <td>&nbsp;</td>
  350. <td><input type="submit" name="back" value="<? echo get_lang('back');?>"></td>
  351. <td><input type="submit" name="saveandexit" value="<?php echo get_lang('createlater'); ?>"></td>
  352. <td><input type="submit" name="next" value="<?php echo get_lang('next'); ?>"></td>
  353. </tr>
  354. </table>
  355. </form>
  356. </table>
  357. <?php
  358. Display :: display_footer();
  359. ?>