--- loncom/interface/lonparmset.pm 2005/06/02 16:35:32 1.200 +++ loncom/interface/lonparmset.pm 2005/06/03 14:25:49 1.203 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Handler to set parameters for assessments # -# $Id: lonparmset.pm,v 1.200 2005/06/02 16:35:32 www Exp $ +# $Id: lonparmset.pm,v 1.203 2005/06/03 14:25:49 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -68,20 +68,11 @@ use Apache::lonnavmaps; my $parmhashid; my %parmhash; +my $symbsid; +my %symbs; # --- end local caches -# -# FIXME: get rid of items below -# -my @ids; -my %symbp; -my %mapp; -my %typep; -my %keyp; -my %uris; -my %maptitles; - ################################################## ################################################## @@ -112,9 +103,13 @@ Returns: A list, the first item is the =cut ################################################## -################################################## sub parmval { my ($what,$id,$def,$uname,$udom,$csec)=@_; + return &parmval_by_symb($what,&symbcache($id),$def,$uname,$udom,$csec); +} + +sub parmval_by_symb { + my ($what,$symb,$def,$uname,$udom,$csec)=@_; # load caches &cacheparmhash(); @@ -128,9 +123,10 @@ sub parmval { my $result=''; my @outpar=(); # ----------------------------------------------------- Cascading lookup scheme + my $map=(&Apache::lonnet::decode_symb($symb))[0]; - my $symbparm=$symbp{$id}.'.'.$what; - my $mapparm=$mapp{$id}.'___(all).'.$what; + my $symbparm=$symb.'.'.$what; + my $mapparm=$map.'___(all).'.$what; my $seclevel=$env{'request.course.id'}.'.['.$csec.'].'.$what; my $seclevelr=$env{'request.course.id'}.'.['.$csec.'].'.$symbparm; @@ -180,8 +176,7 @@ sub parmval { } if (defined($$courseopt{$seclevelr})) { - $outpar[4]=$$courseopt -{$seclevelr}; + $outpar[4]=$$courseopt{$seclevelr}; $result=4; } } @@ -222,6 +217,29 @@ sub cacheparmhash { } } +sub resetsymbcache { + $symbsid=''; +} + +sub symbcache { + my $id=shift; + if ($symbsid ne $env{'request.course.id'}) { + %symbs=(); + } + unless ($symbs{$id}) { + my $navmap = Apache::lonnavmaps::navmap->new(); + if ($id=~/\./) { + my $resource=$navmap->getById($id); + $symbs{$id}=$resource->symb(); + } else { + my $resource=$navmap->getByMapPc($id); + $symbs{$id}=&Apache::lonnet::declutter($resource->src()); + } + $symbsid=$env{'request.course.id'}; + } + return $symbs{$id}; +} + ################################################## ################################################## # @@ -238,14 +256,7 @@ sub cacheparmhash { sub storeparm { my ($sresid,$spnam,$snum,$nval,$ntype,$uname,$udom,$csec)=@_; - my $navmap = Apache::lonnavmaps::navmap->new(); - if ($sresid=~/\./) { - my $resource=$navmap->getById($sresid); - &storeparm_by_symb($resource->symb(),$spnam,$snum,$nval,$ntype,$uname,$udom,$csec); - } else { - my $resource=$navmap->getByMapPc($sresid); - &storeparm_by_symb(&Apache::lonnet::declutter($resource->src()),$spnam,$snum,$nval,$ntype,$uname,$udom,$csec); - } + &storeparm_by_symb(&symbcache($sresid),$spnam,$snum,$nval,$ntype,$uname,$udom,$csec); } # @@ -435,9 +446,8 @@ sub plink { &valout($value,$type).''; } - sub startpage { - my ($r,$id,$udom,$csec,$uname,$have_assesments,$trimheader)=@_; + my ($r,$id,$udom,$csec,$uname,$have_assessments)=@_; my $bodytag=&Apache::loncommon::bodytag('Set/Modify Course Parameters','', 'onUnload="pclose()"'); @@ -447,12 +457,6 @@ sub startpage { my $selscript=&Apache::loncommon::studentbrowser_javascript(); my $pjump_def = &Apache::lonhtmlcommon::pjump_javascript_definition(); my %lt=&Apache::lonlocal::texthash( - 'cep' => "Course Environment Parameters", - 'scep' => "Set Course Environment Parameters", - 'smcap' => "Set/Modify Course Assessment Parameter", - 'mcap' => "Modify Course Assessment Parameters", - 'caphm' => "Course Assessment Parameter - Helper Mode", - 'capom' => "Course Assessment Parameters - Overview Mode", 'captm' => "Course Assessments Parameters - Table Mode", 'sg' => "Section/Group", 'fu' => "For User", @@ -514,26 +518,6 @@ $bodytag $breadcrumbs $overallhelp ENDHEAD - - unless ($trimheader) {$r->print(< -

$lt{'cep'}

- - -
-$assessparmhelp -
-

$lt{'caphm'}

- -
-
-
-

$lt{'capom'}

