File:  [LON-CAPA] / loncom / interface / lontrackstudent.pm
Revision 1.30.2.1: download - view: text, annotated - select for diffs
Wed Jan 6 18:23:27 2010 UTC (14 years, 4 months ago) by raeburn
Branches: GCI_3
Diff to branchpoint 1.30: preferred, unified
- Customization for GCI_3
 - No access to activity log data for CCs in courses in gcitest domain.

    1: # The LearningOnline Network with CAPA
    2: #
    3: # $Id: lontrackstudent.pm,v 1.30.2.1 2010/01/06 18:23:27 raeburn Exp $
    4: #
    5: # Copyright Michigan State University Board of Trustees
    6: #
    7: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
    8: #
    9: # LON-CAPA is free software; you can redistribute it and/or modify
   10: # it under the terms of the GNU General Public License as published by
   11: # the Free Software Foundation; either version 2 of the License, or
   12: # (at your option) any later version.
   13: #
   14: # LON-CAPA is distributed in the hope that it will be useful,
   15: # but WITHOUT ANY WARRANTY; without even the implied warranty of
   16: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   17: # GNU General Public License for more details.
   18: #
   19: # You should have received a copy of the GNU General Public License
   20: # along with LON-CAPA; if not, write to the Free Software
   21: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   22: #
   23: # /home/httpd/html/adm/gpl.txt
   24: #
   25: # http://www.lon-capa.org/
   26: #
   27: ###
   28: 
   29: =pod
   30: 
   31: =head1 NAME
   32: 
   33: lontrackstudent
   34: 
   35: =head1 SYNOPSIS
   36: 
   37: Track student progress through course materials
   38: 
   39: =over 4
   40: 
   41: =cut
   42: 
   43: package Apache::lontrackstudent;
   44: 
   45: use strict;
   46: use Apache::Constants qw(:common :http);
   47: use Apache::lonmysql;
   48: use Apache::lonnet;
   49: use Apache::lonlocal;
   50: use Time::HiRes;
   51: use DateTime();
   52: use lib '/home/httpd/lib/perl/';
   53: use LONCAPA;
   54: 
   55: my $num_records=500;
   56: 
   57: sub get_data {
   58:     my ($r,$prog_state,$navmap,$mode) = @_;
   59:     ##
   60:     ## Compose the query
   61:     &Apache::lonhtmlcommon::Update_PrgWin
   62:         ($r,$prog_state,&mt('Composing Query'));
   63:     #
   64:     # Allow the other server to begin processing the data before we ask for it.
   65:     sleep(5);
   66:     #
   67:     my $max_time = &get_max_time_in_db($r,$prog_state);
   68:     if (defined($max_time)) {
   69:         $r->print('<h3>'.&mt('Activity data compiled up to [_1]',
   70:                              &Apache::lonlocal::locallocaltime($max_time)).
   71:                   '</h3>'.&mt('While data is processed, periodically reload this page for more recent activity').'<br />');
   72:         $r->rflush();
   73:     } else {
   74:         $r->print('<h3>'.&mt('Unable to retrieve any data.  Please reload this page and try again.').'</h3>');
   75:         return;
   76:     }
   77:     my $query = &build_query($mode);
   78:     ##
   79:     ## Send it along
   80:     my $home = $env{'course.'.$env{'request.course.id'}.'.home'};
   81:     my $reply=&Apache::lonnet::metadata_query($query,undef,undef,[$home]);
   82:     if (ref($reply) ne 'HASH') {
   83:         $r->print('<h2>'.
   84:                   &mt('Error contacting home server for course: [_1]',
   85:                       $reply).
   86:                   '</h2>');
   87:         return;
   88:     }
   89:     my $results_file = $r->dir_config('lonDaemons').'/tmp/'.$reply->{$home};
   90:     my $endfile = $results_file.'.end';
   91:     ##
   92:     ## Check for the results
   93:     &Apache::lonhtmlcommon::Update_PrgWin
   94:         ($r,$prog_state,&mt('Waiting for results'));
   95:     my $maxtime = 500;
   96:     my $starttime = time;
   97:     while (! -e $endfile && (time-$starttime < $maxtime)) {
   98:         &Apache::lonhtmlcommon::Update_PrgWin
   99:             ($r,$prog_state,&mt('Waiting up to [_1] seconds for results',
  100:                                 $starttime+$maxtime-time));
  101:         sleep(1);
  102:     }
  103:     if (! -e $endfile) {
  104:         $r->print('<h2>'.
  105:                   &mt('Unable to retrieve data.').'</h2>');
  106:         $r->print(&mt('Please try again in a few minutes.'));
  107:         return;
  108:     }
  109:     $r->rflush();
  110:     #
  111:     &Apache::lonhtmlcommon::Update_PrgWin
  112:         ($r,$prog_state,&mt('Parsing results'));
  113:     #
  114:     my $last = &output_results($r,$results_file,$navmap,$mode);
  115:     my ($sname,$sdom) = ($mode=~/^student:(.*):(.*)$/);
  116:     
  117:     my ($text,$inc);
  118:     if ( $last > 0 && (($last+1) >= $env{'form.start'}+$num_records) ) {
  119: 	$text = 'View more activity by this student';
  120: 	$inc  = $num_records;
  121: 	$r->print(&Apache::loncommon::track_student_link($text,$sname,$sdom,undef,
  122: 							 ($env{'form.start'}+$inc),
  123:                                                          $env{'form.only_body'}
  124: 							 ));
  125: 	$r->print('<br />');
  126:     }
  127:     $r->print('<hr />');
  128:     $text = 'Resubmit last request to check for newer data';
  129:     $r->print(&Apache::loncommon::track_student_link($text,$sname,$sdom,undef,
  130: 						     $env{'form.start'},
  131:                                                      $env{'form.only_body'}));
  132: 
  133:     &Apache::lonhtmlcommon::Update_PrgWin($r,$prog_state,&mt('Finished!'));
  134:     return;
  135: }
  136: 
  137: sub table_names {
  138:     my $cid = $env{'request.course.id'};
  139:     my $domain = $env{'course.'.$cid.'.domain'};
  140:     my $home = $env{'course.'.$cid.'.home'};
  141:     my $course = $env{'course.'.$cid.'.num'};
  142:     my $prefix = $course.'_'.$domain.'_';
  143:     #
  144:     my %tables = 
  145:         ( student =>&Apache::lonmysql::fix_table_name($prefix.'students'),
  146:           res     =>&Apache::lonmysql::fix_table_name($prefix.'resource'),
  147:           machine =>&Apache::lonmysql::fix_table_name($prefix.'machine_table'),
  148:           activity=>&Apache::lonmysql::fix_table_name($prefix.'activity'),
  149:           );
  150:     return %tables;
  151: }
  152: 
  153: sub get_max_time_in_db {
  154:     my ($r,$prog_state) = @_;
  155:     my %table = &table_names();
  156:     my $query = qq{SELECT MAX(time) FROM $table{'activity'} };
  157:     #
  158:     my $home = $env{'course.'.$env{'request.course.id'}.'.home'};
  159:     my $reply=&Apache::lonnet::metadata_query($query,undef,undef,[$home]);
  160:     if (ref($reply) ne 'HASH') {
  161:         return undef;
  162:     }
  163:     my $results_file = $r->dir_config('lonDaemons').'/tmp/'.$reply->{$home};
  164:     my $endfile = $results_file.'.end';
  165:     ##
  166:     ## Check for the results
  167:     &Apache::lonhtmlcommon::Update_PrgWin
  168:         ($r,$prog_state,&mt('Waiting for results'));
  169:     my $maxtime = 500;
  170:     my $starttime = time;
  171:     while (! -e $endfile && (time-$starttime < $maxtime)) {
  172:         &Apache::lonhtmlcommon::Update_PrgWin
  173:             ($r,$prog_state,&mt('Waiting up to [_1] seconds for results',
  174:                                 $starttime+$maxtime-time));
  175:         sleep(1);
  176:     }
  177:     if (! -e $endfile) {
  178:         $r->print('<h2>'.
  179:                   &mt('Unable to retrieve data.').'</h2>');
  180:         $r->print(&mt('Please try again in a few minutes.'));
  181:         return undef;
  182:     }
  183:     $r->rflush();
  184:     #
  185:     &Apache::lonhtmlcommon::Update_PrgWin
  186:         ($r,$prog_state,&mt('Parsing results'));
  187:     #
  188:     if (! open(TIMEDATA,$results_file)) {
  189:         $r->print('<h2>'.&mt('Unable to read results file.').'</h2>'.
  190:                   '<p>'.
  191:                   &mt('This is a serious error and has been logged.  '.
  192:                       'You should contact your system administrator '.
  193:                       'to resolve this issue.').
  194:                   '</p>');
  195:         return;
  196:     }
  197:     #
  198:     my $timestr = '';
  199:     while (my $line = <TIMEDATA>) {
  200:         chomp($line);
  201:         $timestr = &unescape($line);
  202:     }
  203:     close(TIMEDATA);
  204:     return &Apache::lonmysql::unsqltime($timestr);
  205: }
  206: 
  207: sub build_query {
  208:     my ($mode) = @_;
  209:     my $cid = $env{'request.course.id'};
  210:     my $domain = $env{'course.'.$cid.'.domain'};
  211:     my $home = $env{'course.'.$cid.'.home'};
  212:     my $course = $env{'course.'.$cid.'.num'};
  213:     my $prefix = $course.'_'.$domain.'_';
  214:     my $start = ($env{'form.start'}+0);
  215:     #
  216:     my %table = &table_names();
  217:     #
  218:     my $query;
  219:     if ($mode eq 'full_class') {
  220:         $query = qq{
  221:         SELECT B.resource,A.time,C.student,A.action,E.machine,A.action_values 
  222:             FROM $table{'activity'} AS A
  223:             LEFT JOIN $table{'res'}      AS B ON B.res_id=A.res_id 
  224:             LEFT JOIN $table{'student'}  AS C ON C.student_id=A.student_id 
  225:             LEFT JOIN $table{'machine'}  AS E ON E.machine_id=A.machine_id
  226:             ORDER BY A.time DESC
  227:             LIMIT $start, $num_records
  228:         };
  229:     } elsif ($mode =~ /^student:(.*):(.*)$/) {
  230:         my $student = $1.':'.$2;
  231:         $query = qq{
  232:             SELECT B.resource,A.time,A.action,E.machine,A.action_values 
  233:                 FROM $table{'activity'} AS A
  234:                 LEFT JOIN $table{'res'}      AS B ON B.res_id=A.res_id 
  235:                 LEFT JOIN $table{'student'}  AS C ON C.student_id=A.student_id 
  236:                 LEFT JOIN $table{'machine'}  AS E ON E.machine_id=A.machine_id
  237:                 WHERE C.student='$student'
  238:                 ORDER BY A.time DESC
  239:                 LIMIT $start, $num_records
  240:             };
  241:     }
  242:     $query =~ s|$/||g;
  243:     return $query;
  244: }
  245: 
  246: ###################################################################
  247: ###################################################################
  248: sub output_results {
  249:     my ($r,$results_file,$navmap,$mode) = @_;
  250:     ##
  251:     ##
  252:     if (! -s $results_file) {
  253:         # results file is empty, just let them know there is no data
  254:         $r->print('<h2>'.&mt('So far, no data has been returned for your request').'</h2>');
  255:         return -1;
  256:     }
  257:     if (! open(ACTIVITYDATA,$results_file)) {
  258:         $r->print('<h2>'.&mt('Unable to read results file.').'</h2>'.
  259:                   '<p>'.
  260:                   &mt('This is a serious error and has been logged.  '.
  261:                       'You should contact your system administrator '.
  262:                       'to resolve this issue.').
  263:                   '</p>');
  264:         return -2;
  265:     }
  266:     ##
  267:     ##
  268:     my $tableheader;
  269:     if ($mode eq 'full_class') { 
  270:         $tableheader = 
  271:             '<table><tr>'.
  272:             '<th>&nbsp;</th>'.
  273:             '<th>'.&mt('Resource').'</th>'.
  274:             '<th>'.&mt('Time').'</th>'.
  275:             '<th>'.&mt('Student').'</th>'.
  276:             '<th>'.&mt('Action').'</th>'.
  277:  #           '<th>'.&mt('Originating Server').'</th>'.
  278:             '<th align="left">'.&mt('Data').'</th>'.
  279:             '</tr>'.$/;
  280:     } elsif ($mode =~ /^student:(.*):(.*)$/) {
  281:         $tableheader = 
  282:             '<table><tr>'.
  283:             '<th>&nbsp;</th>'.
  284:             '<th>'.&mt('Resource').'</th>'.
  285:             '<th>'.&mt('Time').'</th>'.
  286:             '<th>'.&mt('Action').'</th>'.
  287:  #           '<th>'.&mt('Originating Server').'</th>'.
  288:             '<th align="left">'.&mt('Data').'</th>'.
  289:             '</tr>'.$/;
  290:     }
  291:     my $count = $env{'form.start'}-1;
  292:     $r->rflush();
  293:     ##
  294:     ##
  295: 
  296:     my $cid = $env{'request.course.id'};
  297:     my $cnum = $env{'course.'.$cid.'.num'};
  298:     my $cdom = $env{'course.'.$cid.'.domain'};   
  299:     my $server_timezone = &Apache::lonnet::get_server_timezone($cnum,$cdom);
  300:     if ($server_timezone ne '') {
  301:         if (&Apache::lonlocal::gettimezone($server_timezone) eq 'local') {
  302:             $server_timezone = '';
  303:         }
  304:     }
  305: 
  306:     while (my $line = <ACTIVITYDATA>) {
  307:         # FIXME: does not pass symbs along :(
  308:         chomp($line);
  309:         $line = &unescape($line);
  310:         if (++$count % 50 == 0) {
  311:             if ($count != 0) { 
  312:                 $r->print('</table>'.$/);
  313:                 $r->rflush();
  314:             }
  315:             $r->print($tableheader);
  316:         }
  317:         my ($symb,$timestamp,$student,$action,$machine,$values);
  318:         if ($mode eq 'full_class') {
  319:             ($symb,$timestamp,$student,$action,$machine,$values) = split(',',$line,6);
  320:         } else {
  321:             ($symb,$timestamp,$action,$machine,$values) = split(',',$line,5);
  322:         }
  323: 	foreach ($symb,$timestamp,$student,$action,$machine) {
  324: 	    $_=&unescape($_);
  325: 	}
  326:         my ($title,$src);
  327:         if ($symb =~ m:^/adm/:) {
  328:             $title = $symb;
  329:             $src = $symb;
  330:         } else {
  331:             my $nav_res = $navmap->getBySymb($symb);
  332:             if (defined($nav_res)) {
  333:                 $title = $nav_res->compTitle();
  334:                 $src   = $nav_res->src();
  335:             } else {
  336: 		$src = $symb;
  337: 		if ($src !~ m{/adm}) {
  338: 		    $title = &Apache::lonnet::gettitle($src);
  339: 		} elsif ($values =~ /^\s*$/ && 
  340: 		    (! defined($src) || $src =~ /^\s*$/)) {
  341:                     next;
  342:                 } elsif ($values =~ /^\s*$/) {
  343:                     $values = $src;
  344:                 } else {
  345:                     $title = 'unable to retrieve title';
  346:                     $src   = '/dev/null';
  347:                 }
  348:             }
  349:         }
  350:         my %classes;
  351:         my $class_count=0;
  352:         if (! exists($classes{$symb})) {
  353:             $classes{$symb} = $class_count++;
  354:         }
  355:         my $class = 'a';#.$classes{$symb};
  356:         #
  357:         if ($symb eq '/prtspool/') {
  358:             $class = 'print';
  359:             $title = 'retrieve printout';
  360:         } elsif ($symb =~ m|^/adm/([^/]+)|) {
  361:             $class = $1;
  362:         } elsif ($symb =~ m|^/adm/|) {
  363:             $class = 'adm';
  364:         }
  365:         if ($title eq 'unable to retrieve title') {
  366:             $title =~ s/ /\&nbsp;/g;
  367:             $class = 'warning';
  368:         }
  369:         if (! defined($title) || $title eq '') {
  370:             $title = 'untitled';
  371:             $class = 'warning';
  372:         }
  373:         # Clean up the values
  374: 	$values = &display_values($action,$values);
  375:         #
  376:         # Build the row for output
  377:         my $tablerow = qq{<tr class="$class"><td>}.($count+1).qq{</td>};
  378:         if ($src =~ m|^/adm/|) {
  379:             $tablerow .= 
  380:                 '<td valign="top"><span class="LC_nobreak">'.$title.'</span></td>';
  381:         } else {
  382:             $tablerow .= 
  383:                 '<td valign="top"><span class="LC_nobreak">'.
  384:                 '<a href="'.$src.'">'.$title.'</a>'.
  385:                 '</span></td>';
  386:         }
  387:         if ($server_timezone ne '') {
  388:             $timestamp = &convert_timezone($server_timezone,$timestamp);
  389:         }
  390:         $tablerow .= '<td valign="top"><span class="LC_nobreak">'.$timestamp.'</span></td>';
  391:         if ($mode eq 'full_class') {
  392:             $tablerow.='<td valign="top">'.$student.'</td>';
  393:         }
  394:         $tablerow .= 
  395:             '<td valign="top">'.$action.'</td>'.
  396: #            '<td>'.$machine.'</td>'.
  397:             '<td valign="top">'.$values.'</td>'.
  398:             '</tr>';
  399:         $r->print($tablerow.$/);
  400:     }
  401:     $r->print('</table>'.$/);### if (! $count % 50);
  402:     close(ACTIVITYDATA);
  403:     return $count;
  404: }
  405: 
  406: sub convert_timezone {
  407:     my ($server_timezone,$timestamp) = @_;
  408:     if ($server_timezone && $timestamp) {
  409:         my ($date,$time) = split(/\s+/,$timestamp);
  410:         my ($year,$month,$day) = split(/\-/,$date);
  411:         my ($hour,$minute,$sec) = split(/:/,$time);
  412:         foreach ($month,$day,$hour,$minute,$sec) {
  413:             return $timestamp if $_ eq '';
  414:             $_ =~ s/^0//;
  415:         }
  416:         my $dt = DateTime->new(year      => $year,
  417:                                month     => $month,
  418:                                day       => $day,
  419:                                hour      => $hour,
  420:                                minute    => $minute,
  421:                                second    => $sec,
  422:                                time_zone => $server_timezone,
  423:                               );
  424:         my $unixtime = $dt->epoch;
  425:         $timestamp = &Apache::lonlocal::locallocaltime($unixtime);
  426:     }
  427:     return $timestamp;
  428: }
  429: 
  430: ###################################################################
  431: ###################################################################
  432: sub display_values {
  433:     my ($action,$values)=@_;
  434:     my $result='<table>';
  435:     if ($action eq 'CSTORE') {
  436: 	my %values=map {split('=',$_,-1)} split(/\&/,$values);
  437: 	foreach my $key (sort(keys(%values))) {
  438: 	    $result.='<tr><td align="right">'.
  439: 		&unescape($key).
  440: 		'</td><td>=</td><td align="left">'.
  441: 		&unescape($values{$key}).'</td></tr>';
  442: 	}
  443: 	$result.='</table>';
  444:     } elsif ($action eq 'POST') {
  445: 	my %values;
  446:         foreach my $pair (split(/\&/,$values)) {
  447:             my ($key,$value) = split('=',&unescape($pair),-1);
  448:             $values{$key} = $value;
  449:         }
  450: 	foreach my $key (sort(keys(%values))) {
  451: 	    if ($key eq 'counter') { next; }
  452: 	    $result.='<tr><td align="right">'.$key.'</td>'.
  453: 		'<td>=</td><td align="left">'.$values{$key}.'</td></tr>';
  454: 	}
  455: 	$result.='</table>';
  456:     } else {
  457: 	$result=&unescape($values)
  458:     }
  459:     return $result;
  460: }
  461: ###################################################################
  462: ###################################################################
  463: sub request_data_update {
  464:     my $command = 'prepare activity log';
  465:     my $cid = $env{'request.course.id'};
  466:     my $domain = $env{'course.'.$cid.'.domain'};
  467:     my $home = $env{'course.'.$cid.'.home'};
  468:     my $course = $env{'course.'.$cid.'.num'};
  469: #    &Apache::lonnet::logthis($command.' '.$course.' '.$domain.' '.$home);
  470:     my $result = &Apache::lonnet::metadata_query($command,$course,$domain,
  471:                                                  [$home]);
  472:     return $result;
  473: }
  474: 
  475: ###################################################################
  476: ###################################################################
  477: sub pick_student {
  478:     my ($r) = @_;
  479:     $r->print("Sorry, cannot display classlist at this time.  Come back another time.");
  480:     return;
  481: }
  482: 
  483: ###################################################################
  484: ###################################################################
  485: sub styles {
  486:     return <<END;
  487: <style type="text/css">
  488:     tr.warning   { background-color: \#CCCCCC; }
  489:     tr.chat      { background-color: \#CCCCCC; }
  490:     tr.chatfetch { background-color: \#CCCCCC; }
  491:     tr.navmaps   { background-color: \#CCCCCC; }
  492:     tr.roles     { background-color: \#CCCCCC; }
  493:     tr.flip      { background-color: \#CCCCCC; }
  494:     tr.adm       { background-color: \#CCCCCC; }
  495:     tr.print     { background-color: \#CCCCCC; }
  496:     tr.printout  { background-color: \#CCCCCC; }
  497:     tr.parmset   { background-color: \#CCCCCC; }
  498:     tr.grades    { background-color: \#CCCCCC; }
  499: </style>
  500: END
  501: } 
  502: 
  503: sub developer_centric_styles {
  504:     return <<END;
  505: <style type="text/css">
  506:     tr.warning   { background-color: red; }
  507:     tr.chat      { background-color: yellow; }
  508:     tr.chatfetch { background-color: yellow; }
  509:     tr.evaluate  { background-color: red; }
  510:     tr.navmaps   { background-color: \#777777; }
  511:     tr.roles     { background-color: \#999999; }
  512:     tr.flip      { background-color: \#BBBBBB; }
  513:     tr.adm       { background-color: green; }
  514:     tr.print     { background-color: blue; }
  515:     tr.parmset   { background-color: \#000088; }
  516:     tr.printout  { background-color: blue; }
  517:     tr.grades    { background-color: \#CCCCCC; }
  518: </style>
  519: END
  520: }
  521: 
  522: ###################################################################
  523: ###################################################################
  524: sub handler {
  525:     my $r=shift;
  526:     my $c = $r->connection();
  527:     #
  528:     # Check for overloading here and on the course home server
  529:     my $loaderror=&Apache::lonnet::overloaderror($r);
  530:     if ($loaderror) { return $loaderror; }
  531:     $loaderror=
  532:         &Apache::lonnet::overloaderror
  533:         ($r,
  534:          $env{'course.'.$env{'request.course.id'}.'.home'});
  535:     if ($loaderror) { return $loaderror; }
  536:     #
  537:     # Check for access
  538:     if (! &Apache::lonnet::allowed('vsa',$env{'request.course.id'})) {
  539:         $env{'user.error.msg'}=
  540:             $r->uri.":vsa:0:0:Cannot student activity for complete course";
  541:         if (! 
  542:             &Apache::lonnet::allowed('vsa',
  543:                                      $env{'request.course.id'}.'/'.
  544:                                      $env{'request.course.sec'})) {
  545:             $env{'user.error.msg'}=
  546:                 $r->uri.":vsa:0:0:Cannot view student activity with given role";
  547:             return HTTP_NOT_ACCEPTABLE;
  548:         }
  549:     }
  550:     #
  551:     # Send the header
  552:     &Apache::loncommon::no_cache($r);
  553:     &Apache::loncommon::content_type($r,'text/html');
  554:     $r->send_http_header;
  555:     if ($r->header_only) { return OK; }
  556: 
  557:     if (&Apache::loncommon::needs_gci_custom()) {
  558:         $r->print(&Apache::loncommon::start_page("Student Activity"));
  559:         $r->print('<h3>'.
  560:                   &mt('No student activity display available for Concept Tests') .
  561:                   '</h3>');
  562:         $r->print(&Apache::loncommon::end_page());
  563:         return OK;
  564:     }
  565: 
  566:     #
  567:     # Extract form elements from query string
  568:     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
  569:                       ['selected_student','start','only_body']);
  570:     #
  571:     # We will almost always need this...
  572:     my $navmap = Apache::lonnavmaps::navmap->new();
  573:     if (!defined($navmap)) {
  574:         my $requrl = $r->uri;
  575:         $env{'user.error.msg'} = "$requrl:bre:0:0:Navmap initialization failed.";
  576:         return HTTP_NOT_ACCEPTABLE;
  577:     }
  578:     # 
  579:     &Apache::lonhtmlcommon::clear_breadcrumbs();
  580:     &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/studentactivity',
  581:                                             title=>'Student Activity',
  582:                                             text =>'Student Activity',
  583:                                             faq=>139,
  584:                                             bug=>'instructor interface'});
  585:     #
  586:     # Give the LON-CAPA page header
  587:     my $args;
  588:     if ($env{'form.only_body'}) {
  589:         $args = { only_body => 1, };
  590:     }
  591:     $r->print(&Apache::loncommon::start_page('Student Activity',&styles(),$args).
  592:               &Apache::lonhtmlcommon::breadcrumbs('Student Activity'));
  593:     $r->rflush();
  594:     #
  595:     # Begin form output
  596:     $r->print('<form name="trackstudent" method="post" action="/adm/trackstudent">');
  597:     $r->print('<br />');
  598:     $r->print('<div name="statusline">'.
  599:               &mt('Status: [_1]',
  600:                   '<input type="text" name="status" size="60" value="" readonly="readonly" />').
  601:               '</div>');
  602:     $r->rflush();
  603:     my %prog_state=&Apache::lonhtmlcommon::Create_PrgWin
  604:         ($r,&mt('Student Activity Retrieval'),
  605:          &mt('Student Activity Retrieval'),undef,'inline',undef,
  606:          'trackstudent','status');
  607:     &Apache::lonhtmlcommon::Update_PrgWin
  608:         ($r,\%prog_state,&mt('Contacting course home server'));
  609:     #
  610:     my $result = &request_data_update();
  611:     #
  612:     if (exists($env{'form.selected_student'})) {
  613:         # For now, just show all the data, in the future allow selection of
  614:         # a student
  615:         my ($sname,$sdom) = split(':',$env{'form.selected_student'});
  616:         if ($sname =~ /^$LONCAPA::username_re$/ 
  617: 	    && $sdom =~ /^$LONCAPA::domain_re$/) {
  618:             $r->print('<h2>'.
  619:                       &mt('Recent activity of [_1]',$sname.':'.$sdom).
  620:                       '</h2>');
  621:             $r->print('<p class="LC_info">'
  622:                      .&mt('Compiling student activity data can take a long time.'
  623:                          .' Your request continues to be processed while results are displayed.')
  624:                      .'</p>'
  625:             );
  626:             &get_data($r,\%prog_state,$navmap,
  627:                       'student:'.$env{'form.selected_student'});
  628:         } else {
  629:             $r->print('<h2>'.&mt('Unable to process for [_1]:[_2]',
  630:                                  $sname,$sdom).'</h2>');
  631:         }
  632:     } else {
  633:         # For now, just show all the data instead of limiting it to one student
  634:         &get_data($r,\%prog_state,$navmap,'full_class');
  635:     }
  636:     #
  637:     &Apache::lonhtmlcommon::Update_PrgWin($r,\%prog_state,&mt('Done'));
  638:     &Apache::lonhtmlcommon::Close_PrgWin($r,\%prog_state);
  639:     #
  640:     $r->print("</form>\n");
  641:     $r->print(&Apache::loncommon::end_page());
  642:     $r->rflush();
  643:     #
  644:     return OK;
  645: }
  646: 
  647: 1;
  648: 
  649: #######################################################
  650: #######################################################
  651: 
  652: =pod
  653: 
  654: =back
  655: 
  656: =cut
  657: 
  658: #######################################################
  659: #######################################################
  660: 
  661: __END__
  662: 

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>