Fixing export csv of user reports + we can show more than 500 records in a table. See BT#1771

skala
Julio Montoya 15 years ago
parent 5676a19887
commit f5a6f77245
  1. 5
      main/inc/lib/sortabletable.class.php
  2. 21
      main/inc/lib/tracking.lib.php
  3. 7
      main/tracking/courseLog.php

@ -582,9 +582,10 @@ class SortableTable extends HTML_Table {
for ($nr = 10; $nr <= min(50, $total_number_of_items); $nr += 10) { for ($nr = 10; $nr <= min(50, $total_number_of_items); $nr += 10) {
$result[] = '<option value="'.$nr.'" '. ($nr == $this->per_page ? 'selected="selected"' : '').'>'.$nr.'</option>'; $result[] = '<option value="'.$nr.'" '. ($nr == $this->per_page ? 'selected="selected"' : '').'>'.$nr.'</option>';
} }
if ($total_number_of_items < 500) { // @todo no limits
//if ($total_number_of_items < 500) {
$result[] = '<option value="'.$total_number_of_items.'" '. ($total_number_of_items == $this->per_page ? 'selected="selected"' : '').'>'.api_ucfirst(get_lang('All')).'</option>'; $result[] = '<option value="'.$total_number_of_items.'" '. ($total_number_of_items == $this->per_page ? 'selected="selected"' : '').'>'.api_ucfirst(get_lang('All')).'</option>';
} //}
$result[] = '</select>'; $result[] = '</select>';
$result[] = '<noscript>'; $result[] = '<noscript>';
$result[] = '<button class="save" type="submit">'.get_lang('Save').'</button>'; $result[] = '<button class="save" type="submit">'.get_lang('Save').'</button>';

@ -584,14 +584,11 @@ class Tracking {
if ($count_row_lp>0 && !empty($student_id)) { if ($count_row_lp>0 && !empty($student_id)) {
// Get all views through learning paths filter // Get all views through learning paths filter
$sql = "SELECT MAX(view_count) as vc, id, progress, lp_id, user_id ". //@todo problem whe course have more than 1500 users
"FROM $lp_view_table ". $sql = "SELECT MAX(view_count) as vc, id, progress, lp_id, user_id FROM $lp_view_table ".
"WHERE lp_id IN (".implode(',',$lp_list).") ". "WHERE lp_id IN (".implode(',',$lp_list).") $condition_user1 AND session_id= $session_id GROUP BY lp_id,user_id";
"$condition_user1 AND session_id= $session_id GROUP BY lp_id,user_id"; //var_dump( $sql );
//var_dump( $sql );
$rs_last_lp_view_id = Database::query($sql); $rs_last_lp_view_id = Database::query($sql);
$global_count_item = 0; $global_count_item = 0;
$global_result = 0; $global_result = 0;
@ -606,12 +603,10 @@ class Tracking {
// For the currently analysed view, get the score and // For the currently analysed view, get the score and
// max_score of each item if it is a sco or a TOOL_QUIZ // max_score of each item if it is a sco or a TOOL_QUIZ
$sql_max_score = "SELECT lp_iv.score as score,lp_i.max_score, lp_iv.max_score as max_score_item_view, lp_i.path, lp_i.item_type , lp_i.id as iid". $sql_max_score = "SELECT lp_iv.score as score,lp_i.max_score, lp_iv.max_score as max_score_item_view, lp_i.path, lp_i.item_type, lp_i.id as iid".
" FROM $lp_item_view_table as lp_iv ". " FROM $lp_item_view_table as lp_iv INNER JOIN $lp_item_table as lp_i ".
" INNER JOIN $lp_item_table as lp_i ".
" ON lp_i.id = lp_iv.lp_item_id ". " ON lp_i.id = lp_iv.lp_item_id ".
" AND (lp_i.item_type='sco' ". " AND (lp_i.item_type='sco' OR lp_i.item_type='".TOOL_QUIZ."') ".
" OR lp_i.item_type='".TOOL_QUIZ."') ".
" WHERE lp_view_id='$lp_view_id'"; " WHERE lp_view_id='$lp_view_id'";
//echo $sql_max_score; echo '<br />'; //echo $sql_max_score; echo '<br />';
@ -663,6 +658,7 @@ class Tracking {
" AND orig_lp_item_id = '$item_id' ". " AND orig_lp_item_id = '$item_id' ".
" AND exe_cours_id = '$course_code' AND session_id = $session_id". " AND exe_cours_id = '$course_code' AND session_id = $session_id".
" ORDER BY exe_date DESC limit 1"; " ORDER BY exe_date DESC limit 1";
$result_last_attempt = Database::query($sql_last_attempt); $result_last_attempt = Database::query($sql_last_attempt);
$num = Database :: num_rows($result_last_attempt); $num = Database :: num_rows($result_last_attempt);
if ($num > 0 ) { if ($num > 0 ) {
@ -2317,6 +2313,7 @@ class TrackingCourseLog {
$number_of_items = intval($number_of_items); $number_of_items = intval($number_of_items);
$sql .= " ORDER BY col$column $direction "; $sql .= " ORDER BY col$column $direction ";
$sql .= " LIMIT $from,$number_of_items"; $sql .= " LIMIT $from,$number_of_items";
$res = Database::query($sql); $res = Database::query($sql);
$users = array (); $users = array ();
$t = time(); $t = time();

@ -175,11 +175,13 @@ if ($_GET['studentlist'] == 'false') {
if (isset($_GET['additional_profile_field'])) { if (isset($_GET['additional_profile_field'])) {
$addional_param ='additional_profile_field='.intval($_GET['additional_profile_field']); $addional_param ='additional_profile_field='.intval($_GET['additional_profile_field']);
} }
echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&export=csv&'.$addional_param.'">'.Display::return_icon('csv.gif',get_lang('ExportAsCSV')).get_lang('ExportAsCSV').'</a>'; if (isset($_GET['users_tracking_per_page'])) {
$users_tracking_per_page= '&users_tracking_per_page='.intval($_GET['users_tracking_per_page']);
}
echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&export=csv&'.$addional_param.$users_tracking_per_page.'">'.Display::return_icon('csv.gif',get_lang('ExportAsCSV')).get_lang('ExportAsCSV').'</a>';
} }
echo '</div>'; echo '</div>';
if ($_GET['studentlist'] == 'false') { if ($_GET['studentlist'] == 'false') {
$course_code = api_get_course_id(); $course_code = api_get_course_id();
@ -558,6 +560,7 @@ if ($_GET['studentlist'] == 'false') {
} }
ob_end_clean(); ob_end_clean();
array_unshift($csv_content, $csv_headers); // Adding headers before the content. array_unshift($csv_content, $csv_headers); // Adding headers before the content.
Export :: export_table_csv($csv_content, 'reporting_student_list'); Export :: export_table_csv($csv_content, 'reporting_student_list');
exit; exit;
} }

Loading…
Cancel
Save