--- loncom/interface/lontrackstudent.pm 2006/05/30 12:46:09 1.20 +++ loncom/interface/lontrackstudent.pm 2008/12/11 14:55:15 1.24 @@ -1,6 +1,6 @@ # The LearningOnline Network with CAPA # -# $Id: lontrackstudent.pm,v 1.20 2006/05/30 12:46:09 www Exp $ +# $Id: lontrackstudent.pm,v 1.24 2008/12/11 14:55:15 bisitz Exp $ # # Copyright Michigan State University Board of Trustees # @@ -110,12 +110,21 @@ sub get_data { &Apache::lonhtmlcommon::Update_PrgWin ($r,$prog_state,&mt('Parsing results')); # - &output_results($r,$results_file,$navmap,$mode); + my $last = &output_results($r,$results_file,$navmap,$mode); my ($sname,$sdom) = ($mode=~/^student:(.*):(.*)$/); - $r->print(&Apache::loncommon::track_student_link( - 'View more activity by this student', - $sname,$sdom,undef, - ($env{'form.start'}+$num_records))); + + my ($text,$inc); + if ( $last > 0 && (($last+1) >= $env{'form.start'}+$num_records) ) { + $text = 'View more activity by this student'; + $inc = $num_records; + $r->print(&Apache::loncommon::track_student_link($text,$sname,$sdom,undef, + ($env{'form.start'}+$inc) + )); + $r->print('
'); + } + $text = 'Resubmit last request to check for newer data'; + $r->print(&Apache::loncommon::track_student_link($text,$sname,$sdom,undef, + $env{'form.start'})); &Apache::lonhtmlcommon::Update_PrgWin($r,$prog_state,&mt('Finished!')); return; @@ -239,7 +248,7 @@ sub output_results { if (! -s $results_file) { # results file is empty, just let them know there is no data $r->print('

'.&mt('So far, no data has been returned for your request').'

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

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

'. @@ -248,7 +257,7 @@ sub output_results { 'You should contact your system administrator '. 'to resolve this issue.'). '

'); - return; + return -2; } ## ## @@ -307,10 +316,11 @@ sub output_results { $title = $nav_res->compTitle(); $src = $nav_res->src(); } else { - if ($src =~ m|^/res|) { - $title = $src; - } elsif ($values =~ /^\s*$/ && - (! defined($src) || $src =~ /^\s*$/)) { + $src = $symb; + if ($src !~ m{/adm}) { + $title = &Apache::lonnet::gettitle($src); + } elsif ($values =~ /^\s*$/ && + (! defined($src) || $src =~ /^\s*$/)) { next; } elsif ($values =~ /^\s*$/) { $values = $src; @@ -350,14 +360,14 @@ sub output_results { my $tablerow = qq{}.($count+1).qq{}; if ($src =~ m|^/adm/|) { $tablerow .= - ''.$title.''; + ''.$title.''; } else { $tablerow .= - ''. + ''. ''.$title.''. - ''; + ''; } - $tablerow .= ''.$timestamp.''; + $tablerow .= ''.$timestamp.''; if ($mode eq 'full_class') { $tablerow.=''.$student.''; } @@ -370,7 +380,7 @@ sub output_results { } $r->print(''.$/);### if (! $count % 50); close(ACTIVITYDATA); - return; + return $count; } ################################################################### @@ -388,8 +398,11 @@ sub display_values { } $result.=''; } elsif ($action eq 'POST') { - my %values= - map {split('=',&unescape($_),-1)} split(/\&/,$values); + my %values; + foreach my $pair (split(/\&/,$values)) { + my ($key,$value) = split('=',&unescape($pair),-1); + $values{$key} = $value; + } foreach my $key (sort(keys(%values))) { if ($key eq 'counter') { next; } $result.=''.$key.''. @@ -537,9 +550,10 @@ sub handler { # For now, just show all the data, in the future allow selection of # a student my ($sname,$sdom) = split(':',$env{'form.selected_student'}); - if ($sname =~ /^\w*$/ && $sdom =~ /^\w*$/) { + if ($sname =~ /^$LONCAPA::username_re$/ + && $sdom =~ /^$LONCAPA::domain_re$/) { $r->print('

'. - &mt('Recent activity of [_1]@[_2]',$sname,$sdom). + &mt('Recent activity of [_1]:[_2]',$sname,$sdom). '

'); $r->print('

'.&mt(<'); Compiling student activity data can take a long time. @@ -548,7 +562,7 @@ END &get_data($r,\%prog_state,$navmap, 'student:'.$env{'form.selected_student'}); } else { - $r->print('

'.&mt('Unable to process for [_1]@[_2]', + $r->print('

'.&mt('Unable to process for [_1]:[_2]', $sname,$sdom).'

'); } } else {