survey_edit.php 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  1. <?php
  2. // $Id: course_edit.php,v 1.11 2005/07/08 13:25:54 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. * @package dokeos.admin
  23. ==============================================================================
  24. */
  25. /*
  26. ==============================================================================
  27. INIT SECTION
  28. ==============================================================================
  29. */
  30. $langFile = 'survey';
  31. include ('../inc/global.inc.php');
  32. //api_protect_admin_script();
  33. include (api_get_path(LIBRARY_PATH).'/fileManage.lib.php');
  34. require_once (api_get_path(LIBRARY_PATH)."/surveymanager.lib.php");
  35. $status = surveymanager::get_status();
  36. if($status==5)
  37. {
  38. api_protect_admin_script();
  39. }
  40. require_once (api_get_path(LIBRARY_PATH)."/usermanager.lib.php");
  41. // the variables for the days and the months
  42. // Defining the months of the year to allow translation of the months
  43. $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"));
  44. $arr_date = explode("-",date("Y-m-d"));
  45. $curr_year = $arr_date[0];
  46. $curr_month = $arr_date[1];
  47. $curr_day = $arr_date[2];
  48. $cidReq=$_GET['cidReq'];
  49. $table_course = Database :: get_main_table(MAIN_COURSE_TABLE);
  50. $table_course_survey_rel = Database :: get_main_table(MAIN_COURSE_SURVEY_TABLE);
  51. $table_survey = Database :: get_course_table('survey');
  52. $tbl_category = Database :: get_main_table(MAIN_CATEGORY_TABLE);
  53. $noPHP_SELF = true;
  54. $tool_name = get_lang('ModifySurveyInformation');
  55. $interbredcrump[] = array ("url" => "survey_list.php", "name" => get_lang('Survey'));
  56. $coursePathWeb = api_get_path(WEB_COURSE_PATH);
  57. $coursePathSys = api_get_path(SYS_COURSE_PATH);
  58. $maxFilledSpace = get_setting('default_document_quotum');
  59. $course_code = $id; //note confusion again: int id - string id - string code...
  60. $surveyid = $_REQUEST['surveyid'];
  61. $formSent=0;
  62. if ($_POST['action'] == 'update_survey')
  63. {
  64. $formSent=1;
  65. $cidReq=$_GET['cidReq'];
  66. $surveyid=$_REQUEST['surveyid'];
  67. $surveycode=$_POST['survey_code'];
  68. $surveytitle = $_POST['survey_title'];
  69. $surveysubtitle = $_POST['survey_subtitle'];
  70. $author = $_POST['author'];
  71. $survey_language = $_POST['survey_language'];
  72. $availablefrom = $_POST['fyear']."-".$_POST['fmonth']."-".$_POST['fday'];
  73. $availabletill = $_POST['end_fyear']."-".$_POST['end_fmonth']."-".$_POST['end_fday'];
  74. $isshare = $_POST['isshare'];
  75. $surveytemplate = $_POST['template'];
  76. $surveyintroduction = $_POST['content'];
  77. $surveythanks = $_POST['thanks'];
  78. $savailablefrom=mktime(0,0,0,$_POST['fmonth'],$_POST['fday'], $_POST['fyear']);
  79. $savailabletill=mktime(0,0,0,$_POST['end_fmonth'],$_POST['end_fday'], $_POST['end_fyear']);
  80. $surveytitle=trim($surveytitle);
  81. $surveycode=trim($surveycode);
  82. if(isset($_POST['back'])){
  83. header("location:survey_list.php?cidReq=$cidReq");
  84. exit;
  85. }
  86. if(empty ($surveytitle))
  87. {
  88. $error_message = get_lang('PleaseEnterSurveyTitle');
  89. }
  90. elseif ($savailabletill<=$savailablefrom){
  91. $error_message = get_lang('PleaseEnterValidDate');
  92. }
  93. elseif (empty ($surveycode)){
  94. $error_message = get_lang('PleaseEnterValidCode');
  95. }
  96. else
  97. {
  98. $cidReq = $_GET['cidReq'];
  99. $table_survey = Database :: get_course_table('survey'); $curr_dbname=SurveyManager::update_survey($surveyid,$surveycode,$surveytitle,$surveysubtitle,$author,$survey_language,$availablefrom,$availabletill,$isshare,$surveytemplate,$surveyintroduction,$surveythanks,$cidReq,$table_course);
  100. if(isset($_POST['next']))
  101. {
  102. header("location:select_question_group.php?surveyid=$surveyid&cidReq=$cidReq&curr_dbname=$curr_dbname");
  103. exit;
  104. }
  105. else
  106. {
  107. header("location:survey_list.php?cidReq=$cidReq");
  108. exit;
  109. }
  110. }
  111. }
  112. Display::display_header($tool_name);
  113. api_display_tool_title($tool_name);
  114. if( isset($error_message) )
  115. {
  116. Display::display_error_message($error_message);
  117. }
  118. ?>
  119. <SCRIPT LANGUAGE="JavaScript">
  120. <!-- Begin
  121. function displayTemplate(form) {
  122. var inf = form.template.value;
  123. if(inf=="")
  124. {
  125. alert("Please Select a Template");
  126. }
  127. else
  128. {
  129. window.open(inf+".htm", 'popup', 'width=600,height=600,toolbar = no, status = no');
  130. }
  131. //window.open(inf+".htm");
  132. //win.document.write("" + inf + "");
  133. }
  134. // End -->
  135. </script>
  136. <script src=tbl_change.js type="text/javascript" language="javascript"></script>
  137. <?php
  138. $sql = "select * from $table_survey where survey_id='$surveyid'";
  139. $res = api_sql_query($sql);
  140. $obj = mysql_fetch_object($res);
  141. $arr_avail_from = explode("-",$obj->avail_from);
  142. $avail_year_from = $arr_avail_from['0'];
  143. $avail_month_from = $arr_avail_from['1'];
  144. $avail_day_from = $arr_avail_from['2'];
  145. $arr_avail_till = explode("-",$obj->avail_till);
  146. $avail_year_till = $arr_avail_till['0'];
  147. $avail_month_till = $arr_avail_till['1'];
  148. $avail_day_till = $arr_avail_till['2'];
  149. $template = $obj->template;
  150. $lang=$obj->lang;
  151. ?>
  152. <form name="new_calendar_item" method="post" action="<?php echo $_SERVER['PHP_SELF'];?>?cidReq=<?=$cidReq?>">
  153. <input type="hidden" name="surveyid" value="<?=$surveyid?>">
  154. <input type="hidden" name="action" value="update_survey">
  155. <table>
  156. <tr>
  157. <td><?php echo get_lang('surveycode'); ?></td>
  158. <td><input type="text" name="survey_code" size="20" maxlength="19" value="<?php if($formSent){echo $surveycode;}else {echo $obj->code;} ?>"></td>
  159. </tr>
  160. <tr>
  161. <td><?php echo get_lang('surveytitle'); ?></td>
  162. <td><input type="text" name="survey_title" size="40" maxlength="79" value="<?php if($formSent){echo $surveytitle;}else {echo $obj->title;} ?>"></td>
  163. </tr>
  164. <tr>
  165. <td><?php echo get_lang('surveysubtitle'); ?></td>
  166. <td><input type="text" name="survey_subtitle" size="40" maxlength="79" value="<?php if($formSent){echo $surveysubtitle;}else {echo $obj->subtitle;} ?>"></td>
  167. </tr>
  168. <tr>
  169. <td><?php echo get_lang('author'); ?></td>
  170. <td>
  171. <?php
  172. UserManager::get_teacher_list($cidReq,$obj->author);
  173. ?>
  174. </td>
  175. </tr>
  176. <tr>
  177. <td><?php echo get_lang('surveylanguage'); ?>&nbsp;</td>
  178. <td>
  179. <select name="survey_language">
  180. <option value="english" <?if($lang=='english') echo "selected";?>>English</option>
  181. <option value="french" <?if($lang=='french') echo "selected";?>>Fran&ccedil;ais</option>
  182. <option value="dutch" <?if($lang=='dutch') echo "selected";?>>Nederlands</option>
  183. </select>
  184. </td>
  185. </tr>
  186. <tr id="subtitle">
  187. <td><?php echo get_lang('availablefrom'); ?>&nbsp;</td>
  188. <td>
  189. <select name="fday">
  190. <? for($i=1;$i<=31;$i++){
  191. if($i<=9)
  192. $val = "0".$i;
  193. else
  194. $val = $i;
  195. if($val==$avail_day_from) $selected="selected";
  196. else $selected="";
  197. echo "<option value=\"$val\" $selected>$i</option>\n";
  198. }
  199. ?>
  200. </select>
  201. <!-- month: january ->
  202. december -->
  203. <select name="fmonth">
  204. <?
  205. for($i=1;$i<count($MonthsLong);$i++)
  206. {
  207. if($i<=9)
  208. $val = "0".$i;
  209. else
  210. $val = $i;
  211. if($val == $avail_month_from)
  212. echo "<option value=\"$val\" selected>".$MonthsLong[$i-1]."</option>\n";
  213. else
  214. echo "<option value=\"$val\">".$MonthsLong[$i-1]."</option>\n";
  215. }
  216. ?>
  217. </select>
  218. <select name="fyear">
  219. <?
  220. for($i=$curr_year;$i<=$curr_year+10;$i++){
  221. if($i == $avail_year_from)
  222. echo "<option value=\"$i\" selected>$i</option>\n";
  223. else
  224. echo "<option value=\"$i\">$i</option>\n";
  225. }
  226. ?>
  227. </select>
  228. <a title="Calendar" href="javascript:openCalendar('new_calendar_item', 'f')"><img src="../img/calendar_select.gif" border="0" align="absmiddle"/></a></td>
  229. </tr>
  230. <tr id="subtitle">
  231. <td><?php echo get_lang('availabletill'); ?>&nbsp;</td>
  232. <td>
  233. <select name="end_fday">
  234. <? for($i=1;$i<=31;$i++){
  235. if($i<=9)
  236. $val = "0".$i;
  237. else
  238. $val = $i;
  239. if($val==$avail_day_till) $selected="selected";
  240. else $selected="";
  241. echo "<option value=\"$val\" $selected>$i</option>\n";
  242. }
  243. ?>
  244. </select>
  245. <!-- month: january ->
  246. december -->
  247. <select name="end_fmonth">
  248. <?
  249. for($i=1;$i<count($MonthsLong);$i++)
  250. {
  251. if($i<=9)
  252. $val = "0".$i;
  253. else
  254. $val = $i;
  255. if($val == $avail_month_till)
  256. echo "<option value=\"$val\" selected>".$MonthsLong[$i-1]."</option>\n";
  257. else
  258. echo "<option value=\"$val\">".$MonthsLong[$i-1]."</option>\n";
  259. }
  260. ?>
  261. </select>
  262. <select name="end_fyear">
  263. <?
  264. for($i=$curr_year;$i<=$curr_year+10;$i++){
  265. if($i == $avail_year_till)
  266. echo "<option value=\"$i\" selected>$i</option>\n";
  267. else
  268. echo "<option value=\"$i\">$i</option>\n";
  269. }
  270. ?>
  271. </select>
  272. <a title="Calendar" href="javascript:openCalendar('new_calendar_item', 'end_f')"><img src="../img/calendar_select.gif" border="0" align="absmiddle"/></a></td>
  273. </tr>
  274. <tr>
  275. <td valign="top"><?php echo get_lang('IsShareSurvey'); ?>&nbsp;</td>
  276. <td>
  277. <input type="radio" name="isshare" value="1" <? if($obj->is_shared=='1') echo "checked";?>>Yes&nbsp;<input type="radio" name="isshare" value="0" <? if($obj->is_shared=='0') echo "checked";?>>No
  278. </td>
  279. </tr>
  280. <tr><td valign="top"><?php echo get_lang('surveyintroduction'); ?>&nbsp;</td>
  281. <td>
  282. <?php
  283. api_disp_html_area('content',$obj->intro,'300px');
  284. ?>
  285. <br>
  286. </td>
  287. </tr>
  288. <tr><td valign="top"><?php echo get_lang('Thanks'); ?>&nbsp;</td>
  289. <td>
  290. <?php
  291. api_disp_html_area('thanks',$obj->surveythanks,'200px');
  292. ?>
  293. <br>
  294. </td>
  295. </tr>
  296. <tr>
  297. <td></td>
  298. <td><input type="submit" name="back" value="<?php echo get_lang('back'); ?>">&nbsp;<input type="submit" name="updateandreturn" value="<?php echo get_lang('saveandexit'); ?>">&nbsp;<input type="submit" name="next" value="<?php echo get_lang('next'); ?>"></td>
  299. </tr>
  300. </table>
  301. </form>
  302. </table>
  303. <?php
  304. Display :: display_footer();
  305. ?>