version 1.2, 2001/07/26 15:50:25
|
version 1.8, 2001/10/26 17:29:28
|
Line 8
|
Line 8
|
package Apache::loncommon; |
package Apache::loncommon; |
|
|
use strict; |
use strict; |
|
use POSIX qw(strftime); |
use Apache::Constants qw(:common); |
use Apache::Constants qw(:common); |
use Apache::lonmsg(); |
use Apache::lonmsg(); |
|
|
Line 15 sub get_previous_attempt {
|
Line 16 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.'; |
Line 55 sub get_previous_attempt {
|
Line 61 sub get_previous_attempt {
|
} |
} |
} |
} |
|
|
|
sub get_unprocessed_cgi { |
|
my ($query)= @_; |
|
map { |
|
my ($name, $value) = split(/=/,$_); |
|
$value =~ tr/+/ /; |
|
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg; |
|
if (!defined($ENV{'form.'.$name})) { $ENV{'form.'.$name}=$value; } |
|
} (split(/&/,$query)); |
|
} |
|
|
|
sub cacheheader { |
|
my $date=strftime("%a, %d %b %Y %H:%M:%S GMT",gmtime); |
|
my $output .='<meta HTTP-EQUIV="Expires" CONTENT="'.$date.'" /> |
|
<meta HTTP-EQUIV="Cache-control" CONTENT="no-cache" /> |
|
<meta HTTP-EQUIV="Pragma" CONTENT="no-cache" />'; |
|
return $output; |
|
} |
|
|
1; |
1; |
__END__; |
__END__; |