From d66bf70b133f0319c435f82fb10a00ab8eac4d8a Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Wed, 17 Oct 2012 20:03:29 +0200 Subject: [PATCH] Minor - Cleaning code --- main/newscorm/lp_stats.php | 447 +++++++++++++++++++++---------------- 1 file changed, 256 insertions(+), 191 deletions(-) diff --git a/main/newscorm/lp_stats.php b/main/newscorm/lp_stats.php index 512e3e1e23..8ffec4a541 100644 --- a/main/newscorm/lp_stats.php +++ b/main/newscorm/lp_stats.php @@ -1,4 +1,5 @@ * @todo clean this file like the exercise files J.M */ - /** * Code */ @@ -22,15 +22,14 @@ if (empty($user_id)) { } // Declare variables to be used in lp_stats.php - //When checking the reporting myspace/lp_tracking.php if (isset($_GET['lp_id']) && isset($lp_id) && !empty($lp_id)) { - $lp_id = intval($lp_id); + $lp_id = intval($lp_id); } else { if (isset($_SESSION['oLP'])) { - $lp_id = $_SESSION['oLP']->get_id(); - $list = learnpath::get_flat_ordered_items_list($lp_id); - } + $lp_id = $_SESSION['oLP']->get_id(); + $list = learnpath::get_flat_ordered_items_list($lp_id); + } } $is_allowed_to_edit = api_is_allowed_to_edit(null, true); @@ -45,7 +44,7 @@ $course_id = $course_info['real_id']; if (isset($_GET['student_id'])) { $student_id = intval($_GET['student_id']); } -$session_id = api_get_session_id(); +$session_id = api_get_session_id(); $session_condition = api_get_session_condition($session_id); //When origin is not set that means that the lp_stats are viewed from the "man running" icon @@ -56,54 +55,48 @@ if (!isset($origin)) { //Origin = tracking means that teachers see that info in the Reporting tool if ($origin != 'tracking') { Display::display_reduced_header(); - echo ''; } $output = ''; -// if display in fullscreen required. -if (!empty($_GET['fs']) && strcmp($_GET['fs'], 'true') == 0) { - $output .= ''; -} else { - $output .= '
'; -} // Check if the user asked for the "extend all" option. $extend_all_link = ''; $extend_all = 0; if ($origin == 'tracking') { - $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; + $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; } else { $url_suffix = '&lp_id=' . $lp_id; } if (!empty($_GET['extend_all'])) { - $extend_all_link = 'fold_view'; + $extend_all_link = 'fold_view'; $extend_all = 1; } else { - $extend_all_link = 'extend_view'; + $extend_all_link = 'extend_view'; } if ($origin != 'tracking') { - $output .= ""; + $output .= Display::page_header(get_lang('ScormMystatus')); } -$output .= '

" . get_lang('ScormMystatus') . "

