Annotation of loncom/interface/loncommon.pm, revision 1.1

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

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