[svn r11897] Allow the table sort

skala
Julian Prud'homme 19 years ago
parent c734bdb9e4
commit fb95e6e19d
  1. 35
      main/mySpace/index.php
  2. 2
      main/mySpace/student.php

@ -53,7 +53,14 @@ function count_coaches()
return $total_no_coachs; return $total_no_coachs;
} }
function sort_users($a, $b)
{
global $tracking_column;
if($a[$tracking_column] > $b[$tracking_column])
return 1;
else
return -1;
}
/************************** /**************************
* MAIN CODE * MAIN CODE
@ -424,6 +431,8 @@ if(api_is_allowed_to_create_course() && $view=='teacher')
$table = new SortableTable('tracking_list_course', 'count_teacher_courses'); $table = new SortableTable('tracking_list_course', 'count_teacher_courses');
$parameters['view'] = 'teacher';
$table->set_additional_parameters($parameters);
$table -> set_header(0, get_lang('CourseTitle'), false, 'align="center"'); $table -> set_header(0, get_lang('CourseTitle'), false, 'align="center"');
$table -> set_header(1, get_lang('NbStudents'), false); $table -> set_header(1, get_lang('NbStudents'), false);
$table -> set_header(2, get_lang('TimeSpentInTheCourse'), false); $table -> set_header(2, get_lang('TimeSpentInTheCourse'), false);
@ -533,7 +542,12 @@ if(api_is_allowed_to_create_course() && $view=='teacher')
if(api_is_platform_admin() && $view=='admin'){ if(api_is_platform_admin() && $view=='admin'){
$tracking_column = isset($_GET['tracking_list_coaches_column']) ? $_GET['tracking_list_coaches_column'] : 0;
$tracking_direction = isset($_GET['tracking_list_coaches_direction']) ? $_GET['tracking_list_coaches_direction'] : DESC;
$table = new SortableTable('tracking_list_coaches', 'count_coaches'); $table = new SortableTable('tracking_list_coaches', 'count_coaches');
$parameters['view'] = 'admin';
$table->set_additional_parameters($parameters);
$table -> set_header(0, get_lang('FirstName'), true, 'align="center"'); $table -> set_header(0, get_lang('FirstName'), true, 'align="center"');
$table -> set_header(1, get_lang('LastName'), true, 'align="center"'); $table -> set_header(1, get_lang('LastName'), true, 'align="center"');
$table -> set_header(2, get_lang('TimeSpentOnThePlatform'), false); $table -> set_header(2, get_lang('TimeSpentOnThePlatform'), false);
@ -562,6 +576,8 @@ if(api_is_platform_admin() && $view=='admin'){
$result_coaches=api_sql_query($sqlCoachs, __FILE__, __LINE__); $result_coaches=api_sql_query($sqlCoachs, __FILE__, __LINE__);
$total_no_coachs = mysql_num_rows($result_coaches); $total_no_coachs = mysql_num_rows($result_coaches);
$all_datas=array();
while($a_coachs=mysql_fetch_array($result_coaches)){ while($a_coachs=mysql_fetch_array($result_coaches)){
$time_on_platform = api_time_to_hms(Tracking :: get_time_spent_on_the_platform($a_coachs['user_id'])); $time_on_platform = api_time_to_hms(Tracking :: get_time_spent_on_the_platform($a_coachs['user_id']));
@ -579,7 +595,7 @@ if(api_is_platform_admin() && $view=='admin'){
$table_row[] = $nb_courses; $table_row[] = $nb_courses;
$table_row[] = $nb_sessions; $table_row[] = $nb_sessions;
$table_row[] = '<a href="student.php?id_coach='.$a_coachs['user_id'].'"><img src="'.api_get_path(WEB_IMG_PATH).'2rightarrow.gif" border="0" /></a>'; $table_row[] = '<a href="student.php?id_coach='.$a_coachs['user_id'].'"><img src="'.api_get_path(WEB_IMG_PATH).'2rightarrow.gif" border="0" /></a>';
$table -> addRow($table_row, 'align="right"'); $all_datas[] = $table_row;
$csv_content[] = array( $csv_content[] = array(
$a_coachs['firstname'], $a_coachs['firstname'],
@ -591,6 +607,21 @@ if(api_is_platform_admin() && $view=='admin'){
); );
} }
usort($all_datas, 'sort_users');
if($tracking_direction == 'ASC')
rsort($all_datas);
if($export_csv)
{
usort($csv_content, 'sort_users');
}
foreach($all_datas as $row)
{
$table -> addRow($row,'align="right"');
}
$table -> updateColAttributes(0,array('align'=>'left')); $table -> updateColAttributes(0,array('align'=>'left'));
$table -> updateColAttributes(1,array('align'=>'left')); $table -> updateColAttributes(1,array('align'=>'left'));
$table -> updateColAttributes(3,array('align'=>'left')); $table -> updateColAttributes(3,array('align'=>'left'));

@ -112,7 +112,7 @@ if($isCoach || api_is_platform_admin())
$table -> set_header(4, get_lang('Score'),false); $table -> set_header(4, get_lang('Score'),false);
$table -> set_header(5, get_lang('Student_publication'),false); $table -> set_header(5, get_lang('Student_publication'),false);
$table -> set_header(6, get_lang('Messages'),false); $table -> set_header(6, get_lang('Messages'),false);
$table -> set_header(7, get_lang('LatestLogin'), 'align="center'); $table -> set_header(7, get_lang('LatestLogin'), false);
$table -> set_header(8, get_lang('Details'),false); $table -> set_header(8, get_lang('Details'),false);
if($export_csv) if($export_csv)

Loading…
Cancel
Save