"."\n".''.$extend_all_link.' | '.''.htmlentities(get_lang('ScormLessonTitle'), ENT_QUOTES, $dokeos_charset)." | \n".''.htmlentities(get_lang('ScormStatus'), ENT_QUOTES, $dokeos_charset)." | \n".''.htmlentities(get_lang('ScormScore'), ENT_QUOTES, $dokeos_charset)." | \n".''.htmlentities(get_lang('ScormTime'), ENT_QUOTES, $dokeos_charset)." | ".get_lang('Actions')." | \n";
//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('lp_item');
$TBL_LP_ITEM_VIEW = Database :: get_course_table('lp_item_view');
$TBL_LP_VIEW = Database :: get_course_table('lp_view');
$tbl_stats_exercices = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
$sql = "SELECT max(view_count) FROM $TBL_LP_VIEW WHERE lp_id = $lp_id AND user_id = '".$user_id."'";
$res = api_sql_query($sql, __FILE__, __LINE__);
$view = '';
if (Database :: num_rows($res) > 0) {
$myrow = Database :: fetch_array($res);
$view = $myrow[0];
}
$counter = 0;
//error_log('New LP - Querying views for latest attempt: '.$sql,0);
$total_score = 0;
$total_max_score = 0;
$total_time = 0;
$h = get_lang('h');
if($export_csv)
{
$csv_content[] = array (
get_lang('ScormLessonTitle'),
get_lang('ScormStatus'),
get_lang('ScormScore'),
get_lang('ScormTime')
);
}
foreach ($list as $my_item_id) {
$extend_this = 0;
$qry_order = 'DESC';
if ((!empty ($_GET['extend_id']) and $_GET['extend_id'] == $my_item_id) OR $extend_all) {
$extend_this = 1;
$qry_order = 'ASC';
}
if (!empty ($view)) {
$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.title as mytitle, i.max_score as mymaxscore, i.item_type as item_type, iv.view_count as iv_view_count, iv.id as iv_id, path as path "." FROM $TBL_LP_ITEM as i, $TBL_LP_ITEM_VIEW as iv, $TBL_LP_VIEW as v "." WHERE i.id = iv.lp_item_id "." AND i.id = $my_item_id "." AND iv.lp_view_id = v.id "." AND i.lp_id = $lp_id "." AND v.user_id = ".$user_id.""." AND v.view_count = $view "." ORDER BY iv.view_count $qry_order ";
} 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.title as mytitle, i.max_score as mymaxscore, i.item_type as item_type, iv.view_count as iv_view_count, iv.id as iv_id, path as path "." FROM $TBL_LP_ITEM as i, $TBL_LP_ITEM_VIEW as iv, $TBL_LP_VIEW as v "." WHERE i.id = iv.lp_item_id "." AND i.id = $my_item_id "." AND iv.lp_view_id = v.id "." AND i.lp_id = $lp_id "." AND v.user_id = ".$user_id." "." 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 OR $extend_all) && $num > 0) {
$row = Database :: fetch_array($result);
//if there are several attempts, and the link to extend has been clicked...
if (($counter % 2) == 0) {
$oddclass = "row_odd";
} else {
$oddclass = "row_even";
}
if ($inter_num)
$extend_link = ' '."\n";
$title = $row['mytitle'];
$title = stripslashes($title);
if (empty ($title)) {
$title = rl_get_resource_name(api_get_course_id(), $lp_id, $row['myid']);
}
if ($row['item_type'] != 'dokeos_chapter') {
if($row['item_type'] == 'quiz'){
if($origin != 'tracking'){
$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="'.$_SESSION['_course']['id'].'" ORDER BY exe_date DESC LIMIT 1';
}
else{
$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="'.$_SESSION['_course']['id'].'" ORDER BY exe_date DESC LIMIT 1';
}
$resultLastAttempt = api_sql_query($sql_last_attempt);
$id_last_attempt=mysql_result($resultLastAttempt,0,0);
if($origin != 'tracking'){
$correct_test_link = ' ';
}
else{
$correct_test_link = ' ';
}
}
else{
$correct_test_link='-';
}
$output .= "\n"."$extend_link | \n".''.$title." | \n".' | '."\n".' | '."\n".' | '.$correct_test_link.' | '."\n"." \n";
}
$counter ++;
do {
//check if there are interactions below
$extend_attempt_link = '';
$extend_this_attempt = 0;
if (learnpath :: get_interactions_count_from_db($row['iv_id']) > 0 && !$extend_all) {
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 = ' '."\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 = ' '."\n";
}
}
if (($counter % 2) == 0) {
$oddclass = "row_odd";
} else {
$oddclass = "row_even";
}
$lesson_status = $row['mystatus'];
$score = $row['myscore'];
$time_for_total = $row['mytime'];
$time = learnpathItem :: get_scorm_time('js', $row['mytime']);
$type;
$scoIdentifier = $row['myid'];
if ($score == 0) {
$maxscore = 0;
} else {
$maxscore = $row['mymaxscore'];
}
//Remove "NaN" if any (@todo: locate the source of these NaN)
$time = str_replace('NaN', '00'.$h.'00\'00"', $time);
if (($lesson_status == 'completed') or ($lesson_status == 'passed')) {
$color = 'green';
} else {
$color = 'black';
}
$mylanglist = array ('completed' => 'ScormCompstatus', 'incomplete' => 'ScormIncomplete', 'failed' => 'ScormFailed', 'passed' => 'ScormPassed', 'browsed' => 'ScormBrowsed', 'not attempted' => 'ScormNotAttempted',);
$my_lesson_status = htmlentities(get_lang($mylanglist[$lesson_status]), ENT_QUOTES, $dokeos_charset);
//$my_lesson_status = get_lang($mylanglist[$lesson_status]);
if ($row['item_type'] != 'dokeos_chapter') {
$output .= "\n"." | \n"."$extend_attempt_link | \n".''.htmlentities(get_lang('Attempt'), ENT_QUOTES, $dokeos_charset).' '.$row['iv_view_count']." | \n"
//."".htmlentities($array_status[$lesson_status],ENT_QUOTES,$charset_lang)." | \n"
.''.$my_lesson_status." | \n".''. ($score == 0 ? '-' : $score.'/'.$maxscore)." | \n".''.$time." | | \n"." \n";
}
$counter ++;
if ($extend_this_attempt OR $extend_all) {
$list = learnpath :: get_iv_interactions_array($row['iv_id']);
foreach ($list as $id => $interaction) {
if (($counter % 2) == 0) {
$oddclass = "row_odd";
} else {
$oddclass = "row_even";
}
$output .= "\n".' | '."\n".' | '."\n".' | '."\n".''.$interaction['order_id'].' | '."\n".''.$interaction['id'].' | '."\n"
//."".htmlentities($array_status[$lesson_status],ENT_QUOTES,$charset_lang)." | \n"
.''.$interaction['type']." | \n"
//.''.$interaction['correct_responses']." | \n"
.''.urldecode($interaction['student_response'])." | \n".''.$interaction['result']." | \n".''.$interaction['latency']." | \n".''.$interaction['time']." | \n"." \n";
$counter ++;
}
}
} while ($row = Database :: fetch_array($result));
} elseif($num>0) {
$row = Database :: fetch_array($result);
//check if there are interactions below
$extend_attempt_link = '';
$extend_this_attempt = 0;
$inter_num = learnpath :: get_interactions_count_from_db($row['iv_id']);
if ($inter_num > 0 && !$extend_all) {
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 = ' '."\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 = ' '."\n";
}
}
if (($counter % 2) == 0) {
$oddclass = "row_odd";
} else {
$oddclass = "row_even";
}
//$extend_link = ' ';
$extend_link = '';
if ($inter_num > 1) {
$extend_link = ' ';
}
if (($counter % 2) == 0) {
$oddclass = "row_odd";
} else {
$oddclass = "row_even";
}
$lesson_status = $row['mystatus'];
$score = $row['myscore'];
$subtotal_time = $row['mytime'];
//if($row['mytime']==0){
while ($tmp_row = Database :: fetch_array($result)) {
$subtotal_time += $tmp_row['mytime'];
}
//}
$time_for_total = $subtotal_time;
$time = learnpathItem :: get_scorm_time('js', $subtotal_time);
$scoIdentifier = $row['myid'];
$title = $row['mytitle'];
$title = stripslashes($title);
if ($score == 0) {
$maxscore = 0;
} else {
$maxscore = $row['mymaxscore'];
}
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)
//$time = str_replace('NaN', '00'.$h.'00\'00"', $time);
if (($lesson_status == 'completed') or ($lesson_status == 'passed')) {
$color = 'green';
} else {
$color = 'black';
}
$mylanglist = array ('completed' => 'ScormCompstatus', 'incomplete' => 'ScormIncomplete', 'failed' => 'ScormFailed', 'passed' => 'ScormPassed', 'browsed' => 'ScormBrowsed', 'not attempted' => 'ScormNotAttempted',);
$my_lesson_status = htmlentities(get_lang($mylanglist[$lesson_status]), ENT_QUOTES, $dokeos_charset);
if ($row['item_type'] != 'dokeos_chapter') {
if($row['item_type'] == 'quiz'){
if($origin != 'tracking'){
$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="'.$_SESSION['_course']['id'].'" ORDER BY exe_date DESC LIMIT 1';
}
else{
$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="'.$_SESSION['_course']['id'].'" ORDER BY exe_date DESC LIMIT 1';
}
$resultLastAttempt = api_sql_query($sql_last_attempt);
$id_last_attempt=mysql_result($resultLastAttempt,0,0);
if($origin != 'tracking'){
$correct_test_link = ' ';
}
else{
$correct_test_link = ' ';
}
}
else{
$correct_test_link='-';
}
$output .= "\n"."$extend_link | \n".''.$title.' | '."\n"
//."".htmlentities($array_status[$lesson_status],ENT_QUOTES,$charset_lang)." | \n"
.''.$my_lesson_status." | \n".''. ($score == 0 ? '-' : $score.'/'.$maxscore)." | \n".''.$time." | $correct_test_link | \n"." \n";
if($export_csv)
{
$temp = array();
$temp[] = $title;
$temp[] = html_entity_decode($my_lesson_status);
$temp[] = ($score == 0 ? '-' : $score.'/'.$maxscore);
$temp[] = $time;
$csv_content[] = $temp;
}
}
$counter ++;
if ($extend_this_attempt OR $extend_all) {
$list = learnpath :: get_iv_interactions_array($row['iv_id']);
foreach ($list as $id => $interaction) {
if (($counter % 2) == 0) {
$oddclass = "row_odd";
} else {
$oddclass = "row_even";
}
$output .= "\n".' | '."\n".' | '."\n".' | '."\n".''.$interaction['order_id'].' | '."\n".''.$interaction['id'].' | '."\n"
//."".htmlentities($array_status[$lesson_status],ENT_QUOTES,$charset_lang)." | \n"
.''.$interaction['type']." | \n"
//.''.$interaction['correct_responses']." | \n"
.''.urldecode($interaction['student_response'])." | \n".''.$interaction['result']." | \n".''.$interaction['latency']." | \n".''.$interaction['time']." | \n"." \n";
$counter ++;
}
}
}
//only sum up the latest attempt each time
$total_max_score += $maxscore;
$total_score += $score;
$total_time += $time_for_total;
}
$total_time = learnpathItem :: get_scorm_time('js', $total_time);
//$total_time = str_replace('NaN','00:00:00',$total_time);
$total_time = str_replace('NaN', '00'.$h.'00\'00"', $total_time);
if ($total_max_score == 0) {
$total_max_score = 1;
}
$total_percent = number_format((((float) $total_score / (float) $total_max_score) * 100), 1, '.', '');
if (($counter % 2) == 0) {
$oddclass = "row_odd";
} else {
$oddclass = "row_even";
}
$output .= "\n"." | \n".''.htmlentities(get_lang('AccomplishedStepsTotal'), ENT_QUOTES, $dokeos_charset)." | \n"
//."".htmlentities($array_status[$lesson_status],ENT_QUOTES,$charset_lang)." | \n"
.' | '."\n".''. ($total_score == 0 ? '-' : $total_percent.'%')." | \n".''.$total_time.' | | '."\n"." \n";
$output .= "
|