version 1.1, 2001/02/13 18:18:40
|
version 1.9, 2001/10/31 17:44:42
|
Line 3
|
Line 3
|
# 2/13 Guy Albertelli |
# 2/13 Guy Albertelli |
|
|
# Makes a table out of the previous attempts |
# Makes a table out of the previous attempts |
# Inputs result_from_symbread, user, domain, home_server, course_id |
# Inputs result_from_symbread, user, domain, course_id |
|
|
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(); |
|
|
sub get_previous_attempt { |
sub get_previous_attempt { |
my ($symb,$username,$domain,$home,$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), |
|
$home); |
|
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 56 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; |
|
} |
|
|
|
sub no_cache { |
|
my ($r) = @_; |
|
my $date=strftime("%a, %d %b %Y %H:%M:%S GMT",gmtime); |
|
$r->no_cache(1); |
|
$r->header_out("Pragma" => "no-cache"); |
|
$r->header_out("Expires" => $date); |
|
} |
1; |
1; |
__END__; |
__END__; |