Should fix bug in session reports see #5175

skala
Julio Montoya 13 years ago
parent 97f3988a5e
commit a93694cae4
  1. 8
      main/inc/lib/sessionmanager.lib.php
  2. 53
      main/mySpace/index.php
  3. 6
      main/mySpace/myspace.lib.php
  4. 23
      main/mySpace/student.php

@ -295,7 +295,6 @@ class SessionManager {
$session['session_active'] = Display::return_icon('error.png', get_lang('Inactive'), array(), ICON_SIZE_SMALL);
}
if ($session['date_start'] == '0000-00-00') {
$session['date_start'] = '';
}
@ -313,8 +312,8 @@ class SessionManager {
case SESSION_INVISIBLE: //3
$session['visibility'] = api_ucfirst(get_lang('Invisible'));
break;
}
$formatted_sessions[] = $session;
}
$formatted_sessions[] = $session;
}
}
@ -603,8 +602,7 @@ class SessionManager {
while($row = Database::fetch_array($result)) {
$course_list[]=$row['course_code'];
}
if ($send_email) {
//global $_configuration;
//sending emails only

@ -205,8 +205,7 @@ if (empty($session_id)) {
$count_sessions = count($sessions);
//Students
$nb_students = count($students);
$nb_students = count($students);
$total_time_spent = 0;
$total_courses = 0;
@ -287,9 +286,8 @@ if (empty($session_id)) {
$csv_content[] = array();
} else {
// html part
echo '
<div class="report_section">
<table class="data_table">
echo '<div class="report_section">
<table class="table table-bordered">
<tr>
<td>'.get_lang('InactivesStudents').'</td>
<td align="right">'.$nb_inactive_students.'</td>
@ -307,7 +305,7 @@ if (empty($session_id)) {
<td align="right">'.(is_null($avg_total_progress) ? '' : round($avg_total_progress, 2).'%').'</td>
</tr>
<tr>
<td>'.get_lang('AverageResultsToTheExercices').'</td>
<td>'.get_lang('AvgCourseScore').'</td>
<td align="right">'.(is_null($avg_results_to_exercises) ? '' : round($avg_results_to_exercises, 2).'%').'</td>
</tr>
<tr>
@ -438,22 +436,14 @@ if (api_is_allowed_to_create_course() && $view == 'teacher') {
$nb_sessions_past = $nb_sessions_future = $nb_sessions_current = 0;
$courses = array();
foreach ($sessions as $session) {
if ($session['date_start'] == '0000-00-00') {
$nb_sessions_current ++;
} else {
$date_start = explode('-', $session['date_start']);
$time_start = mktime(0, 0, 0, $date_start[1], $date_start[2], $date_start[0]);
$date_end = explode('-', $session['date_end']);
$time_end = mktime(0, 0, 0, $date_end[1], $date_end[2], $date_end[0]);
if ($time_start < time() && time() < $time_end) {
$nb_sessions_current++;
} elseif (time() < $time_start) {
$nb_sessions_future++;
} elseif (time() > $time_end) {
$nb_sessions_past++;
}
}
foreach ($sessions as $session) {
$visibility = api_get_session_visibility($session['id']);
if ($visibility == SESSION_AVAILABLE) {
$nb_sessions_current ++;
} else {
$nb_sessions_past++;
}
$courses = array_merge($courses, Tracking::get_courses_list_from_session($session['id']));
}
@ -469,28 +459,29 @@ if (api_is_allowed_to_create_course() && $view == 'teacher') {
//csv part
$csv_content[] = array(get_lang('Sessions', ''));
$csv_content[] = array(get_lang('NbActiveSessions', '').';'.$nb_sessions_current);
$csv_content[] = array(get_lang('NbPastSessions', '').';'.$nb_sessions_past);
$csv_content[] = array(get_lang('NbFutureSessions', '').';'.$nb_sessions_future);
$csv_content[] = array(get_lang('NbInactiveSessions', '').';'.$nb_sessions_past);
//$csv_content[] = array(get_lang('NbFutureSessions', '').';'.$nb_sessions_future);
$csv_content[] = array(get_lang('NbStudentPerSession', '').';'.$nb_students_per_session);
$csv_content[] = array(get_lang('NbCoursesPerSession', '').';'.$nb_courses_per_session);
$csv_content[] = array();
} else {
// html part
/*<tr>
<td>'.get_lang('NbFutureSessions').'</td>
<td align="right">'.$nb_sessions_future.'</td>
</tr>*/
echo '
<div class="report_section">
<table class="data_table">
<table class="table table-bordered">
<tr>
<td>'.get_lang('NbActiveSessions').'</td>
<td align="right">'.$nb_sessions_current.'</td>
</tr>
<tr>
<td>'.get_lang('NbPastSessions').'</td>
<td>'.get_lang('NbInactiveSessions').'</td>
<td align="right">'.$nb_sessions_past.'</td>
</tr>
<tr>
<td>'.get_lang('NbFutureSessions').'</td>
<td align="right">'.$nb_sessions_future.'</td>
</tr>
</tr>
<tr>
<td>'.get_lang('NbStudentPerSession').'</td>
<td align="right">'.(is_null($nb_students_per_session) ? '' : $nb_students_per_session).'</td>

@ -1220,8 +1220,6 @@ class MySpace {
* @return array
*/
function get_course_data($from, $number_of_items, $column, $direction) {
global $courses, $csv_content, $charset, $session_id;
// definition database tables
@ -1252,7 +1250,7 @@ class MySpace {
$res = Database::query($sql);
while ($row_course = Database::fetch_row($res)) {
$course_code = $row_course[0];
$course_info = api_get_course_info($course_code);
$avg_assignments_in_course = $avg_messages_in_course = $nb_students_in_course = $avg_progress_in_course = $avg_score_in_course = $avg_time_spent_in_course = $avg_score_in_exercise = 0;
@ -1271,7 +1269,7 @@ class MySpace {
$nb_students_in_course = count($users);
$avg_assignments_in_course = Tracking::count_student_assignments($users, $course_code, $session_id);
$avg_messages_in_course = Tracking::count_student_messages($users, $course_code, $session_id);
$avg_progress_in_course = Tracking::get_avg_student_progress($users, $course_code, array(), $session_id);
$avg_progress_in_course = Tracking::get_avg_student_progress($users, $course_code, array(), $session_id);
$avg_score_in_course = Tracking::get_avg_student_score($users, $course_code, array(), $session_id);
$avg_score_in_exercise = Tracking::get_avg_student_exercise_score($users, $course_code, 0, $session_id);

@ -21,10 +21,10 @@ if (isset($_GET['id_coach']) && intval($_GET['id_coach']) != 0) {
$sql = 'SELECT lastname, firstname FROM '.Database::get_main_table(TABLE_MAIN_USER).' WHERE user_id='.intval($_GET['id_coach']);
$rs = Database::query($sql);
$coach_name = api_get_person_name(Database::result($rs, 0, 1), Database::result($rs, 0, 0));
$title = get_lang('Students').' - '.$coach_name;
$page_title = get_lang('Students').' - '.$coach_name;
} else {
$nameTools = get_lang("Students");
$title = get_lang('Students');
$page_title = get_lang('Students');
}
$this_section = SECTION_TRACKING;
@ -67,7 +67,7 @@ function rsort_users($a, $b) {
}
}
/* MAIN CODE */
/* MAIN CODE */
//if ($isCoach || api_is_platform_admin() || api_is_drh()) {
if (api_is_allowed_to_create_course() || api_is_drh()) {
@ -78,7 +78,7 @@ if (api_is_allowed_to_create_course() || api_is_drh()) {
}
$sort_by_first_name = api_sort_by_first_name();
if (api_is_drh()) {
if (api_is_drh()) {
$menu_items = array();
$menu_items[] = Display::url(Display::return_icon('stats.png', get_lang('MyStats'),'',ICON_SIZE_MEDIUM),api_get_path(WEB_CODE_PATH)."auth/my_progress.php" );
$menu_items[] = Display::return_icon('user_na.png', get_lang('Students'), array(), 32);
@ -100,15 +100,15 @@ if (api_is_allowed_to_create_course() || api_is_drh()) {
echo Display::url(Display::return_icon('export_csv.png', get_lang('ExportAsCSV'), array(), 32), api_get_self().'?export=csv');
echo '</span>';
//}
echo '</div>';
echo Display::page_subheader($title);
echo '</div>';
} else {
echo '<div class="actions"><div style="float:right;">
<a href="javascript: void(0);" onclick="javascript: window.print();"><img align="absbottom" src="../img/printmgr.gif">&nbsp;'.get_lang('Print').'</a>
<a href="'.api_get_self().'?export=csv"><img align="absbottom" src="../img/excel.gif">&nbsp;'.get_lang('ExportAsCSV').'</a>
</div></div>';
echo Display::page_subheader($title);
</div></div>';
}
echo Display::page_subheader($page_title);
if (isset($_GET['id_coach'])) {
$coach_id = intval($_GET['id_coach']);
@ -116,13 +116,13 @@ if (api_is_allowed_to_create_course() || api_is_drh()) {
$coach_id = api_get_user_id();
}
if (api_is_drh()) {
$title = get_lang('YourStudents');
$page_title = get_lang('YourStudents');
if (!isset($_GET['id_session'])) {
if (isset($_GET['user_id'])) {
$user_id = intval($_GET['user_id']);
$user_info = api_get_user_info($user_id);
$title = api_get_person_name($user_info['firstname'], $user_info['lastname']).' : '.get_lang('Students');
$page_title = api_get_person_name($user_info['firstname'], $user_info['lastname']).' : '.get_lang('Students');
$courses_by_teacher = CourseManager::get_course_list_of_user_as_course_admin($user_id);
$students_by_course = array();
if (!empty($courses_by_teacher)) {
@ -154,8 +154,7 @@ if (api_is_allowed_to_create_course() || api_is_drh()) {
if (isset($courses[0])) {
$courses = $courses[0];
}
//Getting students
//Getting students
$students = CourseManager::get_user_list_from_courses_as_coach($coach_id);
} else {

Loading…
Cancel
Save