version 1.2, 2001/07/26 15:50:25
|
version 1.5, 2001/09/13 19:59:33
|
Line 15 sub get_previous_attempt {
|
Line 15 sub get_previous_attempt {
|
my ($symb,$username,$domain,$course)=@_; |
my ($symb,$username,$domain,$course)=@_; |
my $prevattempts=''; |
my $prevattempts=''; |
if ($symb) { |
if ($symb) { |
my $answer=&Apache::lonnet::reply( |
my (%returnhash)= |
"restore:".$domain.':'.$username.':'.$course.':'. |
&Apache::lonnet::restore($symb,$course,$domain,$username); |
&Apache::lonnet::escape($symb)); |
|
my %returnhash=(); |
|
map { |
|
my ($name,$value)=split(/\=/,$_); |
|
$returnhash{&Apache::lonnet::unescape($name)}= |
|
&Apache::lonnet::unescape($value); |
|
} split(/\&/,$answer); |
|
if ($returnhash{'version'}) { |
if ($returnhash{'version'}) { |
my %lasthash=(); |
my %lasthash=(); |
my $version; |
my $version; |
for ($version=1;$version<=$returnhash{'version'};$version++) { |
for ($version=1;$version<=$returnhash{'version'};$version++) { |
map { |
map { |
$lasthash{$_}=$returnhash{$version.':'.$_}; |
$lasthash{$_}=$returnhash{$version.':'.$_}; |
} split(/\:/,$returnhash{$version.':keys'}); |
} sort(split(/\:/,$returnhash{$version.':keys'})); |
} |
} |
$prevattempts='<table border=2></tr><th>History</th>'; |
$prevattempts='<table border=2></tr><th>History</th>'; |
map { |
map { |
$prevattempts.='<th>'.$_.'</th>'; |
$prevattempts.='<th>'.$_.'</th>'; |
} keys %lasthash; |
} sort(keys %lasthash); |
for ($version=1;$version<=$returnhash{'version'};$version++) { |
for ($version=1;$version<=$returnhash{'version'};$version++) { |
$prevattempts.='</tr><tr><th>Attempt '.$version.'</th>'; |
$prevattempts.='</tr><tr><th>Attempt '.$version.'</th>'; |
map { |
map { |
$prevattempts.='<td>'.$returnhash{$version.':'.$_}.'</td>'; |
my $value; |
} keys %lasthash; |
if ($_ =~ /timestamp/) { |
|
$value=scalar(localtime($returnhash{$version.':'.$_})); |
|
} else { |
|
$value=$returnhash{$version.':'.$_}; |
|
} |
|
$prevattempts.='<td>'.$value.'</td>'; |
|
} sort(keys %lasthash); |
} |
} |
$prevattempts.='</tr><tr><th>Current</th>'; |
$prevattempts.='</tr><tr><th>Current</th>'; |
map { |
map { |
$prevattempts.='<td>'.$lasthash{$_}.'</td>'; |
my $value; |
} keys %lasthash; |
if ($_ =~ /timestamp/) { |
|
$value=scalar(localtime($lasthash{$_})); |
|
} else { |
|
$value=$lasthash{$_}; |
|
} |
|
$prevattempts.='<td>'.$value.'</td>'; |
|
} sort(keys %lasthash); |
$prevattempts.='</tr></table>'; |
$prevattempts.='</tr></table>'; |
} else { |
} else { |
$prevattempts='Nothing submitted - no attempts.'; |
$prevattempts='Nothing submitted - no attempts.'; |