Fix reports

1.10.x
Julio Montoya 10 years ago
parent 208a5ca032
commit 88297a51a8
  1. 8
      main/inc/ajax/course_home.ajax.php
  2. 12
      main/inc/lib/events.lib.php
  3. 39
      main/inc/lib/myspace.lib.php
  4. 45
      main/inc/lib/tracking.lib.php
  5. 4
      main/newscorm/learnpath.class.php
  6. 13
      main/newscorm/learnpathList.class.php
  7. 2
      main/session/index.php

@ -152,7 +152,7 @@ switch ($action) {
$last_date = Tracking::get_last_connection_date_on_the_course( $last_date = Tracking::get_last_connection_date_on_the_course(
api_get_user_id(), api_get_user_id(),
$item['id'], $item,
$session_id, $session_id,
false false
); );
@ -285,10 +285,11 @@ switch ($action) {
$last_date = Tracking::get_last_connection_date_on_the_course( $last_date = Tracking::get_last_connection_date_on_the_course(
api_get_user_id(), api_get_user_id(),
$item['id'], $item,
$session_id, $session_id,
false false
); );
if ($lp_item['modified_on'] == '0000-00-00 00:00:00' || empty($lp_item['modified_on'])) { if ($lp_item['modified_on'] == '0000-00-00 00:00:00' || empty($lp_item['modified_on'])) {
$lp_date = api_get_local_time($lp_item['created_on']); $lp_date = api_get_local_time($lp_item['created_on']);
$image = 'new.gif'; $image = 'new.gif';
@ -298,6 +299,7 @@ switch ($action) {
$image = 'moderator_star.png'; $image = 'moderator_star.png';
$label = get_lang('LearnpathUpdated'); $label = get_lang('LearnpathUpdated');
} }
if (strtotime($last_date) < strtotime($lp_date)) { if (strtotime($last_date) < strtotime($lp_date)) {
$icons = Display::return_icon($image, get_lang('TitleNotification').': '.$label.' - '.$lp_date); $icons = Display::return_icon($image, get_lang('TitleNotification').': '.$label.' - '.$lp_date);
} }
@ -413,7 +415,7 @@ switch ($action) {
$lp_url = api_get_path(WEB_CODE_PATH).'newscorm/lp_controller.php?cidReq='.$item['code'].'&id_session='.$session_id.'&lp_id='.$lp_id.'&action=view'; $lp_url = api_get_path(WEB_CODE_PATH).'newscorm/lp_controller.php?cidReq='.$item['code'].'&id_session='.$session_id.'&lp_id='.$lp_id.'&action=view';
$last_date = Tracking::get_last_connection_date_on_the_course( $last_date = Tracking::get_last_connection_date_on_the_course(
api_get_user_id(), api_get_user_id(),
$item['id'], $item,
$session_id, $session_id,
false false
); );

@ -1557,7 +1557,8 @@ class Event
/** /**
* @param int $lp_id * @param int $lp_id
* @param $course_id * @param int $course_id
*
* @return array * @return array
*/ */
public static function get_all_exercises_from_lp($lp_id, $course_id) public static function get_all_exercises_from_lp($lp_id, $course_id)
@ -1566,15 +1567,18 @@ class Event
$course_id = intval($course_id); $course_id = intval($course_id);
$lp_id = intval($lp_id); $lp_id = intval($lp_id);
$sql = "SELECT * FROM $lp_item_table $sql = "SELECT * FROM $lp_item_table
WHERE c_id = $course_id AND lp_id = '".$lp_id."' WHERE
c_id = $course_id AND
lp_id = '".$lp_id."' AND
item_type = 'quiz'
ORDER BY parent_item_id, display_order"; ORDER BY parent_item_id, display_order";
$res = Database::query($sql); $res = Database::query($sql);
$my_exercise_list = array(); $my_exercise_list = array();
while ($row = Database::fetch_array($res, 'ASSOC')) { while ($row = Database::fetch_array($res, 'ASSOC')) {
if ($row['item_type'] == 'quiz') {
$my_exercise_list[] = $row; $my_exercise_list[] = $row;
} }
}
return $my_exercise_list; return $my_exercise_list;
} }

@ -236,7 +236,7 @@ class MySpace
$return .= ' <td width="105px"><div>'.(is_null($exercises_results['percentage']) ? '' : $exercises_results['score_obtained'].'/'.$exercises_results['score_possible'].' ( '.$exercises_results['percentage'].'% )').'</div></td>'; $return .= ' <td width="105px"><div>'.(is_null($exercises_results['percentage']) ? '' : $exercises_results['score_obtained'].'/'.$exercises_results['score_possible'].' ( '.$exercises_results['percentage'].'% )').'</div></td>';
//$return .= ' <td><div>'.$exercises_results['score_possible'].'</div></td>'; //$return .= ' <td><div>'.$exercises_results['score_possible'].'</div></td>';
$return .= ' <td><div>'.$exercises_results['questions_answered'].'</div></td>'; $return .= ' <td><div>'.$exercises_results['questions_answered'].'</div></td>';
$return .= ' <td><div>'.Tracking :: get_last_connection_date_on_the_course ($user_id, $courseId).'</div></td>'; $return .= ' <td><div>'.Tracking :: get_last_connection_date_on_the_course($user_id, $courseInfo).'</div></td>';
$return .= '<tr>'; $return .= '<tr>';
} }
$return .= '</table>'; $return .= '</table>';
@ -1281,7 +1281,7 @@ class MySpace
} }
$nb_messages += Tracking::count_student_messages($row->user_id, $course_code); $nb_messages += Tracking::count_student_messages($row->user_id, $course_code);
$nb_assignments += Tracking::count_student_assignments($row->user_id, $course_code); $nb_assignments += Tracking::count_student_assignments($row->user_id, $course_code);
$last_login_date_tmp = Tracking :: get_last_connection_date_on_the_course ($row->user_id, $courseInfo['real_id'], null, false); $last_login_date_tmp = Tracking :: get_last_connection_date_on_the_course($row->user_id, $courseInfo, null, false);
if($last_login_date_tmp != false && $last_login_date == false) { // TODO: To be cleaned if($last_login_date_tmp != false && $last_login_date == false) { // TODO: To be cleaned
$last_login_date = $last_login_date_tmp; $last_login_date = $last_login_date_tmp;
} else if($last_login_date_tmp != false && $last_login_date != false) { // TODO: Repeated previous condition. To be cleaned. } else if($last_login_date_tmp != false && $last_login_date != false) { // TODO: Repeated previous condition. To be cleaned.
@ -1431,7 +1431,7 @@ class MySpace
$nb_messages += Tracking::count_student_messages($row->user_id, $course_code); $nb_messages += Tracking::count_student_messages($row->user_id, $course_code);
$nb_assignments += Tracking::count_student_assignments($row->user_id, $course_code); $nb_assignments += Tracking::count_student_assignments($row->user_id, $course_code);
$last_login_date_tmp = Tracking :: get_last_connection_date_on_the_course ($row->user_id, $courseId, null, false); $last_login_date_tmp = Tracking::get_last_connection_date_on_the_course($row->user_id, $courseInfo, null, false);
if($last_login_date_tmp != false && $last_login_date == false) { // TODO: To be cleaned. if($last_login_date_tmp != false && $last_login_date == false) { // TODO: To be cleaned.
$last_login_date = $last_login_date_tmp; $last_login_date = $last_login_date_tmp;
} else if($last_login_date_tmp != false && $last_login_date == false) { // TODO: Repeated previous condition. To be cleaned. } else if($last_login_date_tmp != false && $last_login_date == false) { // TODO: Repeated previous condition. To be cleaned.
@ -1619,8 +1619,8 @@ class MySpace
WHERE sc.session_id = '".$session_id."';"; WHERE sc.session_id = '".$session_id."';";
$result = Database::query($sql); $result = Database::query($sql);
while ($row = Database::fetch_object($result)) { while ($row = Database::fetch_object($result)) {
$courseCode = $row->code;
$courseId = $row->c_id; $courseId = $row->c_id;
$courseInfo = api_get_course_info_by_id($courseId);
$return .= '<tr>'; $return .= '<tr>';
// course code // course code
$return .= ' <td width="157px" >'.$row->title.'</td>'; $return .= ' <td width="157px" >'.$row->title.'</td>';
@ -1642,23 +1642,25 @@ class MySpace
$total_score_obtained = 0; $total_score_obtained = 0;
$total_score_possible = 0; $total_score_possible = 0;
$total_questions_answered = 0; $total_questions_answered = 0;
while($row_user = Database::fetch_object($result_users)) { while ($row_user = Database::fetch_object($result_users)) {
// get time spent in the course and session // get time spent in the course and session
$time_spent += Tracking::get_time_spent_on_the_course($row_user->user_id, $courseId, $session_id); $time_spent += Tracking::get_time_spent_on_the_course($row_user->user_id, $courseId, $session_id);
$progress_tmp = Tracking::get_avg_student_progress($row_user->user_id, $row->code, array(), $session_id, true); $progress_tmp = Tracking::get_avg_student_progress($row_user->user_id, $row->code, array(), $session_id, true);
$progress += $progress_tmp[0]; $progress += $progress_tmp[0];
$nb_progress_lp += $progress_tmp[1]; $nb_progress_lp += $progress_tmp[1];
$score_tmp = Tracking :: get_avg_student_score($row_user->user_id, $row->code, array(), $session_id, true); $score_tmp = Tracking :: get_avg_student_score($row_user->user_id, $row->code, array(), $session_id, true);
if(is_array($score_tmp)) { if (is_array($score_tmp)) {
$score += $score_tmp[0]; $score += $score_tmp[0];
$nb_score_lp += $score_tmp[1]; $nb_score_lp += $score_tmp[1];
} }
$nb_messages += Tracking::count_student_messages($row_user->user_id, $row->code, $session_id); $nb_messages += Tracking::count_student_messages($row_user->user_id, $row->code, $session_id);
$nb_assignments += Tracking::count_student_assignments($row_user->user_id, $row->code, $session_id); $nb_assignments += Tracking::count_student_assignments($row_user->user_id, $row->code, $session_id);
$last_login_date_tmp = Tracking :: get_last_connection_date_on_the_course ($row_user->user_id, $courseId, $session_id, false); $last_login_date_tmp = Tracking::get_last_connection_date_on_the_course($row_user->user_id, $courseInfo, $session_id, false);
if($last_login_date_tmp != false && $last_login_date == false) { // TODO: To be cleaned. if ($last_login_date_tmp != false && $last_login_date == false) {
// TODO: To be cleaned.
$last_login_date = $last_login_date_tmp; $last_login_date = $last_login_date_tmp;
} else if($last_login_date_tmp != false && $last_login_date != false) { // TODO: Repeated previous condition! To be cleaned. } else if($last_login_date_tmp != false && $last_login_date != false) {
// TODO: Repeated previous condition! To be cleaned.
// Find the max and assign it to first_login_date // Find the max and assign it to first_login_date
if(strtotime($last_login_date_tmp) > strtotime($last_login_date)) { if(strtotime($last_login_date_tmp) > strtotime($last_login_date)) {
$last_login_date = $last_login_date_tmp; $last_login_date = $last_login_date_tmp;
@ -1779,6 +1781,7 @@ class MySpace
$result = Database::query($sql); $result = Database::query($sql);
while ($row = Database::fetch_object($result)) { while ($row = Database::fetch_object($result)) {
$courseId = $row->c_id; $courseId = $row->c_id;
$courseInfo = api_get_course_info_by_id($courseId);
$csv_row = array(); $csv_row = array();
$csv_row[] = $session_title; $csv_row[] = $session_title;
$csv_row[] = $row->title; $csv_row[] = $row->title;
@ -1825,7 +1828,7 @@ class MySpace
$last_login_date_tmp = Tracking:: get_last_connection_date_on_the_course( $last_login_date_tmp = Tracking:: get_last_connection_date_on_the_course(
$row_user->user_id, $row_user->user_id,
$courseId, $courseInfo,
$session_id, $session_id,
false false
); );
@ -2044,17 +2047,17 @@ class MySpace
} }
} }
// time spent in the course // time spent in the course
$csv_row[] = api_time_to_hms(Tracking :: get_time_spent_on_the_course ($user[4], $courseId)); $csv_row[] = api_time_to_hms(Tracking::get_time_spent_on_the_course ($user[4], $courseId));
// student progress in course // student progress in course
$csv_row[] = round(Tracking :: get_avg_student_progress ($user[4], $row[0]), 2); $csv_row[] = round(Tracking::get_avg_student_progress ($user[4], $row[0]), 2);
// student score // student score
$csv_row[] = round(Tracking :: get_avg_student_score ($user[4], $row[0]), 2); $csv_row[] = round(Tracking::get_avg_student_score($user[4], $row[0]), 2);
// student tes score // student tes score
$csv_row[] = round(Tracking :: get_avg_student_exercise_score ($user[4], $row[0]), 2); $csv_row[] = round(Tracking::get_avg_student_exercise_score($user[4], $row[0]), 2);
// student messages // student messages
$csv_row[] = Tracking :: count_student_messages ($user[4], $row[0]); $csv_row[] = Tracking::count_student_messages($user[4], $row[0]);
// student assignments // student assignments
$csv_row[] = Tracking :: count_student_assignments ($user[4], $row[0]); $csv_row[] = Tracking::count_student_assignments ($user[4], $row[0]);
// student exercises results // student exercises results
$exercises_results = MySpace::exercises_results($user[4], $row[0]); $exercises_results = MySpace::exercises_results($user[4], $row[0]);
$csv_row[] = $exercises_results['score_obtained']; $csv_row[] = $exercises_results['score_obtained'];
@ -2062,9 +2065,9 @@ class MySpace
$csv_row[] = $exercises_results['questions_answered']; $csv_row[] = $exercises_results['questions_answered'];
$csv_row[] = $exercises_results['percentage']; $csv_row[] = $exercises_results['percentage'];
// first connection // first connection
$csv_row[] = Tracking :: get_first_connection_date_on_the_course ($user[4], $courseId); $csv_row[] = Tracking::get_first_connection_date_on_the_course ($user[4], $courseId);
// last connection // last connection
$csv_row[] = strip_tags(Tracking :: get_last_connection_date_on_the_course ($user[4], $courseId)); $csv_row[] = strip_tags(Tracking::get_last_connection_date_on_the_course($user[4], $courseInfo));
$csv_content[] = $csv_row; $csv_content[] = $csv_row;
} }

@ -1531,19 +1531,19 @@ class Tracking
/** /**
* Get last user's connection date on the course * Get last user's connection date on the course
* @param int User id * @param int User id
* @param string Course code * @param array $courseInfo real_id and code are used
* @param int Session id (optional, default=0) * @param int Session id (optional, default=0)
* @return string|bool Date with format long without day or false if there is no date * @return string|bool Date with format long without day or false if there is no date
*/ */
public static function get_last_connection_date_on_the_course( public static function get_last_connection_date_on_the_course(
$student_id, $student_id,
$courseId, $courseInfo,
$session_id = 0, $session_id = 0,
$convert_date = true $convert_date = true
) { ) {
// protect data // protect data
$student_id = intval($student_id); $student_id = intval($student_id);
$courseId = intval($courseId); $courseId = $courseInfo['real_id'];
$session_id = intval($session_id); $session_id = intval($session_id);
$tbl_track_e_access = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS); $tbl_track_e_access = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS);
@ -1561,7 +1561,6 @@ class Tracking
if (empty($last_login_date) || $last_login_date == '0000-00-00 00:00:00') { if (empty($last_login_date) || $last_login_date == '0000-00-00 00:00:00') {
return false; return false;
} }
//$last_login_date_timestamp = api_strtotime($last_login_date, 'UTC');
//see #5736 //see #5736
$last_login_date_timestamp = api_strtotime($last_login_date); $last_login_date_timestamp = api_strtotime($last_login_date);
$now = time(); $now = time();
@ -1570,7 +1569,10 @@ class Tracking
if ($now - $last_login_date_timestamp > 604800) { if ($now - $last_login_date_timestamp > 604800) {
if ($convert_date) { if ($convert_date) {
$last_login_date = api_convert_and_format_date($last_login_date, DATE_FORMAT_SHORT); $last_login_date = api_convert_and_format_date($last_login_date, DATE_FORMAT_SHORT);
$icon = api_is_allowed_to_edit() ? '<a href="'.api_get_path(REL_CODE_PATH).'announcements/announcements.php?action=add&remind_inactive='.$student_id.'" title="'.get_lang('RemindInactiveUser').'"><img src="'.api_get_path(WEB_IMG_PATH).'messagebox_warning.gif" /> </a>': null; $icon = api_is_allowed_to_edit() ?
'<a href="'.api_get_path(REL_CODE_PATH).'announcements/announcements.php?action=add&remind_inactive='.$student_id.'&cidReq='.$courseInfo['code'].'" title="'.get_lang('RemindInactiveUser').'">
<img src="'.api_get_path(WEB_IMG_PATH).'messagebox_warning.gif" /> </a>'
: null;
return $icon. Display::label($last_login_date, 'warning'); return $icon. Display::label($last_login_date, 'warning');
} else { } else {
return $last_login_date; return $last_login_date;
@ -4304,7 +4306,7 @@ class Tracking
); );
$last_connection = Tracking :: get_last_connection_date_on_the_course( $last_connection = Tracking :: get_last_connection_date_on_the_course(
$user_id, $user_id,
$courseId $courseInfo
); );
if (is_null($progress)) { if (is_null($progress)) {
@ -4619,11 +4621,32 @@ class Tracking
); );
$weighting = 0; $weighting = 0;
$last_connection = Tracking :: get_last_connection_date_on_the_course($user_id, $courseId, $session_id_from_get); $last_connection = Tracking:: get_last_connection_date_on_the_course(
$progress = Tracking :: get_avg_student_progress($user_id, $course_code, array(), $session_id_from_get); $user_id,
$total_time_login = Tracking :: get_time_spent_on_the_course($user_id, $courseId, $session_id_from_get); $courseInfo,
$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,
$courseId,
$session_id_from_get
);
$time = api_time_to_hms($total_time_login); $time = api_time_to_hms($total_time_login);
$percentage_score = Tracking :: get_avg_student_score($user_id, $course_code, array(), $session_id_from_get);
$percentage_score = Tracking::get_avg_student_score(
$user_id,
$course_code,
array(),
$session_id_from_get
);
$courseCodeFromGet = isset($_GET['course']) ? $_GET['course'] : null; $courseCodeFromGet = isset($_GET['course']) ? $_GET['course'] : null;
if ($course_code == $courseCodeFromGet && $_GET['session_id'] == $session_id_from_get) { if ($course_code == $courseCodeFromGet && $_GET['session_id'] == $session_id_from_get) {
@ -6442,7 +6465,7 @@ class TrackingCourseLog
$user['count_assignments'] = Tracking::count_student_assignments($user['user_id'], $course_code, $session_id); $user['count_assignments'] = Tracking::count_student_assignments($user['user_id'], $course_code, $session_id);
$user['count_messages'] = Tracking::count_student_messages($user['user_id'], $course_code, $session_id); $user['count_messages'] = Tracking::count_student_messages($user['user_id'], $course_code, $session_id);
$user['first_connection'] = Tracking::get_first_connection_date_on_the_course($user['user_id'], $courseId, $session_id); $user['first_connection'] = Tracking::get_first_connection_date_on_the_course($user['user_id'], $courseId, $session_id);
$user['last_connection'] = Tracking::get_last_connection_date_on_the_course($user['user_id'], $courseId, $session_id); $user['last_connection'] = Tracking::get_last_connection_date_on_the_course($user['user_id'], $courseInfo, $session_id);
// we need to display an additional profile field // we need to display an additional profile field
$user['additional'] = ''; $user['additional'] = '';

@ -2248,8 +2248,8 @@ class learnpath
* Checks if the learning path is visible for student after the progress * Checks if the learning path is visible for student after the progress
* of its prerequisite is completed, considering the time availability and * of its prerequisite is completed, considering the time availability and
* the LP visibility. * the LP visibility.
* @param int Learnpath id * @param int $lp_id
* @param int Student id * @param int $student_id
* @param string Course code (optional) * @param string Course code (optional)
* @param int $sessionId * @param int $sessionId
* @return bool * @return bool

@ -53,6 +53,7 @@ class LearnpathList
$course_id = $course_info['real_id']; $course_id = $course_info['real_id'];
if (empty($course_id)) { if (empty($course_id)) {
return false; return false;
} }
@ -67,7 +68,7 @@ class LearnpathList
$order = "ORDER BY display_order ASC, name ASC"; $order = "ORDER BY display_order ASC, name ASC";
if (isset($order_by)) { if (isset($order_by)) {
$order = Database::parse_conditions(array('order'=>$order_by)); $order = Database::parse_conditions(array('order' => $order_by));
} }
$now = api_get_utc_datetime(); $now = api_get_utc_datetime();
@ -82,11 +83,11 @@ class LearnpathList
"; ";
} }
$categoryFilter = ''; if (!empty($categoryId)) {
if (!is_null($categoryId) && is_numeric($categoryId)) {
$categoryId = intval($categoryId); $categoryId = intval($categoryId);
$categoryFilter = " AND category_id = $categoryId"; $categoryFilter = " AND category_id = $categoryId";
} else {
$categoryFilter = " AND (category_id = 0 OR category_id IS NULL) ";
} }
$sql = "SELECT * FROM $lp_table $sql = "SELECT * FROM $lp_table
@ -97,7 +98,6 @@ class LearnpathList
$categoryFilter $categoryFilter
$order $order
"; ";
$res = Database::query($sql); $res = Database::query($sql);
$names = array(); $names = array();
while ($row = Database::fetch_array($res,'ASSOC')) { while ($row = Database::fetch_array($res,'ASSOC')) {
@ -181,10 +181,11 @@ class LearnpathList
'publicated_on' => $row['publicated_on'], 'publicated_on' => $row['publicated_on'],
'expired_on' => $row['expired_on'], 'expired_on' => $row['expired_on'],
//'category_id' => $row['category_id'], //'category_id' => $row['category_id'],
'subscribe_users' => $row['subscribe_users'] 'subscribe_users' => $row['subscribe_users'],
); );
$names[$row['name']] = $row['id']; $names[$row['name']] = $row['id'];
} }
$this->alpha_list = asort($names); $this->alpha_list = asort($names);
} }

@ -180,7 +180,7 @@ if (!empty($course_list)) {
$last_date = Tracking::get_last_connection_date_on_the_course( $last_date = Tracking::get_last_connection_date_on_the_course(
api_get_user_id(), api_get_user_id(),
$course_info['real_id'], $course_info,
$session_id, $session_id,
false false
); );

Loading…
Cancel
Save