lp_stats.php 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * This script displays statistics on the current learning path (scorm)
  5. *
  6. * This script must be included by lp_controller.php to get basic initialisation
  7. * @package chamilo.learnpath
  8. * @author Yannick Warnier <ywarnier@beeznest.org>
  9. */
  10. require_once 'learnpath.class.php';
  11. //require_once 'scorm.class.php';
  12. require_once 'resourcelinker.inc.php';
  13. require_once api_get_path(LIBRARY_PATH).'tracking.lib.php';
  14. require_once api_get_path(LIBRARY_PATH).'course.lib.php';
  15. if(empty($_SESSION['_course']['id']) && isset($_GET['course'])) {
  16. $course_code = Security::remove_XSS($_GET['course']);
  17. } else {
  18. $course_code = $_SESSION['_course']['id'];
  19. }
  20. if (isset($_GET['student_id'])) {
  21. $student_id = intval($_GET['student_id']);
  22. }
  23. $session_id = api_get_session_id();
  24. $session_condition = api_get_session_condition($session_id);
  25. //The two following variables have to be declared by the includer script
  26. //$lp_id = $_SESSION['oLP']->get_id();
  27. //$list = $_SESSION['oLP']->get_flat_ordered_items_list($lp_id);
  28. //$user_id = $_user['user_id'];
  29. //$stats_charset = $_SESSION['oLP']->encoding
  30. if(!isset($origin))
  31. $origin = '';
  32. if($origin != 'tracking') {
  33. if (!empty ($stats_charset)) {
  34. $lp_charset = $stats_charset;
  35. } else {
  36. $lp_charset = api_get_setting('platform_charset');
  37. }
  38. $charset = $lp_charset;
  39. //$w = $tablewidth -20;
  40. $htmlHeadXtra[] = ''.'<style type="text/css" media="screen, projection">
  41. /*<![CDATA[*/
  42. @import "../css/public_admin/scorm.css";
  43. /*]]>*/
  44. </style>';
  45. include_once api_get_path(INCLUDE_PATH).'reduced_header.inc.php';
  46. echo '<body>';
  47. } else {
  48. //Get learning path's encoding
  49. $TBL_LP = Database :: get_course_table(TABLE_LP_MAIN);
  50. $sql = "SELECT default_encoding FROM $TBL_LP " .
  51. "WHERE id = '".(int)$_GET['lp_id']."'";
  52. $res = Database::query($sql);
  53. if (Database :: num_rows($res) > 0) {
  54. $row = Database::fetch_array($res);
  55. $lp_charset = $row['default_encoding'];
  56. }
  57. }
  58. // The dokeos interface's encoding
  59. $dokeos_charset = api_get_setting('platform_charset');
  60. $output = '';
  61. //if display in fullscreen required
  62. if (!empty($_GET['fs']) && strcmp($_GET['fs'], 'true') == 0) {
  63. $output .= '<table width="100%" align="center">';
  64. } else {
  65. $output .= '<table width="100%">';
  66. }
  67. //check if the user asked for the "extend all" option
  68. $extend_all_link = '';
  69. $extend_all = 0;
  70. if ($origin == 'tracking') {
  71. $url_suffix = '&session_id='.$session_id.'&course=' . Security::remove_XSS($_GET['course']) . '&student_id=' . $student_id . '&lp_id=' . Security::remove_XSS($_GET['lp_id']) . '&origin=' . Security::remove_XSS($_GET['origin']).$from_link;
  72. } else {
  73. $url_suffix = '';
  74. }
  75. if (!empty ($_GET['extend_all'])) {
  76. $extend_all_link = '<a href="' . api_get_self() . '?action=stats' . $url_suffix . '"><img src="../img/view_less_stats.gif" alt="fold_view" border="0" title="'.api_convert_encoding(get_lang('HideAllAttempts'), $lp_charset, $dokeos_charset).'"></a>';
  77. $extend_all = 1;
  78. } else {
  79. $extend_all_link = '<a href="' . api_get_self() . '?action=stats&extend_all=1' . $url_suffix . '"><img src="../img/view_more_stats.gif" alt="extend_view" border="0" title="'.api_convert_encoding(get_lang('ShowAllAttempts'), $lp_charset, $dokeos_charset).'"></a>';
  80. }
  81. if ($origin != 'tracking') {
  82. $output .= "<tr><td><div class='title'>" . api_convert_encoding(get_lang('ScormMystatus'), $lp_charset, $dokeos_charset) . "</div></td></tr>";
  83. }
  84. $output .= "<tr><td>&nbsp;</td></tr>" . "<tr><td>" . "<table border='0' class='data_table'><tr>\n" . '<td width="16">' . $extend_all_link . '</td>' . '<td colspan="4" class="title"><div class="mystatusfirstrow">' . api_convert_encoding(get_lang('ScormLessonTitle'), $lp_charset, $dokeos_charset) . "</div></td>\n" . '<td colspan="2" class="title"><div class="mystatusfirstrow">' . api_convert_encoding(get_lang('ScormStatus'), $lp_charset, $dokeos_charset) . "</div></td>\n" . '<td colspan="2" class="title"><div class="mystatusfirstrow">' . api_convert_encoding(get_lang('ScormScore'), $lp_charset, $dokeos_charset) . "</div></td>\n" . '<td colspan="2" class="title"><div class="mystatusfirstrow">' . api_convert_encoding(get_lang('ScormTime'), $lp_charset, $dokeos_charset) . "</div></td><td class='title'><div class='mystatusfirstrow'>" . api_convert_encoding(get_lang('Actions'), $lp_charset, $dokeos_charset) . "</div></td></tr>\n";
  85. //going through the items using the $items[] array instead of the database order ensures
  86. // we get them in the same order as in the imsmanifest file, which is rather random when using
  87. // the database table
  88. $TBL_LP_ITEM = Database :: get_course_table(TABLE_LP_ITEM);
  89. $TBL_LP_ITEM_VIEW = Database :: get_course_table(TABLE_LP_ITEM_VIEW);
  90. $TBL_LP_VIEW = Database :: get_course_table(TABLE_LP_VIEW);
  91. $tbl_stats_exercices = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
  92. $tbl_stats_attempts= Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
  93. $tbl_quiz_questions= Database :: get_course_table(TABLE_QUIZ_QUESTION);
  94. $sql = "SELECT max(view_count) FROM $TBL_LP_VIEW " .
  95. "WHERE lp_id = $lp_id AND user_id = '" . $user_id . "' $session_condition";
  96. $res = Database::query($sql);
  97. $view = '';
  98. $num = 0;
  99. if (Database :: num_rows($res) > 0) {
  100. $myrow = Database :: fetch_array($res);
  101. $view = $myrow[0];
  102. }
  103. $counter = 0;
  104. //error_log('New LP - Querying views for latest attempt: '.$sql,0);
  105. $total_score = 0;
  106. $total_max_score = 0;
  107. $total_time = 0;
  108. $h = api_convert_encoding(get_lang('h'), $lp_charset, $dokeos_charset);
  109. if (!empty($export_csv)) {
  110. $csv_content[] = array (
  111. api_convert_encoding(get_lang('ScormLessonTitle'), $lp_charset, $dokeos_charset),
  112. api_convert_encoding(get_lang('ScormStatus'), $lp_charset, $dokeos_charset),
  113. api_convert_encoding(get_lang('ScormScore'), $lp_charset, $dokeos_charset),
  114. api_convert_encoding(get_lang('ScormTime'), $lp_charset, $dokeos_charset)
  115. );
  116. }
  117. // get attempts of a exercise
  118. if (isset($_GET['lp_id']) && isset($_GET['my_lp_id'])) {
  119. $clean_lp_item_id = Database::escape_string($_GET['my_lp_id']);
  120. $clean_lp_id = Database::escape_string($_GET['lp_id']);
  121. $clean_course_code = Database :: escape_string($course_code);
  122. $sql_path = "SELECT path FROM $TBL_LP_ITEM WHERE id = '$clean_lp_item_id' AND lp_id = '$clean_lp_id'";
  123. $res_path = Database::query($sql_path);
  124. $row_path = Database::fetch_array($res_path);
  125. if (Database::num_rows($res_path) > 0 ){
  126. if ($origin != 'tracking') {
  127. $sql_attempts = 'SELECT * FROM ' . $tbl_stats_exercices . ' WHERE exe_exo_id="' . (int)$row_path['path'] . '" AND exe_user_id="' . (int)api_get_user_id() . '" AND orig_lp_id = "'.(int)$clean_lp_id.'" AND orig_lp_item_id = "'.(int)$clean_lp_item_id.'" AND exe_cours_id="' . $clean_course_code. '" AND status <> "incomplete" AND session_id = '.$session_id.' ORDER BY exe_date';
  128. } else {
  129. $sql_attempts = 'SELECT * FROM ' . $tbl_stats_exercices . ' WHERE exe_exo_id="' . (int)$row_path['path'] . '" AND exe_user_id="' . $student_id . '" AND orig_lp_id = "'.(int)$clean_lp_id.'" AND orig_lp_item_id = "'.(int)$clean_lp_item_id.'" AND exe_cours_id="' . $clean_course_code. '" AND status <> "incomplete" AND session_id = '.$session_id.' ORDER BY exe_date';
  130. }
  131. $sql_attempts;
  132. }
  133. }
  134. $TBL_QUIZ = Database :: get_course_table(TABLE_QUIZ_TEST);
  135. if (is_array($list) && count($list) > 0) {
  136. foreach ($list as $my_item_id) {
  137. $extend_this = 0;
  138. $qry_order = 'DESC';
  139. if ((!empty ($_GET['extend_id']) and $_GET['extend_id'] == $my_item_id) OR $extend_all) {
  140. $extend_this = 1;
  141. $qry_order = 'ASC';
  142. }
  143. //prepare statement to go through each attempt
  144. if (!empty ($view)) {
  145. $sql = "SELECT iv.status as mystatus, v.view_count as mycount, " .
  146. " iv.score as myscore, iv.total_time as mytime, i.id as myid, i.lp_id as mylpid, iv.lp_view_id as mylpviewid, " .
  147. " i.title as mytitle, i.max_score as mymaxscore, " .
  148. " iv.max_score as myviewmaxscore, " .
  149. " i.item_type as item_type, iv.view_count as iv_view_count, " .
  150. " iv.id as iv_id, path as path" .
  151. " FROM $TBL_LP_ITEM as i, $TBL_LP_ITEM_VIEW as iv, $TBL_LP_VIEW as v" .
  152. " WHERE i.id = iv.lp_item_id " .
  153. " AND i.id = $my_item_id " .
  154. " AND iv.lp_view_id = v.id " .
  155. " AND i.lp_id = $lp_id " .
  156. " AND v.user_id = " . $user_id . " " .
  157. " AND v.view_count = $view " .
  158. " AND v.session_id = $session_id " .
  159. " ORDER BY iv.view_count $qry_order ";
  160. } else {
  161. $sql = "SELECT iv.status as mystatus, v.view_count as mycount, " .
  162. " iv.score as myscore, iv.total_time as mytime, i.id as myid, i.lp_id as mylpid, iv.lp_view_id as mylpviewid, " .
  163. " i.title as mytitle, i.max_score as mymaxscore, " .
  164. " iv.max_score as myviewmaxscore, " .
  165. " i.item_type as item_type, iv.view_count as iv_view_count, " .
  166. " iv.id as iv_id, path as path " .
  167. " FROM $TBL_LP_ITEM as i, $TBL_LP_ITEM_VIEW as iv, $TBL_LP_VIEW as v " .
  168. " WHERE i.id = iv.lp_item_id " .
  169. " AND i.id = $my_item_id " .
  170. " AND iv.lp_view_id = v.id " .
  171. " AND i.lp_id = $lp_id " .
  172. " AND v.user_id = " . $user_id . " " .
  173. " AND v.session_id = $session_id " .
  174. " ORDER BY iv.view_count $qry_order ";
  175. }
  176. //$sql.'<br/>';
  177. $result = Database::query($sql);
  178. $num = Database :: num_rows($result);
  179. $time_for_total = 'NaN';
  180. $is_allowed_to_edit = api_is_allowed_to_edit(null,true);
  181. if (($extend_this || $extend_all) && $num > 0) {
  182. $row = Database :: fetch_array($result);
  183. $result_disabled_ext_all = false;
  184. if($row['item_type'] == 'quiz') {
  185. //check results_disabled in quiz table
  186. $my_path = Database::escape_string($row['path']);
  187. $sql = "SELECT results_disabled FROM $TBL_QUIZ WHERE id ='".(int)$my_path."'";
  188. $res_result_disabled = Database::query($sql);
  189. $row_result_disabled = Database::fetch_row($res_result_disabled);
  190. if (Database::num_rows($res_result_disabled) > 0 && (int)$row_result_disabled[0]===1) {
  191. $result_disabled_ext_all = true;
  192. }
  193. }
  194. //echo '<br><pre>'; print_r($row); echo '</pre><br>';
  195. //if there are several attempts, and the link to extend has been clicked, show each attempt...
  196. if (($counter % 2) == 0) {
  197. $oddclass = "row_odd";
  198. } else {
  199. $oddclass = "row_even";
  200. }
  201. $extend_link='';
  202. if (!empty($inter_num)) {
  203. $extend_link = '<a href="' . api_get_self() . '?action=stats&fold_id=' . $my_item_id . $url_suffix . '"><img src="../img/visible.gif" alt="'.api_convert_encoding(get_lang('HideAttemptView'), $lp_charset, $dokeos_charset).'" title="'.api_convert_encoding(get_lang('HideAttemptView'), $lp_charset, $dokeos_charset).'" border="0"></a>' . "\n";
  204. }
  205. $title = $row['mytitle'];
  206. if (empty ($title)) {
  207. $title = rl_get_resource_name(api_get_course_id(), $lp_id, $row['myid']);
  208. }
  209. if ($row['item_type'] != 'dokeos_chapter') {
  210. $correct_test_link = '-';
  211. //api_convert_encoding($title, $lp_charset, $lp_charset)
  212. $title = Security::remove_XSS($title);
  213. $output .= "<tr class='$oddclass'>\n" . "<td>$extend_link</td>\n" . '<td colspan="4" class="content"><div class="mystatus">' . $title . "</div></td>\n" . '<td colspan="2" class="content"></td>' . "\n" . '<td colspan="2" class="content"></td>' . "\n" . '<td colspan="2" class="content"></td><td class="content"></td>' . "\n" . "</tr>\n";
  214. }
  215. $counter++;
  216. do {
  217. $row['iv_view_count'];
  218. //check if there are interactions below
  219. $extend_attempt_link = '';
  220. $extend_this_attempt = 0;
  221. if ((learnpath :: get_interactions_count_from_db($row['iv_id']) > 0 || learnpath :: get_objectives_count_from_db($row['iv_id']) > 0) && !$extend_all) {
  222. if (!empty ($_GET['extend_attempt_id']) && $_GET['extend_attempt_id'] == $row['iv_id']) {
  223. //the extend button for this attempt has been clicked
  224. $extend_this_attempt = 1;
  225. $extend_attempt_link = '<a href="' . api_get_self() . '?action=stats&extend_id=' . $my_item_id . '&fold_attempt_id=' . $row['iv_id'] . $url_suffix . '"><img src="../img/visible.gif" alt="'.api_convert_encoding(get_lang('HideAttemptView'), $lp_charset, $dokeos_charset).'" title="'.api_convert_encoding(get_lang('HideAttemptView'), $lp_charset, $dokeos_charset).'" border="0"></a>' . "\n";
  226. } else { //same case if fold_attempt_id is set, so not implemented explicitly
  227. //the extend button for this attempt has not been clicked
  228. $extend_attempt_link = '<a href="' . api_get_self() . '?action=stats&extend_id=' . $my_item_id . '&extend_attempt_id=' . $row['iv_id'] . $url_suffix . '"><img src="../img/invisible.gif" alt="'.api_convert_encoding(get_lang('ExtendAttemptView'), $lp_charset, $dokeos_charset).'" title="'.api_convert_encoding(get_lang('ExtendAttemptView'), $lp_charset, $dokeos_charset).'" border="0"></a>' . "\n";
  229. }
  230. }
  231. if (($counter % 2) == 0) {
  232. $oddclass = "row_odd";
  233. } else {
  234. $oddclass = "row_even";
  235. }
  236. $lesson_status = $row['mystatus'];
  237. $score = $row['myscore'];
  238. $time_for_total = $row['mytime'];
  239. $time = learnpathItem :: get_scorm_time('js', $row['mytime']);
  240. $type;
  241. $scoIdentifier = $row['myid'];
  242. if ($score == 0) {
  243. $maxscore = $row['mymaxscore'];
  244. } else {
  245. if ($row['item_type'] == 'sco') {
  246. if (!empty ($row['myviewmaxscore']) && $row['myviewmaxscore'] > 0) {
  247. $maxscore = $row['myviewmaxscore'];
  248. }
  249. elseif ($row['myviewmaxscore'] === '') {
  250. $maxscore = 0;
  251. } else {
  252. $maxscore = $row['mymaxscore'];
  253. }
  254. }
  255. else
  256. {
  257. $maxscore = $row['mymaxscore'];
  258. }
  259. }
  260. //Remove "NaN" if any (@todo: locate the source of these NaN)
  261. $time = str_replace('NaN', '00' . $h . '00\'00"', $time);
  262. if (($lesson_status == 'completed') or ($lesson_status == 'passed')) {
  263. $color = 'green';
  264. } else {
  265. $color = 'black';
  266. }
  267. $mylanglist = array (
  268. 'completed' => 'ScormCompstatus',
  269. 'incomplete' => 'ScormIncomplete',
  270. 'failed' => 'ScormFailed',
  271. 'passed' => 'ScormPassed',
  272. 'browsed' => 'ScormBrowsed',
  273. 'not attempted' => 'ScormNotAttempted',
  274. );
  275. $my_lesson_status = api_convert_encoding(get_lang($mylanglist[$lesson_status]), $lp_charset, $dokeos_charset);
  276. if ($row['item_type'] != 'dokeos_chapter') {
  277. if (!$is_allowed_to_edit && $result_disabled_ext_all) {
  278. $view_score = Display::return_icon('invisible.gif', get_lang('ResultsHiddenByExerciseSetting'));
  279. } else {
  280. $view_score = ($score == 0 ? '/' : ($maxscore === 0 ? $score : $score . '/' . float_format($maxscore, 1)));
  281. }
  282. $output .= "<tr class='$oddclass'>\n" . "<td></td>\n" . "<td>$extend_attempt_link</td>\n" . '<td colspan="3">' . api_convert_encoding(get_lang('Attempt'), $lp_charset, $dokeos_charset) . ' ' . $row['iv_view_count'] . "</td>\n"
  283. //."<td><font color='$color'><div class='mystatus'>".api_htmlentities($array_status[$lesson_status],ENT_QUOTES,$lp_charset)."</div></font></td>\n"
  284. . '<td colspan="2"><font color="' . $color . '"><div class="mystatus">' . $my_lesson_status . "</div></font></td>\n" . '<td colspan="2"><div class="mystatus" align="center">' . $view_score . "</div></td>\n" . '<td colspan="2"><div class="mystatus">'.$time.'</div></td><td></td></tr>';
  285. if (!empty($export_csv)) {
  286. $temp = array ();
  287. $temp[] = $title = Security::remove_XSS($title);
  288. $temp[] = Security::remove_XSS($my_lesson_status);
  289. if ($row['item_type'] == 'quiz') {
  290. if (!$is_allowed_to_edit && $result_disabled_ext_all) {
  291. $temp[] = '/';
  292. } else {
  293. $temp[] = ($score == 0 ? '0/'.$maxscore : ($maxscore == 0 ? $score : $score . '/' . float_format($maxscore, 1)));
  294. }
  295. } else {
  296. $temp[] = ($score == 0 ? '/' : ($maxscore == 0 ? $score : $score . '/' . float_format($maxscore, 1)));
  297. }
  298. $temp[] = $time;
  299. $csv_content[] = $temp;
  300. }
  301. }
  302. $counter++;
  303. if ($extend_this_attempt OR $extend_all) {
  304. $list1 = learnpath :: get_iv_interactions_array($row['iv_id']);
  305. foreach ($list1 as $id => $interaction) {
  306. if (($counter % 2) == 0) {
  307. $oddclass = "row_odd";
  308. } else {
  309. $oddclass = "row_even";
  310. }
  311. $student_response=urldecode($interaction['student_response']);//code added by isaac flores
  312. $content_student_response=array();
  313. $content_student_response=explode('__|',$student_response);
  314. if (count($content_student_response)>0) {
  315. if (count($content_student_response)>=3) {
  316. $new_content_student_response=array_pop($content_student_response);//Pop the element off the end of array
  317. }
  318. $student_response=implode(',',$content_student_response);
  319. }
  320. $output .= "<tr class='$oddclass'>\n" . '<td></td>' . "\n" . '<td></td>' . "\n" . '<td>&nbsp;</td>' . "\n" . '<td>' . $interaction['order_id'] . '</td>' . "\n" . '<td>' . $interaction['id'] . '</td>' . "\n"
  321. //."<td><font color='$color'><div class='mystatus'>".api_convert_encoding($array_status[$lesson_status],$lp_charset,$lp_charset)."</div></font></td>\n"
  322. . '<td colspan="2">' . $interaction['type'] . "</td>\n"
  323. //.'<td>'.$interaction['correct_responses']."</td>\n"
  324. . '<td>' . $student_response . "</td>\n" . '<td>' . $interaction['result'] . "</td>\n" . '<td>' . $interaction['latency'] . "</td>\n" . '<td>' . $interaction['time'] . "</td>\n<td></td>\n</tr>\n";
  325. $counter++;
  326. }
  327. $list2 = learnpath :: get_iv_objectives_array($row['iv_id']);
  328. foreach ($list2 as $id => $interaction) {
  329. if (($counter % 2) == 0) {
  330. $oddclass = "row_odd";
  331. } else {
  332. $oddclass = "row_even";
  333. }
  334. $output .= "<tr class='$oddclass'>\n" . '<td></td>' . "\n" . '<td></td>' . "\n" . '<td>&nbsp;</td>' . "\n" . '<td>' . $interaction['order_id'] . '</td>' . "\n" . '<td colspan="2">' . $interaction['objective_id'] . '</td>' . "\n" .
  335. '<td colspan="2">' . $interaction['status'] . "</td>\n" .
  336. '<td>' . $interaction['score_raw'] . "</td>\n" . '<td>' . $interaction['score_max'] . "</td>\n" . '<td>' . $interaction['score_min'] . "</td>\n<td></td>\n</tr>\n";
  337. $counter++;
  338. }
  339. }
  340. } while ($row = Database :: fetch_array($result));
  341. } elseif ($num > 0) {
  342. $row = Database :: fetch_array($result);
  343. $my_id = $row['myid'];
  344. $my_lp_id = $row['mylpid'];
  345. $my_lp_view_id = $row['mylpviewid'];
  346. $my_path = $row['path'];
  347. $result_disabled_ext_all = false;
  348. if($row['item_type'] == 'quiz') {
  349. //check results_disabled in quiz table
  350. $my_path = Database::escape_string($my_path);
  351. $sql = "SELECT results_disabled FROM $TBL_QUIZ WHERE id ='".(int)$my_path."'";
  352. $res_result_disabled = Database::query($sql);
  353. $row_result_disabled = Database::fetch_row($res_result_disabled);
  354. if (Database::num_rows($res_result_disabled) > 0 && (int)$row_result_disabled[0]===1) {
  355. $result_disabled_ext_all = true;
  356. }
  357. }
  358. //check if there are interactions below
  359. $extend_attempt_link = '';
  360. $extend_this_attempt = 0;
  361. $inter_num = learnpath :: get_interactions_count_from_db($row['iv_id']);
  362. $objec_num = learnpath :: get_objectives_count_from_db($row['iv_id']);
  363. if (($inter_num > 0 || $objec_num > 0) && !$extend_all) {
  364. if (!empty ($_GET['extend_attempt_id']) && $_GET['extend_attempt_id'] == $row['iv_id']) {
  365. //the extend button for this attempt has been clicked
  366. $extend_this_attempt = 1;
  367. $extend_attempt_link = '<a href="' . api_get_self() . '?action=stats&extend_id=' . $my_item_id . '&fold_attempt_id=' . $row['iv_id'] . $url_suffix . '"><img src="../img/visible.gif" alt="'.api_convert_encoding(get_lang('HideAttemptView'),$lp_charset,$charset).'" title="'.api_convert_encoding(get_lang('HideAttemptView'),$lp_charset,$charset).'" border="0"></a>' . "\n";
  368. } else { //same case if fold_attempt_id is set, so not implemented explicitly
  369. //the extend button for this attempt has not been clicked
  370. $extend_attempt_link = '<a href="' . api_get_self() . '?action=stats&extend_id=' . $my_item_id . '&extend_attempt_id=' . $row['iv_id'] . $url_suffix . '"><img src="../img/invisible.gif" alt="'.api_convert_encoding(get_lang('ExtendAttemptView'),$lp_charset,$charset).'" title="'.api_convert_encoding(get_lang('ExtendAttemptView'),$lp_charset,$charset).'" border="0"></a>' . "\n";
  371. }
  372. }
  373. if (($counter % 2) == 0) {
  374. $oddclass = "row_odd";
  375. } else {
  376. $oddclass = "row_even";
  377. }
  378. //$extend_link = '<img src="../img/invisible.gif" alt="extend_disabled">';
  379. $extend_link = '';
  380. if ($inter_num > 1) {
  381. $extend_link = '<a href="' . api_get_self() . '?action=stats&extend_id=' . $my_item_id . '&extend_attempt_id=' . $row['iv_id'] . $url_suffix . '"><img src="../img/invisible.gif" alt="'.api_convert_encoding(get_lang('ExtendAttemptView'),$lp_charset,$charset).'" title="'.api_convert_encoding(get_lang('ExtendAttemptView'),$lp_charset,$charset).'" border="0"></a>';
  382. }
  383. if (($counter % 2) == 0) {
  384. $oddclass = "row_odd";
  385. } else {
  386. $oddclass = "row_even";
  387. }
  388. $lesson_status = $row['mystatus'];
  389. $score = $row['myscore'];
  390. $subtotal_time = $row['mytime'];
  391. //if($row['mytime']==0){
  392. while ($tmp_row = Database :: fetch_array($result)) {
  393. $subtotal_time += $tmp_row['mytime'];
  394. }
  395. //}
  396. //$time_for_total = $subtotal_time;
  397. //$time = learnpathItem :: get_scorm_time('js', $subtotal_time);
  398. $scoIdentifier = $row['myid'];
  399. $title = $row['mytitle'];
  400. // selecting the exe_id from stats attempts tables in order to look the max score value
  401. if ($origin != 'tracking') {
  402. $sql_last_attempt = 'SELECT * FROM ' . $tbl_stats_exercices . ' WHERE exe_exo_id="' . $row['path'] . '" AND exe_user_id="' . api_get_user_id() . '" AND orig_lp_id = "'.$lp_id.'" AND orig_lp_item_id = "'.$row['myid'].'" AND exe_cours_id="' . $course_code . '" AND status <> "incomplete" AND session_id = '.$session_id.' ORDER BY exe_date DESC limit 1';
  403. } else {
  404. $sql_last_attempt = 'SELECT * FROM ' . $tbl_stats_exercices . ' WHERE exe_exo_id="' . $row['path'] . '" AND exe_user_id="' . $student_id . '" AND orig_lp_id = "'.$lp_id.'" AND orig_lp_item_id = "'.$row['myid'].'" AND exe_cours_id="' . $course_code . '" AND status <> "incomplete" AND session_id = '.$session_id.' ORDER BY exe_date DESC limit 1';
  405. }
  406. $resultLastAttempt = Database::query($sql_last_attempt);
  407. $num = Database :: num_rows($resultLastAttempt);
  408. if ($num > 0) {
  409. while ($rowLA = Database :: fetch_array($resultLastAttempt)) {
  410. $id_last_attempt = $rowLA['exe_id'];
  411. }
  412. }
  413. if ($score == 0) {
  414. $maxscore = $row['mymaxscore'];
  415. } else {
  416. if ($row['item_type'] == 'sco') {
  417. if (!empty ($row['myviewmaxscore']) and $row['myviewmaxscore'] > 0) {
  418. $maxscore = $row['myviewmaxscore'];
  419. }
  420. elseif ($row['myviewmaxscore'] === '') {
  421. $maxscore = 0;
  422. } else {
  423. $maxscore = $row['mymaxscore'];
  424. }
  425. } else {
  426. if ($row['item_type'] == 'quiz') {
  427. // get score and total time from last attempt of a exercise en lp
  428. $sql = "SELECT score FROM $TBL_LP_ITEM_VIEW WHERE lp_item_id = '".(int)$my_id."' and lp_view_id = '".(int)$my_lp_view_id."'
  429. ORDER BY view_count DESC limit 1";
  430. $res_score = Database::query($sql);
  431. $row_score = Database::fetch_array($res_score);
  432. $sql = "SELECT SUM(total_time) as total_time FROM $TBL_LP_ITEM_VIEW WHERE lp_item_id = '".(int)$my_id."' and lp_view_id = '".(int)$my_lp_view_id."'";
  433. $res_time = Database::query($sql);
  434. $row_time = Database::fetch_array($res_time);
  435. if (Database::num_rows($res_score) > 0 && Database::num_rows($res_time) > 0) {
  436. $score = (float)$row_score['score'];
  437. $subtotal_time = (int)$row_time['total_time'];
  438. } else {
  439. $score = 0;
  440. $subtotal_time = 0;
  441. }
  442. //echo $subtotal_time ;
  443. //$time = learnpathItem :: get_scorm_time('js', $subtotal_time);
  444. // selecting the max score from an attempt
  445. $sql = "SELECT SUM(t.ponderation) as maxscore from ( SELECT distinct question_id, marks,ponderation FROM $tbl_stats_attempts as at " .
  446. "INNER JOIN $tbl_quiz_questions as q on(q.id = at.question_id) where exe_id ='$id_last_attempt' ) as t";
  447. $result = Database::query($sql);
  448. $row_max_score = Database :: fetch_array($result);
  449. $maxscore = $row_max_score['maxscore'];
  450. } else {
  451. $maxscore = $row['mymaxscore'];
  452. }
  453. }
  454. }
  455. $time_for_total = $subtotal_time;
  456. //$subtotal_time.' - ';
  457. $time = learnpathItem :: get_scorm_time('js', $subtotal_time);
  458. //var_dump($time );
  459. if (empty ($title)) {
  460. $title = rl_get_resource_name(api_get_course_id(), $lp_id, $row['myid']);
  461. }
  462. //Remove "NaN" if any (@todo: locate the source of these NaN)
  463. //$time = str_replace('NaN', '00'.$h.'00\'00"', $time);
  464. if (($lesson_status == 'completed') or ($lesson_status == 'passed')) {
  465. $color = 'green';
  466. } else {
  467. $color = 'black';
  468. }
  469. $mylanglist = array (
  470. 'completed' => 'ScormCompstatus',
  471. 'incomplete' => 'ScormIncomplete',
  472. 'failed' => 'ScormFailed',
  473. 'passed' => 'ScormPassed',
  474. 'browsed' => 'ScormBrowsed',
  475. 'not attempted' => 'ScormNotAttempted',
  476. );
  477. $my_lesson_status = api_convert_encoding(get_lang($mylanglist[$lesson_status]), $lp_charset, $dokeos_charset);
  478. if ($row['item_type'] != 'dokeos_chapter') {
  479. if ($row['item_type'] == 'quiz') {
  480. $correct_test_link = '';
  481. $my_url_suffix ='';
  482. if ($origin != 'tracking' && $origin != 'tracking_course') {
  483. $my_url_suffix = '&course=' . api_get_course_id() . '&student_id=' . api_get_user_id() . '&lp_id=' . Security::remove_XSS($row['mylpid']);
  484. $sql_last_attempt = 'SELECT * FROM ' . $tbl_stats_exercices . ' WHERE exe_exo_id="' . $row['path'] . '" AND exe_user_id="' . api_get_user_id() . '" AND orig_lp_id = "'.$lp_id.'" AND orig_lp_item_id = "'.$row['myid'].'" AND exe_cours_id="' . $course_code . '" AND status <> "incomplete" AND session_id = '.$session_id.' ORDER BY exe_date DESC ';
  485. } else {
  486. $my_url_suffix = '&course=' . Security::remove_XSS($_GET['course']) . '&student_id=' . $student_id . '&lp_id=' . Security::remove_XSS($row['mylpid']).'&origin=' . Security::remove_XSS($_GET['origin'].$from_link);
  487. $sql_last_attempt = 'SELECT * FROM ' . $tbl_stats_exercices . ' WHERE exe_exo_id="' . $row['path'] . '" AND exe_user_id="' . $student_id . '" AND orig_lp_id = "'.$lp_id.'" AND orig_lp_item_id = "'.$row['myid'].'" AND exe_cours_id="' . Database :: escape_string($_GET['course']) . '" AND status <> "incomplete" AND session_id = '.$session_id.' ORDER BY exe_date DESC ';
  488. }
  489. $resultLastAttempt = Database::query($sql_last_attempt);
  490. $num = Database :: num_rows($resultLastAttempt);
  491. if ($num > 0) {
  492. if (isset($_GET['extend_attempt']) && $_GET['extend_attempt'] == 1 && (isset($_GET['lp_id']) && $_GET['lp_id'] == $my_lp_id) && (isset($_GET['my_lp_id']) && $_GET['my_lp_id'] == $my_id) ) {
  493. $correct_test_link = '<a href="' . api_get_self() . '?action=stats' . $my_url_suffix . '&my_ext_lp_id='.$my_id.'"><img src="../img/view_less_stats.gif" alt="fold_view" border="0" title="'.api_convert_encoding(get_lang('HideAllAttempts'),$lp_charset,$charset).'"></a>';
  494. $extend_attempt = 1;
  495. } else {
  496. $correct_test_link = '<a href="' . api_get_self() . '?action=stats&extend_attempt=1'.$my_url_suffix.'&my_lp_id='.$my_id.'"><img src="../img/view_more_stats.gif" alt="extend_view" border="0" title="'.api_convert_encoding(get_lang('ShowAllAttemptsByExercise'),$lp_charset,$charset).'"></a>';
  497. }
  498. } else {
  499. $correct_test_link = '-';
  500. }
  501. } else {
  502. $correct_test_link = '-';
  503. }
  504. //."<td><font color='$color'><div class='mystatus'>".api_htmlentities($array_status[$lesson_status],ENT_QUOTES,$lp_charset)."</div></font></td>\n"
  505. $title = Security::remove_XSS($title);
  506. if ( (isset($_GET['lp_id']) && $_GET['lp_id'] == $my_lp_id ) && (isset($_GET['my_lp_id']) && $_GET['my_lp_id'] == $my_id)) {
  507. $output .= "<tr class='$oddclass' >\n" . "<td>$extend_link</td>\n" . '<td colspan="4"><div class="mystatus">' .$title. '</div></td>' . "\n";
  508. $output .= '<td colspan="2">&nbsp;</td><td colspan="2">&nbsp;</td><td colspan="2">&nbsp;</td><td>'.$correct_test_link.'</td></tr>';
  509. $output .= "</tr>\n";
  510. } else {
  511. if ( (isset($_GET['lp_id']) && $_GET['lp_id'] == $my_lp_id ) && (isset($_GET['my_ext_lp_id']) && $_GET['my_ext_lp_id'] == $my_id)) {
  512. $output .= "<tr class='$oddclass' >\n";
  513. } else {
  514. $output .= "<tr class='$oddclass'>\n";
  515. }
  516. $output .= "<td>$extend_link</td>\n" . '<td colspan="4"><div class="mystatus">' .$title. '</div></td>' . "\n";
  517. $output .= '<td colspan="2"><font color="' . $color . '"><div class="mystatus">' . $my_lesson_status . "</div></font></td>\n" . '<td colspan="2"><div class="mystatus" align="center">';
  518. if ($row['item_type'] == 'quiz') {
  519. if (!$is_allowed_to_edit && $result_disabled_ext_all) {
  520. $output .= Display::return_icon('invisible.gif', get_lang('ResultsHiddenByExerciseSetting'));
  521. } else {
  522. $output .= ($score == 0 ? '0/'.float_format($maxscore, 1) : ($maxscore == 0 ? $score : float_format($score, 1) . '/' . float_format($maxscore, 1)));
  523. }
  524. } else {
  525. $output .= ($score == 0 ? '/' : ($maxscore == 0 ? $score : $score . '/' . $maxscore));
  526. }
  527. $output .= "</div></td>\n" . '<td colspan="2"><div class="mystatus">' . $time . "</div></td><td>$correct_test_link</td>\n";
  528. $output .= "</tr>\n";
  529. }
  530. if (!empty($export_csv)) {
  531. $temp = array ();
  532. $temp[] = api_html_entity_decode($title, ENT_QUOTES, $lp_charset);
  533. $temp[] = api_html_entity_decode($my_lesson_status, ENT_QUOTES, $lp_charset);
  534. if ($row['item_type'] == 'quiz') {
  535. if (!$is_allowed_to_edit && $result_disabled_ext_all) {
  536. $temp[] = '/';
  537. } else {
  538. $temp[] = ($score == 0 ? '0/'.$maxscore : ($maxscore == 0 ? $score : $score . '/' . float_format($maxscore, 1)));
  539. }
  540. } else {
  541. $temp[] = ($score == 0 ? '/' : ($maxscore == 0 ? $score : $score . '/' . float_format($maxscore, 1)));
  542. }
  543. $temp[] = $time;
  544. $csv_content[] = $temp;
  545. }
  546. }
  547. $counter++;
  548. if ($extend_this_attempt OR $extend_all) {
  549. $list1 = learnpath :: get_iv_interactions_array($row['iv_id']);
  550. foreach ($list1 as $id => $interaction) {
  551. if (($counter % 2) == 0) {
  552. $oddclass = "row_odd";
  553. } else {
  554. $oddclass = "row_even";
  555. }
  556. $output .= "<tr class='$oddclass'>\n" . '<td></td>' . "\n" . '<td></td>' . "\n" . '<td>&nbsp;</td>' . "\n" . '<td>' . $interaction['order_id'] . '</td>' . "\n" . '<td>' . $interaction['id'] . '</td>' . "\n"
  557. //."<td><font color='$color'><div class='mystatus'>"api_convert_encoding($array_status[$lesson_status],$lp_charset,$lp_charset)."</div></font></td>\n"
  558. . '<td colspan="2">' . $interaction['type'] . "</td>\n"
  559. //.'<td>'.$interaction['correct_responses']."</td>\n"
  560. . '<td>' . urldecode($interaction['student_response']) . "</td>\n" . '<td>' . $interaction['result'] . "</td>\n" . '<td>' . $interaction['latency'] . "</td>\n" . '<td>' . $interaction['time'] . "</td>\n<td></td>\n</tr>\n";
  561. $counter++;
  562. }
  563. $list2 = learnpath :: get_iv_objectives_array($row['iv_id']);
  564. foreach ($list2 as $id => $interaction) {
  565. if (($counter % 2) == 0) {
  566. $oddclass = "row_odd";
  567. } else {
  568. $oddclass = "row_even";
  569. }
  570. $output .= "<tr class='$oddclass'>\n" . '<td></td>' . "\n" . '<td></td>' . "\n" . '<td>&nbsp;</td>' . "\n" . '<td>' . $interaction['order_id'] . '</td>' . "\n" . '<td colspan="2">' . $interaction['objective_id'] . '</td>' . "\n" .
  571. '<td colspan="2">' . $interaction['status'] . "</td>\n" .
  572. '<td>' . $interaction['score_raw'] . "</td>\n" . '<td>' . $interaction['score_max'] . "</td>\n" . '<td>' . $interaction['score_min'] . "</td>\n<td></td>\n</tr>\n";
  573. $counter++;
  574. }
  575. }
  576. // attempts list by exercise
  577. if ( (isset($_GET['lp_id']) && $_GET['lp_id'] == $my_lp_id ) && (isset($_GET['my_lp_id']) && $_GET['my_lp_id'] == $my_id)) {
  578. $res_attempts = Database::query($sql_attempts);
  579. $num_attempts = Database :: num_rows($res_attempts);
  580. if ($row['item_type'] === 'quiz') {
  581. if ($num_attempts > 0) {
  582. $n=1;
  583. while ($row_attempts = Database :: fetch_array($res_attempts)) {
  584. $my_score = $row_attempts['exe_result'];
  585. $my_maxscore = $row_attempts['exe_weighting'];
  586. $my_exe_id = $row_attempts['exe_id'];
  587. $my_orig_lp = $row_attempts['orig_lp_id'];
  588. $my_orig_lp_item = $row_attempts['orig_lp_item_id'];
  589. $my_exo_exe_id=$row_attempts['exe_exo_id'];
  590. $mktime_start_date = convert_mysql_date($row_attempts['start_date']);
  591. $mktime_exe_date = convert_mysql_date($row_attempts['exe_date']);
  592. $mytime = ((int)$mktime_exe_date-(int)$mktime_start_date);
  593. $time_attemp = learnpathItem :: get_scorm_time('js', $mytime);
  594. $time_attemp = str_replace('NaN', '00' . $h . '00\'00"', $time_attemp);
  595. if (!$is_allowed_to_edit && $result_disabled_ext_all) {
  596. $view_score = Display::return_icon('invisible.gif', get_lang('ResultsHiddenByExerciseSetting'));
  597. } else {
  598. //show only float when need it
  599. $my_score = float_format( $my_score, 1);
  600. $my_maxscore =float_format($my_maxscore, 1);
  601. if ($my_score == 0 ){
  602. $view_score = '0/'.$my_maxscore;
  603. } else {
  604. if ($my_maxscore==0)
  605. $view_score = $my_score;
  606. else
  607. $view_score = $my_score . '/' . $my_maxscore;
  608. }
  609. //$view_score = ($my_score == 0 ? '0.00/'.$my_maxscore : ($my_maxscore == 0 ? $my_score : $my_score . '/' . $my_maxscore));
  610. }
  611. $time_attemp;
  612. $output .= '<tr class="'.$oddclass.'" ><td>&nbsp;</td><td>'.$extend_attempt_link.'</td><td colspan="3">' . api_convert_encoding(get_lang('Attempt'), $lp_charset, $dokeos_charset) . ' ' . $n . '</td>'
  613. . '<td colspan="2"><font color="' . $color . '"><div class="mystatus">' . $my_lesson_status . '</div></font></td><td colspan="2"><div class="mystatus" align="center">' . $view_score . '</div></td><td colspan="2"><div class="mystatus">' . $time_attemp . '</div></td>';
  614. if ($origin != 'tracking') {
  615. if (!$is_allowed_to_edit && $result_disabled_ext_all) {
  616. $output .= '<td><img src="' . api_get_path(WEB_IMG_PATH) . 'quiz_na.gif" alt="'.api_convert_encoding(get_lang('ShowAttempt'), $lp_charset, $dokeos_charset).'" title="'.api_convert_encoding(get_lang('ShowAttempt'), $lp_charset, $dokeos_charset).'"></td>';
  617. } else {
  618. $output .= '<td><a href="../exercice/exercise_show.php?origin=student_progress&myid='.$my_orig_lp.'&my_lp_id='.$my_orig_lp_item.'&id=' . $my_exe_id . '&cidReq=' . $course_code . '&student=' . $student_id .$from_link. '" target="_parent"><img src="' . api_get_path(WEB_IMG_PATH) . 'quiz.gif" alt="'.api_convert_encoding(get_lang('ShowAttempt'), $lp_charset, $dokeos_charset).'" title="'.api_convert_encoding(get_lang('ShowAttempt'), $lp_charset, $dokeos_charset).'"></a></td>';
  619. }
  620. } else {
  621. if (!$is_allowed_to_edit && $result_disabled_ext_all ) {
  622. $output .= '<td><img src="' . api_get_path(WEB_IMG_PATH) . 'quiz_na.gif" alt="'.api_convert_encoding(get_lang('ShowAndQualifyAttempt'), $lp_charset, $dokeos_charset).'" title="'.api_convert_encoding(get_lang('ShowAndQualifyAttempt'), $lp_charset, $dokeos_charset).'"></td>';
  623. } else {
  624. $output .= '<td><a href="../exercice/exercise_show.php?origin=tracking_course&myid='.$my_orig_lp.'&my_lp_id='.$my_orig_lp_item.'&id=' . $my_exe_id . '&cidReq=' . $course_code . '&student=' . $student_id . '&total_time='.$mytime.'&my_exe_exo_id='.$my_exo_exe_id.$from_link.' " target="_parent"><img src="' . api_get_path(WEB_IMG_PATH) . 'quiz.gif" alt="'.api_convert_encoding(get_lang('ShowAndQualifyAttempt'), $lp_charset, $dokeos_charset).'" title="'.api_convert_encoding(get_lang('ShowAndQualifyAttempt'), $lp_charset, $dokeos_charset).'"></a></td>';
  625. }
  626. }
  627. $output .= '</tr>';
  628. $n++;
  629. }
  630. }
  631. $output .= '<tr><td colspan="12">&nbsp;</td></tr>';
  632. }
  633. }
  634. }
  635. $total_time += $time_for_total;
  636. //QUIZZ IN LP
  637. $a_my_id = array();
  638. if (!empty($my_lp_id)) {
  639. $a_my_id[] = $my_lp_id;
  640. }
  641. }
  642. }
  643. if (!empty($a_my_id)) {
  644. $my_studen_id = 0;
  645. $my_course_id = '';
  646. if ($origin == 'tracking') {
  647. $my_studen_id = $student_id;
  648. $my_course_id = Database::escape_string($_GET['course']);
  649. } else {
  650. $my_studen_id = intval(api_get_user_id());
  651. $my_course_id = Database::escape_string(api_get_course_id());
  652. }
  653. $total_score = Tracking::get_avg_student_score($my_studen_id, $my_course_id, $a_my_id);
  654. } else {
  655. if ($origin == 'tracking') {
  656. $my_studen_id = $student_id;
  657. $my_course_id = Database::escape_string($_GET['course']);
  658. if (!empty($my_studen_id) && !empty($my_course_id)) {
  659. $total_score = Tracking::get_avg_student_score($my_studen_id, $my_course_id, array(intval($_GET['lp_id'])));
  660. } else {
  661. $total_score = 0;
  662. }
  663. } else {
  664. $total_score = 0;
  665. }
  666. }
  667. $total_time = learnpathItem :: get_scorm_time('js', $total_time);
  668. //$total_time = str_replace('NaN','00:00:00',$total_time);
  669. $total_time = str_replace('NaN', '00' . $h . '00\'00"', $total_time);
  670. $lp_type = learnpath :: get_type_static($lp_id);
  671. $total_percent = 0;
  672. if(!$is_allowed_to_edit && $result_disabled_ext_all) {
  673. $final_score = Display::return_icon('invisible.gif', get_lang('ResultsHiddenByExerciseSetting'));
  674. } else {
  675. if (is_numeric($total_score))
  676. $final_score = $total_score.'%';
  677. else
  678. $final_score = $total_score;
  679. }
  680. if (($counter % 2) == 0) {
  681. $oddclass = "row_odd";
  682. } else {
  683. $oddclass = "row_even";
  684. }
  685. if (empty($extend_all)) {
  686. $output .= "<tr class='$oddclass'>\n" . "<td></td>\n" . '<td colspan="4"><div class="mystatus"><i>' . api_convert_encoding(get_lang('AccomplishedStepsTotal') , $lp_charset, $dokeos_charset) . "</i></div></td>\n"
  687. . '<td colspan="2"></td>' . "\n" . '<td colspan="2"><div class="mystatus" align="center">' . $final_score . "</div></td>\n" . '<td colspan="2"><div class="mystatus">' . $total_time . '</div></td><td></td>' . "\n" . "</tr>\n";
  688. }
  689. $output .= "</table></td></tr></table>";
  690. if (!empty($export_csv)) {
  691. $temp = array (
  692. '',
  693. '',
  694. '',
  695. ''
  696. );
  697. $csv_content[] = $temp;
  698. $temp = array (
  699. api_convert_encoding(get_lang('AccomplishedStepsTotal') , $lp_charset, $dokeos_charset),
  700. '',
  701. $final_score,
  702. $total_time
  703. );
  704. $csv_content[] = $temp;
  705. ob_end_clean();
  706. Export :: export_table_csv($csv_content, 'reporting_learning_path_details');
  707. exit;
  708. }
  709. if ($origin != 'tracking') {
  710. $output .= "</body></html>";
  711. }
  712. if (empty($export_csv)) {
  713. echo $output;
  714. }