File:  [LON-CAPA] / loncom / interface / loncommon.pm
Revision 1.4: download - view: text, annotated - select for diffs
Mon Jul 30 22:24:34 2001 UTC (22 years, 9 months ago) by albertel
Branches: MAIN
CVS tags: HEAD
- sort columns so they are readable

# 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.':'.$_};
        } sort(split(/\:/,$returnhash{$version.':keys'}));
      }
      $prevattempts='<table border=2></tr><th>History</th>';
      map {
        $prevattempts.='<th>'.$_.'</th>';
      } sort(keys %lasthash);
      for ($version=1;$version<=$returnhash{'version'};$version++) {
        $prevattempts.='</tr><tr><th>Attempt '.$version.'</th>';
        map {
	  $prevattempts.='<td>'.$returnhash{$version.':'.$_}.'</td>';   
        } sort(keys %lasthash);
      }
      $prevattempts.='</tr><tr><th>Current</th>';
      map {
        $prevattempts.='<td>'.$lasthash{$_}.'</td>';
      } sort(keys %lasthash);
      $prevattempts.='</tr></table>';
    } else {
      $prevattempts='Nothing submitted - no attempts.';
    }
  } else {
    $prevattempts='No data.';
  }
}

1;
__END__;

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