@ -269,7 +269,9 @@ class Tracking {
// protect data
$month_filter = '';
if ($start < 0 ) { $ start = 0; }
if ($start < 0 ) {
$start = 0;
}
if (!isset($stop) or ($stop < 0 ) ) {
$stop = api_get_utc_datetime();
}
@ -542,7 +544,9 @@ class Tracking {
*/
public static function get_avg_student_score($student_id, $course_code, $lp_ids = array(), $session_id = null, $return_array = false, $get_only_latest_attempt_results = false) {
$debug = false;
if (empty($lp_ids)) { $debug = false; }
if (empty($lp_ids)) {
$debug = false;
}
if ($debug) echo '< h1 > Tracking::get_avg_student_score< / h1 > ';
// get global tables names
@ -598,7 +602,9 @@ class Tracking {
$use_max_score[$row_lp['id']] = $row_lp['use_max_score'];
}
if ($debug) { echo 'Use max score or not list '; var_dump($use_max_score);}
if ($debug) {
echo 'Use max score or not list '; var_dump($use_max_score);
}
// Init local variables that will be used through the calculation
$progress = 0;
@ -1767,7 +1773,8 @@ class Tracking {
$sql_list_view='';
$rs_last_lp_view_id='';
} elseif ($row_type['lp_type']==2) {//lp scorm
} elseif ($row_type['lp_type']==2) {
//lp scorm
$sql = "SELECT id FROM $lp_view_table WHERE user_id = '".intval($user_id)."' and lp_id='".$row_type['id']."'";
$rs_last_lp_view_id = Database::query($sql);
$lp_view_id = intval(Database::result($rs_last_lp_view_id,0,'id'));
@ -1929,8 +1936,11 @@ class Tracking {
*/
function show_user_progress($user_id, $session_id = 0, $extra_params = '', $show_courses = true) {
require_once api_get_path(LIBRARY_PATH).'sessionmanager.lib.php';
require_once api_get_path(SYS_CODE_PATH).'exercice/exercise.class.php';
global $_configuration;
$tbl_course = Database :: get_main_table(TABLE_MAIN_COURSE);
$tbl_session = Database :: get_main_table(TABLE_MAIN_SESSION);
$tbl_course_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
$tbl_access_rel_course = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
$tbl_session_course_user = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
@ -1940,33 +1950,66 @@ class Tracking {
// get course list
if ($_configuration['multiple_access_urls']) {
$sql = 'SELECT cu.course_code FROM '.$tbl_course_user.' cu INNER JOIN '.$tbl_access_rel_course.' a ON(a.course_code = cu.course_code) WHERE user_id='.$user_id.' AND relation_type< >'.COURSE_RELATION_TYPE_RRHH.' AND access_url_id = '.api_get_current_access_url_id().'';
$sql = 'SELECT cu.course_code as code, title
FROM '.$tbl_course_user.' cu INNER JOIN '.$tbl_access_rel_course.' a ON(a.course_code = cu.course_code) INNER JOIN '.$tbl_course.' c ON( cu.course_code = c.code)
WHERE user_id='.$user_id.' AND relation_type< >'.COURSE_RELATION_TYPE_RRHH.' AND access_url_id = '.api_get_current_access_url_id().' ORDER BY title ';
} else {
$sql = 'SELECT course_code FROM '.$tbl_course_user.' WHERE user_id='.$user_id.' AND relation_type< >'.COURSE_RELATION_TYPE_RRHH.' ';
$sql = 'SELECT course_code as code, title FROM '.$tbl_course_user.' u INNER JOIN '.$tbl_course.' c ON(course_code = c.code)
WHERE u.user_id='.$user_id.' AND relation_type< >'.COURSE_RELATION_TYPE_RRHH.' ORDER BY title ';
}
$rs = Database::query($sql);
$courses = $ course_in_session = array();
$courses = $course_in_session = $temp_ course_in_session = array();
while($row = Database :: fetch_array($rs)) {
$courses[$row['course_code']] = CourseManager::get_course_information($row['course_code']);
$courses = array();
while($row = Database :: fetch_array($rs, 'ASSOC')) {
$courses[$row['code']] = $row['title'];
}
/*
if (!empty($courses)) {
//sort need to be improved
sort($courses);
}*/
// Get the list of sessions where the user is subscribed as student
if ($_configuration['multiple_access_urls']) {
$sql = 'SELECT DISTINCT cu.course_code, id_session as session_id FROM '.$tbl_session_course_user.' cu INNER JOIN '.$tbl_access_rel_session.' a ON(a.session_id = cu.id_session) WHERE id_user='.$user_id.' AND access_url_id = '.api_get_current_access_url_id().'';
$sql = 'SELECT DISTINCT cu.course_code, id_session as session_id, name FROM '.$tbl_session_course_user.' cu INNER JOIN '.$tbl_access_rel_session.' a ON(a.session_id = cu.id_session) INNER JOIN '.$tbl_session.' s ON(s.id = a.session_id)
WHERE id_user='.$user_id.' AND access_url_id = '.api_get_current_access_url_id().' ORDER BY name ';
} else {
$sql = 'SELECT DISTINCT course_code, id_session as session_id FROM '.$tbl_session_course_user.' WHERE id_user='.$user_id;
$sql = 'SELECT DISTINCT course_code, id_session as session_id, name FROM '.$tbl_session_course_user.' u INNER JOIN '.$tbl_session.' s ON(s.id = u.id_session)
WHERE id_user='.$user_id.' ORDER BY name ';
}
$rs = Database::query($sql);
$simple_session_array = array();
while ($row = Database :: fetch_array($rs)) {
$course_in_session[$row['session_id']][$row['course_code']] = CourseManager::get_course_information($row['course_code']);
$course_info = CourseManager::get_course_information($row['course_code']);
$temp_course_in_session[$row['session_id']]['course_list'][$course_info['id']] = $course_info;
$temp_course_in_session[$row['session_id']]['name'] = $row['name'];
$simple_session_array[$row['session_id']] = $row['name'];
}
foreach($simple_session_array as $my_session_id => $session_name) {
$course_list = $temp_course_in_session[$my_session_id]['course_list'];
$my_course_data = array();
foreach($course_list as $course_data) {
$my_course_data[$course_data['id']] = $course_data['title'];
}
$my_course_data = utf8_sort($my_course_data);
$final_course_data = array();
foreach($my_course_data as $course_id => $value) {
$final_course_data[$course_id] = $course_list[$course_id];
}
$course_in_session[$my_session_id]['course_list'] = $final_course_data;
$course_in_session[$my_session_id]['name'] = $session_name;
}
$html = '';
//Courses list
// Course list
if ($show_courses) {
if (!empty($courses)) {
$html .= Display::tag('h1', Display::return_icon('course.png', get_lang('MyCourses'), array(), 22).' '.get_lang('MyCourses'));
@ -1975,27 +2018,27 @@ class Tracking {
'.Display::tag('th', get_lang('Course'), array('width'=>'300px')).'
'.Display::tag('th', get_lang('Time'), array('class'=>'head')).'
'.Display::tag('th', get_lang('Progress'), array('class'=>'head')).'
'.Display::tag('th', get_lang('Score').Display :: return_icon('info3.gif', get_lang('ScormAndLPTestTotalAverage'), array('align' => 'absmiddle', 'hspace' => '3px')),array('class'=>'head')).'
'.Display::tag('th', get_lang('Score').Display::return_icon('info3.gif', get_lang('ScormAndLPTestTotalAverage'), array('align' => 'absmiddle', 'hspace' => '3px')),array('class'=>'head')).'
'.Display::tag('th', get_lang('LastConnexion'), array('class'=>'head')).'
'.Display::tag('th', get_lang('Details'), array('class'=>'head')).'
< / tr > ';
foreach ($courses as $enreg ) {
foreach ($courses as $course_code => $course_title ) {
$weighting = 0;
$total_time_login = Tracking :: get_time_spent_on_the_course($user_id, $enreg['code'] );
$total_time_login = Tracking :: get_time_spent_on_the_course($user_id, $course_code );
$time = api_time_to_hms($total_time_login);
$progress = Tracking :: get_avg_student_progress($user_id, $enreg['code'] );
$percentage_score = Tracking :: get_avg_student_score($user_id, $enreg['code'] , array());
$last_connection = Tracking :: get_last_connection_date_on_the_course($user_id, $enreg['code'] );
$progress = Tracking :: get_avg_student_progress($user_id, $course_code );
$percentage_score = Tracking :: get_avg_student_score($user_id, $course_code , array());
$last_connection = Tracking :: get_last_connection_date_on_the_course($user_id, $course_code );
if ($enreg['code'] == $_GET['course'] & & empty($_GET['session_id'])) {
if ($course_code == $_GET['course'] & & empty($_GET['session_id'])) {
$html .= '< tr class = "row_odd" style = "background-color:#FBF09D" > ';
} else {
$html .= '< tr class = "row_even" > ';
}
$url = api_get_course_url($enreg['code'] , $session_id);
$course_url = Display::url($enreg['title'] , $url, array('target'=>SESSION_LINK_TARGET));
$url = api_get_course_url($course_code , $session_id);
$course_url = Display::url($course_title , $url, array('target'=>SESSION_LINK_TARGET));
$html .= '< td > '.$course_url.'< / td > ';
$html .= '< td align = "center" > '.$time.'< / td > ';
@ -2010,11 +2053,11 @@ class Tracking {
$html .= '< / td > ';
$html .= '< td align = "center" > '.$last_connection.'< / td > ';
$html .= '< td align = "center" > ';
if ($enreg['code'] == $_GET['course'] & & empty($_GET['session_id'])) {
if ($course_code == $_GET['course'] & & empty($_GET['session_id'])) {
$html .= '< a href = "#" > ';
$html .= Display::return_icon('2rightarrow_na.gif', get_lang('Details'));
} else {
$html .= '< a href = "'.api_get_self().'?course='.$enreg['code'] .$extra_params.'" > ';
$html .= '< a href = "'.api_get_self().'?course='.$course_code .$extra_params.'" > ';
$html .= Display::return_icon('2rightarrow.gif', get_lang('Details'));
}
$html .= '< / a > ';
@ -2024,25 +2067,44 @@ class Tracking {
}
}
//Session
// Session list
if (!empty($course_in_session)) {
$html .= Display::tag('h1',Display::return_icon('session.png', get_lang('Sessions'), array(), 22).' '.get_lang('Sessions')) ;
$main_session_graph = '' ;
$exercise_graph_list = array();
$exercise_graph_name_list = array();
if (!isset($_GET['session_id']) & & !isset($_GET['course'])) {
//Load graphics only when calling to an specific session
$session_graph = array();
foreach ($course_in_session as $my_session_id=>$course_list) {
$session_name = api_get_session_name($my_session_id);
$user_count = count(SessionManager::get_users_by_session($session_id));
$all_exercise_graph_name_list = array();
$all_user_results = array();
$all_exercise_graph_list = array();
$all_exercise_start_time = array();
foreach ($course_in_session as $my_session_id => $session_data) {
$course_list = $session_data['course_list'];
$session_name = $session_data['name'];
$user_count = count(SessionManager::get_users_by_session($my_session_id));
$exercise_graph_name_list = array();
$user_results = array();
$exercise_graph_list = array();
foreach ($course_list as $course_data) {
$exercise_list = get_all_exercises($course_data, $my_session_id);
foreach($exercise_list as $exercise_data) {
if (!empty($exercise_data['start_time']) & & $exercise_data['start_time'] != '0000-00-00 00:00:00') {
//echo $session_name.' - '.$course_data['title']." \n ".$exercise_data['title'].'< br / > ';
$exercise_graph_list[] = intval(get_best_average_score_by_exercise($exercise_data['id'], $course_data['code'], $my_session_id, $user_count));
$exercise_obj = New Exercise($course_data['id']);
$exercise_obj->read($exercise_data['id']);
if ($exercise_obj->is_visible()) {
$best_average = intval(get_best_average_score_by_exercise($exercise_data['id'], $course_data['code'], $my_session_id, $user_count));
$exercise_graph_list[] = $best_average;
$all_exercise_graph_list[] = $best_average;
$user_result_data = get_best_attempt_by_user(api_get_user_id(), $exercise_data['id'], $course_data['code'], $my_session_id);
$score = 0;
if (!empty($user_result_data['exe_weighting']) & & intval($user_result_data['exe_weighting']) != 0) {
@ -2050,95 +2112,162 @@ class Tracking {
}
//$user_results[] = 100;
$user_results[] = $score;
$time = api_strtotime($exercise_data['start_time']) ? api_strtotime($exercise_data['start_time']) : 0;
$all_exercise_start_time[] = $time ;
$all_user_results[] = $score;
if (count($exercise_list)< =10) {
$exercise_graph_name_list[]= cut($course_data['title'], 20)." \n ".cut($exercise_data['title'], 20);
$title = cut($course_data['title'], 30)." \n ".cut($exercise_data['title'], 30);
$exercise_graph_name_list[]= $title;
$all_exercise_graph_name_list[] = $title;
} else {
// if there are more than 10 results, space becomes difficult to find, so only show the title of the exercise, not the tool
$exercise_graph_name_list[]= cut($exercise_data['title'], 20);
$title = cut($exercise_data['title'], 30);
$exercise_graph_name_list[]= $title;
$all_exercise_graph_name_list[]= $title;
}
}
}
}
//Graph per session
if (!empty($user_results) & & !empty($exercise_graph_list)) {
$session_graph[$my_session_id] = self::generate_session_exercise_graph($exercise_graph_name_list, $user_results, $exercise_graph_list);
//$session_graph[$my_session_id] = self::generate_session_exercise_graph($exercise_graph_name_list, $user_results, $exercise_graph_list);
}
}
//Complete graph
if (!empty($all_user_results) & & !empty($all_exercise_graph_list)) {
asort($all_exercise_start_time);
//Fix exams order
$final_all_exercise_graph_name_list = array();
$final_all_user_results = array();
$final_all_exercise_graph_list = array();
foreach($all_exercise_start_time as $key => $time) {
$label_time = '';
if (!empty($time)) {
$label_time = date('d-m-y', $time);
//$label_time = api_format_date($time, DATE_FORMAT_NUMBER);
}
$final_all_exercise_graph_name_list[] = $all_exercise_graph_name_list[$key].' '.$label_time;
$final_all_user_results[] = $all_user_results[$key];
$final_all_exercise_graph_list[] = $all_exercise_graph_list[$key];
}
//var_dump($final_all_exercise_graph_name_list, $final_all_user_results, $final_all_exercise_graph_list);
$main_session_graph = self::generate_session_exercise_graph($final_all_exercise_graph_name_list, $final_all_user_results, $final_all_exercise_graph_list);
}
}
$html .= Display::tag('h1',Display::return_icon('session.png', get_lang('Sessions'), array(), 22).' '.get_lang('Sessions'));
$html .= '< table class = "data_table" width = "100%" > ';
//'.Display::tag('th', get_lang('DoneExercises'), array('class'=>'head')).'
$html .= '< tr >
'.Display::tag('th', get_lang('Session'), array('width'=>'300px')).'
'.Display::tag('th', get_lang('PublishedExercises'), array('width'=>'300px')).'
'.Display::tag('th', get_lang('DoneExercises'), array('class'=>'head')).'
'.Display::tag('th', get_lang('New Exercises'), array('class'=>'head')).'
'.Display::tag('th', get_lang('AverageExerciseResult'), array('class'=>'head')).'
'.Display::tag('th', get_lang('Details'), array('class'=>'head')).'
< / tr > ';
foreach ($course_in_session as $key => $course_list) {
foreach ($course_in_session as $my_session_id => $session_data) {
$course_list = $session_data['course_list'];
$session_name = $session_data['name'];
if (isset($session_id) & & !empty($session_id)) {
if ($session_id != $key) {
if ($session_id != $my_session_id ) {
continue;
}
}
$all_exercises = 0;
$all_unanswered_exercises_by_user = 0;
$all_done_exercise = 0;
$all_average = 0;
$stats_array = array();
foreach ($course_list as $enreg) {
foreach($course_list as $course_data) {
//All exercises in the course @todo change for a real count
$exercises = count(get_all_exercises($enreg, $key));
$exercises = get_all_exercises($course_data, $my_session_id);
$count_exercises = 0;
if (!empty($exercises)) {
$count_exercises = count($exercises);
}
//Count of user results
//$done_exercises = get_best_exercise_results_by_course($enreg['code'], $key);
$done_exercises = get_count_exercises_attempted_by_course($enreg['code'], $key);
//$done_exercises = get_count_exercises_attempted_by_course($course_data['code'], $my_session_id);
$done_exercises = null;
$answered_exercises = 0;
if (!empty($exercises)) {
foreach($exercises as $exercise_item) {
$attempts = count_exercise_attempts_by_user(api_get_user_id(), $exercise_item['id'], $course_data['code'], $my_session_id);
if ($attempts > 1) {
$answered_exercises++;
}
}
}
//Average
$average = get_average_score_by_course($enreg['code'], $key);
$average = get_average_score_by_course($course_data['code'], $my_session_id);
$all_exercises += $count_exercises;
$all_exercises += $exercises;
$all_done_exercise += $done_exercises;
$all_unanswered_exercises_by_user += $count_exercises - $answered_ exercises;
// $all_done_exercise += $done_exercises;
$all_average += $average;
$stats_array[$enreg['code']] = array('exercises'=>$exercises, 'done_exercises'=>$done_exercises, 'average'=>$average);
//$stats_array[$course_data ['code']] = array('exercises'=>$count_ exercises, 'unanswered_exercises_by_user'=>$answered_exercises, 'done_exercises'=>$done_exercises, 'average'=>$average);
}
$all_average = $all_average / count($course_list);
if (isset($_GET['session_id']) & & $key == $_GET['session_id']) {
if (isset($_GET['session_id']) & & $my_session_id == $_GET['session_id']) {
$html .= '< tr style = "background-color:#FBF09D" > ';
} else {
$html .= '< tr > ';
}
$url = api_get_path(WEB_CODE_PATH)."session/?session_id={$my_session_id}";
$html .= Display::tag('td', api_get_session_name($key ));
$html .= Display::tag('td', Display::url($session_name, $url, array('target'=>SESSION_LINK_TARGET) ));
$html .= Display::tag('td', $all_exercises);
$html .= Display::tag('td', $all_done_exercise);
$html .= Display::tag('td', $all_unanswered_exercises_by_user);
//$html .= Display::tag('td', $all_done_exercise);
$html .= Display::tag('td', convert_to_percentage($all_average));
if (isset($_GET['session_id']) & & $key == $_GET['session_id']) {
$icon = Display::url(Display::return_icon('2rightarrow_na.gif', get_lang('Details')), '?session_id='.$key );
if (isset($_GET['session_id']) & & $my_session_id == $_GET['session_id']) {
$icon = Display::url(Display::return_icon('2rightarrow_na.gif', get_lang('Details')), '?session_id='.$my_session_id );
} else {
$icon = Display::url(Display::return_icon('2rightarrow.gif', get_lang('Details')), '?session_id='.$key );
$icon = Display::url(Display::return_icon('2rightarrow.gif', get_lang('Details')), '?session_id='.$my_session_id );
}
$html .= Display::tag('td', $icon);
$html .= '< / tr > ';
}
$html .='< / table > < br / > ';
$html .= '< / table > < br / > ';
$html .= Display::div($main_session_graph, array('id'=>'session_graph','class'=>'chart-session', 'style'=>'position:relative; text-align: center;') );
//Checking selected session
if (isset($_GET['session_id'])) {
$key = intval($_GET['session_id']);
$html .= Display::tag('h2',api_get_session_name($key).' - '.get_lang('CourseList'));
$session_id_from_get = intval($_GET['session_id']);
$session_data = $course_in_session[$session_id_from_get];
$course_list = $session_data['course_list'];
$course_list = $course_in_session[$key];
$html .= Display::tag('h2',$session_data['name'].' - '.get_lang('CourseList')) ;
$html .= '< table class = "data_table" width = "100%" > ';
//'.Display::tag('th', get_lang('DoneExercises'), array('class'=>'head')).'
$html .= '
< tr >
< th width = "300px" > '.get_lang('Course').'< / th >
'.Display::tag('th', get_lang('PublishedExercises'), array('class'=>'head')).'
'.Display::tag('th', get_lang('DoneExercises'), array('class'=>'head')).'
'.Display::tag('th', get_lang('NewExercises'), array('class'=>'head')).'
'.Display::tag('th', get_lang('MyAverage'), array('class'=>'head')).'
'.Display::tag('th', get_lang('AverageExerciseResult'), array('class'=>'head')).'
'.Display::tag('th', get_lang('Time') , array('class'=>'head')).'
'.Display::tag('th', get_lang('LPProgress') , array('class'=>'head')).'
@ -2147,38 +2276,64 @@ class Tracking {
'.Display::tag('th', get_lang('Details'), array('class'=>'head')).'
< / tr > ';
foreach ($course_list as $enreg) {
foreach ($course_list as $course_data) {
$course_code = $course_data['code'];
$course_title = $course_data['title'];
//All exercises in the course @todo change for a real count
$exercises = count(get_all_exercises($enreg, $key));
$exercises = get_all_exercises($course_data, $session_id_from_get);
$count_exercises = 0;
if (!empty($exercises)) {
$count_exercises = count($exercises);
}
//Count of user results
//$done_exercises = get_best_exercise_results_by_course($enreg['code'], $key);
$done_exercises = get_count_exercises_attempted_by_course($enreg['code'], $key);
//$done_exercises = get_best_exercise_results_by_course($course_code, $session_id_from_get);
//From course exercises NOT from LP exercises!!!
//$done_exercises = get_count_exercises_attempted_by_course($course_code, $session_id_from_get);
$answered_exercises = 0;
foreach($exercises as $exercise_item) {
$attempts = count_exercise_attempts_by_user(api_get_user_id(), $exercise_item['id'], $course_code, $session_id_from_get);
if ($attempts > 1) {
$answered_exercises++;
}
}
$unanswered_exercises = $count_exercises - $answered_exercises;
//Average
$average = get_average_score_by_course($enreg['code'], $key);
$average = get_average_score_by_course($course_code, $session_id_from_get);
$my_average = get_average_score_by_course_by_user(api_get_user_id(), $course_code, $session_id_from_get);
$stats_array[$enreg['code']] = array('exercises'=>$exercises, 'done_exercises'=>$done_exercises, 'average'=>$average);
$stats_array[$course_code] = array( 'exercises' => $count_exercises,
'unanswered_exercises_by_user' => $unanswered_exercises,
'done_exercises' => $done_exercises,
'average' => $average,
'my_average' => $my_average);
$weighting = 0;
$last_connection = Tracking :: get_last_connection_date_on_the_course($user_id, $enreg['code'], $key);
$progress = Tracking :: get_avg_student_progress($user_id, $enreg['code'],array(), $key);
$total_time_login = Tracking :: get_time_spent_on_the_course($user_id, $enreg['code'], $key);
$last_connection = Tracking :: get_last_connection_date_on_the_course($user_id, $course_code, $session_id_from_get );
$progress = Tracking :: get_avg_student_progress($user_id, $course_code,array(), $session_id_from_get );
$total_time_login = Tracking :: get_time_spent_on_the_course($user_id, $course_code, $session_id_from_get );
$time = api_time_to_hms($total_time_login);
$percentage_score = Tracking :: get_avg_student_score($user_id, $enreg['code'], array(), $key);
$percentage_score = Tracking :: get_avg_student_score($user_id, $course_code, array(), $session_id_from_get );
if ($enreg['code'] == $_GET['course'] & & $_GET['session_id'] == $key ) {
if ($course_code == $_GET['course'] & & $_GET['session_id'] == $session_id_from_get ) {
$html .= '< tr class = "row_odd" style = "background-color:#FBF09D" > ';
} else {
$html .= '< tr class = "row_even" > ';
}
$url = api_get_course_url($enreg['code'], $key );
$course_url = Display::url($enreg['title'] , $url, array('target'=>SESSION_LINK_TARGET));
$url = api_get_course_url($course_code, $session_id_from_get );
$course_url = Display::url($course_title , $url, array('target'=>SESSION_LINK_TARGET));
$html .= Display::tag('td', $course_url);
$html .= Display::tag('td', $stats_array[$enreg['code']]['exercises']);
$html .= Display::tag('td', $stats_array[$enreg['code']]['done_exercises']);
$html .= Display::tag('td', convert_to_percentage($stats_array[$enreg['code']]['average']));
$html .= Display::tag('td', $stats_array[$course_code]['exercises']);
$html .= Display::tag('td', $stats_array[$course_code]['unanswered_exercises_by_user']);
//$html .= Display::tag('td', $stats_array[$course_code]['done_exercises']);
$html .= Display::tag('td', convert_to_percentage($stats_array[$course_code]['my_average']));
$html .= Display::tag('td', $stats_array[$course_code]['average'] == 0 ? '-' : '('.convert_to_percentage($stats_array[$course_code]['average']).')');
$html .= Display::tag('td', $time, array('align'=>'center'));
if (is_numeric($progress)) {
@ -2186,20 +2341,22 @@ class Tracking {
} else {
$progress = '0%';
}
//Progress
$html .= Display::tag('td', $progress, array('align'=>'center'));
if (is_numeric($percentage_score)) {
$percentage_score = $percentage_score.'%';
} else {
$percentage_score = '0%';
}
//Score
$html .= Display::tag('td', $percentage_score, array('align'=>'center'));
$html .= Display::tag('td', $last_connection, array('align'=>'center'));
if ($enreg['code'] == $_GET['course'] & & $_GET['session_id'] == $key ) {
if ($course_code == $_GET['course'] & & $_GET['session_id'] == $session_id_from_get ) {
$details = '< a href = "#" > ';
$details .=Display::return_icon('2rightarrow_na.gif', get_lang('Details'));
} else {
$details = '< a href = "'.api_get_self().'?course='.$enreg['code'].'&session_id='.$key .$extra_params.'" > ';
$details = '< a href = "'.api_get_self().'?course='.$course_code.'&session_id='.$session_id_from_get .$extra_params.'" > ';
$details .=Display::return_icon('2rightarrow.gif', get_lang('Details'));
}
$details .= '< / a > ';
@ -2208,9 +2365,10 @@ class Tracking {
}
$html .= '< / table > ';
if (!empty($session_graph[$key ])) {
$html .= Display::div($session_graph[$my_session_id], array('id'=>'session_graph_'.$key ,'class'=>'chart-session', 'style'=>'position:relative; text-align: center;') );
if (!empty($session_graph[$session_id_from_get ])) {
//$html .= Display::div($session_graph[$session_id_from_get], array('id'=>'session_graph' ,'class'=>'chart-session', 'style'=>'position:relative; text-align: center;') );
}
}
}
if (!empty($html)) {
@ -2249,60 +2407,8 @@ class Tracking {
$session_name = api_get_session_name($session_id);
$html .= Display::tag('h2', $course_info['title']);
$html .='< table class = "data_table" width = "100%" > ';
$html .= Display::tag('th', get_lang('Learnpaths'), array('class'=>'head', 'style'=>'color:#000'));
$html .= Display::tag('th', get_lang('Time'), array('class'=>'head', 'style'=>'color:#000'));
$html .= Display::tag('th', get_lang('Progress'), array('class'=>'head', 'style'=>'color:#000'));
$html .= Display::tag('th', get_lang('Score'), array('class'=>'head', 'style'=>'color:#000'));
$html .= Display::tag('th', get_lang('LastConnexion'), array('class'=>'head', 'style'=>'color:#000'));
$html .= '< / tr > ';
if (empty($session_id)) {
$sql_learnpath = "SELECT lp.name,lp.id FROM ".$tbl_course_lp." AS lp WHERE session_id = 0 ORDER BY lp.display_order";
} else {
$sql_learnpath = "SELECT lp.name,lp.id FROM ".$tbl_course_lp." AS lp ORDER BY lp.display_order";
}
$result_learnpath = Database::query($sql_learnpath);
if (Database::num_rows($result_learnpath) > 0) {
while($learnpath = Database::fetch_array($result_learnpath)) {
$progress = Tracking::get_avg_student_progress($user_id, $course, array($learnpath['id']), $session_id);
$last_connection_in_lp = Tracking::get_last_connection_time_in_lp($user_id, $course, $learnpath['id'], $session_id);
$time_spent_in_lp = Tracking::get_time_spent_in_lp($user_id, $course, array($learnpath['id']), $session_id);
$percentage_score = Tracking::get_avg_student_score($user_id, $course, array($learnpath['id']), $session_id);
if (is_numeric($percentage_score)) {
$percentage_score = $percentage_score.'%';
} else {
$percentage_score = '0%';
}
$time_spent_in_lp = api_time_to_hms($time_spent_in_lp);
$html .= '< tr class = "row_even" > ';
$html .= Display::tag('td', $learnpath['name']);
$html .= Display::tag('td', $time_spent_in_lp, array('align'=>'center'));
if (is_numeric($progress)) {
$progress = $progress.'%';
}
$html .= Display::tag('td', $progress, array('align'=>'center'));
$html .= Display::tag('td', $percentage_score);
$last_connection = '-';
if (!empty($last_connection_in_lp)) {
$last_connection = api_convert_and_format_date($last_connection_in_lp, DATE_TIME_FORMAT_LONG);
}
$html .= Display::tag('td', $last_connection, array('align'=>'center','width'=>'180px'));
$html .= "< / tr > ";
}
} else {
$html .= '< tr >
< td colspan = "4" align = "center" >
'.get_lang('NoLearnpath').'
< / td >
< / tr > ';
}
$html .='< / table > < br / >
< table class = "data_table" width = "100%" > ';
$html .= '< table class = "data_table" width = "100%" > ';
// This code was commented on purpose see BT#924
@ -2406,6 +2512,66 @@ class Tracking {
$html .= '< tr > < td colspan = "5" align = "center" > '.get_lang('NoEx').'< / td > < / tr > ';
}
$html .= '< / table > ';
//LP table results
$html .='< table class = "data_table" width = "100%" > ';
$html .= Display::tag('th', get_lang('Learnpaths'), array('class'=>'head', 'style'=>'color:#000'));
$html .= Display::tag('th', get_lang('Time'), array('class'=>'head', 'style'=>'color:#000'));
$html .= Display::tag('th', get_lang('Progress'), array('class'=>'head', 'style'=>'color:#000'));
$html .= Display::tag('th', get_lang('Score'), array('class'=>'head', 'style'=>'color:#000'));
$html .= Display::tag('th', get_lang('LastConnexion'), array('class'=>'head', 'style'=>'color:#000'));
$html .= '< / tr > ';
if (empty($session_id)) {
$sql_learnpath = "SELECT lp.name,lp.id FROM ".$tbl_course_lp." AS lp WHERE session_id = 0 ORDER BY lp.display_order";
} else {
$sql_learnpath = "SELECT lp.name,lp.id FROM ".$tbl_course_lp." AS lp ORDER BY lp.display_order";
}
$result_learnpath = Database::query($sql_learnpath);
if (Database::num_rows($result_learnpath) > 0) {
while($learnpath = Database::fetch_array($result_learnpath)) {
$progress = Tracking::get_avg_student_progress($user_id, $course, array($learnpath['id']), $session_id);
$last_connection_in_lp = Tracking::get_last_connection_time_in_lp($user_id, $course, $learnpath['id'], $session_id);
$time_spent_in_lp = Tracking::get_time_spent_in_lp($user_id, $course, array($learnpath['id']), $session_id);
$percentage_score = Tracking::get_avg_student_score($user_id, $course, array($learnpath['id']), $session_id);
if (is_numeric($percentage_score)) {
$percentage_score = $percentage_score.'%';
} else {
$percentage_score = '0%';
}
$time_spent_in_lp = api_time_to_hms($time_spent_in_lp);
$html .= '< tr class = "row_even" > ';
$url = api_get_path(WEB_CODE_PATH)."newscorm/lp_controller.php?cidReq={$course_code}&id_session=$session_id&lp_id={$learnpath['id']}&action=view";
$html .= Display::tag('td', Display::url($learnpath['name'], $url, array('target'=>SESSION_LINK_TARGET)));
$html .= Display::tag('td', $time_spent_in_lp, array('align'=>'center'));
if (is_numeric($progress)) {
$progress = $progress.'%';
}
$html .= Display::tag('td', $progress, array('align'=>'center'));
$html .= Display::tag('td', $percentage_score);
$last_connection = '-';
if (!empty($last_connection_in_lp)) {
$last_connection = api_convert_and_format_date($last_connection_in_lp, DATE_TIME_FORMAT_LONG);
}
$html .= Display::tag('td', $last_connection, array('align'=>'center','width'=>'180px'));
$html .= "< / tr > ";
}
} else {
$html .= '< tr >
< td colspan = "4" align = "center" >
'.get_lang('NoLearnpath').'
< / td >
< / tr > ';
}
$html .='< / table > ';
}
if (!empty($html)) {
$html = Display::div($html, array('class'=>'rounded_div', 'style'=>'position:relative; float:none; width:95%'));
@ -2439,20 +2605,22 @@ class Tracking {
$data_set->SetSerieName(get_lang('AverageScore'),"Serie1");
$data_set->SetSerieName(get_lang('MyResults'), "Serie2");
//$data_set->SetXAxisName(get_lang("Exercises "));
$data_set->SetYAxisName(get_lang("Percentage"));
//$data_set->SetYAxisName(get_lang("Percentage "));
$data_set->SetYAxisUnit("%");
// Initialise the graph
$main_width = 82 0;
$main_height = 44 0;
$y_label_angle = 35 ;
$main_width = 86 0;
$main_height = 50 0;
$y_label_angle = 50 ;
$data_set->RemoveSerie("Serie3");
$graph = new pChart($main_width, $main_height);
//$graph->setFixedScale(0,100);
//See 3.2 BT#2797
$graph->setFixedScale(0,100);
$graph->setFontProperties(api_get_path(LIBRARY_PATH).'pchart/fonts/tahoma.ttf',8);
$graph->setGraphArea(75,50,$main_width-140, $main_height-120);
$graph->setGraphArea(65,50,$main_width-20, $main_height-140);
$graph->drawFilledRoundedRectangle(7,7,$main_width-7,$main_height-7,5,240,240,240);
$graph->drawRoundedRectangle(5,5,$main_width-5,$main_height -5,5,230,230,230);
$graph->drawGraphArea(255,255,255,TRUE);
@ -2466,21 +2634,21 @@ class Tracking {
$graph->drawTreshold(0,143,55,72,TRUE,TRUE);
// Draw the cubic curve graph
//$graph->drawCubicCurve($data_set->GetData(),$data_set->GetDataDescription());
$graph->drawLineGraph($data_set->GetData(),$data_set->GetDataDescription());
$graph->drawPlotGraph($data_set->GetData(),$data_set->GetDataDescription(),1,1,230,255,255);
// Finish the graph
$graph->setFontProperties(api_get_path(LIBRARY_PATH).'pchart/fonts/tahoma.ttf',8);
$graph->drawLegend($main_width - 130,50,$data_set->GetDataDescription(),255,255,255);
$graph->setFontProperties(api_get_path(LIBRARY_PATH).'pchart/fonts/tahoma.ttf',10);
$graph->drawLegend($main_width - 150,70,$data_set->GetDataDescription(),255,255,255);
$graph->setFontProperties(api_get_path(LIBRARY_PATH).'pchart/fonts/tahoma.ttf',11);
$graph->drawTitle(50, 30, get_lang('ExercisesInTimeProgressChart'), 50,50,50,$main_width-110, true);
// $main_graph = new pChart($main_width,$main_height);
$graph_id = 'generate_session_exercise_graph'.Security::remove_XSS($_GET['course']).'-'.intval($_GET['session_id']).'-'.api_get_user_id();
if ($cache->IsInCache($graph_id, $data_set->GetData())) {
// if (0) {
// if ($cache->IsInCache($graph_id, $data_set->GetData())) {
if (0) {
//if we already created the img
//echo 'in cache';
$img_file = $cache->GetHash($graph_id,$data_set->GetData());
@ -2831,7 +2999,9 @@ class TrackingCourseLog {
$sql .= " AND tool IN ('document', 'learnpath', 'quiz', 'glossary', 'link', 'course_description', 'announcement', 'thematic', 'thematic_advance', 'thematic_plan')";
if ($column == 0) { $column = '0'; }
if ($column == 0) {
$column = '0';
}
if ($column != '' & & $direction != '') {
if ($column != 2 & & $column != 4) {
$sql .= " ORDER BY col$column $direction";
@ -3281,7 +3451,9 @@ class TrackingCourseLog {
$avg_student_score = Tracking::get_avg_student_score($user['user_id'], $course_code, array(), $session_id);
$avg_student_progress = Tracking::get_avg_student_progress($user['user_id'], $course_code, array(), $session_id);
if (empty($avg_student_progress)) { $avg_student_progress=0; }
if (empty($avg_student_progress)) {
$avg_student_progress=0;
}
$user['average_progress'] = $avg_student_progress.'%';
if (is_numeric($avg_student_score)) {
@ -3485,9 +3657,11 @@ class TrackingUserLog {
< tr >
< td class = "content" > <?php echo $title ; ?> </ td >
< td class = "content" align = "center" > <?php echo $display_date ; ?> </ td >
< td class = "content" align = "center" > <?php echo $hpresults [ $i ][ 1 ]; ?> / <?php echo $hpresults [ $i ][ 2 ]; ?> </ td >
< td class = "content" align = "center" > <?php echo $hpresults [ $i ][ 1 ]; ?> / <?php echo $hpresults [ $i ][ 2 ]; ?>
< / td >
< / tr >
<?php }
<?php }
} else {
$NoHPTestRes = 1;
}