'. - ''; + +$output .= '
' . $extend_all_link . '' . - '
' . get_lang('ScormLessonTitle') . "
" . - '
' . get_lang('ScormStatus') . "
" . - '
' . get_lang('ScormScore') . "
" . - '
' . get_lang('ScormTime') . "
". - '
'.get_lang('Actions') . '
' . + ''; // Going through the items using the $items[] array instead of the database order ensures // we get them in the same order as in the imsmanifest file, which is rather random when using // the database table. -$TBL_LP_ITEM = Database :: get_course_table(TABLE_LP_ITEM); -$TBL_LP_ITEM_VIEW = Database :: get_course_table(TABLE_LP_ITEM_VIEW); -$TBL_LP_VIEW = Database :: get_course_table(TABLE_LP_VIEW); -$tbl_quiz_questions = Database :: get_course_table(TABLE_QUIZ_QUESTION); -$TBL_QUIZ = Database :: get_course_table(TABLE_QUIZ_TEST); -$tbl_stats_exercices = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES); -$tbl_stats_attempts = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT); +$TBL_LP_ITEM = Database :: get_course_table(TABLE_LP_ITEM); +$TBL_LP_ITEM_VIEW = Database :: get_course_table(TABLE_LP_ITEM_VIEW); +$TBL_LP_VIEW = Database :: get_course_table(TABLE_LP_VIEW); +$tbl_quiz_questions = Database :: get_course_table(TABLE_QUIZ_QUESTION); +$TBL_QUIZ = Database :: get_course_table(TABLE_QUIZ_TEST); +$tbl_stats_exercices = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES); +$tbl_stats_attempts = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT); $sql = "SELECT max(view_count) FROM $TBL_LP_VIEW WHERE c_id = $course_id AND lp_id = $lp_id AND user_id = '" . $user_id . "' $session_condition"; $res = Database::query($sql); @@ -120,7 +113,7 @@ $total_time = 0; $h = get_lang('h'); if (!empty($export_csv)) { - $csv_content[] = array ( + $csv_content[] = array( get_lang('ScormLessonTitle'), get_lang('ScormStatus'), get_lang('ScormScore'), @@ -140,10 +133,24 @@ if (isset($_GET['lp_id']) && isset($_GET['lp_item_id'])) { if (Database::num_rows($res_path) > 0) { if ($origin != 'tracking') { $sql_attempts = 'SELECT * FROM ' . $tbl_stats_exercices . ' - WHERE exe_exo_id="' . (int)$row_path['path'] . '" AND status <> "incomplete" AND exe_user_id="' . 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 session_id = '.$session_id.' ORDER BY exe_date'; + WHERE exe_exo_id="' . (int) $row_path['path'] . '" AND + status <> "incomplete" AND + exe_user_id="' . 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 + session_id = ' . $session_id . ' + ORDER BY exe_date'; } else { $sql_attempts = 'SELECT * FROM ' . $tbl_stats_exercices . ' - WHERE exe_exo_id="' . (int)$row_path['path'] . '" AND status <> "incomplete" 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 session_id = '.$session_id.' ORDER BY exe_date'; + WHERE exe_exo_id="' . (int) $row_path['path'] . '" AND + status <> "incomplete" 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 + session_id = ' . $session_id . ' + ORDER BY exe_date'; } } //var_dump($sql_attempts); @@ -154,15 +161,14 @@ if (is_array($list) && count($list) > 0) { foreach ($list as $my_item_id) { $extend_this = 0; $qry_order = 'DESC'; - if ((!empty ($_GET['extend_id']) && $_GET['extend_id'] == $my_item_id) || $extend_all) { + if ((!empty($_GET['extend_id']) && $_GET['extend_id'] == $my_item_id) || $extend_all) { $extend_this = 1; $qry_order = 'ASC'; } // Prepare statement to go through each attempt. if (!empty($view)) { - $sql = "SELECT - iv.status as mystatus, + $sql = "SELECT iv.status as mystatus, v.view_count as mycount, iv.score as myscore, iv.total_time as mytime, @@ -183,25 +189,25 @@ if (is_array($list) && count($list) > 0) { i.id = $my_item_id AND i.lp_id = $lp_id AND v.user_id = $user_id AND - v.view_count = $view AND v.session_id = $session_id + v.view_count = $view AND + v.session_id = $session_id ORDER BY iv.view_count $qry_order "; //var_dump($sql); } else { - $sql = "SELECT - iv.status as mystatus, - v.view_count as mycount, - iv.score as myscore, - iv.total_time as mytime, - i.id as myid, - i.lp_id as mylpid, - iv.lp_view_id as mylpviewid, - i.title as mytitle, - i.max_score as mymaxscore, - iv.max_score as myviewmaxscore, - i.item_type as item_type, - iv.view_count as iv_view_count, - iv.id as iv_id, - path + $sql = "SELECT iv.status as mystatus, + v.view_count as mycount, + iv.score as myscore, + iv.total_time as mytime, + i.id as myid, + i.lp_id as mylpid, + iv.lp_view_id as mylpviewid, + i.title as mytitle, + i.max_score as mymaxscore, + iv.max_score as myviewmaxscore, + i.item_type as item_type, + iv.view_count as iv_view_count, + iv.id as iv_id, + path FROM $TBL_LP_ITEM as i INNER JOIN $TBL_LP_ITEM_VIEW as iv ON (i.id = iv.lp_item_id AND i.c_id = $course_id AND iv.c_id = $course_id) INNER JOIN $TBL_LP_VIEW as v ON (iv.lp_view_id = v.id AND v.c_id = $course_id) @@ -217,23 +223,22 @@ if (is_array($list) && count($list) > 0) { $time_for_total = 'NaN'; //Extend all + extend scorm? - if (($extend_this || $extend_all) && $num > 0) { + if (($extend_this || $extend_all) && $num > 0) { $row = Database :: fetch_array($result); $result_disabled_ext_all = false; if ($row['item_type'] == 'quiz') { // Check results_disabled in quiz table. $my_path = Database::escape_string($row['path']); - $sql = "SELECT results_disabled FROM $TBL_QUIZ WHERE c_id = $course_id AND id ='".$my_path."'"; + $sql = "SELECT results_disabled FROM $TBL_QUIZ WHERE c_id = $course_id AND id ='" . $my_path . "'"; $res_result_disabled = Database::query($sql); $row_result_disabled = Database::fetch_row($res_result_disabled); - if (Database::num_rows($res_result_disabled) > 0 && (int)$row_result_disabled[0] === 1) { + if (Database::num_rows($res_result_disabled) > 0 && (int) $row_result_disabled[0] === 1) { $result_disabled_ext_all = true; } } - //echo '
'; print_r($row); echo '

'; // If there are several attempts, and the link to extend has been clicked, show each attempt... if (($counter % 2) == 0) { $oddclass = 'row_odd'; @@ -242,7 +247,7 @@ if (is_array($list) && count($list) > 0) { } $extend_link = ''; if (!empty($inter_num)) { - $extend_link = ''.get_lang('HideAttemptView').'' . "\n"; + $extend_link = '' . get_lang('HideAttemptView') . '' . "\n"; } $title = $row['mytitle']; @@ -253,7 +258,15 @@ if (is_array($list) && count($list) > 0) { if ($row['item_type'] != 'dokeos_chapter') { $correct_test_link = '-'; $title = Security::remove_XSS($title); - $output .= "" . "" . '" . ''.''.'' . ""; + $output .= ' + + + + + + '; } $counter++; @@ -263,13 +276,13 @@ if (is_array($list) && count($list) > 0) { $extend_attempt_link = ''; $extend_this_attempt = 0; if ((learnpath :: get_interactions_count_from_db($row['iv_id'], $course_id) > 0 || learnpath :: get_objectives_count_from_db($row['iv_id'], $course_id) > 0) && !$extend_all) { - if (!empty ($_GET['extend_attempt_id']) && $_GET['extend_attempt_id'] == $row['iv_id']) { + if (!empty($_GET['extend_attempt_id']) && $_GET['extend_attempt_id'] == $row['iv_id']) { // The extend button for this attempt has been clicked. $extend_this_attempt = 1; - $extend_attempt_link = ''.get_lang('HideAttemptView').'' . "\n"; + $extend_attempt_link = '' . get_lang('HideAttemptView') . ''; } else { // Same case if fold_attempt_id is set, so not implemented explicitly. // The extend button for this attempt has not been clicked. - $extend_attempt_link = ''.get_lang('ExtendAttemptView').'' . "\n"; + $extend_attempt_link = '' . get_lang('ExtendAttemptView') . ''; } } @@ -290,7 +303,7 @@ if (is_array($list) && count($list) > 0) { $maxscore = $row['mymaxscore']; } else { if ($row['item_type'] == 'sco') { - if (!empty ($row['myviewmaxscore']) && $row['myviewmaxscore'] > 0) { + if (!empty($row['myviewmaxscore']) && $row['myviewmaxscore'] > 0) { $maxscore = $row['myviewmaxscore']; } elseif ($row['myviewmaxscore'] === '') { $maxscore = 0; @@ -309,24 +322,24 @@ if (is_array($list) && count($list) > 0) { } else { $class_status = 'default'; } - $mylanglist = array ( - 'completed' => 'ScormCompstatus', - 'incomplete' => 'ScormIncomplete', - 'failed' => 'ScormFailed', - 'passed' => 'ScormPassed', - 'browsed' => 'ScormBrowsed', + $mylanglist = array( + 'completed' => 'ScormCompstatus', + 'incomplete' => 'ScormIncomplete', + 'failed' => 'ScormFailed', + 'passed' => 'ScormPassed', + 'browsed' => 'ScormBrowsed', 'not attempted' => 'ScormNotAttempted' ); $my_lesson_status = get_lang($mylanglist[$lesson_status]); - if ($row['item_type'] != 'dokeos_chapter') { + if ($row['item_type'] != 'dokeos_chapter') { if (!$is_allowed_to_edit && $result_disabled_ext_all) { $view_score = Display::return_icon('invisible.gif', get_lang('ResultsHiddenByExerciseSetting')); - } else { + } else { switch ($row['item_type']) { case 'sco': - if ($maxscore == 0 ) { + if ($maxscore == 0) { $view_score = $score; } else { $view_score = show_score($score, $maxscore, false); @@ -338,30 +351,29 @@ if (is_array($list) && count($list) > 0) { default: $view_score = show_score($score, $maxscore, false); break; - } + } } - $output .= ' + $output .= ' - - - - - + + + + + '; if (!empty($export_csv)) { - $temp = array (); + $temp = array(); $temp[] = $title = Security::remove_XSS($title); $temp[] = Security::remove_XSS($my_lesson_status); if ($row['item_type'] == 'quiz') { if (!$is_allowed_to_edit && $result_disabled_ext_all) { - $temp[] = '/'; + $temp[] = '/'; } else { - $temp[] = ($score == 0 ? '0/'.$maxscore : ($maxscore == 0 ? $score : $score . '/' . float_format($maxscore, 1))); + $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))); } @@ -382,17 +394,17 @@ if (is_array($list) && count($list) > 0) { } $student_response = urldecode($interaction['student_response']); // Code added by Isaac Flores. $content_student_response = array(); - $content_student_response = explode('__|',$student_response); + $content_student_response = explode('__|', $student_response); - if (count($content_student_response)>0) { + if (count($content_student_response) > 0) { if (count($content_student_response) >= 3) { $new_content_student_response = array_pop($content_student_response); // Pop the element off the end of array. } - $student_response = implode(',',$content_student_response); + $student_response = implode(',', $content_student_response); } - $output .= "" . '' . '' .'' . '' .'' - . '" - . '" . '" . '" . '"; + $output .= "" . '' . '' . '' . '' . '' + . '" + . '" . '" . '" . '"; $counter++; } $list2 = learnpath :: get_iv_objectives_array($row['iv_id']); @@ -402,22 +414,21 @@ if (is_array($list) && count($list) > 0) { } else { $oddclass = 'row_even'; } - $output .= "" . '' . ''.'' .''. ''. - '\n" . - '" . '" . '"; + $output .= "" . '' . '' . '' . '' . '' . + '\n" . + '" . '" . '"; $counter++; } } } while ($row = Database :: fetch_array($result)); - } elseif ($num > 0) { //Not extended - $row = Database :: fetch_array($result,'ASSOC'); - $my_id = $row['myid']; - $my_lp_id = $row['mylpid']; - $my_lp_view_id = $row['mylpviewid']; - $my_path = $row['path']; + $row = Database :: fetch_array($result, 'ASSOC'); + $my_id = $row['myid']; + $my_lp_id = $row['mylpid']; + $my_lp_view_id = $row['mylpviewid']; + $my_path = $row['path']; $result_disabled_ext_all = false; @@ -425,11 +436,11 @@ if (is_array($list) && count($list) > 0) { // Check results_disabled in quiz table. $my_path = Database::escape_string($my_path); - $sql = "SELECT results_disabled FROM $TBL_QUIZ WHERE c_id = $course_id AND id ='".(int)$my_path."'"; + $sql = "SELECT results_disabled FROM $TBL_QUIZ WHERE c_id = $course_id AND id ='" . (int) $my_path . "'"; $res_result_disabled = Database::query($sql); $row_result_disabled = Database::fetch_row($res_result_disabled); - if (Database::num_rows($res_result_disabled) > 0 && (int)$row_result_disabled[0] === 1) { + if (Database::num_rows($res_result_disabled) > 0 && (int) $row_result_disabled[0] === 1) { $result_disabled_ext_all = true; } } @@ -442,13 +453,13 @@ if (is_array($list) && count($list) > 0) { $extend_attempt_link = ''; if (($inter_num > 0 || $objec_num > 0)) { - if (!empty ($_GET['extend_attempt_id']) && $_GET['extend_attempt_id'] == $row['iv_id']) { + if (!empty($_GET['extend_attempt_id']) && $_GET['extend_attempt_id'] == $row['iv_id']) { // The extend button for this attempt has been clicked. $extend_this_attempt = 1; - $extend_attempt_link = ''.get_lang('HideAttemptView').'' . "\n"; + $extend_attempt_link = '' . get_lang('HideAttemptView') . '' . "\n"; } else { // Same case if fold_attempt_id is set, so not implemented explicitly. // The extend button for this attempt has not been clicked. - $extend_attempt_link = ''.get_lang('ExtendAttemptView').'' . "\n"; + $extend_attempt_link = '' . get_lang('ExtendAttemptView') . '' . "\n"; } } @@ -460,12 +471,12 @@ if (is_array($list) && count($list) > 0) { $extend_link = ''; if ($inter_num > 1) { - $extend_link = ''.get_lang('ExtendAttemptView').''; + $extend_link = '' . get_lang('ExtendAttemptView') . ''; } - $lesson_status = $row['mystatus']; - $score = $row['myscore']; - $subtotal_time = $row['mytime']; + $lesson_status = $row['mystatus']; + $score = $row['myscore']; + $subtotal_time = $row['mytime']; //if ($row['mytime'] == 0) { while ($tmp_row = Database :: fetch_array($result)) { @@ -475,13 +486,29 @@ if (is_array($list) && count($list) > 0) { //$time_for_total = $subtotal_time; //$time = learnpathItem :: get_scorm_time('js', $subtotal_time); $scoIdentifier = $row['myid']; - $title = $row['mytitle']; + $title = $row['mytitle']; // Selecting the exe_id from stats attempts tables in order to look the max score value. if ($origin != 'tracking') { - $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'; + $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'; } else { - $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'; + $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'; } $resultLastAttempt = Database::query($sql_last_attempt); @@ -497,10 +524,9 @@ if (is_array($list) && count($list) > 0) { $maxscore = $row['mymaxscore']; } else { if ($row['item_type'] == 'sco') { - if (!empty ($row['myviewmaxscore']) and $row['myviewmaxscore'] > 0) { + if (!empty($row['myviewmaxscore']) and $row['myviewmaxscore'] > 0) { $maxscore = $row['myviewmaxscore']; - } - elseif ($row['myviewmaxscore'] === '') { + } elseif ($row['myviewmaxscore'] === '') { $maxscore = 0; } else { $maxscore = $row['mymaxscore']; @@ -509,30 +535,33 @@ if (is_array($list) && count($list) > 0) { if ($row['item_type'] == 'quiz') { // Get score and total time from last attempt of a exercise en lp. $sql = "SELECT score FROM $TBL_LP_ITEM_VIEW - WHERE c_id = $course_id AND lp_item_id = '".(int)$my_id."' and lp_view_id = '".(int)$my_lp_view_id."' + WHERE c_id = $course_id AND lp_item_id = '" . (int) $my_id . "' AND lp_view_id = '" . (int) $my_lp_view_id . "' ORDER BY view_count DESC limit 1"; $res_score = Database::query($sql); $row_score = Database::fetch_array($res_score); $sql = "SELECT SUM(total_time) as total_time FROM $TBL_LP_ITEM_VIEW - WHERE c_id = $course_id AND lp_item_id = '".(int)$my_id."' and lp_view_id = '".(int)$my_lp_view_id."'"; + WHERE c_id = $course_id AND lp_item_id = '" . (int) $my_id . "' AND lp_view_id = '" . (int) $my_lp_view_id . "'"; $res_time = Database::query($sql); $row_time = Database::fetch_array($res_time); if (Database::num_rows($res_score) > 0 && Database::num_rows($res_time) > 0) { - $score = (float)$row_score['score']; - $subtotal_time = (int)$row_time['total_time']; + $score = (float) $row_score['score']; + $subtotal_time = (int) $row_time['total_time']; } else { $score = 0; - $subtotal_time = 0; + $subtotal_time = 0; } //echo $subtotal_time ; //$time = learnpathItem :: get_scorm_time('js', $subtotal_time); // Selecting the max score from an attempt. - $sql = "SELECT SUM(t.ponderation) as maxscore FROM ( - SELECT distinct question_id, marks, ponderation FROM $tbl_stats_attempts as at INNER JOIN $tbl_quiz_questions as q - ON (q.id = at.question_id AND q.c_id = $course_id ) - WHERE exe_id ='$id_last_attempt' ) as t"; + $sql = "SELECT SUM(t.ponderation) as maxscore + FROM ( + SELECT distinct question_id, marks, ponderation + FROM $tbl_stats_attempts as at INNER JOIN $tbl_quiz_questions as q + ON (q.id = at.question_id AND q.c_id = $course_id + ) + WHERE exe_id ='$id_last_attempt' ) as t"; $result = Database::query($sql); $row_max_score = Database :: fetch_array($result); @@ -545,7 +574,7 @@ if (is_array($list) && count($list) > 0) { $time_for_total = $subtotal_time; $time = learnpathItem :: get_scorm_time('js', $subtotal_time); - if (empty ($title)) { + if (empty($title)) { $title = rl_get_resource_name(api_get_course_id(), $lp_id, $row['myid']); } // Remove "NaN" if any (@todo: locate the source of these NaN) @@ -557,12 +586,12 @@ if (is_array($list) && count($list) > 0) { $class_status = 'default'; } - $mylanglist = array ( - 'completed' => 'ScormCompstatus', - 'incomplete' => 'ScormIncomplete', - 'failed' => 'ScormFailed', - 'passed' => 'ScormPassed', - 'browsed' => 'ScormBrowsed', + $mylanglist = array( + 'completed' => 'ScormCompstatus', + 'incomplete' => 'ScormIncomplete', + 'failed' => 'ScormFailed', + 'passed' => 'ScormPassed', + 'browsed' => 'ScormBrowsed', 'not attempted' => 'ScormNotAttempted' ); @@ -571,24 +600,24 @@ if (is_array($list) && count($list) > 0) { if ($row['item_type'] != 'dokeos_chapter') { if ($row['item_type'] == 'quiz') { $correct_test_link = ''; - $my_url_suffix =''; + $my_url_suffix = ''; if ($origin != 'tracking' && $origin != 'tracking_course') { $my_url_suffix = '&course=' . api_get_course_id() . '&student_id=' . api_get_user_id() . '&lp_id=' . Security::remove_XSS($row['mylpid']); - $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 '; + $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 '; } else { - $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); - $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 '; + $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); + $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 '; } $resultLastAttempt = Database::query($sql_last_attempt); $num = Database :: num_rows($resultLastAttempt); if ($num > 0) { - if (isset($_GET['extend_attempt']) && $_GET['extend_attempt'] == 1 && (isset($_GET['lp_id']) && $_GET['lp_id'] == $my_lp_id) && (isset($_GET['lp_item_id']) && $_GET['lp_item_id'] == $my_id) ) { - $correct_test_link = 'fold_view'; + if (isset($_GET['extend_attempt']) && $_GET['extend_attempt'] == 1 && (isset($_GET['lp_id']) && $_GET['lp_id'] == $my_lp_id) && (isset($_GET['lp_item_id']) && $_GET['lp_item_id'] == $my_id)) { + $correct_test_link = 'fold_view'; $extend_attempt = 1; } else { - $correct_test_link = 'extend_view'; + $correct_test_link = 'extend_view'; } } else { $correct_test_link = '-'; @@ -599,42 +628,42 @@ if (is_array($list) && count($list) > 0) { $title = Security::remove_XSS($title); - if ( (isset($_GET['lp_id']) && $_GET['lp_id'] == $my_lp_id && false) ) { - $output .= ''; - $output .= ''; + if ((isset($_GET['lp_id']) && $_GET['lp_id'] == $my_lp_id && false)) { + $output .= ''; + $output .= ''; $output .= ""; } else { - if ( (isset($_GET['lp_id']) && $_GET['lp_id'] == $my_lp_id ) && (isset($_GET['lp_item_id']) && $_GET['lp_item_id'] == $my_id)) { + if ((isset($_GET['lp_id']) && $_GET['lp_id'] == $my_lp_id ) && (isset($_GET['lp_item_id']) && $_GET['lp_item_id'] == $my_id)) { $output .= ""; } else { $output .= ""; } - $output .= ''; - $output .= '" . ''; + $output .= '" . '" . '"; - $output .= ""; + } + $output .= ''; + $output .= ""; } if (!empty($export_csv)) { - $temp = array (); + $temp = array(); $temp[] = api_html_entity_decode($title, ENT_QUOTES); $temp[] = api_html_entity_decode($my_lesson_status, ENT_QUOTES); if ($row['item_type'] == 'quiz') { if (!$is_allowed_to_edit && $result_disabled_ext_all) { - $temp[] = '/'; + $temp[] = '/'; } else { - $temp[] = ($score == 0 ? '0/'.$maxscore : ($maxscore == 0 ? $score : $score . '/' . float_format($maxscore, 1))); + $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))); @@ -655,9 +684,19 @@ if (is_array($list) && count($list) > 0) { } else { $oddclass = 'row_even'; } - $output .= "\n" . '' . "\n" . '' . "\n" . '' . "\n" . '' . "\n" . '' . "\n" - . '\n" - . '\n" . '\n" . '\n" . '\n\n\n"; + $output .= ' + + + + + + + + + + + + '; $counter++; } $list2 = learnpath :: get_iv_objectives_array($row['iv_id']); @@ -667,9 +706,18 @@ if (is_array($list) && count($list) > 0) { } else { $oddclass = 'row_even'; } - $output .= "" . '' . '' . '' . ''.''. - '" . - '" . '" . '\n\n"; + $output .= ' + + + + + + + + + + + '; $counter++; } } @@ -683,28 +731,28 @@ if (is_array($list) && count($list) > 0) { if ($num_attempts > 0) { $n = 1; while ($row_attempts = Database :: fetch_array($res_attempts)) { - $my_score = $row_attempts['exe_result']; - $my_maxscore = $row_attempts['exe_weighting']; - $my_exe_id = $row_attempts['exe_id']; - $my_orig_lp = $row_attempts['orig_lp_id']; - $my_orig_lp_item = $row_attempts['orig_lp_item_id']; - $my_exo_exe_id = $row_attempts['exe_exo_id']; - $mktime_start_date = api_strtotime($row_attempts['start_date'],'UTC'); - $mktime_exe_date = api_strtotime($row_attempts['exe_date'],'UTC'); + $my_score = $row_attempts['exe_result']; + $my_maxscore = $row_attempts['exe_weighting']; + $my_exe_id = $row_attempts['exe_id']; + $my_orig_lp = $row_attempts['orig_lp_id']; + $my_orig_lp_item = $row_attempts['orig_lp_item_id']; + $my_exo_exe_id = $row_attempts['exe_exo_id']; + $mktime_start_date = api_strtotime($row_attempts['start_date'], 'UTC'); + $mktime_exe_date = api_strtotime($row_attempts['exe_date'], 'UTC'); if ($mktime_start_date && $mktime_exe_date) { - $mytime = ((int)$mktime_exe_date-(int)$mktime_start_date); + $mytime = ((int) $mktime_exe_date - (int) $mktime_start_date); $time_attemp = learnpathItem :: get_scorm_time('js', $mytime); $time_attemp = str_replace('NaN', '00' . $h . '00\'00"', $time_attemp); } else { - $time_attemp = ' - '; + $time_attemp = ' - '; } if (!$is_allowed_to_edit && $result_disabled_ext_all) { - $view_score = Display::return_icon('invisible.gif', get_lang('ResultsHiddenByExerciseSetting')); + $view_score = Display::return_icon('invisible.gif', get_lang('ResultsHiddenByExerciseSetting')); } else { // Show only float when need it. //$my_score = float_format( $my_score, 1); //$my_maxscore =float_format($my_maxscore, 1); - if ($my_score == 0 ) { + if ($my_score == 0) { //$view_score = '0/'.$my_maxscore; $view_score = show_score(0, $my_maxscore, false); } else { @@ -725,22 +773,30 @@ if (is_array($list) && count($list) > 0) { $my_lesson_status = get_lang($mylanglist['incomplete']); } - $output .= '' - . ''; - if ($origin != 'tracking') { - if (!$is_allowed_to_edit && $result_disabled_ext_all) { - $output .= ''; + $output .= ' + + + + + + '; + if ($origin != 'tracking') { + if (!$is_allowed_to_edit && $result_disabled_ext_all) { + $output .= ''; } else { - $output .= ''; + $output .= ''; } } else { - if (!$is_allowed_to_edit && $result_disabled_ext_all ) { - $output .= ''; + if (!$is_allowed_to_edit && $result_disabled_ext_all) { + $output .= ''; } else { - $output .= ''; + $output .= ''; } } $output .= ''; @@ -772,7 +828,7 @@ if (!empty($a_my_id)) { $my_course_id = Database::escape_string(api_get_course_id()); } //var_dump($my_studen_id, $my_course_id,$a_my_id); - if (isset($_GET['extend_attempt'])) { + if (isset($_GET['extend_attempt'])) { //"Right green cross" extended $total_score = Tracking::get_avg_student_score($my_studen_id, $my_course_id, $a_my_id, api_get_session_id(), false, false); } else { @@ -783,7 +839,7 @@ if (!empty($a_my_id)) { // Extend all "left green cross" if ($origin == 'tracking') { $my_course_id = Database::escape_string($_GET['course']); - // var_dump($student_id, $my_course_id ); + // var_dump($student_id, $my_course_id ); if (!empty($student_id) && !empty($my_course_id)) { $total_score = Tracking::get_avg_student_score($student_id, $my_course_id, array(intval($_GET['lp_id'])), api_get_session_id(), false, false); } else { @@ -804,7 +860,7 @@ if (!$is_allowed_to_edit && $result_disabled_ext_all) { $final_score = Display::return_icon('invisible.gif', get_lang('ResultsHiddenByExerciseSetting')); } else { if (is_numeric($total_score)) - $final_score = $total_score.'%'; + $final_score = $total_score . '%'; else $final_score = $total_score; } @@ -816,21 +872,30 @@ if (($counter % 2) == 0) { } //if (empty($extend_all)) { - $output .= "\n" . "\n" . '\n" - . '' . "\n" . '\n" . '' . "\n" . "\n"; +$output .= ' + + + + + + '; //} -$output .= "
' . $extend_all_link . '' . + '
' . get_lang('ScormLessonTitle') . "
" . + '
' . get_lang('ScormStatus') . "
" . + '
' . get_lang('ScormScore') . "
" . + '
' . get_lang('ScormTime') . "
" . + '
' . get_lang('Actions') . '
$extend_link
' . $title . "
'.$extend_link.' +
'.$title.'
+
'.$extend_attempt_link.''.get_lang('Attempt').' '.$row['iv_view_count'].''.Display::label($my_lesson_status, $class_status).'
'.$view_score.'
'.$time.'
' . $extend_attempt_link . '' . get_lang('Attempt') . ' ' . $row['iv_view_count'] . '' . Display::label($my_lesson_status, $class_status) . '
' . $view_score . '
' . $time . '
 ' . $interaction['order_id'] . '' . $interaction['id'] . '' . $interaction['type'] . "' . $student_response . "' . $interaction['result'] . "' . $interaction['latency'] . "' . $interaction['time'] . "
 ' . $interaction['order_id'] . '' . $interaction['id'] . '' . $interaction['type'] . "' . $student_response . "' . $interaction['result'] . "' . $interaction['latency'] . "' . $interaction['time'] . "
 ' . $interaction['order_id'] . '' . $interaction['objective_id'] . '' . $interaction['status'] . "' . $interaction['score_raw'] . "' . $interaction['score_max'] . "' . $interaction['score_min'] . "
 ' . $interaction['order_id'] . '' . $interaction['objective_id'] . '' . $interaction['status'] . "' . $interaction['score_raw'] . "' . $interaction['score_max'] . "' . $interaction['score_min'] . "
