dokeos-learnpath
[ class tree: dokeos-learnpath ] [ index: dokeos-learnpath ] [ all elements ]

Source for file lp_stats.php

Documentation is available at lp_stats.php

  1. <?php
  2. /*
  3. ==============================================================================
  4.     Dokeos - elearning and course management software
  5.  
  6.     Copyright (c) 2008 Dokeos SPRL
  7.  
  8.     For a full list of contributors, see "credits.txt".
  9.     The full license can be read in "license.txt".
  10.  
  11.     This program is free software; you can redistribute it and/or
  12.     modify it under the terms of the GNU General Public License
  13.     as published by the Free Software Foundation; either version 2
  14.     of the License, or (at your option) any later version.
  15.  
  16.     See the GNU General Public License for more details.
  17.  
  18.     Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
  19.     Mail: info@dokeos.com
  20. ==============================================================================
  21. */
  22. /**
  23.  * This script displays statistics on the current learning path (scorm)
  24.  * 
  25.  * This script must be included by lp_controller.php to get basic initialisation
  26.  * @package dokeos.learnpath
  27.  * @author Yannick Warnier <ywarnier@beeznest.org>
  28.  */
  29.  
  30. require_once('learnpath.class.php');
  31. //require_once('scorm.class.php');
  32. require_once ('resourcelinker.inc.php');
  33.  
  34.  
  35. if(empty($_SESSION['_course']['id']&& isset($_GET['course']))
  36. {
  37.     $course_code Database :: escape_string($_GET['course']);
  38. }
  39. else
  40. {
  41.     $course_code $_SESSION['_course']['id'];
  42. }
  43.  
  44. //The two following variables have to be declared by the includer script 
  45. //$lp_id = $_SESSION['oLP']->get_id();
  46. //$list = $_SESSION['oLP']->get_flat_ordered_items_list($lp_id);
  47. //$user_id = $_user['user_id'];
  48. //$stats_charset = $_SESSION['oLP']->encoding
  49. if(!isset($origin))
  50.     $origin '';
  51. if($origin != 'tracking')
  52. {
  53.     if (!empty ($stats_charset)) {
  54.         $charset_lang $stats_charset;
  55.     else {
  56.         $charset_lang api_get_setting('platform_charset');
  57.     }
  58.     $dokeos_charset api_get_setting('platform_charset');
  59.     $charset $charset_lang;
  60.     $w $tablewidth -20;
  61.     $htmlHeadXtra[''.'<style type="text/css" media="screen, projection">
  62.         /*<![CDATA[*/
  63.         @import "../css/public_admin/scorm.css";
  64.         /*]]>*/
  65.     </style>';
  66.     include_once ('../inc/reduced_header.inc.php');
  67.     echo '<body>';
  68. }
  69.  
  70. //if display in fullscreen required
  71. if (strcmp($_GET["fs"]"true"== 0
  72. {
  73.     $output .= '<table width="100%" align="center">';
  74. else 
  75. {
  76.     $output .= '<table width="100%">';
  77. }
  78.  
  79. //check if the user asked for the "extend all" option
  80. $extend_all_link '';
  81. $extend_all 0;
  82.  
  83. if($origin == 'tracking')
  84. {
  85.     $url_suffix '&course='.$_GET['course'].'&student_id='.$_GET['student_id'].'&lp_id='.$_GET['lp_id'].'&origin='.$_GET['origin'];
  86. }
  87. else
  88. {
  89.     $url_suffix '';
  90. }
  91.     
  92. if (!empty ($_GET['extend_all'])) 
  93. {
  94.     $extend_all_link '<a href="'.api_get_self().'?action=stats'.$url_suffix.'"><img src="../img/view_less_stats.gif" alt="fold_view" border="0"></a>';
  95.     $extend_all 1;
  96. else
  97. {
  98.     $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"></a>';
  99. }
  100.  
  101. if($origin != 'tracking')
  102. {
  103.     $output .= "<tr><td><div class='title'>".htmlentities(get_lang('ScormMystatus')ENT_QUOTES$dokeos_charset)."</div></td></tr>";
  104. }
  105. $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">'.htmlentities(get_lang('ScormLessonTitle')ENT_QUOTES$dokeos_charset)."</div></td>\n".'<td colspan="2" class="title"><div class="mystatusfirstrow">'.htmlentities(get_lang('ScormStatus')ENT_QUOTES$dokeos_charset)."</div></td>\n".'<td colspan="2" class="title"><div class="mystatusfirstrow">'.htmlentities(get_lang('ScormScore')ENT_QUOTES$dokeos_charset)."</div></td>\n".'<td colspan="2" class="title"><div class="mystatusfirstrow">'.htmlentities(get_lang('ScormTime')ENT_QUOTES$dokeos_charset)."</div></td><td class='title'><div class='mystatusfirstrow'>".htmlentities(get_lang('Actions')ENT_QUOTES$dokeos_charset)."</div></td></tr>\n";
  106. //going through the items using the $items[] array instead of the database order ensures
  107. // we get them in the same order as in the imsmanifest file, which is rather random when using
  108. // the database table
  109. $TBL_LP_ITEM Database :: get_course_table('lp_item');
  110. $TBL_LP_ITEM_VIEW Database :: get_course_table('lp_item_view');
  111. $TBL_LP_VIEW Database :: get_course_table('lp_view');
  112. $tbl_stats_exercices         Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
  113. $sql "SELECT max(view_count) FROM $TBL_LP_VIEW .
  114.         "WHERE lp_id = $lp_id AND user_id = '".$user_id."'";
  115. $res api_sql_query($sql__FILE____LINE__);
  116. $view '';
  117.  
  118. if (Database :: num_rows($res0
  119. {
  120.     $myrow Database :: fetch_array($res);
  121.     $view $myrow[0];
  122. }
  123.  
  124. $counter 0;
  125. //error_log('New LP - Querying views for latest attempt: '.$sql,0);
  126. $total_score 0;
  127. $total_max_score 0;
  128. $total_time 0;
  129. $h get_lang('h');
  130.  
  131. if($export_csv)
  132. {
  133.     $csv_content[array 
  134.                             get_lang('ScormLessonTitle'),
  135.                             get_lang('ScormStatus'),
  136.                             get_lang('ScormScore'),
  137.                             get_lang('ScormTime')
  138.                            );
  139. }
  140.  
  141. foreach ($list as $my_item_id
  142. {
  143.     $extend_this 0;
  144.     $qry_order 'DESC';
  145.     if ((!empty ($_GET['extend_id']and $_GET['extend_id'== $my_item_idOR $extend_all{
  146.         $extend_this 1;
  147.         $qry_order 'ASC';
  148.     }
  149.     //prepare statement to go through each attempt
  150.     if (!empty ($view)) 
  151.     {
  152.         $sql "SELECT iv.status as mystatus, v.view_count as mycount, " .
  153.                 "iv.score as myscore, iv.total_time as mytime, i.id as myid, " .
  154.                 "i.title as mytitle, i.max_score as mymaxscore, " .
  155.                 "iv.max_score as myviewmaxscore, " .
  156.                 "i.item_type as item_type, iv.view_count as iv_view_count, " .
  157.                 "iv.id as iv_id, path as path ".
  158.                 " FROM $TBL_LP_ITEM as i, $TBL_LP_ITEM_VIEW as iv, $TBL_LP_VIEW as v ".
  159.                 " WHERE i.id = iv.lp_item_id ".
  160.                 " AND i.id = $my_item_id ".
  161.                 " AND iv.lp_view_id = v.id ".
  162.                 " AND i.lp_id = $lp_id ".
  163.                 " AND v.user_id = ".$user_id." ".
  164.                 " AND v.view_count = $view ".
  165.                 " ORDER BY iv.view_count $qry_order ";
  166.     else {
  167.         $sql "SELECT iv.status as mystatus, v.view_count as mycount, " .
  168.                 "iv.score as myscore, iv.total_time as mytime, i.id as myid, " .
  169.                 "i.title as mytitle, i.max_score as mymaxscore, " .
  170.                 "iv.max_score as myviewmaxscore, " .
  171.                 "i.item_type as item_type, iv.view_count as iv_view_count, " .
  172.                 "iv.id as iv_id, path as path ".
  173.                 " FROM $TBL_LP_ITEM as i, $TBL_LP_ITEM_VIEW as iv, $TBL_LP_VIEW as v ".    
  174.                 " WHERE i.id = iv.lp_item_id ".
  175.                 " AND i.id = $my_item_id ".
  176.                 " AND iv.lp_view_id = v.id ".
  177.                 " AND i.lp_id = $lp_id ".
  178.                 " AND v.user_id = ".$user_id." ".
  179.                 " ORDER BY iv.view_count $qry_order ";
  180.     }
  181.     $result api_sql_query($sql__FILE____LINE__);
  182.     $num Database :: num_rows($result);
  183.     $time_for_total 'NaN';
  184.     if (($extend_this OR $extend_all&& $num 0
  185.     {
  186.         $row Database :: fetch_array($result);
  187.  
  188.         //if there are several attempts, and the link to extend has been clicked, show each attempt...
  189.         if (($counter 2== 0
  190.         {
  191.             $oddclass "row_odd";
  192.         }
  193.         else 
  194.         {
  195.             $oddclass "row_even";
  196.         }
  197.         if ($inter_num)
  198.         {
  199.             $extend_link '<a href="'.api_get_self().'?action=stats&fold_id='.$my_item_id.$url_suffix.'"><img src="../img/visible.gif" alt="fold_view" border="0"></a>'."\n";
  200.         }
  201.         $title $row['mytitle'];
  202.         $title stripslashes(html_entity_decode($title,ENT_QUOTES$dokeos_charset));
  203.         
  204.         if (empty ($title)) 
  205.         {
  206.             $title rl_get_resource_name(api_get_course_id()$lp_id$row['myid']);
  207.         }
  208.  
  209.         if ($row['item_type'!= 'dokeos_chapter'
  210.         {
  211.             $correct_test_link array();
  212.             if($row['item_type'== 'quiz')
  213.             {
  214.                 
  215.                 if($origin != 'tracking')
  216.                 {
  217.                     $sql_last_attempt='SELECT exe_id FROM '.$tbl_stats_exercices.' WHERE exe_exo_id="'.$row['path'].'" AND exe_user_id="'.api_get_user_id().'" AND exe_cours_id="'.$course_code.'" ORDER BY exe_date DESC limit 1';
  218.                 }
  219.                 else
  220.                 {
  221.                     $sql_last_attempt='SELECT exe_id FROM '.$tbl_stats_exercices.' WHERE exe_exo_id="'.$row['path'].'" AND exe_user_id="'.$_GET['student_id'].'" AND exe_cours_id="'.$course_code.'" ORDER BY exe_date DESC limit 1';
  222.                 }
  223.                 
  224.                 $resultLastAttempt api_sql_query($sql_last_attempt,__FILE__,__LINE__);
  225.                 
  226.                 $num Database::num_rows($resultLastAttempt);
  227.                 if($num>0)
  228.                 {    
  229.                     if($num>1)
  230.                     {
  231.                         while($rowLA Database::fetch_row($resultLastAttempt))
  232.                         {
  233.                             $id_last_attempt $rowLA[0];
  234.                             if($origin != 'tracking')
  235.                             {
  236.                                 $correct_test_link '<a href="../exercice/exercise_show.php?origin=student_progress&id='.$id_last_attempt.'&cidReq='.$course_code.'" target="_parent"><img src="'.api_get_path(WEB_IMG_PATH).'quiz.gif"></a>';
  237.                             }
  238.                             else
  239.                             {
  240.                                 $correct_test_link '<a href="../exercice/exercise_show.php?origin=tracking_course&id='.$id_last_attempt.'&cidReq='.$course_code.'&student='.$_GET['student_id'].'" target="_parent"><img src="'.api_get_path(WEB_IMG_PATH).'quiz.gif"></a>';
  241.                             }                            
  242.                         }
  243.                     }
  244.                     else
  245.                     {                    
  246.                         $id_last_attempt=Database::result($resultLastAttempt,0,0);
  247.                         if($origin != 'tracking')
  248.                         {
  249.                             $correct_test_link '<a href="../exercice/exercise_show.php?origin=student_progress&id='.$id_last_attempt.'&cidReq='.$course_code.'" target="_parent"><img src="'.api_get_path(WEB_IMG_PATH).'quiz.gif"></a>';
  250.                         }
  251.                         else
  252.                         {
  253.                             $correct_test_link '<a href="../exercice/exercise_show.php?origin=tracking_course&id='.$id_last_attempt.'&cidReq='.$course_code.'&student='.$_GET['student_id'].'" target="_parent"><img src="'.api_get_path(WEB_IMG_PATH).'quiz.gif"></a>';
  254.                         }
  255.                     }
  256.                 }
  257.                 
  258.             }
  259.             else{
  260.                 $correct_test_link='-';
  261.             }
  262.             //new attempt
  263.             $output .= "<tr class='$oddclass'>\n"."<td>$extend_link</td>\n".'<td colspan="4" class="content"><div class="mystatus">'.htmlentities($title,ENT_QUOTES,$charset_lang)."</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";
  264.         }
  265.  
  266.         $counter ++;
  267.         do {
  268.             //check if there are interactions below
  269.             $extend_attempt_link '';
  270.             $extend_this_attempt 0;
  271.             if ((learnpath :: get_interactions_count_from_db($row['iv_id']|| learnpath :: get_objectives_count_from_db($row['iv_id']&& !$extend_all{
  272.                 if (!empty ($_GET['extend_attempt_id']&& $_GET['extend_attempt_id'== $row['iv_id']{
  273.                     //the extend button for this attempt has been clicked
  274.                     $extend_this_attempt 1;
  275.                     $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="fold_attempt_view" border="0"></a>'."\n";
  276.                 else //same case if fold_attempt_id is set, so not implemented explicitly
  277.                     //the extend button for this attempt has not been clicked
  278.                     $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="extend_attempt_view" border="0"></a>'."\n";
  279.                 }
  280.             }
  281.  
  282.             if (($counter 2== 0
  283.             {
  284.                 $oddclass "row_odd";
  285.             else {
  286.                 $oddclass "row_even";
  287.             }
  288.             $lesson_status $row['mystatus'];
  289.             $score $row['myscore'];
  290.             $time_for_total $row['mytime'];
  291.             $time learnpathItem :: get_scorm_time('js'$row['mytime']);
  292.             $type;
  293.             $scoIdentifier $row['myid'];
  294.             if ($score == 0{
  295.                 $maxscore 0;
  296.             else {
  297.                 if($row['item_type'== 'sco')
  298.                 {
  299.                     if(!empty($row['myviewmaxscore']and $row['myviewmaxscore']>0)
  300.                     {
  301.                         $maxscore=$row['myviewmaxscore'];
  302.                     }
  303.                     elseif($row['myviewmaxscore'=== '')
  304.                     {
  305.                         $maxscore 0;
  306.                     }
  307.                     else
  308.                     {
  309.                         $maxscore $row['mymaxscore'];
  310.                     }
  311.                 }
  312.                 else
  313.                 {
  314.                     $maxscore $row['mymaxscore'];
  315.                 }
  316.             }
  317.             //Remove "NaN" if any (@todo: locate the source of these NaN)
  318.             $time str_replace('NaN''00'.$h.'00\'00"'$time);
  319.             if (($lesson_status == 'completed'or ($lesson_status == 'passed')) {
  320.                 $color 'green';
  321.             else {
  322.                 $color 'black';
  323.             }
  324.             $mylanglist array ('completed' => 'ScormCompstatus''incomplete' => 'ScormIncomplete''failed' => 'ScormFailed''passed' => 'ScormPassed''browsed' => 'ScormBrowsed''not attempted' => 'ScormNotAttempted',);
  325.             $my_lesson_status htmlentities(get_lang($mylanglist[$lesson_status])ENT_QUOTES$dokeos_charset);
  326.             //$my_lesson_status = get_lang($mylanglist[$lesson_status]);
  327.             if ($row['item_type'!= 'dokeos_chapter'{
  328.                 $output .= "<tr class='$oddclass'>\n"."<td></td>\n"."<td>$extend_attempt_link</td>\n".'<td colspan="3">'.htmlentities(get_lang('Attempt')ENT_QUOTES$dokeos_charset).' '.$row['iv_view_count']."</td>\n"
  329.                 //."<td><font color='$color'><div class='mystatus'>".htmlentities($array_status[$lesson_status],ENT_QUOTES,$charset_lang)."</div></font></td>\n"
  330.                 .'<td colspan="2"><font color="'.$color.'"><div class="mystatus">'.$my_lesson_status."</div></font></td>\n".'<td colspan="2"><div class="mystatus" align="center">'($score == '-' ($maxscore==0?$score:$score.'/'.$maxscore))."</div></td>\n".'<td colspan="2"><div class="mystatus">'.$time."</div></td><td></td>\n"."</tr>\n";
  331.             }
  332.  
  333.             $counter ++;
  334.             if ($extend_this_attempt OR $extend_all{
  335.                 $list1 learnpath :: get_iv_interactions_array($row['iv_id']);
  336.                 foreach ($list1 as $id => $interaction{
  337.                     if (($counter 2== 0{
  338.                         $oddclass "row_odd";
  339.                     else {
  340.                         $oddclass "row_even";
  341.                     }
  342.                     $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"
  343.                     //."<td><font color='$color'><div class='mystatus'>".htmlentities($array_status[$lesson_status],ENT_QUOTES,$charset_lang)."</div></font></td>\n"
  344.                     .'<td colspan="2">'.$interaction['type']."</td>\n"
  345.                     //.'<td>'.$interaction['correct_responses']."</td>\n"
  346.                     .'<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";
  347.                     $counter ++;
  348.                 }
  349.                 $list2 learnpath :: get_iv_objectives_array($row['iv_id']);
  350.                 foreach ($list2 as $id => $interaction{
  351.                     if (($counter 2== 0{
  352.                         $oddclass "row_odd";
  353.                     else {
  354.                         $oddclass "row_even";
  355.                     }
  356.                     $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"
  357.                     .'<td colspan="2">'.$interaction['status']."</td>\n"
  358.                     .'<td>'.$interaction['score_raw']."</td>\n".'<td>'.$interaction['score_max']."</td>\n".'<td>'.$interaction['score_min']."</td>\n<td></td>\n</tr>\n";
  359.                     $counter ++;
  360.                 }
  361.             }
  362.         while ($row Database :: fetch_array($result));
  363.     elseif($num>0{
  364.         $row Database :: fetch_array($result);
  365.  
  366.         //check if there are interactions below
  367.         $extend_attempt_link '';
  368.         $extend_this_attempt 0;
  369.         $inter_num learnpath :: get_interactions_count_from_db($row['iv_id']);
  370.         $objec_num learnpath :: get_objectives_count_from_db($row['iv_id']);
  371.         if (($inter_num || $objec_num 0&& !$extend_all{
  372.             if (!empty ($_GET['extend_attempt_id']&& $_GET['extend_attempt_id'== $row['iv_id']{
  373.                 //the extend button for this attempt has been clicked
  374.                 $extend_this_attempt 1;
  375.                 $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="fold_attempt_view" border="0"></a>'."\n";
  376.             else //same case if fold_attempt_id is set, so not implemented explicitly
  377.                 //the extend button for this attempt has not been clicked
  378.                 $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="extend_attempt_view" border="0"></a>'."\n";
  379.             }
  380.         }
  381.  
  382.         if (($counter 2== 0{
  383.             $oddclass "row_odd";
  384.         else {
  385.             $oddclass "row_even";
  386.         }
  387.         //$extend_link = '<img src="../img/invisible.gif" alt="extend_disabled">';
  388.         $extend_link '';
  389.         if ($inter_num 1{
  390.             $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="extend_view" border="0"></a>';
  391.         }
  392.         if (($counter 2== 0{
  393.             $oddclass "row_odd";
  394.         else {
  395.             $oddclass "row_even";
  396.         }
  397.         $lesson_status $row['mystatus'];
  398.         $score $row['myscore'];
  399.         $subtotal_time $row['mytime'];
  400.         //if($row['mytime']==0){
  401.         while ($tmp_row Database :: fetch_array($result))
  402.         {
  403.             $subtotal_time += $tmp_row['mytime'];
  404.         }
  405.         //}
  406.         $time_for_total $subtotal_time;
  407.         $time learnpathItem :: get_scorm_time('js'$subtotal_time);
  408.         $scoIdentifier $row['myid'];
  409.         $title $row['mytitle'];        
  410.         $title stripslashes(html_entity_decode($title,ENT_QUOTES$dokeos_charset));
  411.         
  412.         if ($score == 0
  413.         {
  414.             $maxscore 0;
  415.         
  416.         else 
  417.         {
  418.                 if($row['item_type'== 'sco')
  419.                 {
  420.                     if(!empty($row['myviewmaxscore']and $row['myviewmaxscore']>0)
  421.                     {
  422.                         $maxscore=$row['myviewmaxscore'];
  423.                     }
  424.                     elseif($row['myviewmaxscore'=== '')
  425.                     {
  426.                         $maxscore 0;
  427.                     }
  428.                     else
  429.                     {
  430.                         $maxscore $row['mymaxscore'];
  431.                     }
  432.                 }
  433.                 else
  434.                 {
  435.                     $maxscore $row['mymaxscore'];
  436.                 }
  437.         }
  438.         if (empty ($title)) 
  439.         {
  440.             $title rl_get_resource_name(api_get_course_id()$lp_id$row['myid']);
  441.         }
  442.         //Remove "NaN" if any (@todo: locate the source of these NaN)
  443.         //$time = str_replace('NaN', '00'.$h.'00\'00"', $time);
  444.                 
  445.         if (($lesson_status == 'completed'or ($lesson_status == 'passed')) {
  446.             $color 'green';
  447.         else {
  448.             $color 'black';
  449.         }
  450.         $mylanglist array ('completed' => 'ScormCompstatus''incomplete' => 'ScormIncomplete''failed' => 'ScormFailed''passed' => 'ScormPassed''browsed' => 'ScormBrowsed''not attempted' => 'ScormNotAttempted',);
  451.         $my_lesson_status htmlentities(get_lang($mylanglist[$lesson_status])ENT_QUOTES$dokeos_charset);
  452.  
  453.         if ($row['item_type'!= 'dokeos_chapter'{
  454.             if($row['item_type'== 'quiz'){
  455.                 $correct_test_link '';
  456.                 
  457.                 if($origin != 'tracking' && $origin != 'tracking_course'){
  458.                     $sql_last_attempt='SELECT exe_id FROM '.$tbl_stats_exercices.' WHERE exe_exo_id="'.$row['path'].'" AND exe_user_id="'.api_get_user_id().'" AND exe_cours_id="'.$course_code.'" ORDER BY exe_date ASC';
  459.                 }
  460.                 else{
  461.                     $sql_last_attempt='SELECT exe_id FROM '.$tbl_stats_exercices.' WHERE exe_exo_id="'.$row['path'].'" AND exe_user_id="'.Database::escape_string($_GET['student_id']).'" AND exe_cours_id="'.Database::escape_string($_GET['course']).'" ORDER BY exe_date';
  462.                 }
  463.                 
  464.                 $resultLastAttempt api_sql_query($sql_last_attempt,__FILE__,__LINE__);
  465.                 $num Database::num_rows($resultLastAttempt);
  466.                 if($num>0)
  467.                 {
  468.                     if($num>1)
  469.                     {
  470.                         $i 1;
  471.                         while($rowLA Database::fetch_array($resultLastAttempt))
  472.                         {
  473.                             $laid $rowLA['exe_id'];
  474.                             if($origin != 'tracking')
  475.                             {
  476.                                 $correct_test_link .= '<a href="../exercice/exercise_show.php?origin=student_progress&id='.$laid.'&cidReq='.$course_code.'" target="_parent" title="'.get_lang('Attempt').' '.$i.'"><img src="'.api_get_path(WEB_IMG_PATH).'quiz.gif"></a> ';
  477.                             }
  478.                             else
  479.                             {
  480.                                 $correct_test_link .= '<a href="../exercice/exercise_show.php?origin=tracking_course&id='.$laid.'&cidReq='.Security::remove_XSS(Database::escape_string($_GET['course'])).'&student='.$_GET['student_id'].'" target="_parent" title="'.get_lang('Attempt').' '.$i.'"><img src="'.api_get_path(WEB_IMG_PATH).'quiz.gif"></a> ';
  481.                             }
  482.                             $i++;
  483.                         }
  484.                         $correct_test_link substr($correct_test_link,0,-1);
  485.                     }
  486.                     else
  487.                     {
  488.                         $id_last_attempt=Database::result($resultLastAttempt,0,0);
  489.                         
  490.                         if($origin != 'tracking'){
  491.                             $correct_test_link '<a href="../exercice/exercise_show.php?origin=student_progress&id='.$id_last_attempt.'&cidReq='.$course_code.'" target="_parent"><img src="'.api_get_path(WEB_IMG_PATH).'quiz.gif"></a>';
  492.                         }
  493.                         else{
  494.                             $correct_test_link '<a href="../exercice/exercise_show.php?origin=tracking_course&id='.$id_last_attempt.'&cidReq='.Security::remove_XSS(Database::escape_string($_GET['course'])).'&student='.$_GET['student_id'].'" target="_parent"><img src="'.api_get_path(WEB_IMG_PATH).'quiz.gif"></a>';
  495.                         }
  496.                     }
  497.                 }
  498.                 else
  499.                 {
  500.                     $correct_test_link='-';
  501.                 }
  502.             }
  503.             else{
  504.                 $correct_test_link='-';
  505.             }
  506.             
  507.             $output .= "<tr class='$oddclass'>\n"."<td>$extend_link</td>\n".'<td colspan="4"><div class="mystatus">'.htmlentities($title,ENT_QUOTES,$charset_lang).'</div></td>'."\n"
  508.             //."<td><font color='$color'><div class='mystatus'>".htmlentities($array_status[$lesson_status],ENT_QUOTES,$charset_lang)."</div></font></td>\n"
  509.             .'<td colspan="2"><font color="'.$color.'"><div class="mystatus">'.$my_lesson_status."</div></font></td>\n".'<td colspan="2"><div class="mystatus" align="center">'($score == '-' ($maxscore==0?$score:$score.'/'.$maxscore))."</div></td>\n".'<td colspan="2"><div class="mystatus">'.$time."</div></td><td>$correct_test_link</td>\n"."</tr>\n";
  510.                         
  511.             if($export_csv)
  512.             {
  513.                 $temp array();
  514.                 $temp[$title;
  515.                 $temp[html_entity_decode($my_lesson_status);
  516.                 $temp[($score == '-' ($maxscore==0?$score:$score.'/'.$maxscore));
  517.                 $temp[$time;
  518.                 $csv_content[$temp;
  519.             }
  520.         }
  521.  
  522.         $counter ++;
  523.  
  524.         if ($extend_this_attempt OR $extend_all{
  525.             $list1 learnpath :: get_iv_interactions_array($row['iv_id']);
  526.             foreach ($list1 as $id => $interaction{
  527.                 if (($counter 2== 0{
  528.                     $oddclass "row_odd";
  529.                 else {
  530.                     $oddclass "row_even";
  531.                 }
  532.                 $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"
  533.                 //."<td><font color='$color'><div class='mystatus'>".htmlentities($array_status[$lesson_status],ENT_QUOTES,$charset_lang)."</div></font></td>\n"
  534.                 .'<td colspan="2">'.$interaction['type']."</td>\n"
  535.                 //.'<td>'.$interaction['correct_responses']."</td>\n"
  536.                 .'<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";
  537.                 $counter ++;
  538.             }
  539.             $list2 learnpath :: get_iv_objectives_array($row['iv_id']);
  540.             foreach ($list2 as $id => $interaction{
  541.                 if (($counter 2== 0{
  542.                     $oddclass "row_odd";
  543.                 else {
  544.                     $oddclass "row_even";
  545.                 }
  546.                 $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"
  547.                 .'<td colspan="2">'.$interaction['status']."</td>\n"
  548.                 .'<td>'.$interaction['score_raw']."</td>\n".'<td>'.$interaction['score_max']."</td>\n".'<td>'.$interaction['score_min']."</td>\n<td></td>\n</tr>\n";
  549.                 $counter ++;
  550.             }
  551.         }
  552.         
  553.     }
  554.     //only sum up the latest attempt each time
  555.     $total_max_score += $maxscore;
  556.     $total_score += $score;
  557.     $total_time += $time_for_total;
  558. }
  559.  
  560. $total_time learnpathItem :: get_scorm_time('js'$total_time);
  561. //$total_time = str_replace('NaN','00:00:00',$total_time);
  562. $total_time str_replace('NaN''00'.$h.'00\'00"'$total_time);
  563. $lp_type learnpath::get_type_static($lp_id);
  564. $total_percent 0;
  565. $final_score '0%';
  566. if($lp_type == 2//if scorm
  567. {
  568.     if($total_max_score == 0)
  569.     {
  570.         $total_percent number_format((float) $total_score1'.''');
  571.         $final_score ($total_score == '-' $total_percent);
  572.     }
  573.     else
  574.     {
  575.         $total_percent number_format((((float) $total_score / (float) $total_max_score100)1'.''');    
  576.         $final_score ($total_score == '-' $total_percent.'%');
  577.     }
  578. }
  579. else
  580. {        
  581.     if ($total_max_score == 0{
  582.         $total_max_score 1;
  583.     }
  584.     $total_percent number_format((((float) $total_score / (float) $total_max_score100)1'.''');
  585.     $final_score ($total_score == '-' $total_percent.'%');
  586. }
  587. if (($counter 2== 0{
  588.     $oddclass "row_odd";
  589. else {
  590.     $oddclass "row_even";
  591. }
  592.  
  593. $output .= "<tr class='$oddclass'>\n"."<td></td>\n".'<td colspan="4"><div class="mystatus"><i>'.htmlentities(get_lang('AccomplishedStepsTotal')ENT_QUOTES$dokeos_charset)."</i></div></td>\n"
  594. //."<td><font color='$color'><div class='mystatus'>".htmlentities($array_status[$lesson_status],ENT_QUOTES,$charset_lang)."</div></font></td>\n"
  595. .'<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";
  596.  
  597. $output .= "</table></td></tr></table>";
  598.  
  599. if($export_csv)
  600. {
  601.     $temp array('','','','');
  602.     $csv_content[$temp;    
  603.     $temp array(get_lang('AccomplishedStepsTotal'),'',$final_score,$total_time);
  604.     $csv_content[$temp
  605.     ob_end_clean();    
  606.     Export :: export_table_csv($csv_content'reporting_learning_path_details');
  607. }
  608.  
  609. if($origin != 'tracking')
  610. {
  611.     $output .= "</body></html>";
  612.  
  613. if(!$export_csv)
  614. {
  615.     echo $output;
  616. }
  617. ?>

Documentation generated on Thu, 12 Jun 2008 14:03:24 -0500 by phpDocumentor 1.4.1