index.php 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Template (front controller in MVC pattern) used for distpaching to the controllers depend on the current action
  5. * @author Christian Fasanando <christian1827@gmail.com>
  6. * @package chamilo.course_progress
  7. */
  8. // name of the language file that needs to be included
  9. $language_file = array ('course_description', 'pedaSuggest', 'userInfo', 'admin');
  10. // including files
  11. require_once '../inc/global.inc.php';
  12. require_once api_get_path(LIBRARY_PATH).'attendance.lib.php';
  13. require_once api_get_path(LIBRARY_PATH).'thematic.lib.php';
  14. require_once api_get_path(LIBRARY_PATH).'app_view.php';
  15. //require_once 'attendance_controller.php';
  16. require_once 'thematic_controller.php';
  17. require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php';
  18. require_once api_get_path(LIBRARY_PATH).'course.lib.php';
  19. require_once api_get_path(LIBRARY_PATH).'sortabletable.class.php';
  20. require_once api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php';
  21. //require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/gradebook_functions.inc.php';
  22. // current section
  23. $this_section = SECTION_COURSES;
  24. // protect a course script
  25. api_protect_course_script(true);
  26. // defining constants
  27. define('ADD_THEMATIC_PLAN', 6);
  28. // get actions
  29. $actions = array('thematic_details', 'thematic_list', 'thematic_add', 'thematic_edit', 'thematic_delete', 'moveup', 'movedown',
  30. 'thematic_plan_list', 'thematic_plan_add', 'thematic_plan_edit', 'thematic_plan_delete',
  31. 'thematic_advance_list', 'thematic_advance_add', 'thematic_advance_edit', 'thematic_advance_delete');
  32. $action = 'thematic_details';
  33. if (isset($_GET['action']) && in_array($_GET['action'],$actions)) {
  34. $action = $_GET['action'];
  35. }
  36. if (isset($_POST['action']) && $_POST['action'] == 'thematic_delete_select') {
  37. $action = 'thematic_delete_select';
  38. }
  39. if (isset($_GET['isStudentView']) && $_GET['isStudentView'] == 'true') {
  40. $action = 'thematic_details';
  41. }
  42. if ($action == 'thematic_details' || $action == 'thematic_list') {
  43. $_SESSION['thematic_control'] = $action;
  44. }
  45. // get thematic id
  46. if (isset($_GET['thematic_id'])) {
  47. $thematic_id = intval($_GET['thematic_id']);
  48. }
  49. // get thematic plan description type
  50. if (isset($_GET['description_type'])) {
  51. $description_type = intval($_GET['description_type']);
  52. }
  53. // instance thematic object for using like library here
  54. $thematic = new Thematic();
  55. // thematic controller object
  56. $thematic_controller = new ThematicController();
  57. if (!empty($thematic_id)) {
  58. // thematic data by id
  59. $thematic_data = $thematic->get_thematic_list($thematic_id);
  60. }
  61. // get default thematic plan title
  62. $default_thematic_plan_title = $thematic->get_default_thematic_plan_title();
  63. $htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery.js" type="text/javascript" language="javascript"></script>';
  64. $htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/thickbox.js" type="text/javascript" language="javascript"></script>';
  65. $htmlHeadXtra[] = '<link rel="stylesheet" href="'.api_get_path(WEB_LIBRARY_PATH).'javascript/thickbox.css" type="text/css" media="projection, screen">';
  66. $htmlHeadXtra[] = '<script language="javascript">
  67. function datetime_by_attendance(selected_value) {
  68. $.ajax({
  69. contentType: "application/x-www-form-urlencoded",
  70. beforeSend: function(objeto) {},
  71. type: "POST",
  72. url: "'.api_get_path(WEB_AJAX_PATH).'thematic.ajax.php?a=get_datetime_by_attendance",
  73. data: "attendance_id="+selected_value,
  74. success: function(datos) {
  75. $("#div_datetime_attendance").html(datos);
  76. }
  77. });
  78. }
  79. function update_done_thematic_advance(selected_value) {
  80. $.ajax({
  81. contentType: "application/x-www-form-urlencoded",
  82. beforeSend: function(objeto) {},
  83. type: "GET",
  84. url: "'.api_get_path(WEB_AJAX_PATH).'thematic.ajax.php?a=update_done_thematic_advance&thematic_advance_id="+selected_value,
  85. data: "thematic_advance_id="+selected_value,
  86. success: function(datos) {
  87. $("#div_result").html(datos);
  88. }
  89. });
  90. // clean all radios
  91. for (var i=0; i<$("input[@name=\'done_thematic\']").length;i++) {
  92. var id_radio_thematic = $("input[@name=\'done_thematic\']").get(i).id;
  93. $("#td_"+id_radio_thematic).css({"background-color":"#FFF"});
  94. }
  95. // set background to previous radios
  96. for (var i=0; i<$("input[@name=\'done_thematic\']").length;i++) {
  97. var id_radio_thematic = $("input[@name=\'done_thematic\']").get(i).id;
  98. $("#td_"+id_radio_thematic).css({"background-color":"#E5EDF9"});
  99. if ($("input[@name=\'done_thematic\']").get(i).value == selected_value) {
  100. break;
  101. }
  102. }
  103. }
  104. function check_per_attendance(obj) {
  105. if (obj.checked) {
  106. document.getElementById(\'div_datetime_by_attendance\').style.display=\'block\';
  107. document.getElementById(\'div_custom_datetime\').style.display=\'none\';
  108. } else {
  109. document.getElementById(\'div_datetime_by_attendance\').style.display=\'none\';
  110. document.getElementById(\'div_custom_datetime\').style.display=\'block\';
  111. }
  112. }
  113. function check_per_custom_date(obj) {
  114. if (obj.checked) {
  115. document.getElementById(\'div_custom_datetime\').style.display=\'block\';
  116. document.getElementById(\'div_datetime_by_attendance\').style.display=\'none\';
  117. } else {
  118. document.getElementById(\'div_custom_datetime\').style.display=\'none\';
  119. document.getElementById(\'div_datetime_by_attendance\').style.display=\'block\';
  120. }
  121. }
  122. </script>';
  123. // interbreadcrumbs
  124. //$interbreadcrumb[] = array ('url' => 'index.php?'.api_get_cidreq().'&action=thematic_details'.$param_gradebook.$student_param, 'name' => get_lang('ToolAttendance'));
  125. //if ($action == 'attendance_add') {
  126. //$interbreadcrumb[] = array ('url' => '#', 'name' => get_lang('CreateANewAttendance'));
  127. //}
  128. if ($action == 'thematic_list') {
  129. $interbreadcrumb[] = array ('url' => '#', 'name' => get_lang('ThematicControl'));
  130. }
  131. if ($action == 'thematic_add') {
  132. $interbreadcrumb[] = array ('url' => 'index.php?'.api_get_cidreq().'&action='.$_SESSION['thematic_control'], 'name' => get_lang('ThematicControl'));
  133. $interbreadcrumb[] = array ('url' => '#', 'name' => get_lang('NewThematicSection'));
  134. }
  135. if ($action == 'thematic_edit') {
  136. $interbreadcrumb[] = array ('url' => 'index.php?'.api_get_cidreq().'&action='.$_SESSION['thematic_control'], 'name' => get_lang('ThematicControl'));
  137. $interbreadcrumb[] = array ('url' => '#', 'name' => get_lang('EditThematicSection'));
  138. }
  139. if ($action == 'thematic_details') {
  140. $interbreadcrumb[] = array ('url' => '#', 'name' => get_lang('ThematicControl'));
  141. }
  142. if ($action == 'thematic_plan_list' || $action == 'thematic_plan_delete') {
  143. $interbreadcrumb[] = array ('url' => 'index.php?'.api_get_cidreq().'&action='.$_SESSION['thematic_control'], 'name' => get_lang('ThematicControl'));
  144. $interbreadcrumb[] = array ('url' => '#', 'name' => $thematic_data['title'].':'.get_lang('ThematicPlan'));
  145. }
  146. if ($action == 'thematic_plan_add' || $action == 'thematic_plan_edit') {
  147. $interbreadcrumb[] = array ('url' => 'index.php?'.api_get_cidreq().'&action='.$_SESSION['thematic_control'], 'name' => get_lang('ThematicControl'));
  148. $interbreadcrumb[] = array ('url' => 'index.php?'.api_get_cidreq().'&action=thematic_plan_list&thematic_id='.$thematic_id, 'name' => $thematic_data['title'].':'.get_lang('ThematicPlan'));
  149. if ($description_type >= ADD_THEMATIC_PLAN) {
  150. $interbreadcrumb[] = array ('url' => '#', 'name' => get_lang('NewBloc'));
  151. } else {
  152. $interbreadcrumb[] = array ('url' => '#', 'name' => $default_thematic_plan_title[$description_type]);
  153. }
  154. }
  155. if ($action == 'thematic_advance_list' || $action == 'thematic_advance_delete') {
  156. $interbreadcrumb[] = array ('url' => 'index.php?'.api_get_cidreq().'&action='.$_SESSION['thematic_control'], 'name' => get_lang('ThematicControl'));
  157. $interbreadcrumb[] = array ('url' => '#', 'name' => $thematic_data['title'].':'.get_lang('ThematicAdvance'));
  158. }
  159. if ($action == 'thematic_advance_add' || $action == 'thematic_advance_edit') {
  160. $interbreadcrumb[] = array ('url' => 'index.php?'.api_get_cidreq().'&action='.$_SESSION['thematic_control'], 'name' => get_lang('ThematicControl'));
  161. $interbreadcrumb[] = array ('url' => 'index.php?'.api_get_cidreq().'&action=thematic_advance_list&thematic_id='.$thematic_id, 'name' => $thematic_data['title'].':'.get_lang('ThematicAdvance'));
  162. $interbreadcrumb[] = array ('url' => '#', 'name' => get_lang('NewThematicAdvance'));
  163. }
  164. // distpacher actions to controller
  165. switch ($action) {
  166. case 'thematic_add' :
  167. case 'thematic_edit' :
  168. case 'thematic_delete' :
  169. case 'thematic_delete_select' :
  170. case 'thematic_details' :
  171. case 'moveup' :
  172. case 'movedown' :
  173. case 'thematic_list' : $thematic_controller->thematic($action);
  174. break;
  175. case 'thematic_plan_list' :
  176. case 'thematic_plan_add' :
  177. case 'thematic_plan_edit' :
  178. case 'thematic_plan_delete' : $thematic_controller->thematic_plan($action);
  179. break;
  180. case 'thematic_advance_list' :
  181. case 'thematic_advance_add' :
  182. case 'thematic_advance_edit' :
  183. case 'thematic_advance_delete' : $thematic_controller->thematic_advance($action);
  184. break;
  185. }
  186. ?>