- -
-
-ENDHEAD2 - } my %sectionhash=(); my $sections=''; if (&Apache::loncommon::get_sections( @@ -552,8 +536,8 @@ ENDHEAD2

$lt{'captm'}

ENDHEAD3 - if (!$have_assesments) { - $r->print(''.&mt('There are no assesment parameters in this course to set.').'
'); + if (!$have_assessments) { + $r->print(''.&mt('There are no assessment parameters in this course to set.').'
'); } else { $r->print(< @@ -574,7 +558,7 @@ ENDHEAD } sub print_row { - my ($r,$which,$part,$name,$rid,$default,$defaulttype,$display,$defbgone, + my ($r,$which,$part,$name,$symbp,$rid,$default,$defaulttype,$display,$defbgone, $defbgtwo,$parmlev,$uname,$udom,$csec)=@_; # get the values for the parameter in cascading order # empty levels will remain empty @@ -596,7 +580,7 @@ sub print_row { } my $parm=$$display{$which}; - if ($parmlev eq 'full' || $parmlev eq 'brief') { + if ($parmlev eq 'full') { $r->print('' .$$part{$which}.''); } else { @@ -631,42 +615,30 @@ sub print_row { &print_td($r,11,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); - if ($parmlev eq 'brief') { - - &print_td($r,7,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); - - if ($csec) { - &print_td($r,4,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); - } - if ($uname) { - &print_td($r,1,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); - } - } else { - - &print_td($r,10,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); - &print_td($r,9,'#FFDDDD',$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); - &print_td($r,8,'#FFDDDD',$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); - &print_td($r,7,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); + &print_td($r,10,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); + &print_td($r,9,'#FFDDDD',$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); + &print_td($r,8,'#FFDDDD',$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); + &print_td($r,7,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); + + if ($csec) { + &print_td($r,6,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); + &print_td($r,5,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); + &print_td($r,4,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); + } + if ($uname) { + &print_td($r,3,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); + &print_td($r,2,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); + &print_td($r,1,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); + } - if ($csec) { - &print_td($r,6,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); - &print_td($r,5,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); - &print_td($r,4,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); - } - if ($uname) { - &print_td($r,3,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); - &print_td($r,2,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); - &print_td($r,1,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); - } - } # end of $brief if/else } # end of $parmlev if/else $r->print(''. &valout($outpar[$result],$typeoutpar[$result]).''); - if ($parmlev eq 'full' || $parmlev eq 'brief') { + if ($parmlev eq 'full') { my $sessionval=&Apache::lonnet::EXT('resource.'.$$part{$which}. - '.'.$$name{$which},$symbp{$rid}); + '.'.$$name{$which},$$symbp{$rid}); # this doesn't seem to work, and I don't think is correct # my $sessionvaltype=&Apache::lonnet::EXT('resource.'.$$part{$which}. @@ -696,6 +668,7 @@ sub print_td { $r->print(''."\n"); } + =pod =item B: Given the course data hash, extractResourceInformation extracts lots of information about the course's resources into a variety of hashes. @@ -835,6 +808,15 @@ Variables used (guessed by Jeremy): sub assessparms { my $r=shift; + + my @ids=(); + my %symbp=(); + my %mapp=(); + my %typep=(); + my %keyp=(); + my %uris=(); + my %maptitles=(); + # -------------------------------------------------------- Variable declaration my %allkeys=(); my %allmaps=(); @@ -879,7 +861,6 @@ sub assessparms { my $pssymb=''; my $parmlev=''; - my $trimheader=''; my $prevvisit=$env{'form.prevvisit'}; unless ($env{'form.parmlev'}) { @@ -898,13 +879,11 @@ sub assessparms { if (!@pscat) { @pscat=('all'); } $pschp=''; $parmlev = 'full'; - $trimheader='yes'; } elsif ($env{'form.symb'}) { $pssymb=$env{'form.symb'}; if (!@pscat) { @pscat=('all'); } $pschp=''; $parmlev = 'full'; - $trimheader='yes'; } else { $env{'form.url'}=''; } @@ -989,11 +968,7 @@ sub assessparms { if ($psprt[0] eq "all" || !@psprt) {@psprt = (keys %allparts);} # ------------------------------------------------------------------ Start page - my $have_assesments=1; - if (scalar(keys(%allkeys)) eq 0) { $have_assesments=0; } - - $trimheader = 'yes'; - &startpage($r,$id,$udom,$csec,$uname,$have_assesments,$trimheader); + &startpage($r,$id,$udom,$csec,$uname,scalar(keys(%allkeys))); # if ($env{'form.url'}) { # $r->print('print(''); - &print_row($r,$_,\%part,\%name,$mapid,\%default, + &print_row($r,$_,\%part,\%name,\%symbp,$mapid,\%default, \%type,\%display,$defbgone,$defbgtwo, $parmlev,$uname,$udom,$csec); # $r->print("resource.$part{$_}.$name{$_},$symbp{$mapid}\n"); @@ -1496,7 +1471,7 @@ ENDMAPONE foreach (sort keys %name) { $r->print(''); - &print_row($r,$_,\%part,\%name,$mapid,\%default, + &print_row($r,$_,\%part,\%name,\%symbp,$mapid,\%default, \%type,\%display,$defbgone,$defbgtwo,$parmlev,$uname,$udom,$csec); # $r->print("resource.$part{$_}.$name{$_},$symbp{$mapid}\n"); } @@ -2184,22 +2159,13 @@ sub handler { &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, ['action','state']); -# ----------------------------------------------------------- Clear out garbage - - - @ids=(); - %symbp=(); - %mapp=(); - %typep=(); - %keyp=(); - - %maptitles=(); &Apache::lonhtmlcommon::clear_breadcrumbs(); &Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/parmset", text=>"Parameter Manager", faq=>9, bug=>'Instructor Interface'}); + # ----------------------------------------------------- Needs to be in a course my $parm_permission = (&Apache::lonnet::allowed('opa',$env{'request.course.id'}) || @@ -2211,6 +2177,11 @@ sub handler { &Apache::loncommon::content_type($r,'text/html'); $r->send_http_header; + + # id numbers can change on re-ordering of folders + + &resetsymbcache(); + # # Main switch on form.action and form.state, as appropriate #