--- loncom/interface/lonparmset.pm 2000/11/20 22:56:01 1.1 +++ loncom/interface/lonparmset.pm 2000/11/23 20:50:41 1.7 @@ -9,7 +9,7 @@ # # 10/11,10/12,10/16 Gerd Kortemeyer) # -# 11/20 Gerd Kortemeyer +# 11/20,11/21,11/22,11/23 Gerd Kortemeyer package Apache::lonparmset; @@ -17,6 +17,94 @@ use strict; use Apache::lonnet; use Apache::Constants qw(:common :http REDIRECT); use GDBM_File; +use Apache::lonmeta; + + +my %courseopt; +my %useropt; +my %bighash; +my %parmhash; + +my @ids; +my %symbp; +my %typep; + +my $uname; +my $udom; +my $uhome; + +my $csec; + +my $fcat; + +# -------------------------------------------- Figure out a cascading parameter + +sub parmval { + my ($what,$id)=@_; +# ----------------------------------------------------- Cascading lookup scheme + my $symbparm=$symbp{$id}.'.'.$what; + my $reslevel= + $ENV{'request.course.id'}.'.'.$symbparm; + my $seclevel= + $ENV{'request.course.id'}.'.'. + $ENV{'request.course.sec'}.'.'.$what; + my $courselevel= + $ENV{'request.course.id'}.'.'.$what; + +# ----------------------------------------------------------- first, check user + + if ($uname) { + if ($useropt{$reslevel}) { return $useropt{$reslevel}; } + if ($useropt{$seclevel}) { return $useropt{$seclevel}; } + if ($useropt{$courselevel}) { return $useropt{$courselevel}; } + } + +# -------------------------------------------------------- second, check course + + if ($courseopt{$reslevel}) { return $courseopt{$reslevel}; } + if ($courseopt{$seclevel}) { return $courseopt{$seclevel}; } + if ($courseopt{$courselevel}) { return $courseopt{$courselevel}; } + +# ------------------------------------------------------ third, check map parms + + my $thisparm=$parmhash{$symbparm}; + if ($thisparm) { return $thisparm; } + +# --------------------------------------------- last, look in resource metadata + + my $filename='/home/httpd/res/'.$bighash{'src_'.$id}.'.meta'; + if (-e $filename) { + my @content; + { + my $fh=Apache::File->new($filename); + @content=<$fh>; + } + if (join('',@content)=~ + /\<$what[^\>]*\>([^\<]*)\<\/$what\>/) { + return $1; + } + } + return ''; +} + +# ---------------------------------------------------------------- Sort routine + +sub bycat { + if ($fcat eq '') { + $a<=>$b; + } else { + &parmval('0.'.$fcat,$a)<=>&parmval('0.'.$fcat,$b); + } +} + +# -------------------------------------------------------- Produces link anchor + +sub plink { + my ($type,$dis,$value,$marker,$return,$call)=@_; + return ''. + (($type=~/^date/)?localtime($value):$value).''; +} # ================================================================ Main Handler @@ -33,21 +121,168 @@ sub handler { if (($ENV{'request.course.fn'}) && (&Apache::lonnet::allowed('opa',$ENV{'request.course.id'}))) { +# -------------------------------------------------------- Variable declaration + + %courseopt=(); + %useropt=(); + %bighash=(); - my %bighash; - if (tie(%bighash,'GDBM_File',$ENV{'request.course.fn'}.'.db', - &GDBM_READER,0640)) { + @ids=(); + %symbp=(); + %typep=(); + + $uname=$ENV{'form.uname'}; + $udom=$ENV{'form.udom'}; + unless ($udom) { $uname=''; } + $uhome=''; + my $message=''; + if ($uname) { + $uhome=&Apache::lonnet::homeserver($uname,$udom); + } + if ($uhome eq 'no_host') { + $message= + "
'.
+ $bighash{'src_'.$rid}.' '. + $bighash{'title_'.$rid}); + if ($thistitle) { + $r->print(' ('.$thistitle.')'); + } + $r->print(' | ');
+ my $i;
+ for ($i=0;$i<$totalparms;$i++) {
+ $r->print("$part[$i] | $display[$i] | "); + $r->print(''.&plink($type[$i],$display[$i],'987684455').' | '); + $r->print("