--- loncom/interface/lonparmset.pm 2005/06/04 15:26:13 1.207 +++ loncom/interface/lonparmset.pm 2005/06/04 17:35:19 1.208 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Handler to set parameters for assessments # -# $Id: lonparmset.pm,v 1.207 2005/06/04 15:26:13 www Exp $ +# $Id: lonparmset.pm,v 1.208 2005/06/04 17:35:19 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -766,6 +766,87 @@ sub extractResourceInformation { } } + +################################################## +################################################## + +sub parmmenu { + my ($r,$allparms,$pscat)=@_; + my $tempkey; + $r->print(< + function checkall(value, checkName) { + for (i=0; i +ENDSCRIPT + $r->print(&mt('Select Parameters to View')); + $r->print("\n"); + my $cnt=0; + foreach $tempkey (sort { $$allparms{$a} cmp $$allparms{$b} } + keys %{$allparms} ) { + ++$cnt; + $r->print("\n") if ($cnt%2); + $r->print("\n'); + } + $r->print(' + +'); + $r->print('
print('value="'.$tempkey.'"'); + if ($$pscat[0] eq "all" || grep $_ eq $tempkey, @{$pscat}) { + $r->print(' checked'); + } + $r->print('>'.$$allparms{$tempkey}.'
+ + + +
'); +} + +sub menu { + my ($r,$allparms,$allparts,$allkeys,$pscat,$psprt,$fcat)=@_; + my $tempkey; + + &parmmenu($r,$allkeys,$pscat); + + $r->print(''); + $r->print(''); + + $r->print(''); + + $r->print('

'.&mt('Sort list by').''); + $r->print('

'); + +} + ################################################## ################################################## @@ -848,7 +929,6 @@ sub assessparms { my $pschp=$env{'form.pschp'}; my @psprt=&Apache::loncommon::get_env_multiple('form.psprt'); if (!@psprt) { $psprt[0]='0'; } - my $showoptions=$env{'form.showoptions'}; my $pssymb=''; my $parmlev=''; @@ -1006,112 +1086,16 @@ sub assessparms { } else { my ($map,$id,$resource)=&Apache::lonnet::decode_symb($pssymb); $r->print("".&mt('Specific Resource')."$resource"); - $r->print(''); + $r->print(''); $r->print(''); - $r->print(''); - } - - $r->print('

'); -# $r->print("Show: $showoptions"); -# $r->print("pscat: @pscat"); -# $r->print("psprt: @psprt"); -# $r->print("fcat: $fcat"); - - if ($showoptions eq 'show') { - my $tempkey; - - $r->print(''.&mt('Select Parameters to View').''); - - $r->print(''); - my $cnt=0; - foreach $tempkey (sort { $allparms{$a} cmp $allparms{$b} } - keys %allparms ) { - ++$cnt; - $r->print('') if ($cnt%2); - $r->print(''); - } - $r->print(' - -'); - $r->print('
print('value="'.$tempkey.'"'); - if ($pscat[0] eq "all" || grep $_ eq $tempkey, @pscat) { - $r->print(' checked'); - } - $r->print('>'.$allparms{$tempkey}.'
- - - - -
'); - -# $r->print('Select Parts'); - $r->print('
'); - - $r->print(''.&mt('Sort list by').''); - $r->print(''); - - $r->print('
'); - - } else { # hide options - include any necessary extras here - - $r->print(''."\n"); + $r->print('
'); - unless (@pscat) { - foreach (keys %allparms ) { - $r->print(''."\n"); - } - } else { - foreach (@pscat) { - $r->print(''."\n"); - } - } - unless (@psprt) { - foreach (keys %allparts ) { - $r->print(''."\n"); - } - } else { - foreach (@psprt) { - $r->print(''."\n"); - } - } + &menu($r,\%allparms,\%allparts,\%allkeys,\@pscat,\@psprt,$fcat); - } - $r->print('
'); if (($prevvisit) || ($pschp) || ($pssymb)) { $submitmessage = &mt("Update Course Assessment Parameter Display"); } else { @@ -1119,13 +1103,6 @@ sub assessparms { } $r->print(''); -# my @temp_psprt; -# foreach my $t (@psprt) { -# push(@temp_psprt, grep {eval (/^$t\./ || ($_ == $t))} (keys %allparts)); -# } - -# @psprt = @temp_psprt; - my @temp_pscat; map { my $cat = $_; @@ -1852,30 +1829,11 @@ sub readdata { return $resourcedata; } -sub extractuser { - my $key=shift; - return ($key=~/^$env{'request.course.id'}.\[useropt\:(\w+)\:(\w+)\]\./); -} -sub overview { - my $r=shift; - my $bodytag=&Apache::loncommon::bodytag( - 'Set/Modify Course Assessment Parameters'); - my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'}; - my $crs = $env{'course.'.$env{'request.course.id'}.'.num'}; - my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs(undef,'Overview'); - my $html=&Apache::lonxml::xmlbegin(); - $r->print(< -LON-CAPA Course Environment - -$bodytag -$breadcrumbs -
- -ENDOVER # Setting + +sub storedata { + my ($r,$crs,$dom)=@_; # Set userlevel immediately # Do an intermediate store of course level my $olddata=&readdata($crs,$dom); @@ -1960,10 +1918,15 @@ ENDOVER } &Apache::lonnet::devalidatecourseresdata($crs,$dom); } -# Read modified data +} - my $resourcedata=&readdata($crs,$dom); +sub extractuser { + my $key=shift; + return ($key=~/^$env{'request.course.id'}.\[useropt\:(\w+)\:(\w+)\]\./); +} +sub listdata { + my ($r,$resourcedata,$listdata)=@_; # Start list output my $oldsection=''; @@ -1972,7 +1935,7 @@ ENDOVER my $pointer=0; $tableopen=0; my $foundkeys=0; - foreach my $thiskey (sort keys %{$resourcedata}) { + foreach my $thiskey (sort keys %{$listdata}) { if ($$resourcedata{$thiskey.'.type'}) { my ($middle,$part,$name)= ($thiskey=~/^$env{'request.course.id'}\.(?:(.+)\.)*([\w\s]+)\.(\w+)$/); @@ -2034,9 +1997,61 @@ ENDOVER $r->print(''); } } - + return $foundkeys; +} + +sub newoverview { + my $r=shift; + my $bodytag=&Apache::loncommon::bodytag( + 'Set Course Assessment Parameters'); + my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'}; + my $crs = $env{'course.'.$env{'request.course.id'}.'.num'}; + my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs(undef,'Overview'); + my $html=&Apache::lonxml::xmlbegin(); + $r->print(< +LON-CAPA Parameters + +$bodytag +$breadcrumbs + +ENDOVER + $r->print(&tableend(). + '

'); +} + +sub overview { + my $r=shift; + my $bodytag=&Apache::loncommon::bodytag( + 'Modify Course Assessment Parameters'); + my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'}; + my $crs = $env{'course.'.$env{'request.course.id'}.'.num'}; + my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs(undef,'Overview'); + my $html=&Apache::lonxml::xmlbegin(); + $r->print(< +LON-CAPA Parameters + +$bodytag +$breadcrumbs +
+ENDOVER +# Store modified + + &storedata($r,$crs,$dom); + +# Read modified data + + my $resourcedata=&readdata($crs,$dom); + +# List data + + my $foundkeys=&listdata($r,$resourcedata,$resourcedata); + $r->print(&tableend().'

'. - ($foundkeys?'':&mt('There are no course or section parameters.')).'

'); + ($foundkeys?'':&mt('There are no parameters.')).'

'); } ################################################## @@ -2174,6 +2189,10 @@ ENDMAINFORMHEAD { text => 'Modify Course Assessment Parameters - Overview Mode', action => 'setoverview', permission => $parm_permission, + }, + { text => 'Set Course Assessment Parameters - Overview Mode', + action => 'newoverview', + permission => $parm_permission, }, { text => 'Set/Modify Course Assessment Parameters - Table Mode', action => 'settable', @@ -2286,6 +2305,10 @@ sub handler { &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setoverview', text=>"Overview Mode"}); &overview($r); + } elsif ($env{'form.action'} eq 'newoverview' && $parm_permission) { + &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setoverview', + text=>"Overview Mode"}); + &newoverview($r); } elsif ($env{'form.action'} eq 'settable' && $parm_permission) { &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=settable', text=>"Table Mode",