--- loncom/interface/lontrackstudent.pm 2004/08/19 21:07:35 1.3
+++ loncom/interface/lontrackstudent.pm 2004/08/23 15:03:15 1.4
@@ -1,6 +1,6 @@
# The LearningOnline Network with CAPA
#
-# $Id: lontrackstudent.pm,v 1.3 2004/08/19 21:07:35 matthew Exp $
+# $Id: lontrackstudent.pm,v 1.4 2004/08/23 15:03:15 matthew Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -71,16 +71,18 @@ sub get_all_data {
my $activity_table = $prefix.'activity';
#
$query = qq{
- select B.resource,A.time,C.student,D.action,E.machine,A.action_values
+ SELECT B.resource,A.time,C.student,D.action,E.machine,A.action_values
FROM $activity_table AS A
- LEFT JOIN $res_table AS B ON B.res_id=A.res_id
+ LEFT JOIN $res_table AS B ON B.res_id=A.res_id
LEFT JOIN $student_table AS C ON C.student_id=A.student_id
LEFT JOIN $action_table AS D ON D.action_id=A.action_id
LEFT JOIN $machine_table AS E ON E.machine_id=A.machine_id
- LIMIT 500
+ WHERE A.student_id>10
+ ORDER BY A.time ASC
+ LIMIT 5000
};
$query =~ s|$/||g;
- # &Apache::lonnet::logthis($query);
+ &Apache::lonnet::logthis($query);
##
## Send it along
my $reply=&Apache::lonnet::metadata_query($query,undef,undef,[$home]);
@@ -100,9 +102,10 @@ sub get_all_data {
my $maxtime = 500;
my $starttime = time;
while (! -e $endfile && (time-$starttime < $maxtime)) {
- sleep(1);
&Apache::lonhtmlcommon::Update_PrgWin
- ($r,$prog_state,&mt('Waiting for results'));
+ ($r,$prog_state,&mt('Waiting up to [_1] seconds for results',
+ $starttime+$maxtime-time));
+ sleep(1);
}
if (! -e $endfile) {
$r->print('
'.
@@ -112,10 +115,21 @@ sub get_all_data {
}
&Apache::lonhtmlcommon::Update_PrgWin
($r,$prog_state,&mt('Parsing results'));
+ &output_results($r,$results_file,$navmap);
+ &Apache::lonhtmlcommon::Update_PrgWin
+ ($r,$prog_state,&mt('Finished!'));
+ return;
+}
+
+sub output_results {
+ my ($r,$results_file,$navmap) = @_;
if (! open(ACTIVITYDATA,$results_file)) {
- $r->print(''.
- &mt('Unable to read results file. This is a serious error and has been logged. You should contact your system administrator to resolve this issue. If you are the system administrator, I feel sorry for you.').
- '
');
+ $r->print(''.&mt('Unable to read results file.').'
'.
+ '
'.
+ &mt('This is a serious error and has been logged. '.
+ 'You should contact your system administrator '.
+ 'to resolve this issue.').
+ '
');
return;
}
my $tableheader =
@@ -127,7 +141,7 @@ sub get_all_data {
''.&mt('Originating Server').' | '.
''.&mt('Data').' | '.
''.$/;
- my $count =0;
+ my $count = 0;
$r->print($tableheader);
$r->rflush();
while (my $line = ) {
@@ -140,34 +154,51 @@ sub get_all_data {
my ($symb,$timestamp,$student,$action,$machine,$values) =
map { &Apache::lonnet::unescape($_); } split(',',$line,6);
my ($title,$src);
- if ($symb =~ m:^/(res|adm)/:) {
+ if ($symb =~ m:^/adm/:) {
$title = $symb;
$src = $symb;
+ } elsif ($symb eq '/prtspool/') {
+ $title = "Printout";
+ $src = undef;
} else {
- # We may need to add 'uploaded/' to the symb
- #
- # Hey, guess what - navmaps->getBySymb
- # does not work with uploaded resources/new style courses/something
- # The fact that our symbs do not have uploaded/ prepended to them
- # then they (most often but not always) should, is likely to be
- # a puzzle too.
- #&Apache::lonnet::logthis('trackstudent:symb = '.$symb);
- # my $nav_res = $navmap->getBySymb($symb);
- $title = 'resource title goes here'; # $nav_res->title();
- $src = '/dev/null'; # $nav_res->src();
+ my $nav_res = $navmap->getBySymb($symb);
+ if (defined($nav_res)) {
+ $title = $nav_res->title();
+ $src = $nav_res->src();
+ } else {
+ $title = 'unable to retrieve title';
+ $src = '/dev/null';
+ }
}
- $r->print(''.
- ''.''.$title.''.' | '.
+ my $class = '';
+ #
+ if ($symb eq '/printout/') {
+ $class = 'print';
+ $title = 'retrieve printout';
+ } elsif ($symb =~ m|^/adm/([^/]+)|) {
+ $class = $1;
+ } elsif ($symb =~ m|^/adm/|) {
+ $class = 'adm';
+ }
+ if ($title eq 'unable to retrieve title') {
+ $title =~ s/ /\ /g;
+ $class = 'warning';
+ }
+ if (! defined($title) || $title eq '') {
+ $title = 'untitled';
+ $class = 'warning';
+ }
+ $r->print('
'.
+ ''.$title.''.' | '.
''.$timestamp.' | '.
''.$student.' | '.
''.$action.' | '.
''.$machine.' | '.
- ''.$values.' | '.'
'.$/);
+ ''.($class?$symb:'').' | '.''.$/);
+# ''.$symb.' | '.''.$/);
}
$r->print(''.$/);
close(ACTIVITYDATA);
- &Apache::lonhtmlcommon::Update_PrgWin
- ($r,$prog_state,&mt('Finished!'));
return;
}
@@ -190,6 +221,21 @@ sub request_data_update {
###################################################################
###################################################################
+sub styles {
+ return <
+ tr.warning { background-color: red; }
+ tr.chat { background-color: yellow; }
+ tr.chatfetch { background-color: yellow; }
+ tr.navmaps { background-color: \#777777; }
+ tr.roles { background-color: \#999999; }
+ tr.flip { background-color: \#BBBBBB; }
+ tr.adm { background-color: green; }
+ tr.print { background-color: blue; }
+ tr.printout { background-color: blue; }
+
+END
+}
###################################################################
###################################################################
@@ -241,7 +287,7 @@ sub handler {
bug=>'instructor interface'});
#
# Give the LON-CAPA page header
- $r->print(''.
+ $r->print(''.&styles.''.
&mt('Student Activity').
"\n".
&Apache::loncommon::bodytag('Student Activity').
@@ -267,21 +313,19 @@ sub handler {
if (ref($result) eq 'HASH') {
$result = join(' ',map { $_.'=>'.$result->{$_}; } keys(%$result));
}
- $r->print(''.$result.'
');
+ &Apache::lonnet::logthis('result from request_data_update: '.$result);
#
if (! exists($ENV{'form.selected_student'})) {
- # Choose a student
- $r->print('If you worked here you would be done by now');
+ # For now, just show all the data, in the future allow selection of
+ # a student
+ &get_all_data($r,\%prog_state,$navmap);
} else {
- # Show a students activity
- $r->print('I would like to have something to show you but I do not.');
+ # For now, just show all the data instead of limiting it to one student
+ &get_all_data($r,\%prog_state,$navmap);
}
#
- &get_all_data($r,\%prog_state,$navmap);
-
-# &Apache::lonhtmlcommon::Update_PrgWin
-# ($r,\%prog_state,&mt('Done'));
-
+ &Apache::lonhtmlcommon::Update_PrgWin($r,\%prog_state,&mt('Done'));
+ &Apache::lonhtmlcommon::Close_PrgWin($r,\%prog_state);
#
$r->print("\n");
$r->print("\n\n");