my_progress.php 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519
  1. <?php
  2. $langFile = array('registration','tracking');
  3. $cidReset = true;
  4. $nameTools="Ma progression";
  5. require ('../inc/global.inc.php');
  6. if(isset($_GET['id_session']))
  7. {
  8. $id_session = intval($_GET['id_session']);
  9. $_SESSION['id_session']=$id_session;
  10. }
  11. elseif(isset($_SESSION['id_session']))
  12. {
  13. $id_session=$_SESSION['id_session'];
  14. }
  15. else
  16. {
  17. $id_session=0;
  18. }
  19. api_block_anonymous_users();
  20. Display :: display_header($nameTools);
  21. $tbl_course = Database :: get_main_table(MAIN_COURSE_TABLE);
  22. $tbl_user = Database :: get_main_table(MAIN_USER_TABLE);
  23. $tbl_session = Database :: get_main_table(MAIN_SESSION_TABLE);
  24. $tbl_course_user = Database :: get_main_table(MAIN_COURSE_USER_TABLE);
  25. $tbl_session_course = Database :: get_main_table(MAIN_SESSION_COURSE_TABLE);
  26. $tbl_session_course_user = Database :: get_main_table(MAIN_SESSION_COURSE_USER_TABLE);
  27. $tbl_stats_lastaccess = Database :: get_statistic_table(STATISTIC_TRACK_E_LASTACCESS_TABLE);
  28. $tbl_stats_exercices = Database :: get_statistic_table(STATISTIC_TRACK_E_EXERCICES_TABLE);
  29. $tbl_course_lp_view = Database :: get_course_table('lp_view');
  30. $tbl_course_lp_view_item = Database :: get_course_table('lp_item_view');
  31. $tbl_course_lp = Database :: get_course_table('lp');
  32. $tbl_course_lp_item = Database :: get_course_table('lp_item');
  33. $tbl_course_quiz = Database :: get_course_table('quiz');
  34. $result=api_sql_query("SELECT DISTINCT id, name, date_start, date_end FROM session_rel_course_rel_user,session WHERE id_session=id AND id_user=$_uid ORDER BY date_start, date_end, name",__FILE__,__LINE__);
  35. $Sessions=api_store_result($result);
  36. $Courses=array();
  37. if($id_session)
  38. {
  39. /*
  40. $result=api_sql_query("SELECT code, title, CONCAT(user.lastname,' ',user.firstname) coach, email
  41. FROM $tbl_session_course_user AS session_course_user, $tbl_session_course AS session_course, $tbl_course AS course, $tbl_user AS user
  42. WHERE session_course_user.id_session='$id_session'
  43. AND session_course_user.id_user='$_uid'
  44. AND session_course_user.course_code=course.code
  45. AND session_course_user.id_session=session_course.id_session
  46. AND session_course_user.course_code=session_course.course_code
  47. AND session_course.id_coach=user.user_id
  48. ORDER BY title",__FILE__,__LINE__);
  49. */
  50. $sql = "SELECT DISTINCT code,title, CONCAT(lastname, ' ',firstname) coach, username, date_start, date_end, db_name
  51. FROM $tbl_course , $tbl_session_course
  52. LEFT JOIN $tbl_user
  53. ON $tbl_session_course.id_coach = $tbl_user.user_id
  54. INNER JOIN $tbl_session_course_user
  55. ON $tbl_session_course_user.id_session = $tbl_session_course.id_session
  56. AND $tbl_session_course_user.id_user = '$_uid'
  57. INNER JOIN $tbl_session ON $tbl_session.id = $tbl_session_course.id_session
  58. WHERE $tbl_session_course.course_code=code
  59. AND $tbl_session_course.id_session='$id_session'
  60. ORDER BY title";
  61. $result=api_sql_query($sql);
  62. $Courses=api_store_result($result);
  63. }
  64. api_display_tool_title($nameTools);
  65. $now=date('Y-m-d');
  66. ?>
  67. Commencez par sélectionner une session de cours ci-dessous.<br><br>
  68. Vous pourrez ensuite suivre votre progression pour chaque cours auquel vous êtes inscrit.<br><br>
  69. <form method="get" action="<?php echo $_SERVER['PHP_SELF']; ?>" style="margin: 0px;">
  70. <center>
  71. Session de cours :
  72. <select name="id_session">
  73. <option value="0">---------- Choisissez ----------</option>
  74. <?php
  75. $date_start=$date_end=$now;
  76. foreach($Sessions as $enreg)
  77. {
  78. if($enreg['id'] == $id_session)
  79. {
  80. $date_start=$enreg['date_start'];
  81. $date_end=$enreg['date_end'];
  82. }
  83. $enreg['date_start']=explode('-',$enreg['date_start']);
  84. $enreg['date_start']=$enreg['date_start'][2].'/'.$enreg['date_start'][1].'/'.$enreg['date_start'][0];
  85. $enreg['date_end']=explode('-',$enreg['date_end']);
  86. $enreg['date_end']=$enreg['date_end'][2].'/'.$enreg['date_end'][1].'/'.$enreg['date_end'][0];
  87. ?>
  88. <option value="<?php echo $enreg['id']; ?>" <?php if($enreg['id'] == $id_session) echo 'selected="selected"'; ?> ><?php echo htmlentities($enreg['name']); if($date_start!='0000-00-00') { ?> (du <?php echo $enreg['date_start']; ?> au <?php echo $enreg['date_end']; ?>)<?php } ?></option>
  89. <?php
  90. }
  91. unset($Sessions);
  92. ?>
  93. </select>
  94. <input type="submit" value="Valider">
  95. </center>
  96. </form>
  97. <br><br>
  98. <table class="data_table" width="100%">
  99. <tr class="tableName">
  100. <td colspan="6">
  101. <strong><?php echo get_lang('MyLearnpath'); ?></strong>
  102. </td>
  103. </tr>
  104. <tr>
  105. <th><?php echo get_lang('Course'); ?></th>
  106. <th><?php echo get_lang('Time'); ?></th>
  107. <th><?php echo get_lang('Progress'); ?></th>
  108. <th><?php echo get_lang('Score'); ?></th>
  109. <th><?php echo get_lang('LastConnexion'); ?></th>
  110. <th><?php echo get_lang('Details'); ?></th>
  111. </tr>
  112. <?php
  113. $i = 0;
  114. $totalWeighting = 0;
  115. $totalScore = 0;
  116. $totalItem = 0;
  117. $totalProgress = 0;
  118. foreach($Courses as $enreg)
  119. {
  120. $sqlTime = "SELECT total_time
  121. FROM ".$enreg['db_name'].'.'.$tbl_course_lp_view_item." AS lpi
  122. INNER JOIN ".$enreg['db_name'].'.'.$tbl_course_lp_view." AS lpv
  123. ON lpv.lp_id = lpi.lp_view_id
  124. AND lpv.user_id = ".$_uid
  125. ;
  126. $result = api_sql_query($sqlTime);
  127. while($totalTime = mysql_fetch_array($result))
  128. {
  129. //print_r($totalTime);
  130. }
  131. $sqlScore = "SELECT exe_result,exe_weighting
  132. FROM $tbl_stats_exercices
  133. WHERE exe_user_id = ".$_uid."
  134. AND exe_cours_id = '".$enreg['code']."'
  135. ";
  136. $resultScore = api_sql_query($sqlScore);
  137. $i = 0;
  138. $score = 0;
  139. while($a_score = mysql_fetch_array($resultScore))
  140. {
  141. $score = $score + $a_score['exe_result'];
  142. $weighting = $weighting + $a_score['exe_weighting'];
  143. $i++;
  144. }
  145. $totalScore = $totalScore + $score;
  146. $totalWeighting = $totalWeighting + $weighting;
  147. $pourcentageScore = round(($score*100)/$weighting);
  148. $weighting = 0;
  149. $sqlLastAccess = " SELECT access_date
  150. FROM $tbl_stats_lastaccess
  151. WHERE access_user_id = ".$_uid."
  152. AND access_cours_code = '".$enreg['code']."'
  153. ORDER BY access_date DESC LIMIT 0,1"
  154. ;
  155. $result = api_sql_query($sqlLastAccess);
  156. $lastAccess = mysql_fetch_array($result);
  157. if(!empty($lastAccess['access_date']))
  158. {
  159. $a_lastConnexion = explode(' ',$lastAccess['access_date']);
  160. $a_date = explode('-',$a_lastConnexion[0]);
  161. $a_heure = explode(':',$a_lastConnexion[1]);
  162. $lastConnexion = $a_date[2]."/".$a_date[1]."/".$a_date[0];
  163. $lastAccessTms = mktime ( $a_heure[0], $a_heure[1] ,$a_heure[2] ,$a_date[1], $a_date[2],$a_date[0]);
  164. }
  165. else
  166. {
  167. $lastConnexion = get_lang('NoConnexion');
  168. }
  169. $sqlProgress = "SELECT COUNT(DISTINCT item_view.lp_item_id) AS nbItem
  170. FROM ".$enreg['db_name'].".".$tbl_course_lp_view_item." AS item_view
  171. INNER JOIN ".$enreg['db_name'].".".$tbl_course_lp_view." AS view
  172. ON view.user_id = ".$_uid."
  173. WHERE item_view.status = 'completed'
  174. ";
  175. $resultProgress = api_sql_query($sqlProgress);
  176. $a_nbItem = mysql_fetch_array($resultProgress);
  177. $table = $enreg['db_name'].'.'.$tbl_course_lp_item;
  178. $nbTotalItem = Database :: count_rows($table);
  179. $totalItem = $totalItem + $nbTotalItem;
  180. $totalProgress = $totalProgress + $a_nbItem['nbItem'];
  181. $progress = round(($a_nbItem['nbItem'] * 100)/$nbTotalItem);
  182. /*$time = $lastAccessTms - $firstAccessTms;
  183. if($time >= 60)
  184. {
  185. $minute = round($time/60);
  186. if($minute >= 60)
  187. {
  188. $heure = round($minute/60);
  189. $minute = $minute - round((60*(($time/60)/60)));
  190. if($minute == 0)
  191. {
  192. $minute = '00';
  193. }
  194. }
  195. else
  196. {
  197. $heure = 0;
  198. }
  199. $temps = $heure.'h'.$minute;
  200. }
  201. else
  202. {
  203. $temps = '0h00';
  204. }
  205. $totalTime .= $time; */
  206. ?>
  207. <tr class='<?php echo $i?'row_odd':'row_even'; ?>'>
  208. <td>
  209. <?php echo htmlentities($enreg['title']); ?>
  210. </td>
  211. <td align='center'>
  212. <?php echo $temps; ?>
  213. </td>
  214. <td align='center'>
  215. <?php echo $progress.'%'; ?>
  216. </td>
  217. <td align='center'>
  218. <?php echo $pourcentageScore.'%'; ?>
  219. </td>
  220. <td align='center'>
  221. <?php echo $lastConnexion; ?>
  222. </td>
  223. <td align='center'>
  224. <a href="<?php echo $SERVER['PHP_SELF']; ?>?course=<?php echo $enreg['code']; ?>"> -> </a>
  225. </td>
  226. </tr>
  227. <?php
  228. $i=$i ? 0 : 1;
  229. }
  230. unset($Courses);
  231. /*if($totalTime >= 60)
  232. {
  233. $minute = round($totalTime / 60);
  234. if($minute >= 60)
  235. {
  236. $heure = round($minute / 60);
  237. $minute = $minute - round((60*(($time/60)/60)));
  238. if($minute == 0)
  239. {
  240. $minute = '00';
  241. }
  242. }
  243. else
  244. {
  245. $heure = 0;
  246. }
  247. $totalTemps = $heure.'h'.$minute;
  248. }
  249. else
  250. {
  251. $totalTemps = '0h00';
  252. }*/
  253. $totalPourcentageScore = round(($totalScore*100)/$totalWeighting);
  254. $progress = round(($totalProgress*100)/$totalItem);
  255. ?>
  256. <tr class='total'>
  257. <td>
  258. <strong><?php echo get_lang('Total'); ?></strong>
  259. </td>
  260. <td align='center'>
  261. <?php echo $totalTemps; ?>
  262. </td>
  263. <td align='center'>
  264. <?php echo $progress.'%'; ?>
  265. </td>
  266. <td align='center'>
  267. <?php echo $totalPourcentageScore.'%'; ?>
  268. </td>
  269. <td>
  270. </td>
  271. <td>
  272. </td>
  273. </tr>
  274. </table>
  275. <br/><br/>
  276. <?php
  277. /*
  278. * **********************************************************************************************
  279. *
  280. * Details for one course
  281. *
  282. * **********************************************************************************************
  283. */
  284. if(isset($_GET['course']))
  285. {
  286. $sqlInfosCourse = " SELECT course.code,course.title,course.db_name,CONCAT(user.firstname,' ',user.lastname,' / ',user.email) as tutor_infos
  287. FROM $tbl_user as user,$tbl_course as course
  288. INNER JOIN $tbl_session_course as sessionCourse
  289. ON sessionCourse.course_code = course.code
  290. WHERE sessionCourse.id_coach = user.user_id
  291. AND course.code= '".$_GET['course']."'
  292. ";
  293. $resultInfosCourse = api_sql_query($sqlInfosCourse);
  294. $a_infosCours = mysql_fetch_array($resultInfosCourse);
  295. $tableTitle = $a_infosCours['title'].' - '.get_lang('Tutor').' : '.$a_infosCours['tutor_infos'];
  296. ?>
  297. <table class="data_table" width="100%">
  298. <tr class="tableName">
  299. <td colspan="4">
  300. <strong><?php echo $tableTitle; ?></strong>
  301. </td>
  302. </tr>
  303. <tr>
  304. <th class="head"><?php echo get_lang('Learnpath'); ?></th>
  305. <th class="head"><?php echo get_lang('Time'); ?></th>
  306. <th class="head"><?php echo get_lang('Progress'); ?></th>
  307. <th class="head"><?php echo get_lang('LastConnexion'); ?></th>
  308. </tr>
  309. <?php
  310. $sqlLearnpath = " SELECT lp.name,lp.id
  311. FROM ".$a_infosCours['db_name'].".".$tbl_course_lp." AS lp
  312. ";
  313. $resultLearnpath = api_sql_query($sqlLearnpath);
  314. if(mysql_num_rows($resultLearnpath)>0)
  315. {
  316. while($a_learnpath = mysql_fetch_array($resultLearnpath))
  317. {
  318. $sqlProgress = "SELECT COUNT(DISTINCT lp_item_id) AS nbItem
  319. FROM ".$a_infosCours['db_name'].".".$tbl_course_lp_view_item." AS item_view
  320. INNER JOIN ".$a_infosCours['db_name'].".".$tbl_course_lp_view." AS view
  321. ON item_view.lp_view_id = view.id
  322. AND view.lp_id = ".$a_learnpath['id']."
  323. AND view.user_id = ".$_uid."
  324. WHERE item_view.status = 'completed'
  325. ";
  326. $resultProgress = api_sql_query($sqlProgress);
  327. $a_nbItem = mysql_fetch_array($resultProgress);
  328. $sqlTotalItem = " SELECT COUNT(item_type) AS totalItem
  329. FROM ".$a_infosCours['db_name'].".".$tbl_course_lp_item."
  330. WHERE lp_id = ".$a_learnpath['id']
  331. ;
  332. $resultItem = api_sql_query($sqlTotalItem);
  333. $a_totalItem = mysql_fetch_array($resultItem);
  334. $progress = round(($a_nbItem['nbItem'] * 100)/$a_totalItem['totalItem']);
  335. echo "<tr>
  336. <td>
  337. ";
  338. echo $a_learnpath['name'];
  339. echo " </td>
  340. <td>
  341. ";
  342. echo " </td>
  343. <td align='center'>
  344. ";
  345. echo $progress.'%';
  346. echo " </td>
  347. <td align='center'>
  348. ";
  349. echo "unknown";
  350. echo " </td>
  351. </tr>
  352. ";
  353. }
  354. }
  355. else
  356. {
  357. echo " <tr>
  358. <td colspan='4'>
  359. ".get_lang('NoLearnpath')."
  360. </td>
  361. </tr>
  362. ";
  363. }
  364. ?>
  365. <tr>
  366. <th class="head"><?php echo get_lang('Exercices'); ?></th>
  367. <th class="head"><?php echo get_lang('Score'); ?></th>
  368. <th class="head"><?php echo get_lang('Essais'); ?></th>
  369. <th class="head"><?php echo get_lang('Correction'); ?></th>
  370. </tr>
  371. <?php
  372. $sqlExercices = " SELECT quiz.title,id
  373. FROM ".$a_infosCours['db_name'].".".$tbl_course_quiz." AS quiz
  374. ";
  375. $resuktExercices = api_sql_query($sqlExercices);
  376. while($a_exercices = mysql_fetch_array($resuktExercices))
  377. {
  378. $sqlEssais = " SELECT COUNT(ex.exe_id) as essais
  379. FROM $tbl_stats_exercices AS ex
  380. WHERE ex.exe_cours_id = '".$a_infosCours['code']."'
  381. AND ex.exe_exo_id = ".$a_exercices['id']
  382. ;
  383. $resultEssais = api_sql_query($sqlEssais);
  384. $a_essais = mysql_fetch_array($resultEssais);
  385. $sqlScore = "SELECT exe_result,exe_weighting
  386. FROM $tbl_stats_exercices
  387. WHERE exe_user_id = ".$_uid."
  388. AND exe_cours_id = '".$a_infosCours['code']."'
  389. AND exe_exo_id = ".$a_exercices['id']
  390. ;
  391. $resultScore = api_sql_query($sqlScore);
  392. $score = 0;
  393. while($a_score = mysql_fetch_array($resultScore))
  394. {
  395. $score = $score + $a_score['exe_result'];
  396. $weighting = $weighting + $a_score['exe_weighting'];
  397. }
  398. $pourcentageScore = round(($score*100)/$weighting);
  399. $weighting = 0;
  400. echo "<tr>
  401. <td>
  402. ";
  403. echo $a_exercices['title'];
  404. echo " </td>
  405. ";
  406. echo " <td align='center'>
  407. ";
  408. echo $pourcentageScore.'%';
  409. echo " </td>
  410. <td align='center'>
  411. ";
  412. echo $a_essais['essais'];
  413. echo " </td>
  414. <td>
  415. ";
  416. echo " </td>
  417. </tr>
  418. ";
  419. }
  420. ?>
  421. </table>
  422. <?php
  423. }
  424. Display :: display_footer();
  425. ?>