index.php 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Session view
  5. * @package chamilo.session
  6. * @author Julio Montoya <gugli100@gmail.com> Beeznest
  7. */
  8. use ChamiloSession as Session;
  9. $cidReset = true;
  10. //require_once '../inc/global.inc.php';
  11. if (empty($_GET['session_id'])) {
  12. api_not_allowed();
  13. }
  14. $session_id = isset($_GET['session_id']) ? intval($_GET['session_id']): null;
  15. $sessionField = new ExtraFieldValue('session');
  16. $valueAllowVisitors = $sessionField->get_values_by_handler_and_field_variable(
  17. $session_id,
  18. 'allow_visitors'
  19. );
  20. $allowVisitors = $valueAllowVisitors != false;
  21. if (!$allowVisitors) {
  22. // Only users who are logged in can proceed.
  23. api_block_anonymous_users();
  24. }
  25. $this_section = SECTION_COURSES;
  26. $htmlHeadXtra[] = api_get_jqgrid_js();
  27. $course_id = isset($_GET['course_id']) ? intval($_GET['course_id']) : null;
  28. Session::write('id_session', $session_id);
  29. // Clear the exercise session just in case
  30. Session::erase('objExercise');
  31. $userId = api_get_user_id();
  32. $session_info = SessionManager::fetch($session_id);
  33. $session_list = SessionManager::get_sessions_by_coach(api_get_user_id());
  34. $course_list = SessionManager::get_course_list_by_session_id($session_id);
  35. // Getting all sessions where I'm subscribed
  36. /*$new_session_list = array();
  37. if (!api_is_anonymous()) {
  38. $new_session_list = UserManager::get_personal_session_course_list(api_get_user_id());
  39. }
  40. $user_course_list = array();
  41. foreach ($new_session_list as $session_item) {
  42. $user_course_list[] = $session_item['code'];
  43. }*/
  44. $userIsGeneralCoach = SessionManager::user_is_general_coach($userId, $session_id);
  45. $user_course_list = array();
  46. foreach ($course_list as $course) {
  47. $status = SessionManager::get_user_status_in_course_session(
  48. $userId,
  49. $course['real_id'],
  50. $session_id
  51. );
  52. if ($status !== false || api_is_platform_admin() || $userIsGeneralCoach) {
  53. $user_course_list[] = $course['code'];
  54. }
  55. }
  56. if (empty($user_course_list)) {
  57. api_not_allowed(true);
  58. }
  59. $my_session_list = array();
  60. $final_array = array();
  61. /*
  62. if (!empty($new_session_list)) {
  63. foreach ($new_session_list as $item) {
  64. $my_session_id = isset($item['id_session']) ? $item['id_session'] : null;
  65. if (isset($my_session_id) && !in_array($my_session_id, $my_session_list) && $session_id == $my_session_id) {
  66. $final_array[$my_session_id]['name'] = $item['session_name'];
  67. //Get all courses by session where I'm subscribed
  68. $my_course_list = UserManager::get_courses_list_by_session(api_get_user_id(), $my_session_id);
  69. foreach ($my_course_list as $my_course) {
  70. $course = array();
  71. $course_info = api_get_course_info($my_course['code']);
  72. // Getting all visible exercises from the current course
  73. $exercise_list = ExerciseLib::get_all_exercises(
  74. $course_info,
  75. $my_session_id,
  76. true,
  77. null,
  78. false,
  79. 1
  80. );
  81. $course['name'] = $course_info['name'];
  82. $course['id'] = $course_info['real_id'];
  83. if (!empty($exercise_list)) {
  84. foreach ($exercise_list as $exercise_item) {
  85. //Loading the exercise
  86. $exercise = new Exercise($course_info['real_id']);
  87. $exercise->read($exercise_item['id']);
  88. $visible_return = $exercise->is_visible();
  89. if ($visible_return['value'] != false) {
  90. // Reading all Exercise results by user, exercise_id, code, and session.
  91. $user_results = Event::getExerciseResultsByUser(
  92. api_get_user_id(),
  93. $exercise_item['id'],
  94. $my_course['code'],
  95. $my_session_id
  96. );
  97. $course['exercises'][$exercise_item['id']]['data']['exercise_data'] = $exercise;
  98. $course['exercises'][$exercise_item['id']]['data']['results'] = $user_results;
  99. }
  100. }
  101. $final_array[$my_session_id]['data'][$my_course['code']] = $course;
  102. }
  103. }
  104. }
  105. $my_session_list[] = $my_session_id;
  106. }
  107. }*/
  108. $new_course_list = array();
  109. if (!empty($course_list)) {
  110. foreach ($course_list as $course_data) {
  111. if (in_array($course_data['code'], $user_course_list) ||
  112. api_is_anonymous()
  113. ) {
  114. $course_data['title'] = Display::url(
  115. $course_data['title'],
  116. api_get_course_url($course_data['code'], $session_id)
  117. );
  118. } else {
  119. continue;
  120. }
  121. $list = new LearnpathList(
  122. api_get_user_id(),
  123. $course_data['code'],
  124. $session_id,
  125. 'publicated_on ASC',
  126. true
  127. );
  128. $lp_list = $list->get_flat_list();
  129. $lp_count = 0;
  130. if (!empty($lp_list)) {
  131. foreach ($lp_list as $valLp) {
  132. if ($valLp['lp_visibility']) {
  133. $lp_count++;
  134. }
  135. }
  136. }
  137. $course_info = api_get_course_info($course_data['code']);
  138. $exercise_count = count(
  139. ExerciseLib::get_all_exercises(
  140. $course_info,
  141. $session_id,
  142. true,
  143. null,
  144. false,
  145. 1
  146. )
  147. );
  148. $max_mutation_date = '';
  149. $last_date = Tracking::get_last_connection_date_on_the_course(
  150. api_get_user_id(),
  151. $course_info,
  152. $session_id,
  153. false
  154. );
  155. $icons = '';
  156. foreach ($lp_list as $item) {
  157. if ($item['modified_on'] == '0000-00-00 00:00:00' || empty($item['modified_on'])) {
  158. $lp_date_original = $item['created_on'];
  159. $image = 'new.gif';
  160. $label = get_lang('LearnpathAdded');
  161. } else {
  162. $lp_date_original = $item['modified_on'];
  163. $image = 'moderator_star.png';
  164. $label = get_lang('LearnpathUpdated');
  165. }
  166. $mutation_date = api_strtotime($item['publicated_on']) > api_strtotime($lp_date_original) ? $item['publicated_on'] : $lp_date_original;
  167. if (api_strtotime($mutation_date) > api_strtotime($max_mutation_date)) {
  168. $max_mutation_date = $mutation_date;
  169. }
  170. if (strtotime($last_date) < strtotime($lp_date_original)) {
  171. if (empty($icons)) {
  172. $icons .= ' '.Display::return_icon(
  173. $image,
  174. get_lang('TitleNotification').': '.$label.' - '.$lp_date_original
  175. ).' ';
  176. }
  177. }
  178. }
  179. $new_course_list[] = array(
  180. 'title'=> $course_data['title'].$icons,
  181. // 'recent_lps' => $icons,
  182. //'max_mutation_date' => substr(api_get_local_time($max_mutation_date),0,10),
  183. 'exercise_count' => $exercise_count,
  184. 'lp_count' => $lp_count
  185. );
  186. }
  187. }
  188. // If the requested session does not exist in my list we stop the script
  189. /*if (!api_is_platform_admin()) {
  190. if (!api_is_anonymous() && !in_array($session_id, $my_session_list)) {
  191. api_not_allowed(true);
  192. }
  193. }*/
  194. //If session is not active we stop de script
  195. if (!api_is_allowed_to_session_edit()) {
  196. api_not_allowed();
  197. }
  198. $entityManager = Database::getManager();
  199. $session = $entityManager->find('ChamiloCoreBundle:Session', $session_id);
  200. $sessionTitleLink = api_get_configuration_value('courses_list_session_title_link');
  201. if ($sessionTitleLink == 2 && $session->getNbrCourses() === 1) {
  202. $sessionCourses = $session->getCourses();
  203. $sessionCourse = $sessionCourses[0]->getCourse();
  204. $courseUrl = $sessionCourse->getDirectory() . '/index.php?';
  205. $courseUrl .= http_build_query([
  206. 'id_session' => $session->getId()
  207. ]);
  208. header('Location: ' . api_get_path(WEB_COURSE_PATH) . $courseUrl);
  209. exit;
  210. }
  211. Display::display_header(get_lang('Session'));
  212. $session_select = array();
  213. foreach ($session_list as $item) {
  214. $session_select[$item['id']] = $item['name'];
  215. }
  216. // Session list form
  217. if (count($session_select) > 1) {
  218. $form = new FormValidator('exercise_admin', 'get', api_get_self().'?session_id='.$session_id);
  219. $form->addElement('select', 'session_id', get_lang('SessionList'), $session_select, 'onchange="javascript:change_session()"');
  220. $defaults['session_id'] = $session_id;
  221. $form->setDefaults($defaults);
  222. $form->display();
  223. }
  224. if (empty($session_id)) {
  225. $user_list = UserManager::get_user_list();
  226. } else {
  227. $user_list = SessionManager::get_users_by_session($session_id);
  228. }
  229. //Final data to be show
  230. $my_real_array = $new_exercises = array();
  231. $now = time();
  232. foreach ($final_array as $session_data) {
  233. $my_course_list = isset($session_data['data']) ? $session_data['data']: array();
  234. if (!empty($my_course_list)) {
  235. foreach ($my_course_list as $my_course_code=>$course_data) {
  236. $courseInfo = api_get_course_info($my_course_code);
  237. if (isset($course_id) && !empty($course_id)) {
  238. if ($course_id != $course_data['id']) {
  239. continue;
  240. }
  241. }
  242. if (!empty($course_data['exercises'])) {
  243. // Exercises
  244. foreach ($course_data['exercises'] as $my_exercise_id => $exercise_data) {
  245. $best_score_data = ExerciseLib::get_best_attempt_in_course(
  246. $my_exercise_id,
  247. $courseInfo['real_id'],
  248. $session_id
  249. );
  250. $best_score = '';
  251. if (!empty($best_score_data)) {
  252. $best_score = ExerciseLib::show_score($best_score_data['exe_result'], $best_score_data['exe_weighting']);
  253. }
  254. // Exercise results
  255. $counter = 1;
  256. foreach ($exercise_data as $exercise_item) {
  257. $result_list = $exercise_item['results'];
  258. $exercise_info = $exercise_item['exercise_data'];
  259. if ($exercise_info->start_time == '0000-00-00 00:00:00') {
  260. $start_date = '-';
  261. } else {
  262. $start_date = $exercise_info->start_time;
  263. }
  264. if (!empty($result_list)) {
  265. foreach ($result_list as $exercise_result) {
  266. $platform_score = ExerciseLib::show_score($exercise_result['exe_result'], $exercise_result['exe_weighting']);
  267. $my_score = 0;
  268. if(!empty($exercise_result['exe_weighting']) && intval($exercise_result['exe_weighting']) != 0) {
  269. $my_score = $exercise_result['exe_result']/$exercise_result['exe_weighting'];
  270. }
  271. $position = ExerciseLib::get_exercise_result_ranking(
  272. $my_score,
  273. $exercise_result['exe_id'],
  274. $my_exercise_id,
  275. $my_course_code,
  276. $session_id,
  277. $user_list
  278. );
  279. $exercise_info->exercise = Display::url(
  280. $exercise_info->exercise,
  281. api_get_path(WEB_CODE_PATH)."exercice/result.php?cidReq=$my_course_code&id={$exercise_result['exe_id']}&id_session=$session_id&show_headers=1",
  282. array('target'=>SESSION_LINK_TARGET,'class'=>'exercise-result-link')
  283. );
  284. $my_real_array[]= array(
  285. 'status' => Display::return_icon('quiz.gif', get_lang('Attempted'),'', ICON_SIZE_SMALL),
  286. 'date' => $start_date,
  287. 'course' => $course_data['name'],
  288. 'exercise' => $exercise_info->exercise,
  289. 'attempt' => $counter,
  290. 'result' => $platform_score,
  291. 'best_result' => $best_score,
  292. 'position' => $position
  293. );
  294. $counter++;
  295. }
  296. } else {
  297. // We check the date validation of the exercise if the user can make it
  298. if ($exercise_info->start_time != '0000-00-00 00:00:00') {
  299. $allowed_time = api_strtotime($exercise_info->start_time, 'UTC');
  300. if ($now < $allowed_time) {
  301. continue;
  302. }
  303. }
  304. $exercise_info->exercise = Display::url(
  305. $exercise_info->exercise,
  306. api_get_path(WEB_CODE_PATH)."exercice/overview.php?cidReq=$my_course_code&exerciseId={$exercise_info->id}&id_session=$session_id",
  307. array('target'=>SESSION_LINK_TARGET)
  308. );
  309. $new_exercises[]= array(
  310. 'status' => Display::return_icon('star.png', get_lang('New'), array('width'=>ICON_SIZE_SMALL)),
  311. 'date' => $start_date,
  312. 'course' => $course_data['name'],
  313. 'exercise' => $exercise_info->exercise,
  314. 'attempt' => '-',
  315. 'result' => '-',
  316. 'best_result' => '-',
  317. 'position' => '-'
  318. );
  319. }
  320. }
  321. }
  322. }
  323. }
  324. }
  325. }
  326. $my_real_array = ArrayClass::msort($my_real_array, 'date', 'asc');
  327. if (!empty($new_exercises)) {
  328. $my_real_array = array_merge($new_exercises, $my_real_array);
  329. }
  330. $start = $end = $start_only = $end_only ='';
  331. if (!empty($session_info['access_start_date']) && $session_info['access_start_date'] != '0000-00-00') {
  332. $start = api_convert_and_format_date($session_info['access_start_date'], DATE_FORMAT_SHORT);
  333. $start_only = get_lang('From').' '.$session_info['access_start_date'];
  334. }
  335. if (!empty($session_info['access_start_date']) && $session_info['access_end_date'] != '0000-00-00') {
  336. $end = api_convert_and_format_date($session_info['access_end_date'], DATE_FORMAT_SHORT);
  337. $end_only = get_lang('Until').' '.$session_info['access_end_date'];
  338. }
  339. if (!empty($start) && !empty($end)) {
  340. $dates = Display::tag('i', sprintf(get_lang('FromDateXToDateY'), $start, $end));
  341. } else {
  342. $dates = Display::tag('i', $start_only.' '.$end_only);
  343. }
  344. echo Display::tag('h1', $session_info['name']);
  345. echo $dates.'<br />';
  346. if ($session_info['show_description'] == 1) {
  347. ?>
  348. <div class="home-course-intro">
  349. <div class="page-course">
  350. <div class="page-course-intro">
  351. <p><?php echo $session_info['description']; ?></p>
  352. </div>
  353. </div>
  354. </div>
  355. <?php
  356. }
  357. // All Learnpaths grid settings (First tab, first subtab)
  358. $columns_courses = array(
  359. get_lang('Title'), get_lang('NumberOfPublishedExercises'), get_lang('NumberOfPublishedLps')
  360. );
  361. $column_model_courses = array(
  362. array('name'=>'title', 'index'=>'title', 'width'=>'400px', 'align'=>'left', 'sortable'=>'true'),
  363. //array('name'=>'recent_lps', 'index'=>'recent_lps', 'width'=>'10px', 'align'=>'left', 'sortable'=>'false'),
  364. // array('name'=>'max_mutation_date', 'index'=>'max_mutation_date', 'width'=>'120px', 'align'=>'left', 'sortable'=>'true'),
  365. array('name'=>'exercise_count', 'index'=>'exercise_count', 'width'=>'180px', 'align'=>'left', 'sortable'=>'true'),
  366. array('name'=>'lp_count', 'index'=>'lp_count', 'width'=>'180px', 'align'=>'left', 'sortable'=>'true')
  367. );
  368. $extra_params_courses['height'] = '100%';
  369. $extra_params_courses['autowidth'] = 'true'; //use the width of the parent
  370. //$extra_params_courses['gridview'] = "false";
  371. /*$extra_params_courses['rowNum'] = 9000;
  372. $extra_params_courses['height'] = "100%";
  373. $extra_params_courses['autowidth'] = 'false'; //use the width of the parent
  374. $extra_params_courses['recordtext'] = '';
  375. $extra_params_courses['pgtext'] = '';
  376. $extra_params_courses['pgbuttons'] = false;*/
  377. //$extra_params_courses['width'] = '50%';
  378. //$extra_params_courses['autowidth'] = 'true';
  379. $url = api_get_path(WEB_AJAX_PATH).'course_home.ajax.php?a=session_courses_lp_default&session_id='.$session_id.'&course_id='.$course_id;
  380. $columns = array(
  381. get_lang('PublicationDate'),
  382. get_lang('Course'),
  383. get_lang('LearningPaths')
  384. );
  385. $column_model = array(
  386. array('name'=>'date', 'index'=>'date', 'width'=>'120', 'align'=>'left', 'sortable'=>'true'),
  387. array('name'=>'course', 'index'=>'course', 'width'=>'300', 'align'=>'left', 'sortable'=>'true', 'wrap_cell' => 'true'),
  388. array('name'=>'lp', 'index'=>'lp', 'width'=>'440', 'align'=>'left', 'sortable'=>'true')
  389. );
  390. $extra_params = array();
  391. $extra_params['sortname'] = 'date';
  392. /*
  393. $extra_params['sortorder'] = 'asc';
  394. $extra_params['pgbuttons'] = false;
  395. $extra_params['recordtext'] = '';
  396. $extra_params['pgtext'] = '';
  397. $extra_params['height'] = "100%";
  398. */
  399. //$extra_params['autowidth'] = 'true'; //use the width of the parent
  400. //$extra_params['width'] = '90%';
  401. //$extra_params['autowidth'] = 'true'; //use the width of the parent
  402. //$extra_params['forceFit'] = 'true'; //use the width of the parent
  403. //$extra_params['altRows'] = 'true'; //zebra style
  404. $extra_params['height'] = '100%';
  405. $extra_params['autowidth'] = 'true'; //use the width of the parent
  406. //Per course grid settings
  407. $url_by_course = api_get_path(WEB_AJAX_PATH).'course_home.ajax.php?a=session_courses_lp_by_course&session_id='.$session_id.'&course_id='.$course_id;
  408. $extra_params_course = array();
  409. $extra_params_course['grouping'] = 'true';
  410. $extra_params_course['groupingView'] = array(
  411. 'groupCollapse' => false,
  412. 'groupField' => array('course'),
  413. 'groupColumnShow' => array('false'),
  414. 'groupText' => array('<b>'.get_lang('Course').' {0}</b>')
  415. );
  416. $extra_params_course['autowidth'] = 'true'; //use the width of the parent
  417. $extra_params_course['height'] = "100%";
  418. //Per Week grid
  419. $url_week = api_get_path(WEB_AJAX_PATH).'course_home.ajax.php?a=session_courses_lp_by_week&session_id='.$session_id.'&course_id='.$course_id;
  420. $column_week = array(
  421. get_lang('PeriodWeek'),
  422. get_lang('PublicationDate'),
  423. get_lang('Course'),
  424. get_lang('LearningPaths')
  425. );
  426. $column_week_model = array(
  427. array('name'=>'week', 'index'=>'week', 'width'=>'40', 'align'=>'left', 'sortable'=>'false'),
  428. array('name'=>'date', 'index'=>'date', 'width'=>'120', 'align'=>'left', 'sortable'=>'false'),
  429. array('name'=>'course', 'index'=>'course', 'width'=>'300', 'align'=>'left', 'sortable'=>'true', 'wrap_cell' => 'true'),
  430. array('name'=>'lp', 'index'=>'lp', 'width'=>'440', 'align'=>'left', 'sortable'=>'true')
  431. );
  432. $extra_params_week = array();
  433. $extra_params_week['grouping'] = 'true';
  434. //For more details see http://www.trirand.com/jqgridwiki/doku.php?id=wiki:grouping
  435. $extra_params_week['groupingView'] = array(
  436. 'groupCollapse' => false,
  437. 'groupDataSorted' => false,
  438. 'groupField' => array('week'),
  439. 'groupOrder' => array('desc'),
  440. 'groupColumnShow' => 'false',
  441. 'groupText' => array('<b>' . get_lang('PeriodWeek') . ' {0}</b>')
  442. );
  443. $extra_params_week['autowidth'] = 'true'; //use the width of the parent
  444. $extra_params_week['height'] = '100%';
  445. // MyQCM grid
  446. if (!api_is_anonymous()) {
  447. $column_exercise = array(
  448. get_lang('Status'),
  449. get_lang('ExerciseStartDate'),
  450. get_lang('Course'),
  451. get_lang('Exercise'),
  452. get_lang('Attempts'),
  453. get_lang('Result'),
  454. get_lang('BestResultInCourse'),
  455. get_lang('Ranking')
  456. );
  457. $column_exercise_model = array(
  458. array('name'=>'status', 'index'=>'status', 'width'=>'40', 'align'=>'left', 'sortable'=>'false'),
  459. array('name'=>'date', 'index'=>'date', 'width'=>'130','align'=>'left', 'sortable'=>'true'),
  460. array('name'=>'course', 'index'=>'course', 'width'=>'200','align'=>'left', 'sortable'=>'true', 'wrap_cell' => 'true'),
  461. array('name'=>'exercise', 'index'=>'exercise', 'width'=>'200','align'=>'left', 'sortable'=>'false'),
  462. array('name'=>'attempt', 'index'=>'attempt', 'width'=>'60', 'align'=>'center', 'sortable'=>'true'),
  463. array('name'=>'result', 'index'=>'result', 'width'=>'120','align'=>'center', 'sortable'=>'true'),
  464. array('name'=>'best_result','index'=>'best_result','width'=>'140','align'=>'center', 'sortable'=>'true'),
  465. array('name'=>'position', 'index'=>'position', 'width'=>'55', 'align'=>'center', 'sortable'=>'true')
  466. );
  467. $extra_params_exercise['height'] = '100%';
  468. $extra_params_exercise['autowidth'] = 'true';
  469. //$extra_params_exercise['sortname'] = 'status';
  470. //$extra_params_exercise['sortorder'] = 'desc';
  471. //$extra_params_exercise['grouping'] = 'true';
  472. //$extra_params_exercise['groupingView'] = array('groupField'=>array('course'),'groupColumnShow'=>'false','groupText' => array('<b>'.get_lang('Course').' {0}</b>'));
  473. //$extra_params_exercise['groupingView'] = array('groupField'=>array('course'),'groupColumnShow'=>'false','groupText' => array('<b>'.get_lang('Course').' {0} - {1} Item(s)</b>'));
  474. }
  475. ?>
  476. <br />
  477. <script>
  478. function change_session() {
  479. document.exercise_admin.submit();
  480. }
  481. $(function() {
  482. //js used when generating images on the fly see function Tracking::show_course_detail()
  483. $(".dialog").dialog("destroy");
  484. $(".dialog").dialog({
  485. autoOpen: false,
  486. show: "blind",
  487. resizable: false,
  488. height:300,
  489. width:550,
  490. modal: true
  491. });
  492. $(".opener").click(function() {
  493. var my_id = $(this).attr('id');
  494. var big_image = '#main_graph_' + my_id;
  495. $( big_image ).dialog("open");
  496. return false;
  497. });
  498. /* Binds a tab id in the url */
  499. $("#tabs").bind('tabsselect', function(event, ui) {
  500. window.location.href=ui.tab;
  501. });
  502. <?php
  503. //Displays js code to use a jqgrid
  504. echo Display::grid_js('courses', '', $columns_courses, $column_model_courses, $extra_params_courses, $new_course_list);
  505. echo Display::grid_js('list_default', $url, $columns, $column_model,$extra_params,array(), '');
  506. echo Display::grid_js('list_course', $url_by_course, $columns, $column_model,$extra_params_course,array(),'');
  507. echo Display::grid_js('list_week', $url_week, $column_week, $column_week_model, $extra_params_week,array(),'');
  508. if (!api_is_anonymous()) {
  509. echo Display::grid_js('exercises', '', $column_exercise, $column_exercise_model, $extra_params_exercise, $my_real_array);
  510. }
  511. ?>
  512. });
  513. </script>
  514. <?php
  515. $courseCode = isset($_GET['course']) ? $_GET['course'] : null;
  516. $reportingTab = '';
  517. if (!api_is_anonymous()) {
  518. $reportingTab = Tracking::show_user_progress(
  519. api_get_user_id(),
  520. $session_id,
  521. '#tabs-4',
  522. false,
  523. false
  524. );
  525. if (!empty($reportingTab)) {
  526. $reportingTab .= '<br />'.Tracking::show_course_detail(
  527. api_get_user_id(),
  528. $courseCode,
  529. $session_id
  530. );
  531. }
  532. if (empty($reportingTab)) {
  533. $reportingTab = Display::return_message(get_lang('NoDataAvailable'), 'warning');
  534. }
  535. }
  536. // Main headers
  537. $headers = array(
  538. Display::return_icon('moderator_star.png'),
  539. get_lang('Courses'),
  540. get_lang('LearningPaths')
  541. );
  542. if (!api_is_anonymous()) {
  543. $headers[] = get_lang('MyQCM');
  544. $headers[] = get_lang('MyStatistics');
  545. }
  546. // Sub headers
  547. /*$sub_header = array(
  548. get_lang('AllLearningPaths'),
  549. get_lang('PerWeek'),
  550. get_lang('ByCourse')
  551. );
  552. // Sub headers data
  553. $lpTab = Display::tabs(
  554. $sub_header,
  555. array(
  556. //Display::grid_html('list_default'),
  557. Display::grid_html('list_week'),
  558. //Display::grid_html('list_course')
  559. ),
  560. 'sub_tab'
  561. );*/
  562. $coursesTab = Display::grid_html('courses');
  563. $starTab = Display::grid_html('list_default');
  564. $tabs = array(
  565. $starTab,
  566. $coursesTab,
  567. Display::grid_html('list_course'),
  568. Display::grid_html('exercises'),
  569. $reportingTab
  570. );
  571. $tabToHide = api_get_configuration_value('session_hide_tab_list');
  572. if (!empty($tabToHide)) {
  573. foreach ($tabToHide as $columnId) {
  574. unset($headers[$columnId]);
  575. unset($tabs[$columnId]);
  576. }
  577. }
  578. // Main headers data
  579. echo Display::tabs(
  580. $headers,
  581. $tabs
  582. );
  583. Display::display_footer();