From 901575e3985ae513fc3cfda1a25671ab4bbd6f78 Mon Sep 17 00:00:00 2001 From: Cristian Fasanando Date: Thu, 14 May 2009 00:28:19 +0200 Subject: [PATCH] [svn r20613] Fixed bug problema al exportar un csv desde reporte - see FS#4189 (by rvelasquez) --- main/newscorm/lp_stats.php | 76 ++++++++++++++++++++++++-------------- 1 file changed, 49 insertions(+), 27 deletions(-) diff --git a/main/newscorm/lp_stats.php b/main/newscorm/lp_stats.php index 355fccf3fc..4820b7d302 100644 --- a/main/newscorm/lp_stats.php +++ b/main/newscorm/lp_stats.php @@ -213,13 +213,13 @@ if (is_array($list) && count($list) > 0){ " ORDER BY iv.view_count $qry_order "; } - $result = api_sql_query($sql, __FILE__, __LINE__); $num = Database :: num_rows($result); $time_for_total = 'NaN'; + if (($extend_this || $extend_all) && $num > 0) { $row = Database :: fetch_array($result); - $result_disabled_ext_all = false; + $result_disabled_ext_all = false; if($row['item_type'] == 'quiz') { //check results_disabled in quiz table $my_path = Database::escape_string($row['path']); @@ -245,8 +245,7 @@ if (is_array($list) && count($list) > 0){ $extend_link = ''.get_lang('HideAttemptView').'' . "\n"; } $title = $row['mytitle']; - $title = stripslashes(api_html_entity_decode($title, ENT_QUOTES, $dokeos_charset)); - + if (empty ($title)) { $title = rl_get_resource_name(api_get_course_id(), $lp_id, $row['myid']); } @@ -320,19 +319,41 @@ if (is_array($list) && count($list) > 0){ ); $my_lesson_status = api_htmlentities(get_lang($mylanglist[$lesson_status]), ENT_QUOTES, $dokeos_charset); - + if ($row['item_type'] != 'dokeos_chapter') { if (!api_is_allowed_to_edit() && $result_disabled_ext_all) { - $view_score = '-'; + $view_score = '/'; } else { - $view_score = ($score == 0 ? '-' : ($maxscore === 0 ? $score : $score . '/' . $maxscore)); - } + $view_score = ($score == 0 ? '/' : ($maxscore === 0 ? $score : $score . '/' . float_format($maxscore, 1))); + } $output .= "\n" . "\n" . "$extend_attempt_link\n" . '' . api_htmlentities(get_lang('Attempt'), ENT_QUOTES, $dokeos_charset) . ' ' . $row['iv_view_count'] . "\n" //."
".htmlentities($array_status[$lesson_status],ENT_QUOTES,$lp_charset)."
\n" . '
' . $my_lesson_status . "
\n" . '
' . $view_score . "
\n" . '
'.$time.'
'; + + if (!empty($export_csv)) { + $temp = array (); + $temp[] = api_html_entity_decode($title, ENT_QUOTES, $lp_charset); + $temp[] = api_html_entity_decode($my_lesson_status, ENT_QUOTES, $lp_charset); + + if ($row['item_type'] == 'quiz') { + + if (!api_is_allowed_to_edit() && $result_disabled_ext_all) { + $temp[] = '/'; + } else { + $temp[] = ($score == 0 ? '0/'.$maxscore : ($maxscore == 0 ? $score : $score . '/' . float_format($maxscore, 1))); + } + + } else { + $temp[] = ($score == 0 ? '/' : ($maxscore == 0 ? $score : $score . '/' . float_format($maxscore, 1))); + } + + $temp[] = $time; + $csv_content[] = $temp; + } } - + $counter++; + if ($extend_this_attempt OR $extend_all) { $list1 = learnpath :: get_iv_interactions_array($row['iv_id']); foreach ($list1 as $id => $interaction) { @@ -361,7 +382,7 @@ if (is_array($list) && count($list) > 0){ $counter++; } } - } while ($row = Database :: fetch_array($result)); + } while ($row = Database :: fetch_array($result)); } elseif ($num > 0) { $row = Database :: fetch_array($result); @@ -435,7 +456,7 @@ if (is_array($list) && count($list) > 0){ } else { $sql_last_attempt = 'SELECT * FROM ' . $tbl_stats_exercices . ' WHERE exe_exo_id="' . $row['path'] . '" AND exe_user_id="' . $_GET['student_id'] . '" AND orig_lp_id = "'.$lp_id.'" AND orig_lp_item_id = "'.$row['myid'].'" AND exe_cours_id="' . $course_code . '" AND status <> "incomplete" ORDER BY exe_date DESC limit 1'; } - + $resultLastAttempt = api_sql_query($sql_last_attempt, __FILE__, __LINE__); $num = Database :: num_rows($resultLastAttempt); if ($num > 0) { @@ -499,7 +520,7 @@ if (is_array($list) && count($list) > 0){ } } $time_for_total = $subtotal_time; - $time = learnpathItem :: get_scorm_time('js', $subtotal_time); + $time = learnpathItem :: get_scorm_time('js', $subtotal_time); if (empty ($title)) { $title = rl_get_resource_name(api_get_course_id(), $lp_id, $row['myid']); } @@ -549,7 +570,7 @@ if (is_array($list) && count($list) > 0){ } else { $correct_test_link = '-'; } - + //."
".htmlentities($array_status[$lesson_status],ENT_QUOTES,$lp_charset)."
\n" if ( (isset($_GET['lp_id']) && $_GET['lp_id'] == $my_lp_id ) && (isset($_GET['my_lp_id']) && $_GET['my_lp_id'] == $my_id)) { @@ -567,41 +588,43 @@ if (is_array($list) && count($list) > 0){ if ($row['item_type'] == 'quiz') { if (!api_is_allowed_to_edit() && $result_disabled_ext_all) { - $output .= '-'; + $output .= '/'; } else { - $output .= ($score == 0 ? '0/'.float_format( $maxscore, 1) : ($maxscore == 0 ? $score : float_format( $score, 1) . '/' . float_format($maxscore, 1))); + $output .= ($score == 0 ? '0/'.float_format($maxscore, 1) : ($maxscore == 0 ? $score : float_format($score, 1) . '/' . float_format($maxscore, 1))); } } else { - $output .= ($score == 0 ? '-' : ($maxscore == 0 ? $score : $score . '/' . $maxscore)); + $output .= ($score == 0 ? '/' : ($maxscore == 0 ? $score : $score . '/' . $maxscore)); } $output .= "\n" . '
' . $time . "
$correct_test_link\n"; $output .= "\n"; - } - + } + if (!empty($export_csv)) { $temp = array (); $temp[] = api_html_entity_decode($title, ENT_QUOTES, $lp_charset); $temp[] = api_html_entity_decode($my_lesson_status, ENT_QUOTES, $lp_charset); + if ($row['item_type'] == 'quiz') { if (!api_is_allowed_to_edit() && $result_disabled_ext_all) { - $temp[] = '-'; + $temp[] = '/'; } else { - $temp[] = ($score == 0 ? '0/'.$maxscore : ($maxscore == 0 ? $score : $score . '/' . $maxscore)); + $temp[] = ($score == 0 ? '0/'.$maxscore : ($maxscore == 0 ? $score : $score . '/' . float_format($maxscore, 1))); } } else { - $temp[] = ($score == 0 ? '-' : ($maxscore == 0 ? $score : $score . '/' . $maxscore)); + $temp[] = ($score == 0 ? '/' : ($maxscore == 0 ? $score : $score . '/' . float_format($maxscore, 1))); } $temp[] = $time; $csv_content[] = $temp; } + } - + $counter++; - + if ($extend_this_attempt OR $extend_all) { $list1 = learnpath :: get_iv_interactions_array($row['iv_id']); foreach ($list1 as $id => $interaction) { @@ -630,7 +653,7 @@ if (is_array($list) && count($list) > 0){ $counter++; } } - + // attempts list by exercise if ( (isset($_GET['lp_id']) && $_GET['lp_id'] == $my_lp_id ) && (isset($_GET['my_lp_id']) && $_GET['my_lp_id'] == $my_id)) { @@ -692,15 +715,14 @@ if (is_array($list) && count($list) > 0){ $output .= ' '; } } - } - + $total_time += $time_for_total; //QUIZZ IN LP $a_my_id = array(); if (!empty($my_lp_id)) { $a_my_id[] = $my_lp_id; - } + } } }