my_progress_ind.php 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. require_once '../inc/global.inc.php';
  4. $allow = api_get_configuration_value('extra');
  5. if (empty($allow)) {
  6. exit;
  7. }
  8. api_block_anonymous_users();
  9. $nameTools = get_lang('MyProgress');
  10. $this_section = 'session_my_progress_ind';
  11. $_user = api_get_user_info();
  12. $tbl_stats_exercices = Database:: get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
  13. $tbl_stats_access = Database:: get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS);
  14. Display::display_header($nameTools);
  15. $result = Database::query(
  16. "SELECT DISTINCT session.id as id, name, access_start_date date_start, access_end_date date_end
  17. FROM session_rel_course_rel_user,session
  18. WHERE session_id=session.id AND user_id=".$_user['user_id']."
  19. ORDER BY date_start, date_end, name");
  20. $Sessions = Database::store_result($result);
  21. $Courses = [];
  22. foreach ($Sessions as $enreg) {
  23. $id_session_temp = $enreg['id'];
  24. $sql8 = "SELECT *
  25. FROM course
  26. WHERE code = '$courses_code'
  27. ";
  28. $result8 = Database::query($sql8);
  29. $course_code_id = Database::fetch_array($result8);
  30. $c_id = $course_code_id['id'];
  31. $sql = "SELECT DISTINCT c_id,title, CONCAT(lastname, ' ',firstname) coach, username, date_start, date_end, db_name
  32. FROM $tbl_course , $tbl_session_course
  33. LEFT JOIN $tbl_user
  34. ON $tbl_session_course.id_coach = $tbl_user.user_id
  35. INNER JOIN $tbl_session_course_user
  36. ON $tbl_session_course_user.id_session = $tbl_session_course.id_session
  37. AND $tbl_session_course_user.id_user = '".$_user['user_id']."'
  38. INNER JOIN $tbl_session ON $tbl_session.id = $tbl_session_course.id_session
  39. WHERE $tbl_session_course.c_id=$c_id
  40. AND $tbl_session_course.id_session='$id_session_temp'
  41. ORDER BY title";
  42. $result = Database::query($sql);
  43. while ($a_session_courses = Database::fetch_array($result)) {
  44. $a_session_courses['id_session'] = $id_session_temp;
  45. $Courses[$a_session_courses['code']] = $a_session_courses;
  46. }
  47. }
  48. // affichage des jours complétés dans les parcours l'élève
  49. //on recherche les cours où sont inscrit les user
  50. $user_c_id = $_user['user_id'];
  51. $sql2 = "SELECT c_id, user_id
  52. FROM course_rel_user
  53. WHERE user_id = '$user_c_id'
  54. ";
  55. $result2 = Database::query($sql2);
  56. $Total = 0;
  57. while ($a_courses = Database::fetch_array($result2)) {
  58. $courses_code = $a_courses['c_id'];
  59. //on sort le c_id avec le code du cours
  60. //$sql8 = "SELECT *
  61. // FROM course
  62. // WHERE code = '$courses_code'
  63. // ";
  64. // $result8 = Database::query($sql8);
  65. // $course_code_id = Database::fetch_array($result8) ;
  66. $c_id = $courses_code;
  67. //pours chaque cours dans lequel il est inscrit, on cherche les jours complétés
  68. $Req1 = "SELECT *
  69. FROM c_lp_view
  70. WHERE user_id = '$user_c_id' AND c_id = '$c_id'
  71. ";
  72. $res = Database::query($Req1);
  73. while ($result = Database::fetch_array($res)) {
  74. $lp_id = $result['lp_id'];
  75. $lp_id_view = $result['id'];
  76. $c_id_view = $result['c_id'];
  77. $Req2 = "SELECT id, lp_id ,title ,item_type
  78. FROM c_lp_item
  79. WHERE lp_id = '$lp_id'
  80. AND title LIKE '(+)%'
  81. AND c_id = '$c_id_view'
  82. AND item_type = 'document'
  83. ";
  84. $res2 = Database::query($Req2);
  85. while ($resulta = Database::fetch_array($res2)) {
  86. $lp_item_id = $resulta['id'];
  87. $Req3 = " SELECT Max(id)
  88. FROM c_lp_item_view
  89. WHERE
  90. lp_item_id = '$lp_item_id' AND
  91. lp_view_id = '$lp_id_view' AND
  92. c_id = '$c_id_view' AND
  93. status = 'completed'
  94. ";
  95. $res3 = Database::query($Req3);
  96. while ($resul = Database::fetch_array($res3)) {
  97. $max = $resul['0'];
  98. $Req4 = "SELECT COUNT( id )
  99. FROM c_lp_item_view
  100. WHERE
  101. id = '$max' AND
  102. c_id = '$c_id_view'
  103. ";
  104. $res4 = Database::query($Req4);
  105. while ($resultat = Database::fetch_array($res4)) {
  106. if ($resultat[0] == null) {
  107. $resultat[0] = 0;
  108. }
  109. $Total = $Total + $resultat[0];
  110. }
  111. }
  112. }
  113. }
  114. }
  115. api_display_tool_title($nameTools);
  116. $now = date('Y-m-d');
  117. $tbl_personal_agenda = Database:: get_main_table(TABLE_PERSONAL_AGENDA);
  118. //on compte le nombre de m% dans l'agenda pour chaque module
  119. $sqljtot = "SELECT COUNT( * ) AS TOT
  120. FROM $tbl_personal_agenda
  121. WHERE user = '".$_user['user_id']."'
  122. And title like 'm%'
  123. ";
  124. $resultjt = Database::query($sqljtot);
  125. $jour_realise = 0;
  126. while ($jtot = Database::fetch_array($resultjt)) {
  127. $jour_realise_tot = ($jour_realise + $jtot['TOT']) / 2;
  128. }
  129. //fin des jour de l'agenda
  130. //on trouve le nombre dans l'agenda selon la date d'aujourdhui
  131. //si rien n'est inscrit cette journée dans l'agenda, recule de -1
  132. $jour_agenda = '';
  133. $tour = -1;
  134. while ($jour_agenda == '') {
  135. $tour++;
  136. $date = date("Y-m-d", mktime(0, 0, 0, date("m"), date("d") - $tour, date("Y")));
  137. $sql4 = "SELECT title FROM $tbl_personal_agenda
  138. WHERE user = '".$_user['user_id']."' AND
  139. text='Pour le calendrier, ne pas effacer' AND
  140. date like '".$date." %:%' ";
  141. $result4 = Database::query($sql4);
  142. $res4 = Database::fetch_array($result4);
  143. $jour_agenda = $res4['title'];
  144. if ($tour > 300) {
  145. break;
  146. }
  147. }
  148. $diff = $jour_agenda - $Total;
  149. if ($diff > 0) {
  150. $sing = get_lang('retard');
  151. } else {
  152. $sing = get_lang('avance');
  153. }
  154. $diff = abs($diff);
  155. ?>
  156. <table class="data_table">
  157. <th rowspan="5">
  158. <?php
  159. //on récupere les points de controle de l'élève
  160. $pt[] = '0';
  161. $pt[] = '0';
  162. $sqlcontrole = "SELECT diff
  163. FROM $tbl_stats_exercices
  164. WHERE exe_user_id = ".$_user['user_id']."
  165. AND diff != ''
  166. ORDER BY exe_date ASC
  167. ";
  168. $result = Database::query($sqlcontrole);
  169. while ($ptctl = Database::fetch_array($result)) {
  170. $pt[] = $ptctl['diff'];
  171. }
  172. //graphique de suivi
  173. /*include "../inc/teechartphp/sources/TChart.php";
  174. $chart = new TChart(500, 300);
  175. $chart->getAspect()->setView3D(false);
  176. $chart->getHeader()->setText("Graphique de suivi");
  177. $chart->getAxes()->getLeft()->setMinimumOffset(10);
  178. $chart->getAxes()->getLeft()->setMaximumOffset(10);
  179. $chart->getAxes()->getBottom()->setMinimumOffset(10);
  180. $chart->getAxes()->getBottom()->setMaximumOffset(10);
  181. $line1 = new Line($chart->getChart());
  182. $data = $pt;
  183. $line1->addArray($data);
  184. foreach ($chart->getSeries() as $serie) {
  185. $pointer = $serie->getPointer();
  186. $pointer->setVisible(true);
  187. $pointer->getPen()->setVisible(false);
  188. $pointer->setHorizSize(2);
  189. $pointer->setVertSize(2);
  190. $marks = $serie->getMarks();
  191. $marks->setVisible(true);
  192. $marks->setArrowLength(5);
  193. $marks->getArrow()->setVisible(false);
  194. $marks->setTransparent(true);
  195. }
  196. $x = $_user['user_id'];
  197. $line1->getPointer()->setStyle(PointerStyle::$CIRCLE);
  198. $chart->getLegend()->setVisible(false);
  199. $chart->render("../garbage/$x-image.png");
  200. $rand = rand();
  201. print '<img src="../garbage/'.$x.'-image.png?rand='.$rand.'">';
  202. */
  203. ?>
  204. <tr>
  205. <th align="left" width="412">
  206. <?php echo get_lang('Cumulatif_agenda'); ?>:
  207. <b><font color=#CC0000> <?php echo $jour_realise_tot; ?></font></b>
  208. </th>
  209. </tr>
  210. <tr>
  211. <th align="left">
  212. <?php echo get_lang('Cumulatif'); ?> <b><font color=#CC0000> <?php echo $Total; ?></font></b>
  213. </th>
  214. </tr>
  215. <tr>
  216. <th align="left">
  217. <?php echo get_lang('jours_selon_horaire'); ?>:
  218. <b><font color=#CC0000> <?php echo $jour_agenda; ?><?php echo $Days; ?></font></b>
  219. </th>
  220. </tr>
  221. <tr>
  222. <th align="left">
  223. <?php echo get_lang('diff2'); ?>:
  224. <b><font color=#CC0000> <?php echo $diff; ?><?php echo $Days, $sing; ?></font></b>
  225. </th>
  226. </tr>
  227. </table>
  228. <hr>
  229. <table class='data_table'>
  230. <tr>
  231. <th><?php echo get_lang('level'); ?> </th>
  232. <th>
  233. <?php echo get_lang('lang_date'); ?>
  234. </th>
  235. <th>
  236. <?php echo get_lang('interventions_commentaires'); ?>
  237. </th>
  238. </tr>
  239. <?php
  240. $sqlinter = "SELECT *
  241. FROM $tbl_stats_exercices
  242. WHERE exe_user_id = ".$_user['user_id']."
  243. And level != 0
  244. Order by LEVEL ASC";
  245. $resultinter = Database::query($sqlinter);
  246. $level = '';
  247. while ($a_inter = Database::fetch_array($resultinter)) {
  248. $level = $a_inter['level'];
  249. $mod_no = $a_inter['mod_no'];
  250. $inter_coment = Security::remove_XSS($a_inter['inter_coment']);
  251. $inter_date = substr($a_inter['exe_date'], 0, 11);
  252. echo "
  253. <tr>
  254. <td> ".$a_inter['level']."</td>
  255. <td> $inter_date </td>
  256. <td>$inter_coment</td>";
  257. $exe_id = $a_inter['exe_id'];
  258. }
  259. if ($level == 3) {
  260. echo '<span style="color: red; font-weight: bold;"><img src="../img/anim/pointeranim.gif"align="middle" > ';
  261. echo $limit;
  262. echo '</span>';
  263. }
  264. ?>
  265. <p>
  266. </table><br>
  267. <?php
  268. //début de fin des cours prevu
  269. $user_info = api_get_user_info();
  270. $user_id = api_get_user_id();
  271. //On cherche le calendrier pour ce user et le c_id de ce calendrier
  272. $sql = "SELECT *
  273. FROM user
  274. WHERE user_id = '$user_id'
  275. ";
  276. $result = Database::query($sql);
  277. $horaire_id = Database::fetch_array($result);
  278. $nom_hor = $horaire_id['official_code'];
  279. $c_id_horaire = strstr($nom_hor, '.');
  280. $c_id_horaire = str_replace(".", "", "$c_id_horaire");
  281. // Courses
  282. echo '<h3>'.get_lang('Course').'</h3>';
  283. echo '<table class="data_table">';
  284. echo '<tr>
  285. <th>'.get_lang('Course').'</th>
  286. <th>'.get_lang('Time').'</th>
  287. <th>'.get_lang('FirstConnexion').'</th>
  288. <th>'.get_lang('Progress').'</th>
  289. <th>'.get_lang('fin_mod_prevue').'</th>
  290. </tr>';
  291. //on recherche les cours où sont inscrit les user
  292. $user_c_id = $_user['user_id'];
  293. $sql2 = "SELECT c_id, user_id
  294. FROM course_rel_user
  295. WHERE user_id = '$user_id'";
  296. $result2 = Database::query($sql2);
  297. while ($a_courses = Database::fetch_array($result2)) {
  298. $courses_code = $a_courses['c_id'];
  299. //on sort le c_id avec le code du cours
  300. $sql8 = "SELECT title, code
  301. FROM course
  302. WHERE id = '$courses_code'";
  303. $result8 = Database::query($sql8);
  304. $course_code_id = Database::fetch_array($result8);
  305. $c_id = $courses_code;
  306. $c_title = $course_code_id['title'];
  307. // Francois Belisle Kezber
  308. // The Tracking Class still uses the course code rather then the course id.
  309. $tracking_c_code = $course_code_id['code'];
  310. // time spent on the course
  311. $time_spent_on_course = api_time_to_hms(Tracking:: get_time_spent_on_the_course($user_id, $c_id, $session_id));
  312. // firts connection date
  313. $sql2 = "SELECT STR_TO_DATE(access_date,'%Y-%m-%d')
  314. FROM $tbl_stats_access
  315. WHERE
  316. access_user_id = '$user_id' AND
  317. c_id = '$c_id'
  318. ORDER BY access_id ASC
  319. LIMIT 0,1";
  320. //Francois Belisle Kezber
  321. // mysql fonctions rather then Database::
  322. // conversion to Database::
  323. $rs2 = Database::query($sql2);
  324. $num_rows = Database::num_rows($rs2);
  325. if ($num_rows > 0) {
  326. $rw2 = Database::fetch_array($rs2);
  327. $first_connection_date_to_module = $rw2[0];
  328. }
  329. //pour trouver la date de fin prévue du module
  330. $end_date_module = get_lang('hors_cal');
  331. //on trouve le nombre de jour pour ce module
  332. $sql = "SELECT * FROM c_cal_set_module
  333. where c_id = '$c_id'";
  334. $res = Database::query($sql);
  335. $resulta = Database::fetch_array($res);
  336. $nombre_heure = $resulta['minutes'];
  337. // on trouve le nombre de minute par jour
  338. $sql = "SELECT * FROM c_cal_horaire
  339. where c_id = '$c_id_horaire'
  340. AND name = '$nom_hor'
  341. ";
  342. $res = Database::query($sql);
  343. $resulta = Database::fetch_array($res);
  344. $nombre_minutes = (int) $resulta['num_minute'];
  345. //on calcule le nombre de jour par module
  346. $nombre_jours_module = 0;
  347. if (!empty($nombre_minutes)) {
  348. $nombre_jours_module = $nombre_heure * '60' / $nombre_minutes;
  349. }
  350. //on arrondi
  351. $nombre_jours_module = (int) $nombre_jours_module;
  352. //on trouve la date de fin de chaque module AND date = date_format('$first_connection_date_to_module','%Y-%m-%d')
  353. $sql = "SELECT * FROM c_cal_dates
  354. WHERE
  355. horaire_name = '$nom_hor' AND
  356. c_id = '$c_id_horaire' AND
  357. STR_TO_DATE(date,'%Y-%m-%d') >= STR_TO_DATE('$first_connection_date_to_module','%Y-%m-%d')
  358. ORDER BY STR_TO_DATE(date, '%Y-%m-%d') asc
  359. LIMIT $nombre_jours_module, 18446744073709551615
  360. ";
  361. $res = Database::query($sql);
  362. //Database::data_seek($res,$nombre_jours_module);
  363. $row = Database::fetch_row($res);
  364. $end_date_module = $row[1];
  365. //fin de trouver la date de fin prévue du module
  366. //progression en %
  367. $t_lp = Database:: get_course_table(TABLE_LP_MAIN);
  368. $sql_lp = " SELECT lp.name, lp.id FROM $t_lp lp WHERE c_id = '$c_id' ORDER BY lp.display_order";
  369. $rs_lp = Database::query($sql_lp);
  370. $i = 0;
  371. while ($learnpath = Database:: fetch_array($rs_lp)) {
  372. $lp_id = intval($learnpath['id']);
  373. $lp_name = $learnpath['name'];
  374. $any_result = false;
  375. // Get progress in lp
  376. // Francois Belisle Kezber
  377. // Course Code passed rather then course_id
  378. $progress = Tracking::get_avg_student_progress(
  379. $user_c_id, /*$c_id*/
  380. $tracking_c_code,
  381. [$lp_id],
  382. $session_id
  383. );
  384. if ($progress === null) {
  385. $progress = '0%';
  386. } else {
  387. $any_result = true;
  388. }
  389. // Get time in lp
  390. // Francois Belisle Kezber
  391. // Course Code passed rather then course_id
  392. $total_time = Tracking::get_time_spent_in_lp(
  393. $user_c_id, /*$c_id*/
  394. $tracking_c_code,
  395. [$lp_id],
  396. $session_id
  397. );
  398. if (!empty($total_time)) {
  399. $any_result = true;
  400. }
  401. if ($i % 2 == 0) {
  402. $css_class = "row_even";
  403. } else {
  404. $css_class = "row_odd";
  405. }
  406. $i++;
  407. if (is_numeric($progress)) {
  408. $progress = $progress.'%';
  409. } else {
  410. $progress = '-';
  411. }
  412. $data_learnpath[/*$i*/
  413. $lp_id][] = $progress.'%';
  414. }
  415. $warming = '';
  416. $today = date('Y-m-d');
  417. if (isset($end_date_module) && $end_date_module <= $today and $progress != '100%') {
  418. $warming = '<b><font color=#CC0000> '.get_lang('limite_atteinte').'</font></b>';
  419. }
  420. $end_date_module = $end_date_module.$warming;
  421. echo '<tr>
  422. <td >'.$c_title.'</td>
  423. <td >'.$time_spent_on_course.'</td>
  424. <td >'.$first_connection_date_to_module.'</td>
  425. <td >'.$progress.'</td>
  426. <td >'.$end_date_module.'</td>';
  427. echo '</tr>';
  428. }
  429. echo '</table>';
  430. ?> </table>
  431. <br/><br/>
  432. <table class='data_table'>
  433. <tr>
  434. <th colspan="6">
  435. <?php
  436. echo get_lang('result_exam');
  437. //echo $_user['name'];
  438. ?>
  439. </th>
  440. <tr>
  441. <th><?php echo get_lang('module'); ?></th>
  442. <th><?php echo get_lang('result_exam'); ?></th>
  443. <th><?php echo get_lang('result_rep_1'); ?></th>
  444. <th><?php echo get_lang('result_rep_2'); ?></th>
  445. <th><?php echo get_lang('comment'); ?></th>
  446. </tr>
  447. <?php
  448. $sqlexam = "SELECT *
  449. FROM $tbl_stats_exercices
  450. WHERE exe_user_id = '".$_user['user_id']."'
  451. AND c_id = '0' AND mod_no != '0'
  452. ORDER BY mod_no ASC";
  453. $resultexam = Database::query($sqlexam);
  454. while ($a_exam = Database::fetch_array($resultexam)) {
  455. $ex_id = $a_exam['ex_id'];
  456. $mod_no = $a_exam['mod_no'];
  457. $score_ex = $a_exam['score_ex'];
  458. $score_rep1 = $a_exam['score_rep1'];
  459. $score_rep2 = $a_exam['score_rep2'];
  460. $coment = stripslashes($a_exam['coment']);
  461. echo "
  462. <tr>
  463. <td><center> ".$a_exam['mod_no']."
  464. </td>
  465. <td><center>
  466. ".$a_exam['score_ex']."
  467. </td>
  468. <td><center>
  469. ".$a_exam['score_rep1']."
  470. </td><center>
  471. <td><center>
  472. ".$a_exam['score_rep2']."
  473. </td>
  474. <td>$coment
  475. ";
  476. $exe_idd = $a_exam['exe_id']; ?>
  477. </tr>
  478. <?php
  479. }
  480. ?>
  481. </table>
  482. <?php
  483. Display::display_footer();