version 1.10, 2004/12/16 22:04:41
|
version 1.13, 2005/02/09 21:21:08
|
Line 44 package Apache::lontrackstudent;
|
Line 44 package Apache::lontrackstudent;
|
|
|
use strict; |
use strict; |
use Apache::Constants qw(:common :http); |
use Apache::Constants qw(:common :http); |
|
use Apache::lonmysql; |
use Apache::lonnet(); |
use Apache::lonnet(); |
use Apache::lonlocal; |
use Apache::lonlocal; |
use Time::HiRes; |
use Time::HiRes; |
use Time::Local; |
|
|
|
sub get_data { |
sub get_data { |
my ($r,$prog_state,$navmap,$mode) = @_; |
my ($r,$prog_state,$navmap,$mode) = @_; |
Line 119 sub table_names {
|
Line 119 sub table_names {
|
my $prefix = $course.'_'.$domain.'_'; |
my $prefix = $course.'_'.$domain.'_'; |
# |
# |
my %tables = |
my %tables = |
( student => $prefix.'students', |
( student =>&Apache::lonmysql::fix_table_name($prefix.'students'), |
res => $prefix.'resource', |
res =>&Apache::lonmysql::fix_table_name($prefix.'resource'), |
machine => $prefix.'machine_table', |
machine =>&Apache::lonmysql::fix_table_name($prefix.'machine_table'), |
activity=> $prefix.'activity', |
activity=>&Apache::lonmysql::fix_table_name($prefix.'activity'), |
); |
); |
return %tables; |
return %tables; |
} |
} |
Line 178 sub get_max_time_in_db {
|
Line 178 sub get_max_time_in_db {
|
$timestr = &Apache::lonnet::unescape($line); |
$timestr = &Apache::lonnet::unescape($line); |
} |
} |
close(TIMEDATA); |
close(TIMEDATA); |
my ($year,$month,$day,$hour,$min,$sec) = |
return &Apache::lonmysql::unsqltime($timestr); |
($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; |
|
} |
} |
|
|
sub build_query { |
sub build_query { |
Line 232 sub output_results {
|
Line 225 sub output_results {
|
my ($r,$results_file,$navmap,$mode) = @_; |
my ($r,$results_file,$navmap,$mode) = @_; |
## |
## |
## |
## |
|
if (! -s $results_file) { |
|
# results file is empty, just let them know there is no data |
|
$r->print('<h2>'.&mt('No data was returned for your request').'</h2>'); |
|
return; |
|
} |
if (! open(ACTIVITYDATA,$results_file)) { |
if (! open(ACTIVITYDATA,$results_file)) { |
$r->print('<h2>'.&mt('Unable to read results file.').'</h2>'. |
$r->print('<h2>'.&mt('Unable to read results file.').'</h2>'. |
'<p>'. |
'<p>'. |
Line 281 sub output_results {
|
Line 279 sub output_results {
|
} |
} |
my ($symb,$timestamp,$student,$action,$machine,$values); |
my ($symb,$timestamp,$student,$action,$machine,$values); |
if ($mode eq 'full_class') { |
if ($mode eq 'full_class') { |
($symb,$timestamp,$student,$action,$machine,$values) = |
($symb,$timestamp,$student,$action,$machine,$values) = split(',',$line,6); |
map { &Apache::lonnet::unescape($_); } split(',',$line,6); |
|
} else { |
} else { |
($symb,$timestamp,$action,$machine,$values) = |
($symb,$timestamp,$action,$machine,$values) = split(',',$line,5); |
map { &Apache::lonnet::unescape($_); } split(',',$line,5); |
|
} |
} |
|
foreach ($symb,$timestamp,$student,$action,$machine) { |
|
$_=&Apache::lonnet::unescape($_); |
|
} |
my ($title,$src); |
my ($title,$src); |
if ($symb =~ m:^/adm/:) { |
if ($symb =~ m:^/adm/:) { |
$title = $symb; |
$title = $symb; |
Line 294 sub output_results {
|
Line 293 sub output_results {
|
} else { |
} else { |
my $nav_res = $navmap->getBySymb($symb); |
my $nav_res = $navmap->getBySymb($symb); |
if (defined($nav_res)) { |
if (defined($nav_res)) { |
$title = $nav_res->title(); |
$title = $nav_res->compTitle(); |
$src = $nav_res->src(); |
$src = $nav_res->src(); |
} else { |
} else { |
if ($src =~ m|^/res|) { |
if ($src =~ m|^/res|) { |
Line 334 sub output_results {
|
Line 333 sub output_results {
|
$class = 'warning'; |
$class = 'warning'; |
} |
} |
# Clean up the values |
# Clean up the values |
$values =~ s/counter=\d+$//; |
$values = &display_values($action,$values); |
# |
# |
# Build the row for output |
# Build the row for output |
my $tablerow = qq{<tr class="$class">}; |
my $tablerow = qq{<tr class="$class">}; |
if ($src =~ m|^/adm/|) { |
if ($src =~ m|^/adm/|) { |
$tablerow .= |
$tablerow .= |
'<td><nobr>'.$title.'</td>'; |
'<td valign="top"><nobr>'.$title.'</nobr></td>'; |
} else { |
} else { |
$tablerow .= |
$tablerow .= |
'<td><nobr>'. |
'<td valign="top"><nobr>'. |
'<a href="'.$src.'">'.$title.'</a>'. |
'<a href="'.$src.'">'.$title.'</a>'. |
'</nobr></td>'; |
'</nobr></td>'; |
} |
} |
$tablerow .= '<td><nobr>'.$timestamp.'</nobr></td>'; |
$tablerow .= '<td valign="top"><nobr>'.$timestamp.'</nobr></td>'; |
if ($mode eq 'full_class') { |
if ($mode eq 'full_class') { |
$tablerow.='<td>'.$student.'</td>'; |
$tablerow.='<td valign="top">'.$student.'</td>'; |
} |
} |
$tablerow .= |
$tablerow .= |
'<td>'.$action.'</td>'. |
'<td valign="top">'.$action.'</td>'. |
# '<td>'.$machine.'</td>'. |
# '<td>'.$machine.'</td>'. |
'<td>'.$values.'</td>'. |
'<td valign="top">'.$values.'</td>'. |
'</tr>'; |
'</tr>'; |
$r->print($tablerow.$/); |
$r->print($tablerow.$/); |
} |
} |
Line 365 sub output_results {
|
Line 364 sub output_results {
|
|
|
################################################################### |
################################################################### |
################################################################### |
################################################################### |
|
sub display_values { |
|
my ($action,$values)=@_; |
|
my $result='<table>'; |
|
if ($action eq 'CSTORE') { |
|
my %values=map {split('=',$_,-1)} split(/\&/,$values); |
|
foreach my $key (sort(keys(%values))) { |
|
$result.='<tr><td align="right">'. |
|
&Apache::lonnet::unescape($key). |
|
'</td><td>=</td><td align="left">'. |
|
&Apache::lonnet::unescape($values{$key}).'</td></tr>'; |
|
} |
|
$result.='</table>'; |
|
} elsif ($action eq 'POST') { |
|
my %values= |
|
map {split('=',&Apache::lonnet::unescape($_),-1)} split(/\&/,$values); |
|
foreach my $key (sort(keys(%values))) { |
|
if ($key eq 'counter') { next; } |
|
$result.='<tr><td align="right">'.$key.'</td>'. |
|
'<td>=</td><td align="left">'.$values{$key}.'</td></tr>'; |
|
} |
|
$result.='</table>'; |
|
} else { |
|
$result=&Apache::lonnet::unescape($values) |
|
} |
|
return $result; |
|
} |
|
################################################################### |
|
################################################################### |
sub request_data_update { |
sub request_data_update { |
my $command = 'prepare activity log'; |
my $command = 'prepare activity log'; |
my $cid = $ENV{'request.course.id'}; |
my $cid = $ENV{'request.course.id'}; |
Line 497 sub handler {
|
Line 524 sub handler {
|
($r,\%prog_state,&mt('Contacting course home server')); |
($r,\%prog_state,&mt('Contacting course home server')); |
# |
# |
my $result = &request_data_update(); |
my $result = &request_data_update(); |
if (ref($result) eq 'HASH') { |
|
$result = join(' ',map { $_.'=>'.$result->{$_}; } keys(%$result)); |
|
} |
|
# |
# |
if (exists($ENV{'form.selected_student'})) { |
if (exists($ENV{'form.selected_student'})) { |
# For now, just show all the data, in the future allow selection of |
# For now, just show all the data, in the future allow selection of |