index.php 25 KB

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