progression.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. <?php
  2. /*
  3. * Created on 28 juil. 2006 by Elixir Interactive http://www.elixir-interactive.com
  4. */
  5. $nameTools= get_lang('Progression');
  6. $langFile = array ('registration', 'index','trad4all','tracking');
  7. $cidReset=true;
  8. require ('../inc/global.inc.php');
  9. $this_section = "session_my_space";
  10. api_block_anonymous_users();
  11. $interbreadcrumb[] = array ("url" => "index.php", "name" => get_lang('MySpace'));
  12. Display :: display_header($nameTools);
  13. $tbl_course = Database :: get_main_table(MAIN_COURSE_TABLE);
  14. $tbl_user = Database :: get_main_table(MAIN_USER_TABLE);
  15. $tbl_session_course = Database :: get_main_table(MAIN_SESSION_COURSE_TABLE);
  16. $tbl_session = Database :: get_main_table(MAIN_SESSION_TABLE);
  17. $tbl_track_exercice = Database :: get_statistic_table(STATISTIC_TRACK_E_EXERCICES_TABLE);
  18. /*
  19. ===============================================================================
  20. FUNCTION
  21. ===============================================================================
  22. */
  23. function exportCsv($a_header,$a_data)
  24. {
  25. global $archiveDirName;
  26. $fileName = 'test.csv';
  27. $archivePath = api_get_path(SYS_PATH).$archiveDirName.'/';
  28. $archiveURL = api_get_path(WEB_CODE_PATH).'course_info/download.php?archive=';
  29. if(!$open = fopen($archivePath.$fileName,'w+'))
  30. {
  31. $message = get_lang('noOpen');
  32. }
  33. else
  34. {
  35. $info = '';
  36. foreach($a_header as $header)
  37. {
  38. $info .= $header.';';
  39. }
  40. $info .= "\r\n";
  41. foreach($a_data as $data)
  42. {
  43. foreach($data as $infos)
  44. {
  45. $info .= $infos.';';
  46. }
  47. $info .= "\r\n";
  48. }
  49. fwrite($open,$info);
  50. fclose($open);
  51. chmod($fileName,0777);
  52. $message = get_lang('UsageDatacreated');
  53. header("Location:".$archiveURL.$fileName);
  54. }
  55. return $message;
  56. }
  57. /*
  58. ===============================================================================
  59. MAIN CODE
  60. ===============================================================================
  61. */
  62. $sqlCourse = " SELECT title,code
  63. FROM $tbl_course as course
  64. ORDER BY title ASC
  65. ";
  66. $resultCourse = api_sql_query($sqlCourse);
  67. if(mysql_num_rows($resultCourse)>0)
  68. {
  69. if(isset($_POST['export']))
  70. {
  71. $exportResult = exportCsv($header,$data);
  72. Display :: display_error_message($exportResult);
  73. }
  74. echo '<table class="data_table">
  75. <tr>
  76. <th>
  77. '.get_lang('Course').'
  78. </th>
  79. <th>
  80. '.get_lang('TempsFrequentation').'
  81. </th>
  82. <th>
  83. '.get_lang('Progression').'
  84. </th>
  85. <th>
  86. '.get_lang('MoyenneTest').'
  87. </th>
  88. </tr>
  89. ';
  90. $header = array(get_lang('Course'),get_lang('TempsFrequentation'),get_lang('Progression'),get_lang('MoyenneTest'));
  91. while($a_course= mysql_fetch_array($resultCourse))
  92. {
  93. $sqlMoyTest = " SELECT exe_result,exe_weighting
  94. FROM $tbl_track_exercice
  95. WHERE exe_cours_id = '".$a_course['code']."'
  96. ";
  97. $resultMoyTest = api_sql_query($sqlMoyTest);
  98. $result = 0;
  99. $weighting = 0;
  100. while($a_moyTest = mysql_fetch_array($resultMoyTest))
  101. {
  102. $result = $result + $a_moyTest['exe_result'];
  103. $weighting = $weighting + $a_moyTest['exe_weighting'];
  104. }
  105. $moyenneTest = round(($result*100)/$weighting);
  106. echo '<tr>
  107. <td>
  108. '.$a_course['title'].'
  109. </td>
  110. <td>
  111. </td>
  112. <td>
  113. </td>
  114. <td align="center">
  115. '.$moyenneTest.'%
  116. </td>
  117. </tr>
  118. ';
  119. }
  120. echo '</table>';
  121. echo "<br /><br />";
  122. echo "<form method='post'>
  123. <input type='submit' name='export' value='".get_lang('exportExcel')."'/>
  124. <form>";
  125. }
  126. else
  127. {
  128. echo get_lang('NoCourse');
  129. }
  130. /*
  131. ==============================================================================
  132. FOOTER
  133. ==============================================================================
  134. */
  135. Display :: display_footer();
  136. ?>