'.$extend_link.'
'.$title.'
   '.$correct_test_link.'
' . $extend_link . '
' . $title . '
   ' . $correct_test_link . '
'.$extend_link.'
'.$title.'
' . Display::label($my_lesson_status, $class_status). "
'; + $output .= '
' . $extend_link . '
' . $title . '
' . Display::label($my_lesson_status, $class_status) . "
'; if ($row['item_type'] == 'quiz') { - if (!$is_allowed_to_edit && $result_disabled_ext_all) { + if (!$is_allowed_to_edit && $result_disabled_ext_all) { $output .= Display::return_icon('invisible.gif', get_lang('ResultsHiddenByExerciseSetting')); } else { - // $output .= ($score == 0 ? '0/'.float_format($maxscore, 1) : ($maxscore == 0 ? $score : float_format($score, 1) . '/' . float_format($maxscore, 1))); - $output .= show_score($score, $maxscore, false); + // $output .= ($score == 0 ? '0/'.float_format($maxscore, 1) : ($maxscore == 0 ? $score : float_format($score, 1) . '/' . float_format($maxscore, 1))); + $output .= show_score($score, $maxscore, false); } - } else { + } else { $output .= ($score == 0 ? '/' : ($maxscore == 0 ? $score : $score . '/' . $maxscore)); - } - $output .= "
' . $time . "
$correct_test_link
' . $time .'
'.$correct_test_link.'
 ' . $interaction['order_id'] . '' . $interaction['id'] . '' . $interaction['type'] . "' . urldecode($interaction['student_response']) . "' . $interaction['result'] . "' . $interaction['latency'] . "' . $interaction['time'] . "
