--- loncom/interface/lontrackstudent.pm 2004/12/22 22:54:59 1.11 +++ loncom/interface/lontrackstudent.pm 2005/02/17 08:29:43 1.14 @@ -1,6 +1,6 @@ # The LearningOnline Network with CAPA # -# $Id: lontrackstudent.pm,v 1.11 2004/12/22 22:54:59 albertel Exp $ +# $Id: lontrackstudent.pm,v 1.14 2005/02/17 08:29:43 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -44,10 +44,10 @@ package Apache::lontrackstudent; use strict; use Apache::Constants qw(:common :http); +use Apache::lonmysql; use Apache::lonnet(); use Apache::lonlocal; use Time::HiRes; -use Time::Local; sub get_data { my ($r,$prog_state,$navmap,$mode) = @_; @@ -119,10 +119,10 @@ sub table_names { my $prefix = $course.'_'.$domain.'_'; # my %tables = - ( student => $prefix.'students', - res => $prefix.'resource', - machine => $prefix.'machine_table', - activity=> $prefix.'activity', + ( student =>&Apache::lonmysql::fix_table_name($prefix.'students'), + res =>&Apache::lonmysql::fix_table_name($prefix.'resource'), + machine =>&Apache::lonmysql::fix_table_name($prefix.'machine_table'), + activity=>&Apache::lonmysql::fix_table_name($prefix.'activity'), ); return %tables; } @@ -178,14 +178,7 @@ sub get_max_time_in_db { $timestr = &Apache::lonnet::unescape($line); } close(TIMEDATA); - my ($year,$month,$day,$hour,$min,$sec) = - ($timestr =~ /^(\d+)-(\d+)-(\d+) (\d+):(\d+):(\d+)/); - $month -= 1; # Good old timelocal - my $max_time = undef; - if (eval("&timelocal($sec,$min,$hour,$day,$month,$year)")) { - $max_time = &timelocal($sec,$min,$hour,$day,$month,$year); - } - return $max_time; + return &Apache::lonmysql::unsqltime($timestr); } sub build_query { @@ -232,6 +225,11 @@ sub output_results { my ($r,$results_file,$navmap,$mode) = @_; ## ## + if (! -s $results_file) { + # results file is empty, just let them know there is no data + $r->print('

'.&mt('No data was returned for your request').'

'); + return; + } if (! open(ACTIVITYDATA,$results_file)) { $r->print('

'.&mt('Unable to read results file.').'

'. '

'. @@ -503,7 +501,8 @@ sub handler { bug=>'instructor interface'}); # # Give the LON-CAPA page header - $r->print(''.&styles.''. + my $html=&Apache::lonxml::xmlbegin(); + $r->print($html.'<head>'.&styles().'<title>'. &mt('Student Activity'). "\n". &Apache::loncommon::bodytag('Student Activity'). @@ -526,9 +525,6 @@ sub handler { ($r,\%prog_state,&mt('Contacting course home server')); # my $result = &request_data_update(); - if (ref($result) eq 'HASH') { - $result = join(' ',map { $_.'=>'.$result->{$_}; } keys(%$result)); - } # if (exists($ENV{'form.selected_student'})) { # For now, just show all the data, in the future allow selection of