From: sam_marshall Date: Fri, 24 Oct 2008 16:20:37 +0000 (+0000) Subject: MDL-17003: Completion progress report needs paging system as large reports can kill... X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=35da0e876855b82051c48ae97e48b05990773430;p=moodle.git MDL-17003: Completion progress report needs paging system as large reports can kill browser --- diff --git a/course/report/progress/index.php b/course/report/progress/index.php index 978ecd1359..99d0c27348 100644 --- a/course/report/progress/index.php +++ b/course/report/progress/index.php @@ -1,8 +1,9 @@ get_record('course',array('id'=>required_param('course',PARAM_INT))); if(!$course) { @@ -18,6 +19,9 @@ $format=optional_param('format','',PARAM_ALPHA); $excel=$format=='excelcsv'; $csv=$format=='csv' || $excel; +// Whether to start at a particular position +$start=optional_param('start',0,PARAM_INT); + // Whether to show idnumber // TODO: This should really not be using a config option 'intended' for // gradebook, but that option is also used in quiz reports as well. There ought @@ -54,8 +58,8 @@ $activities=$completion->get_activities(); if(count($activities)==0) { print_error('err_noactivities','completion',$reportsurl); } -$progress=$completion->get_progress_all($firstnamesort,$group); +$progress=$completion->get_progress_all($firstnamesort,$group,COMPLETION_REPORT_PAGE,$start); if($csv) { header('Content-Disposition: attachment; filename=progress.'. @@ -93,17 +97,47 @@ if($csv) { groups_print_course_menu($course,$CFG->wwwroot.'/course/report/progress/?course='.$course->id); } ++// Do we need a paging bar? +if($progress->total > COMPLETION_REPORT_PAGE) { + $pagingbar='
'; + + if($start>0) { + $newstart=$start-COMPLETION_REPORT_PAGE; + if($newstart<0) { + $newstart=0; + } + $pagingbar.=link_arrow_left(get_string('previous'),'./?course='.$course->id. + ($newstart ? '&start='.$newstart : ''),false,'completion_prev'); + } + + $a=new StdClass; + $a->from=$start+1; + $a->to=$start+COMPLETION_REPORT_PAGE; + $a->total=$progress->total; + $pagingbar.='

'.get_string('reportpage','completion',$a).'

'; + + if($start+COMPLETION_REPORT_PAGE < $progress->total) { + $pagingbar.=link_arrow_right(get_string('next'),'./?course='.$course->id. + '&start='.($start+COMPLETION_REPORT_PAGE),false,'completion_next'); + } + + $pagingbar.='
'; +} else { + $pagingbar=''; +} + // Okay, let's draw the table of progress info, // Start of table if(!$csv) { print '
'; // ugh - if(count($progress)==0) { + if(count($progress->users)==0) { print '

'.get_string('err_nousers','completion').'

'; print '

'.get_string('continue').'

'; print_footer($course); exit; } + print $pagingbar; print ''; // User heading / sort option @@ -166,7 +200,7 @@ if($csv) { } // Row for each user -foreach($progress as $user) { +foreach($progress->users as $user) { // User name if($csv) { print csv_quote(fullname($user)); @@ -186,9 +220,9 @@ foreach($progress as $user) { // Get progress information and state if(array_key_exists($activity->id,$user->progress)) { - $progress=$user->progress[$activity->id]; - $state=$progress->completionstate; - $date=userdate($progress->timemodified); + $thisprogress=$user->progress[$activity->id]; + $state=$thisprogress->completionstate; + $date=userdate($thisprogress->timemodified); } else { $state=COMPLETION_INCOMPLETE; $date=''; @@ -233,6 +267,7 @@ if($csv) { exit; } print '
'; +print $pagingbar; print '