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 (23 years, 3 months ago) by albertel
Branches: MAIN
CVS tags: HEAD
- fixed to not use reply, but rather restore

# The LearningOnline Network
# a pile of common routines
# 2/13 Guy Albertelli

# Makes a table out of the previous attempts
# Inputs result_from_symbread, user, domain, course_id

package Apache::loncommon;

use strict;
use Apache::Constants qw(:common);
use Apache::lonmsg();

sub get_previous_attempt {
  my ($symb,$username,$domain,$course)=@_;
  my $prevattempts='';
  if ($symb) {
    my (%returnhash)=
      &Apache::lonnet::restore($symb,$course,$domain,$username);
    if ($returnhash{'version'}) {
      my %lasthash=();
      my $version;
      for ($version=1;$version<=$returnhash{'version'};$version++) {
        map {
	  $lasthash{$_}=$returnhash{$version.':'.$_};
        } split(/\:/,$returnhash{$version.':keys'});
      }
      $prevattempts='<table border=2></tr><th>History</th>';
      map {
        $prevattempts.='<th>'.$_.'</th>';
      } keys %lasthash;
      for ($version=1;$version<=$returnhash{'version'};$version++) {
        $prevattempts.='</tr><tr><th>Attempt '.$version.'</th>';
        map {
	  $prevattempts.='<td>'.$returnhash{$version.':'.$_}.'</td>';   
        } keys %lasthash;
      }
      $prevattempts.='</tr><tr><th>Current</th>';
      map {
        $prevattempts.='<td>'.$lasthash{$_}.'</td>';
      } keys %lasthash;
      $prevattempts.='</tr></table>';
    } else {
      $prevattempts='Nothing submitted - no attempts.';
    }
  } else {
    $prevattempts='No data.';
  }
}

1;
__END__;

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