'.$interaction['order_id'].''.$interaction['id'].'' . $interaction['type'].''.urldecode($interaction['student_response']).''.$interaction['result'].''.$interaction['latency'].''.$interaction['time'].'
 ' . $interaction['order_id'] . '' . $interaction['objective_id'] . '' . $interaction['status'] . "' . $interaction['score_raw'] . "' . $interaction['score_max'] . "' . $interaction['score_min'] . "
' . $interaction['order_id'] . ''.$interaction['objective_id'] . '' . $interaction['status'] . '' . $interaction['score_raw'].'' . $interaction['score_max'] .'' . $interaction['score_min'].'
 '.$extend_attempt_link.'' . get_lang('Attempt') . ' ' . $n . '' . Display::label($my_lesson_status, $class_status).' -
' . $view_score . '
' . $time_attemp . '
'.get_lang('ShowAttempt').'
' . $extend_attempt_link . '' . get_lang('Attempt') . ' ' . $n . '' . Display::label($my_lesson_status, $class_status) . ' +
' . $view_score . '
+
+
' . $time_attemp . '
+
' . get_lang('ShowAttempt') . ' - '.get_lang('ShowAttempt').' + ' . get_lang('ShowAttempt') . ''.get_lang('ShowAndQualifyAttempt').'' . get_lang('ShowAndQualifyAttempt') . ' - '.get_lang('ShowAndQualifyAttempt').' + ' . get_lang('ShowAndQualifyAttempt') . '
' . get_lang('AccomplishedStepsTotal') . "
' . $final_score . "
' . $total_time . '
+
' . get_lang('AccomplishedStepsTotal') .'
+
+
' . $final_score.'
+
' . $total_time . '
"; +$output .= ""; if (!empty($export_csv)) { - $temp = array ( + $temp = array( '', '', '', '' ); $csv_content[] = $temp; - $temp = array ( + $temp = array( get_lang('AccomplishedStepsTotal'), '', $final_score,