--- loncom/interface/lonparmset.pm 2000/11/21 12:22:29 1.2 +++ loncom/interface/lonparmset.pm 2000/11/22 12:16:03 1.4 @@ -9,7 +9,7 @@ # # 10/11,10/12,10/16 Gerd Kortemeyer) # -# 11/20,11/21 Gerd Kortemeyer +# 11/20,11/21,11/22 Gerd Kortemeyer package Apache::lonparmset; @@ -17,17 +17,17 @@ 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 @srcp; -my @typep; -my @resp; -my @mapp; -my @symbp; +my @ids; +my %symbp; +my %typep; my $uname; my $udom; @@ -35,12 +35,14 @@ my $uhome; my $csec; +my $fcat; + # -------------------------------------------- Figure out a cascading parameter sub parmval { - my ($what,$idx)=@_; + my ($what,$id)=@_; # ----------------------------------------------------- Cascading lookup scheme - my $symbparm=$symbp[$idx].'.'.$what; + my $symbparm=$symbp{$id}.'.'.$what; my $reslevel= $ENV{'request.course.id'}.'.'.$symbparm; my $seclevel= @@ -51,9 +53,11 @@ sub parmval { # ----------------------------------------------------------- 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 @@ -65,11 +69,10 @@ sub parmval { my $thisparm=$parmhash{$symbparm}; if ($thisparm) { return $thisparm; } - # --------------------------------------------- last, look in resource metadata - my $filename='/home/httpd/res/'.$srcp[$idx].'.meta'; + my $filename='/home/httpd/res/'.$bighash{'src_'.$id}.'.meta'; if (-e $filename) { my @content; { @@ -84,6 +87,16 @@ sub parmval { return ''; } +# ---------------------------------------------------------------- Sort routine + +sub bycat { + if ($fcat eq '') { + $a<=>$b; + } else { + &parmval('0.'.$fcat,$a)<=>&parmval('0.'.$fcat,$b); + } +} + # ================================================================ Main Handler sub handler { @@ -105,21 +118,28 @@ sub handler { %useropt=(); %bighash=(); - @srcp=(); - @typep=(); - @resp=(); - @mapp=(); - @symbp=(); + @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= + "

Unknown User $uname at Domain $udom

"; + $uname=''; + } $csec=$ENV{'form.csec'}; + unless ($csec) { $csec=''; } + $fcat=$ENV{'form.fcat'}; + unless ($fcat) { $fcat=''; } # ------------------------------------------------------------------- Tie hashs if ((tie(%bighash,'GDBM_File',$ENV{'request.course.fn'}.'.db', @@ -154,25 +174,53 @@ sub handler { if ($_=~/^src\_(\d+)\.(\d+)$/) { my $mapid=$1; my $resid=$2; + my $id=$mapid.'.'.$resid; if ($bighash{$_}=~/\.(problem|exam|quiz|assess|survey|form)$/) { - $typep[$#typep+1]=$1; - $mapp[$#mapp+1]=$mapid; - $resp[$#resp+1]=$resid; - $srcp[$#srcp+1]=&Apache::lonnet::declutter($bighash{$_}); - $symbp[$#symbp+1]= + $ids[$#ids+1]=$id; + $typep{$id}=$1; + $symbp{$id}= &Apache::lonnet::declutter($bighash{'map_id_'.$mapid}). - '___'.$resid.'___'.$srcp[$#srcp]; + '___'.$resid.'___'. + &Apache::lonnet::declutter($bighash{$_}); } } } keys %bighash; # ------------------------------------------------------------------- Sort this - + @ids=sort bycat @ids; # ------------------------------------------------------------------ Start page $r->content_type('text/html'); $r->send_http_header; - $r->print(''); - - $r->print(''); + $r->print( + '

Set Assessment Parameters

'); + $r->print("

Course: $ENV{'course.'. + $ENV{'request.course.id'}.'.description'}

"); + if ($csec) { + $r->print("

Section/Group: $csec

"); + } + if ($uname) { + $r->print("

For User $uname at Domain $udom"); + } + if ($uhome eq 'no_host') { + $r->print($message); + } + $r->print(''); + map { + $r->print(''); +# ------------------------------------------------------ Entry for one resource + my %metadata=&Apache::lonmeta::unpackagemeta( + &Apache::lonnet::getfile('/home/httpd/html/'.$bighash{'src_'.$_}.'.meta'),1); + map { + if ($_=~/^parameter\_(\d+)\_(\w+)\_\_dis\_\_(.+)$/) { + my $part=$1; + my $name=$2; + my $display=$3; + my $type=$metadata{$_}; + } + } keys %metadata; +# -------------------------------------------------- End entry for one resource + $r->print(''); + } @ids; + $r->print('
'); untie(%bighash); untie(%parmhash); }