# 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>