File:  [LON-CAPA] / loncom / interface / loncommon.pm
Revision 1.3: download - view: text, annotated - select for diffs
Thu Jul 26 16:00:24 2001 UTC (22 years, 10 months ago) by albertel
Branches: MAIN
CVS tags: HEAD
- fixed to not use reply, but rather restore

    1: # The LearningOnline Network
    2: # a pile of common routines
    3: # 2/13 Guy Albertelli
    4: 
    5: # Makes a table out of the previous attempts
    6: # Inputs result_from_symbread, user, domain, course_id
    7: 
    8: package Apache::loncommon;
    9: 
   10: use strict;
   11: use Apache::Constants qw(:common);
   12: use Apache::lonmsg();
   13: 
   14: sub get_previous_attempt {
   15:   my ($symb,$username,$domain,$course)=@_;
   16:   my $prevattempts='';
   17:   if ($symb) {
   18:     my (%returnhash)=
   19:       &Apache::lonnet::restore($symb,$course,$domain,$username);
   20:     if ($returnhash{'version'}) {
   21:       my %lasthash=();
   22:       my $version;
   23:       for ($version=1;$version<=$returnhash{'version'};$version++) {
   24:         map {
   25: 	  $lasthash{$_}=$returnhash{$version.':'.$_};
   26:         } split(/\:/,$returnhash{$version.':keys'});
   27:       }
   28:       $prevattempts='<table border=2></tr><th>History</th>';
   29:       map {
   30:         $prevattempts.='<th>'.$_.'</th>';
   31:       } keys %lasthash;
   32:       for ($version=1;$version<=$returnhash{'version'};$version++) {
   33:         $prevattempts.='</tr><tr><th>Attempt '.$version.'</th>';
   34:         map {
   35: 	  $prevattempts.='<td>'.$returnhash{$version.':'.$_}.'</td>';   
   36:         } keys %lasthash;
   37:       }
   38:       $prevattempts.='</tr><tr><th>Current</th>';
   39:       map {
   40:         $prevattempts.='<td>'.$lasthash{$_}.'</td>';
   41:       } keys %lasthash;
   42:       $prevattempts.='</tr></table>';
   43:     } else {
   44:       $prevattempts='Nothing submitted - no attempts.';
   45:     }
   46:   } else {
   47:     $prevattempts='No data.';
   48:   }
   49: }
   50: 
   51: 1;
   52: __END__;

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