';
+ $prevattempts='';
$prevattempts.='History | ';
foreach (sort(keys %lasthash)) {
my ($ign,@parts) = split(/\./,$_);
@@ -834,6 +1048,7 @@ sub get_previous_attempt {
} else {
$value=$lasthash{$_};
}
+ if ($_ =~/$regexp$/ && (defined &$gradesub)) {$value = &$gradesub($value)}
$prevattempts.=''.$value.' | ';
}
$prevattempts.='
| ';
@@ -891,6 +1106,207 @@ sub get_student_answers {
###############################################
+
+sub timehash {
+ my @ltime=localtime(shift);
+ return ( 'seconds' => $ltime[0],
+ 'minutes' => $ltime[1],
+ 'hours' => $ltime[2],
+ 'day' => $ltime[3],
+ 'month' => $ltime[4]+1,
+ 'year' => $ltime[5]+1900,
+ 'weekday' => $ltime[6],
+ 'dayyear' => $ltime[7]+1,
+ 'dlsav' => $ltime[8] );
+}
+
+sub maketime {
+ my %th=@_;
+ return POSIX::mktime(
+ ($th{'seconds'},$th{'minutes'},$th{'hours'},
+ $th{'day'},$th{'month'}-1,$th{'year'}-1900,0,0,$th{'dlsav'}));
+}
+
+
+sub findallcourses {
+ my %courses=();
+ my $now=time;
+ foreach (keys %ENV) {
+ if ($_=~/^user\.role\.\w+\.\/(\w+)\/(\w+)/) {
+ my ($starttime,$endtime)=$ENV{$_};
+ my $active=1;
+ if ($starttime) {
+ if ($now<$starttime) { $active=0; }
+ }
+ if ($endtime) {
+ if ($now>$endtime) { $active=0; }
+ }
+ if ($active) { $courses{$1.'_'.$2}=1; }
+ }
+ }
+ return keys %courses;
+}
+
+###############################################
+###############################################
+
+=pod
+
+=item &domainlogo()
+
+Inputs: $domain (usually will be undef)
+
+Returns: A link to a domain logo, if the domain logo exists.
+If the domain logo does not exist, a description of the domain.
+
+=cut
+
+###############################################
+###############################################
+sub domainlogo {
+ my ($domain) = @_;
+ if (! $domain) {
+ # Determine domain if we have not been given one
+ $domain = $Apache::lonnet::perlvar{'lonDefDomain'};
+ if ($ENV{'user.domain'}) { $domain=$ENV{'user.domain'}; }
+ if ($ENV{'request.role.domain'}) {
+ $domain=$ENV{'request.role.domain'};
+ }
+ }
+ # See if there is a logo
+ if (-e '/home/httpd/html/adm/lonDomLogos/'.$domain.'.gif') {
+ return '';
+ } elsif(exists($Apache::lonnet::domaindescription{$domain})) {
+ return $Apache::lonnet::domaindescription{$domain};
+ } else {
+ return '';
+ }
+}
+
+###############################################
+###############################################
+
+=pod
+
+=item &bodytag()
+
+Returns a uniform header for LON-CAPA web pages.
+
+Inputs:
+
+ $title, A title to be displayed on the page.
+ $function, the current role (can be undef).
+ $addentries, extra parameters for the tag.
+ $bodyonly, if defined, only return the tag.
+ $domain, if defined, force a given domain.
+
+Returns: A uniform header for LON-CAPA web pages.
+If $bodyonly is nonzero, a string containing a tag will be returned.
+If $bodyonly is undef or zero, an html string containing a tag and
+other decorations will be returned.
+
+=cut
+
+###############################################
+###############################################
+sub bodytag {
+ my ($title,$function,$addentries,$bodyonly,$domain)=@_;
+ unless ($function) {
+ $function='student';
+ if ($ENV{'request.role'}=~/^(cc|in|ta|ep)/) {
+ $function='coordinator';
+ }
+ if ($ENV{'request.role'}=~/^(su|dc|ad|li)/) {
+ $function='admin';
+ }
+ if (($ENV{'request.role'}=~/^(au|ca)/) ||
+ ($ENV{'REQUEST_URI'}=~/^(\/priv|\~)/)) {
+ $function='author';
+ }
+ }
+ my $img='';
+ my $pgbg='';
+ my $tabbg='';
+ my $font='';
+ my $link='';
+ my $alink='#CC0000';
+ my $vlink='';
+ if ($function eq 'admin') {
+ $img='admin';
+ $pgbg='#FFFFCC';
+ $tabbg='#CCCC99';
+ $font='#772200';
+ $link='#663300';
+ $vlink='#666600';
+ } elsif ($function eq 'coordinator') {
+ $img='coordinator';
+ $pgbg='#CCFFFF';
+ $tabbg='#CCCCFF';
+ $font='#000044';
+ $link='#003333';
+ $vlink='#006633';
+ } elsif ($function eq 'author') {
+ $img='author';
+ $pgbg='#CCFFFF';
+ $tabbg='#CCFFCC';
+ $font='#004400';
+ $link='#003333';
+ $vlink='#006666';
+ } else {
+ $img='student';
+ $pgbg='#FFFFAA';
+ $tabbg='#FF9900';
+ $font='#991100';
+ $link='#993300';
+ $vlink='#996600';
+ }
+# role and realm
+ my ($role,$realm)
+ =&Apache::lonnet::plaintext((split(/\./,$ENV{'request.role'}))[0]);
+# realm
+ if ($ENV{'request.course.id'}) {
+ $realm=
+ $ENV{'course.'.$ENV{'request.course.id'}.'.description'};
+ }
+ unless ($realm) { $realm=' '; }
+# Set messages
+ my $messages=&domainlogo($domain);
+# Output
+ my $bodytag = <
+END
+ if ($bodyonly) {
+ return $bodytag;
+ } else {
+ return(<
+
+ |
+$messages |
+
+
+
+ $title
+ |
+
+ $ENV{'environment.firstname'}
+ $ENV{'environment.middlename'}
+ $ENV{'environment.lastname'}
+ $ENV{'environment.generation'}
+
+ |
+
+
+$role
+ |
+
+$realm |
+ |