File:  [LON-CAPA] / loncom / interface / loncommon.pm
Revision 1.2: download - view: text, annotated - select for diffs
Thu Jul 26 15:50:25 2001 UTC (22 years, 10 months ago) by albertel
Branches: MAIN
CVS tags: HEAD
- trying to eliminate the use of Apache::lonnet::homeserver

    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 $answer=&Apache::lonnet::reply(
   19: 				      "restore:".$domain.':'.$username.':'.$course.':'.
   20: 				      &Apache::lonnet::escape($symb));
   21:     my %returnhash=();
   22:     map {
   23:       my ($name,$value)=split(/\=/,$_);
   24:       $returnhash{&Apache::lonnet::unescape($name)}=
   25: 	&Apache::lonnet::unescape($value);
   26:     } split(/\&/,$answer);
   27:     if ($returnhash{'version'}) {
   28:       my %lasthash=();
   29:       my $version;
   30:       for ($version=1;$version<=$returnhash{'version'};$version++) {
   31:         map {
   32: 	  $lasthash{$_}=$returnhash{$version.':'.$_};
   33:         } split(/\:/,$returnhash{$version.':keys'});
   34:       }
   35:       $prevattempts='<table border=2></tr><th>History</th>';
   36:       map {
   37:         $prevattempts.='<th>'.$_.'</th>';
   38:       } keys %lasthash;
   39:       for ($version=1;$version<=$returnhash{'version'};$version++) {
   40:         $prevattempts.='</tr><tr><th>Attempt '.$version.'</th>';
   41:         map {
   42: 	  $prevattempts.='<td>'.$returnhash{$version.':'.$_}.'</td>';   
   43:         } keys %lasthash;
   44:       }
   45:       $prevattempts.='</tr><tr><th>Current</th>';
   46:       map {
   47:         $prevattempts.='<td>'.$lasthash{$_}.'</td>';
   48:       } keys %lasthash;
   49:       $prevattempts.='</tr></table>';
   50:     } else {
   51:       $prevattempts='Nothing submitted - no attempts.';
   52:     }
   53:   } else {
   54:     $prevattempts='No data.';
   55:   }
   56: }
   57: 
   58: 1;
   59: __END__;

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