--- loncom/interface/lonparmset.pm 2003/12/12 15:13:50 1.145 +++ loncom/interface/lonparmset.pm 2005/06/13 15:35:37 1.220 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Handler to set parameters for assessments # -# $Id: lonparmset.pm,v 1.145 2003/12/12 15:13:50 www Exp $ +# $Id: lonparmset.pm,v 1.220 2005/06/13 15:35:37 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -62,24 +62,16 @@ use GDBM_File; use Apache::lonhomework; use Apache::lonxml; use Apache::lonlocal; +use Apache::lonnavmaps; -my %courseopt; -my %useropt; +# --- Caches local to lonparmset + +my $parmhashid; my %parmhash; +my $symbsid; +my %symbs; -my @ids; -my %symbp; -my %mapp; -my %typep; -my %keyp; - -my %maptitles; - -my $uname; -my $udom; -my $uhome; -my $csec; -my $coursename; +# --- end local caches ################################################## ################################################## @@ -96,10 +88,10 @@ Inputs: $what - a parameter spec (inclu Returns: A list, the first item is the index into the remaining list of items of parm valuse that is the active one, the list consists of parm values at the 11 possible levels -11- resource default -10- map default -9 - General Course -8 - Map or Folder level in course +11 - General Course +10 - Map or Folder level in course +9- resource default +8- map default 7 - resource level in course 6 - General for section 5 - Map or Folder level for section @@ -111,87 +103,258 @@ Returns: A list, the first item is the =cut ################################################## -################################################## sub parmval { - my ($what,$id,$def)=@_; + 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(); + + my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; + my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; + my $useropt=&Apache::lonnet::get_userresdata($uname,$udom); + my $courseopt=&Apache::lonnet::get_courseresdata($cnum,$cdom); + + 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 $seclevel=$ENV{'request.course.id'}.'.['.$csec.'].'.$what; - my $seclevelr=$ENV{'request.course.id'}.'.['.$csec.'].'.$symbparm; - my $seclevelm=$ENV{'request.course.id'}.'.['.$csec.'].'.$mapparm; - - my $courselevel=$ENV{'request.course.id'}.'.'.$what; - my $courselevelr=$ENV{'request.course.id'}.'.'.$symbparm; - my $courselevelm=$ENV{'request.course.id'}.'.'.$mapparm; + my $symbparm=$symb.'.'.$what; + my $mapparm=$map.'___(all).'.$what; -# -------------------------------------------------------- first, check default + my $seclevel=$env{'request.course.id'}.'.['.$csec.'].'.$what; + my $seclevelr=$env{'request.course.id'}.'.['.$csec.'].'.$symbparm; + my $seclevelm=$env{'request.course.id'}.'.['.$csec.'].'.$mapparm; - if (defined($def)) { $outpar[11]=$def; $result=11; } + my $courselevel=$env{'request.course.id'}.'.'.$what; + my $courselevelr=$env{'request.course.id'}.'.'.$symbparm; + my $courselevelm=$env{'request.course.id'}.'.'.$mapparm; -# ----------------------------------------------------- second, check map parms - my $thisparm=$parmhash{$symbparm}; - if (defined($thisparm)) { $outpar[10]=$thisparm; $result=10; } -# --------------------------------------------------------- third, check course +# --------------------------------------------------------- first, check course - if (defined($courseopt{$courselevel})) { - $outpar[9]=$courseopt{$courselevel}; - $result=9; + if (defined($$courseopt{$courselevel})) { + $outpar[11]=$$courseopt{$courselevel}; + $result=11; } - if (defined($courseopt{$courselevelm})) { - $outpar[8]=$courseopt{$courselevelm}; - $result=8; + if (defined($$courseopt{$courselevelm})) { + $outpar[10]=$$courseopt{$courselevelm}; + $result=10; } - if (defined($courseopt{$courselevelr})) { - $outpar[7]=$courseopt{$courselevelr}; +# ------------------------------------------------------- second, check default + + if (defined($def)) { $outpar[9]=$def; $result=9; } + +# ------------------------------------------------------ third, check map parms + + my $thisparm=$parmhash{$symbparm}; + if (defined($thisparm)) { $outpar[8]=$thisparm; $result=8; } + + if (defined($$courseopt{$courselevelr})) { + $outpar[7]=$$courseopt{$courselevelr}; $result=7; } +# ------------------------------------------------------ fourth, back to course if (defined($csec)) { - if (defined($courseopt{$seclevel})) { - $outpar[6]=$courseopt{$seclevel}; + if (defined($$courseopt{$seclevel})) { + $outpar[6]=$$courseopt{$seclevel}; $result=6; } - if (defined($courseopt{$seclevelm})) { - $outpar[5]=$courseopt{$seclevelm}; + if (defined($$courseopt{$seclevelm})) { + $outpar[5]=$$courseopt{$seclevelm}; $result=5; } - if (defined($courseopt{$seclevelr})) { - $outpar[4]=$courseopt{$seclevelr}; + if (defined($$courseopt{$seclevelr})) { + $outpar[4]=$$courseopt{$seclevelr}; $result=4; } } -# ---------------------------------------------------------- fourth, check user +# ---------------------------------------------------------- fifth, check user if (defined($uname)) { - if (defined($useropt{$courselevel})) { - $outpar[3]=$useropt{$courselevel}; + if (defined($$useropt{$courselevel})) { + $outpar[3]=$$useropt{$courselevel}; $result=3; } - if (defined($useropt{$courselevelm})) { - $outpar[2]=$useropt{$courselevelm}; + if (defined($$useropt{$courselevelm})) { + $outpar[2]=$$useropt{$courselevelm}; $result=2; } - if (defined($useropt{$courselevelr})) { - $outpar[1]=$useropt{$courselevelr}; + if (defined($$useropt{$courselevelr})) { + $outpar[1]=$$useropt{$courselevelr}; $result=1; } } return ($result,@outpar); } +sub resetparmhash { + $parmhashid=''; +} + +sub cacheparmhash { + if ($parmhashid eq $env{'request.course.fn'}) { return; } + my %parmhashfile; + if (tie(%parmhashfile,'GDBM_File', + $env{'request.course.fn'}.'_parms.db',&GDBM_READER(),0640)) { + %parmhash=%parmhashfile; + untie %parmhashfile; + $parmhashid=$env{'request.course.fn'}; + } +} + +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}; +} + +################################################## +################################################## +# +# Store a parameter by ID +# +# Takes +# - resource id +# - name of parameter +# - level +# - new value +# - new type +# - username +# - userdomain + +sub storeparm { + my ($sresid,$spnam,$snum,$nval,$ntype,$uname,$udom,$csec)=@_; + &storeparm_by_symb(&symbcache($sresid),$spnam,$snum,$nval,$ntype,$uname,$udom,$csec); +} + +# +# Store a parameter by symb +# +# Takes +# - symb +# - name of parameter +# - level +# - new value +# - new type +# - username +# - userdomain + +sub storeparm_by_symb { +# ---------------------------------------------------------- Get symb, map, etc + my ($symb,$spnam,$snum,$nval,$ntype,$uname,$udom,$csec)=@_; +# ---------------------------------------------------------- Construct prefixes + $spnam=~s/\_([^\_]+)$/\.$1/; + my $map=(&Apache::lonnet::decode_symb($symb))[0]; + my $symbparm=$symb.'.'.$spnam; + my $mapparm=$map.'___(all).'.$spnam; + + my $seclevel=$env{'request.course.id'}.'.['.$csec.'].'.$spnam; + my $seclevelr=$env{'request.course.id'}.'.['.$csec.'].'.$symbparm; + my $seclevelm=$env{'request.course.id'}.'.['.$csec.'].'.$mapparm; + + my $courselevel=$env{'request.course.id'}.'.'.$spnam; + my $courselevelr=$env{'request.course.id'}.'.'.$symbparm; + my $courselevelm=$env{'request.course.id'}.'.'.$mapparm; + + my $storeunder=''; + if (($snum==11) || ($snum==3)) { $storeunder=$courselevel; } + if (($snum==10) || ($snum==2)) { $storeunder=$courselevelm; } + if (($snum==7) || ($snum==1)) { $storeunder=$courselevelr; } + if ($snum==6) { $storeunder=$seclevel; } + if ($snum==5) { $storeunder=$seclevelm; } + if ($snum==4) { $storeunder=$seclevelr; } + + my $delete; + if ($nval eq '') { $delete=1;} + my %storecontent = ($storeunder => $nval, + $storeunder.'.type' => $ntype); + my $reply=''; + if ($snum>3) { +# ---------------------------------------------------------------- Store Course +# + my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; + my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; +# Expire sheets + &Apache::lonnet::expirespread('','','studentcalc'); + if (($snum==7) || ($snum==4)) { + &Apache::lonnet::expirespread('','','assesscalc',$symb); + } elsif (($snum==8) || ($snum==5)) { + &Apache::lonnet::expirespread('','','assesscalc',$map); + } else { + &Apache::lonnet::expirespread('','','assesscalc'); + } +# Store parameter + if ($delete) { + $reply=&Apache::lonnet::del + ('resourcedata',[keys(%storecontent)],$cdom,$cnum); + } else { + $reply=&Apache::lonnet::cput + ('resourcedata',\%storecontent,$cdom,$cnum); + } + &Apache::lonnet::devalidatecourseresdata($cnum,$cdom); + } else { +# ------------------------------------------------------------------ Store User +# +# Expire sheets + &Apache::lonnet::expirespread($uname,$udom,'studentcalc'); + if ($snum==1) { + &Apache::lonnet::expirespread + ($uname,$udom,'assesscalc',$symb); + } elsif ($snum==2) { + &Apache::lonnet::expirespread + ($uname,$udom,'assesscalc',$map); + } else { + &Apache::lonnet::expirespread($uname,$udom,'assesscalc'); + } +# Store parameter + if ($delete) { + $reply=&Apache::lonnet::del + ('resourcedata',[keys(%storecontent)],$udom,$uname); + } else { + $reply=&Apache::lonnet::cput + ('resourcedata',\%storecontent,$udom,$uname); + } + &Apache::lonnet::devalidateuserresdata($uname,$udom); + } + + if ($reply=~/^error\:(.*)/) { + return "Write Error: $1"; + } + return ''; +} + ################################################## ################################################## @@ -240,7 +403,7 @@ sub valout { $result.=$sec.' secs '; } $result=~s/\s+$//; - } elsif ($type=~/^date/) { + } elsif (&isdateparm($type)) { $result = localtime($value); } else { $result = $value; @@ -271,43 +434,31 @@ sub plink { my ($type,$dis,$value,$marker,$return,$call)=@_; my $winvalue=$value; unless ($winvalue) { - if ($type=~/^date/) { - $winvalue=$ENV{'form.recent_'.$type}; + if (&isdateparm($type)) { + $winvalue=$env{'form.recent_'.$type}; } else { - $winvalue=$ENV{'form.recent_'.(split(/\_/,$type))[0]}; + $winvalue=$env{'form.recent_'.(split(/\_/,$type))[0]}; } } + + return ''. &valout($value,$type).''; } - sub startpage { - my ($r,$id,$udom,$csec,$uname,$have_assesments,$trimheader)=@_; + my $r=shift; my $bodytag=&Apache::loncommon::bodytag('Set/Modify Course Parameters','', 'onUnload="pclose()"'); - my $chooseopt=&Apache::loncommon::select_dom_form($udom,'udom').' '. - &Apache::loncommon::selectstudent_link('parmform','uname','udom'); + my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs(undef,'Table Mode Parameter Setting'); 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", - 'oi' => "or ID", - 'ad' => "at Domain" - ); + my $html=&Apache::lonxml::xmlbegin(); $r->print(< +$html LON-CAPA Course Parameters +ENDSCRIPT + $r->print(); + $r->print("\n"); + my $cnt=0; + foreach $tempkey (&keysindisplayorder($allparms,$keyorder)) { + $r->print("\n'); + $cnt++; + if ($cnt==3) { + $r->print("\n"); + $cnt=0; + } + } + $r->print(' + +'); + $r->print('
print('value="'.$tempkey.'"'); + if ($$pscat[0] eq "all" || grep $_ eq $tempkey, @{$pscat}) { + $r->print(' checked'); + } + $r->print('>'.$$allparms{$tempkey}.'
+Select All
+Select Common Only +
+Add Problem Dates +Add Content Dates
+Add Discussion Settings +Add Visibilities
+Add Part Parameters +
+Unselect All +
'); +} + +sub partmenu { + my ($r,$allparts,$psprt)=@_; + $r->print(''); +} + +sub usermenu { + my ($r,$uname,$id,$udom,$csec)=@_; + my $chooseopt=&Apache::loncommon::select_dom_form($udom,'udom').' '. + &Apache::loncommon::selectstudent_link('parmform','uname','udom'); + my $selscript=&Apache::loncommon::studentbrowser_javascript(); + my %lt=&Apache::lonlocal::texthash( + 'sg' => "Section/Group", + 'fu' => "For User", + 'oi' => "or ID", + 'ad' => "at Domain" + ); + my %sectionhash=(); + my $sections=''; + if (&Apache::loncommon::get_sections( + $env{'course.'.$env{'request.course.id'}.'.domain'}, + $env{'course.'.$env{'request.course.id'}.'.num'}, + \%sectionhash)) { + $sections=$lt{'sg'}.': '; + } + $r->print(< +$sections +
+$lt{'fu'} + +$lt{'oi'} + +$lt{'ad'} +$chooseopt + +ENDMENU +} + +sub displaymenu { + my ($r,$allparms,$allparts,$pscat,$psprt,$keyorder)=@_; + $r->print('
'.&mt('Select Parameters to View').''. + &mt('Select Parts to View').'
'); + &parmmenu($r,$allparms,$pscat,$keyorder); + $r->print(''); + &partmenu($r,$allparts,$psprt); + $r->print('
'); +} + +sub mapmenu { + my ($r,$allmaps,$pschp,$maptitles)=@_; + $r->print(&mt('Select Enclosing Map or Folder').' '); + $r->print('"); +} + +sub levelmenu { + my ($r,$alllevs,$parmlev)=@_; + $r->print(&mt('Select Parameter Level'). + &Apache::loncommon::help_open_topic('Course_Parameter_Levels').' '); + $r->print('"); +} + + +sub sectionmenu { + my ($r,$selectedsections)=@_; + my %sectionhash=(); + + if (&Apache::loncommon::get_sections( + $env{'course.'.$env{'request.course.id'}.'.domain'}, + $env{'course.'.$env{'request.course.id'}.'.num'}, + \%sectionhash)) { + $r->print('\n"); + } +} + +sub keysplit { + my $keyp=shift; + return (split(/\,/,$keyp)); +} + +sub keysinorder { + my ($name,$keyorder)=@_; + return sort { + $$keyorder{$a} <=> $$keyorder{$b}; + } (keys %{$name}); +} + +sub keysindisplayorder { + my ($name,$keyorder)=@_; + return sort { + $$keyorder{'parameter_0_'.$a} <=> $$keyorder{'parameter_0_'.$b}; + } (keys %{$name}); +} + +sub sortmenu { + my ($r,$sortorder)=@_; + $r->print('
print(' checked="on"'); + } + $r->print(' />'.&mt('Sort by realm first, then student (group/section)')); + $r->print('
print(' checked="on"'); + } + $r->print(' />'.&mt('Sort by student (group/section) first, then realm')); +} + +sub standardkeyorder { + return ('parameter_0_opendate' => 1, + 'parameter_0_duedate' => 2, + 'parameter_0_answerdate' => 3, + 'parameter_0_interval' => 4, + 'parameter_0_weight' => 5, + 'parameter_0_maxtries' => 6, + 'parameter_0_hinttries' => 7, + 'parameter_0_contentopen' => 8, + 'parameter_0_contentclose' => 9, + 'parameter_0_type' => 10, + 'parameter_0_problemstatus' => 11, + 'parameter_0_hiddenresource' => 12, + 'parameter_0_hiddenparts' => 13, + 'parameter_0_display' => 14, + 'parameter_0_ordered' => 15, + 'parameter_0_tol' => 16, + 'parameter_0_sig' => 17, + 'parameter_0_turnoffunit' => 18, + 'parameter_0_discussend' => 19, + 'parameter_0_discusshide' => 20); } ################################################## @@ -658,23 +1054,37 @@ 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=(); my %alllevs=(); + my $uname; + my $udom; + my $uhome; + my $csec; + + my $coursename=$env{'course.'.$env{'request.course.id'}.'.description'}; + $alllevs{'Resource Level'}='full'; -# $alllevs{'Resource Level [BRIEF]'}='brief'; - $alllevs{'Map Level'}='map'; + $alllevs{'Map/Folder Level'}='map'; $alllevs{'Course Level'}='general'; my %allparms; my %allparts; - - my %defp; - %courseopt=(); - %useropt=(); - my %bighash=(); +# +# Order in which these parameters will be displayed +# + my %keyorder=&standardkeyorder(); @ids=(); %symbp=(); @@ -682,53 +1092,49 @@ sub assessparms { my $message=''; - $csec=$ENV{'form.csec'}; - $udom=$ENV{'form.udom'}; - unless ($udom) { $udom=$r->dir_config('lonDefDomain'); } + $csec=$env{'form.csec'}; + + if ($udom=$env{'form.udom'}) { + } elsif ($udom=$env{'request.role.domain'}) { + } elsif ($udom=$env{'user.domain'}) { + } else { + $udom=$r->dir_config('lonDefDomain'); + } my @pscat=&Apache::loncommon::get_env_multiple('form.pscat'); - my $pschp=$ENV{'form.pschp'}; + 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=''; - my $trimheader=''; - my $prevvisit=$ENV{'form.prevvisit'}; - -# unless ($parmlev==$ENV{'form.parmlev'}) { -# $parmlev = 'full'; -# } - unless ($ENV{'form.parmlev'}) { + unless ($env{'form.parmlev'}) { $parmlev = 'map'; } else { - $parmlev = $ENV{'form.parmlev'}; + $parmlev = $env{'form.parmlev'}; } # ----------------------------------------------- Was this started from grades? - if (($ENV{'form.command'} eq 'set') && ($ENV{'form.url'}) - && (!$ENV{'form.dis'})) { - my $url=$ENV{'form.url'}; + if (($env{'form.command'} eq 'set') && ($env{'form.url'}) + && (!$env{'form.dis'})) { + my $url=$env{'form.url'}; $url=~s-^http://($ENV{'SERVER_NAME'}|$ENV{'HTTP_HOST'})--; $pssymb=&Apache::lonnet::symbread($url); if (!@pscat) { @pscat=('all'); } $pschp=''; $parmlev = 'full'; - $trimheader='yes'; - } elsif ($ENV{'form.symb'}) { - $pssymb=$ENV{'form.symb'}; + } elsif ($env{'form.symb'}) { + $pssymb=$env{'form.symb'}; if (!@pscat) { @pscat=('all'); } $pschp=''; $parmlev = 'full'; - $trimheader='yes'; } else { - $ENV{'form.url'}=''; + $env{'form.url'}=''; } - my $id=$ENV{'form.id'}; + my $id=$env{'form.id'}; if (($id) && ($udom)) { $uname=(&Apache::lonnet::idget($udom,$id))[1]; if ($uname) { @@ -739,7 +1145,7 @@ sub assessparms { &mt('at domain')." '$udom'"; } } else { - $uname=$ENV{'form.uname'}; + $uname=$env{'form.uname'}; } unless ($udom) { $uname=''; } $uhome=''; @@ -752,13 +1158,13 @@ sub assessparms { $uname=''; } else { $csec=&Apache::lonnet::getsection($udom,$uname, - $ENV{'request.course.id'}); + $env{'request.course.id'}); if ($csec eq '-1') { $message="". &mt("User")." '$uname' ".&mt("at domain")." '$udom' ". &mt("not in this course").""; $uname=''; - $csec=$ENV{'form.csec'}; + $csec=$env{'form.csec'}; } else { my %name=&Apache::lonnet::userenvironment($udom,$uname, ('firstname','middlename','lastname','generation','id')); @@ -772,302 +1178,62 @@ sub assessparms { unless ($csec) { $csec=''; } - my $fcat=$ENV{'form.fcat'}; - unless ($fcat) { $fcat=''; } - -# ------------------------------------------------------------------- Tie hashs - if (!(tie(%bighash,'GDBM_File',$ENV{'request.course.fn'}.'.db', - &GDBM_READER(),0640))) { - $r->print("Unable to access course data. (File $ENV{'request.course.fn'}.db not tieable)"); - return ; - } - if (!(tie(%parmhash,'GDBM_File', - $ENV{'request.course.fn'}.'_parms.db',&GDBM_READER(),0640))) { - $r->print("Unable to access parameter data. (File $ENV{'request.course.fn'}_parms.db not tieable)"); - return ; - } - # --------------------------------------------------------- Get all assessments - extractResourceInformation(\%bighash, \@ids, \%typep,\%keyp, \%allparms, \%allparts, \%allkeys, \%allmaps, $fcat, \%defp, \%mapp, \%symbp,\%maptitles); + &extractResourceInformation(\@ids, \%typep,\%keyp, \%allparms, \%allparts, \%allmaps, + \%mapp, \%symbp,\%maptitles,\%uris, + \%keyorder); $mapp{'0.0'} = ''; $symbp{'0.0'} = ''; # ---------------------------------------------------------- Anything to store? - if ($ENV{'form.pres_marker'}) { - my ($sresid,$spnam,$snum)=split(/\&/,$ENV{'form.pres_marker'}); - $spnam=~s/\_([^\_]+)$/\.$1/; -# ---------------------------------------------------------- Construct prefixes - - my $symbparm=$symbp{$sresid}.'.'.$spnam; - my $mapparm=$mapp{$sresid}.'___(all).'.$spnam; - - my $seclevel=$ENV{'request.course.id'}.'.['.$csec.'].'.$spnam; - my $seclevelr=$ENV{'request.course.id'}.'.['.$csec.'].'.$symbparm; - my $seclevelm=$ENV{'request.course.id'}.'.['.$csec.'].'.$mapparm; - - my $courselevel=$ENV{'request.course.id'}.'.'.$spnam; - my $courselevelr=$ENV{'request.course.id'}.'.'.$symbparm; - my $courselevelm=$ENV{'request.course.id'}.'.'.$mapparm; - - my $storeunder=''; - if (($snum==9) || ($snum==3)) { $storeunder=$courselevel; } - if (($snum==8) || ($snum==2)) { $storeunder=$courselevelm; } - if (($snum==7) || ($snum==1)) { $storeunder=$courselevelr; } - if ($snum==6) { $storeunder=$seclevel; } - if ($snum==5) { $storeunder=$seclevelm; } - if ($snum==4) { $storeunder=$seclevelr; } - - my $delete; - if ($ENV{'form.pres_value'} eq '') { $delete=1;} - my %storecontent = ($storeunder => $ENV{'form.pres_value'}, - $storeunder.'.type' => $ENV{'form.pres_type'}); - my $reply=''; - if ($snum>3) { -# ---------------------------------------------------------------- Store Course -# -# Expire sheets - &Apache::lonnet::expirespread('','','studentcalc'); - if (($snum==7) || ($snum==4)) { - &Apache::lonnet::expirespread('','','assesscalc',$symbp{$sresid}); - } elsif (($snum==8) || ($snum==5)) { - &Apache::lonnet::expirespread('','','assesscalc',$mapp{$sresid}); - } else { - &Apache::lonnet::expirespread('','','assesscalc'); - } -# Store parameter - if ($delete) { - $reply=&Apache::lonnet::del - ('resourcedata',[keys(%storecontent)], - $ENV{'course.'.$ENV{'request.course.id'}.'.domain'}, - $ENV{'course.'.$ENV{'request.course.id'}.'.num'}); - } else { - $reply=&Apache::lonnet::cput - ('resourcedata',\%storecontent, - $ENV{'course.'.$ENV{'request.course.id'}.'.domain'}, - $ENV{'course.'.$ENV{'request.course.id'}.'.num'}); - } - } else { -# ------------------------------------------------------------------ Store User -# -# Expire sheets - &Apache::lonnet::expirespread($uname,$udom,'studentcalc'); - if ($snum==1) { - &Apache::lonnet::expirespread - ($uname,$udom,'assesscalc',$symbp{$sresid}); - } elsif ($snum==2) { - &Apache::lonnet::expirespread - ($uname,$udom,'assesscalc',$mapp{$sresid}); - } else { - &Apache::lonnet::expirespread($uname,$udom,'assesscalc'); - } -# Store parameter - if ($delete) { - $reply=&Apache::lonnet::del - ('resourcedata',[keys(%storecontent)],$udom,$uname); - } else { - $reply=&Apache::lonnet::cput - ('resourcedata',\%storecontent,$udom,$uname); - } - } - - if ($reply=~/^error\:(.*)/) { - $message.="Write Error: $1"; + if ($env{'form.pres_marker'}) { + my @markers=split(/\&\&\&/,$env{'form.pres_marker'}); + my @values=split(/\&\&\&/,$env{'form.pres_value'}); + my @types=split(/\&\&\&/,$env{'form.pres_type'}); + for (my $i=0;$i<=$#markers;$i++) { + $message.=&storeparm(split(/\&/,$markers[$i]), + $values[$i], + $types[$i], + $uname,$udom,$csec); } # ---------------------------------------------------------------- Done storing $message.='

'.&mt('Changes can take up to 10 minutes before being active for all students.').&Apache::loncommon::help_open_topic('Caching').'

'; } -# --------------------------------------------- Devalidate cache for this child - &Apache::lonnet::devalidatecourseresdata( - $ENV{'course.'.$ENV{'request.course.id'}.'.num'}, - $ENV{'course.'.$ENV{'request.course.id'}.'.domain'}); - &Apache::lonnet::clear_EXT_cache_status(); -# -------------------------------------------------------------- Get coursedata - %courseopt = &Apache::lonnet::dump - ('resourcedata', - $ENV{'course.'.$ENV{'request.course.id'}.'.domain'}, - $ENV{'course.'.$ENV{'request.course.id'}.'.num'}); -# --------------------------------------------------- Get userdata (if present) - if ($uname) { - %useropt=&Apache::lonnet::dump('resourcedata',$udom,$uname); - } - -# ------------------------------------------------------------------- Sort this - - @ids=sort { - if ($fcat eq '') { - $a<=>$b; - } else { - my ($result,@outpar)=&parmval($fcat,$a,$defp{$a}); - my $aparm=$outpar[$result]; - ($result,@outpar)=&parmval($fcat,$b,$defp{$b}); - my $bparm=$outpar[$result]; - 1*$aparm<=>1*$bparm; - } - } @ids; #----------------------------------------------- if all selected, fill in array - if ($pscat[0] eq "all" || !@pscat) {@pscat = (keys %allparms);} + if ($pscat[0] eq "all") {@pscat = (keys %allparms);} + if (!@pscat) { @pscat=('duedate','opendate','answerdate','weight','maxtries') }; if ($psprt[0] eq "all" || !@psprt) {@psprt = (keys %allparts);} # ------------------------------------------------------------------ Start page - my $have_assesments=1; - if (scalar(keys(%allkeys)) eq 0) { $have_assesments=0; } - - &startpage($r,$id,$udom,$csec,$uname,$have_assesments,$trimheader); - - if (!$have_assesments) { - untie(%bighash); - untie(%parmhash); - return ''; - } -# if ($ENV{'form.url'}) { -# $r->print(''); -# } - $r->print(''); + &startpage($r); foreach ('tolerance','date_default','date_start','date_end', 'date_interval','int','float','string') { $r->print(''); + $env{'form.recent_'.$_}.'" name="recent_'.$_.'">'); } - - $r->print('

'.$message.'

'); - my $submitmessage = &mt('Update Section or Specific User'); if (!$pssymb) { - $r->print('\n"); - - $r->print(''); + $r->print('
'.&mt('Select Parameter Level').''); - $r->print('
'); - $r->print('\n"); + $r->print(''); } + $r->print('
'); + &levelmenu($r,\%alllevs,$parmlev); if ($parmlev ne 'general') { - $r->print('
'.&mt('Select Enclosing Map or Folder').'
'); + &mapmenu($r,\%allmaps,$pschp,\%maptitles); + $r->print('
'); + &displaymenu($r,\%allparms,\%allparts,\@pscat,\@psprt,\%keyorder); } else { my ($map,$id,$resource)=&Apache::lonnet::decode_symb($pssymb); - $r->print("".&mt('Specific Resource')."$resource"); - $r->print(''); - $r->print(''); - $r->print(''); - } - - $r->print('
print(" checked ");} - $r->print(' name="showoptions" value="show">'.&mt('Show More Options').'
'); -# $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(''); - $r->print(''); - - my $cnt=0; - foreach $tempkey (sort { $allparms{$a} cmp $allparms{$b} } - keys %allparms ) { - ++$cnt; - $r->print('') unless ($cnt%2); - $r->print(''); - } - $r->print('
print(' checked') unless (@pscat); - $r->print('>'.&mt('All Parameters').'
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"); - - 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"); - } - } - + $r->print(&mt('Specific Resource').": ".$resource. + '
'); } - $r->print('
'); - if (($prevvisit) || ($pschp) || ($pssymb)) { - $submitmessage = &mt("Update Course Assessment Parameter Display"); - } else { - $submitmessage = &mt("Set/Modify Course Assessment Parameters"); - } - $r->print(''); + &usermenu($r,$uname,$id,$udom,$csec); -# my @temp_psprt; -# foreach my $t (@psprt) { -# push(@temp_psprt, grep {eval (/^$t\./ || ($_ == $t))} (keys %allparts)); -# } + $r->print('

'.$message.'

'); -# @psprt = @temp_psprt; + $r->print('
'); my @temp_pscat; map { @@ -1077,13 +1243,13 @@ sub assessparms { @pscat = @temp_pscat; - if (($prevvisit) || ($pschp) || ($pssymb)) { + if (($env{'form.prevvisit'}) || ($pschp) || ($pssymb)) { # ----------------------------------------------------------------- Start Table my @catmarker=map { tr|.|_|; 'parameter_'.$_; } @pscat; - my $csuname=$ENV{'user.name'}; - my $csudom=$ENV{'user.domain'}; + my $csuname=$env{'user.name'}; + my $csudom=$env{'user.domain'}; - if ($parmlev eq 'full' || $parmlev eq 'brief') { + if ($parmlev eq 'full') { my $coursespan=$csec?8:5; $r->print('

'); $r->print(''); @@ -1112,8 +1278,9 @@ sub assessparms { $r->print(<$lt{'pie'} - - + + + ENDTABLETWO if ($csec) { $r->print(" - - + + ENDTABLEHEADFOUR if ($csec) { @@ -1144,18 +1311,20 @@ ENDTABLEHEADFOUR my $rid=$_; my ($inmapid)=($rid=~/\.(\d+)$/); - if (($pschp eq 'all') || ($allmaps{$pschp} eq $mapp{$rid}) || - ($pssymb eq $symbp{$rid})) { + if ((!$pssymb && + (($pschp eq 'all') || ($allmaps{$pschp} eq $mapp{$rid}))) + || + ($pssymb && $pssymb eq $symbp{$rid})) { # ------------------------------------------------------ Entry for one resource - if ($defbgone eq '"E0E099"') { - $defbgone='"E0E0DD"'; + if ($defbgone eq '"#E0E099"') { + $defbgone='"#E0E0DD"'; } else { - $defbgone='"E0E099"'; + $defbgone='"#E0E099"'; } - if ($defbgtwo eq '"FFFF99"') { - $defbgtwo='"FFFFDD"'; + if ($defbgtwo eq '"#FFFF99"') { + $defbgtwo='"#FFFFDD"'; } else { - $defbgtwo='"FFFF99"'; + $defbgtwo='"#FFFF99"'; } my $thistitle=''; my %name= (); @@ -1164,9 +1333,9 @@ ENDTABLEHEADFOUR my %display=(); my %type= (); my %default=(); - my $uri=&Apache::lonnet::declutter($bighash{'src_'.$rid}); + my $uri=&Apache::lonnet::declutter($uris{$rid}); - foreach (split(/\,/,$keyp{$rid})) { + foreach (&keysplit($keyp{$rid})) { my $tempkeyp = $_; if (grep $_ eq $tempkeyp, @catmarker) { $part{$_}=&Apache::lonnet::metadata($uri,$_.'.part'); @@ -1182,14 +1351,14 @@ ENDTABLEHEADFOUR my $totalparms=scalar keys %name; if ($totalparms>0) { my $firstrow=1; - my $title=$bighash{'title_'.$rid}; - $title=~s/\:/:/g; + my $title=&Apache::lonnet::gettitle($uri); $r->print(''); - foreach (sort keys %name) { + foreach (&keysinorder(\%name,\%keyorder)) { unless ($firstrow) { $r->print(''); } else { undef $firstrow; } - &print_row($r,$_,\%part,\%name,$rid,\%default, + &print_row($r,$_,\%part,\%name,\%symbp,$rid,\%default, \%type,\%display,$defbgone,$defbgtwo, - $parmlev); + $parmlev,$uname,$udom,$csec); } } } } # end foreach ids # -------------------------------------------------- End entry for one resource $r->print('
$lt{'csv'}
($csuname $lt{'at'} $csudom)
$lt{'rl'}$lt{'ic'}
$lt{'ic'}$lt{'rl'}$lt{'ic'}". @@ -1122,8 +1289,8 @@ ENDTABLETWO $r->print(<
$lt{'aut'}$lt{'type'} $lt{'emof'}$lt{'part'}$lt{'pn'}$lt{'def'}$lt{'femof'}$lt{'gen'}$lt{'foremf'}$lt{'fr'}$lt{'gen'}$lt{'foremf'}$lt{'def'}$lt{'femof'}$lt{'fr'}
'. join(' / ',split(/\//,$uri)). '

'. - "$title"); @@ -1210,23 +1379,23 @@ ENDTABLEHEADFOUR $r->print('

'); - } # end of brief/full + } # end of full #--------------------------------------------------- Entry for parm level map if ($parmlev eq 'map') { my $defbgone = '"E0E099"'; @@ -1263,7 +1432,7 @@ ENDTABLEHEADFOUR # $r->print("$mapid:$map: $rid
\n"); if ($map eq $mapid) { - my $uri=&Apache::lonnet::declutter($bighash{'src_'.$rid}); + my $uri=&Apache::lonnet::declutter($uris{$rid}); # $r->print("Keys: $keyp{$rid}
\n"); #-------------------------------------------------------------------- @@ -1273,7 +1442,7 @@ ENDTABLEHEADFOUR # When storing information, store as part 0 # When requesting information, request from full part #------------------------------------------------------------------- - foreach (split(/\,/,$keyp{$rid})) { + foreach (&keysplit($keyp{$rid})) { my $tempkeyp = $_; my $fullkeyp = $tempkeyp; $tempkeyp =~ s/_\w+_/_0_/; @@ -1323,11 +1492,11 @@ ENDMAPONE $r->print(''.&mt('Default Value').''); $r->print(''.&mt('Parameter in Effect').''); - foreach (sort keys %name) { - &print_row($r,$_,\%part,\%name,$mapid,\%default, + foreach (&keysinorder(\%name,\%keyorder)) { + $r->print(''); + &print_row($r,$_,\%part,\%name,\%symbp,$mapid,\%default, \%type,\%display,$defbgone,$defbgtwo, - $parmlev); -# $r->print("resource.$part{$_}.$name{$_},$symbp{$mapid}\n"); + $parmlev,$uname,$udom,$csec); } $r->print(""); } # end each map @@ -1350,7 +1519,7 @@ ENDMAPONE foreach (@ids) { my $rid = $_; - my $uri=&Apache::lonnet::declutter($bighash{'src_'.$rid}); + my $uri=&Apache::lonnet::declutter($uris{$rid}); #-------------------------------------------------------------------- # @catmarker contains list of all possible parameters including part #s @@ -1359,7 +1528,7 @@ ENDMAPONE # When storing information, store as part 0 # When requesting information, request from full part #------------------------------------------------------------------- - foreach (split(/\,/,$keyp{$rid})) { + foreach (&keysplit($keyp{$rid})) { my $tempkeyp = $_; my $fullkeyp = $tempkeyp; $tempkeyp =~ s/_\w+_/_0_/; @@ -1400,17 +1569,15 @@ ENDMAPONE $r->print(''.&mt('Default Value').''); $r->print(''.&mt('Parameter in Effect').''); - foreach (sort keys %name) { - &print_row($r,$_,\%part,\%name,$mapid,\%default, - \%type,\%display,$defbgone,$defbgtwo,$parmlev); -# $r->print("resource.$part{$_}.$name{$_},$symbp{$mapid}\n"); + foreach (&keysinorder(\%name,\%keyorder)) { + $r->print(''); + &print_row($r,$_,\%part,\%name,\%symbp,$mapid,\%default, + \%type,\%display,$defbgone,$defbgtwo,$parmlev,$uname,$udom,$csec); } $r->print(""); } # end of $parmlev eq general } $r->print(''); - untie(%bighash); - untie(%parmhash); } # end sub assessparms @@ -1437,17 +1604,19 @@ sub crsenv { my $setoutput=''; my $bodytag=&Apache::loncommon::bodytag( 'Set Course Environment 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, + 'Edit Course Environment'); + my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'}; + my $crs = $env{'course.'.$env{'request.course.id'}.'.num'}; # # Go through list of changes - foreach (keys %ENV) { + foreach (keys %env) { next if ($_!~/^form\.(.+)\_setparmval$/); my $name = $1; - my $value = $ENV{'form.'.$name.'_value'}; + my $value = $env{'form.'.$name.'_value'}; if ($name eq 'newp') { - $name = $ENV{'form.newp_name'}; + $name = $env{'form.newp_name'}; } if ($name eq 'url') { $value=~s/^\/res\///; @@ -1487,13 +1656,34 @@ sub crsenv { if ($name =~ /^default_enrollment_(start|end)_date$/) { $value=&Apache::lonhtmlcommon::get_date_from_form($name.'_value'); } + # Get existing cloners + my @oldcloner = (); + if ($name eq 'cloners') { + my %clonenames=&Apache::lonnet::dump('environment',$dom,$crs,'cloners'); + if ($clonenames{'cloners'} =~ /,/) { + @oldcloner = split/,/,$clonenames{'cloners'}; + } else { + $oldcloner[0] = $clonenames{'cloners'}; + } + } # # Let the user know we made the changes - if ($name) { + if ($name && defined($value)) { + if ($name eq 'cloners') { + $value =~ s/^,//; + $value =~ s/,$//; + } my $put_result = &Apache::lonnet::put('environment', {$name=>$value},$dom,$crs); if ($put_result eq 'ok') { $setoutput.=&mt('Set').' '.$name.' '.&mt('to').' '.$value.'.
'; + if ($name eq 'cloners') { + &change_clone($value,\@oldcloner); + } + # Flush the course logs so course description is immediately updated + if ($name eq 'description' && defined($value)) { + &Apache::lonnet::flushcourselogs(); + } } else { $setoutput.=&mt('Unable to set').' '.$name.' '.&mt('to'). ' '.$value.' '.&mt('due to').' '.$put_result.'.
'; @@ -1502,7 +1692,7 @@ sub crsenv { } # ------------------------- Re-init course environment entries for this session - &Apache::lonnet::coursedescription($ENV{'request.course.id'}); + &Apache::lonnet::coursedescription($env{'request.course.id'}); # -------------------------------------------------------- Get parameters again @@ -1519,14 +1709,12 @@ sub crsenv { &mt('Modification may make assessment data inaccessible'). '', 'description' => ''.&mt('Course Description').'', - 'courseid' => ''.&mt('Course ID').' '.&mt('or').' '.&mt('number'). + 'courseid' => ''.&mt('Course ID or number'). '
'. '('.&mt('internal').', '.&mt('optional').')', - 'grading' => ''.&mt('Grading').''. - ' "'.&mt('standard').'", "'.&mt('external').'", '. - &mt('or any other value').'.'. - ' '.&mt('Default for new courses is').' "'. - &mt('standard').'".', + 'cloners' => ''.&mt('Users allowed to clone course').'
(user:domain,user:domain)
'.&mt('Users with active Course Coordinator role in the course automatically have the right to clone it, and can be omitted from list.'), + 'grading' => ''.&mt('Grading').'
'. + '"standard", "external", or "spreadsheet" '.&Apache::loncommon::help_open_topic('GradingOptions'), 'default_xml_style' => ''.&mt('Default XML Style File').' '. ' ''.&mt('Feedback Addresses for Course Policy').''. '
(user:domain,user:domain(section;section;...;*;...),...)', 'hideemptyrows' => ''.&mt('Hide Empty Rows in Spreadsheets').'
'. - '("yes" for default hiding)', + '('.&mt('"[_1]" for default hiding','yes').')', 'pageseparators' => ''.&mt('Visibly Separate Items on Pages').'
'. - '("'.&mt('yes').'" '.&mt('for visible separation').', '. + '('.&mt('"[_1]" for visible separation','yes').', '. &mt('changes will not show until next login').')', + 'student_classlist_view' => ''.&mt('Allow students to view classlist.').''.&mt('("all":students can view all sections,"section":students can only view their own section.blank or "disabled" prevents student view.'), 'plc.roles.denied'=> ''.&mt('Disallow live chatroom use for Roles'). '
"st": '. - 'student, "ta": '. + &mt('student').', "ta": '. 'TA, "in": '. - 'instructor;
role,role,...) '. + &mt('instructor').';
'.&mt('role,role,...').') '. Apache::loncommon::help_open_topic("Course_Disable_Discussion"), 'plc.users.denied' => ''.&mt('Disallow live chatroom use for Users').'
'. @@ -1580,33 +1769,60 @@ sub crsenv { ",'spreadsheet')\">$SelectSpreadsheetFile

", 'allow_limited_html_in_feedback' => ''.&mt('Allow limited HTML in discussion posts').'
'. - '('.&mt('Set value to').' "'.&mt('yes').'" '.&mt('to allow').')', + '('.&mt('Set value to "[_1]" to allow',"yes").')', + 'allow_discussion_post_editing' + => ''.&mt('Allow users to edit/delete their own discussion posts').'
'. + '('.&mt('Set value to "[_1]" to allow',"yes").')', 'rndseed' => ''.&mt('Randomization algorithm used').'
'. ''.&mt('Modifying this will make problems').' '. &mt('have different numbers and answers').'', + 'receiptalg' + => ''.&mt('Receipt algorithm used').'
'. + &mt('This controls how receipt numbers are generated.'), + 'suppress_tries' + => ''.&mt('Suppress number of tries in printing').'('. + &mt('yes if supress').')', 'problem_stream_switch' => ''.&mt('Allow problems to be split over pages').'
'. - ' ("'.&mt('yes').'" '.&mt('if allowed, anything else if not').')', + ' ('.&mt('"[_1]" if allowed, anything else if not','yes').')', + 'default_paper_size' + => ''.&mt('Default paper type').'
'. + ' ('.&mt('supported types').': Letter [8 1/2x11 in], Legal [8 1/2x14 in],'. + ' Tabloid [11x17 in], Executive [7 1/2x10 in], A2 [420x594 mm],'. + ' A3 [297x420 mm], A4 [210x297 mm], A5 [148x210 mm], A6 [105x148 mm])', 'anonymous_quiz' - => ''.&mt('Anonimous quiz/exam').'
'. + => ''.&mt('Anonymous quiz/exam').'
'. ' ('.&mt('yes').' '.&mt('to avoid print students names').' )', - 'default_enrollment_start_date' => ''.&mt('Default beginning date when enrolling students').'', - 'default_enrollment_end_date' => ''.&mt('Default ending date when enrolling students').'', + 'default_enrollment_start_date' => ''.&mt('Default beginning date for student access.').'', + 'default_enrollment_end_date' => ''.&mt('Default ending date for student access.').'', + 'nothideprivileged' => ''.&mt('Privileged users that should not be hidden on staff listings').''. + '
(user:domain,user:domain,...)', 'languages' => ''.&mt('Languages used').'', 'disable_receipt_display' => ''.&mt('Disable display of problem receipts').'
'. - ' ("'.&mt('yes').'" '.&mt('to disable, anything else if not').')' + ' ('.&mt('"[_1]" to disable, anything else if not','yes').')', + 'disablesigfigs' + => ''.&mt('Disable checking of Significant Figures').'
'. + ' ('.&mt('"[_1]" to disable, anything else if not','yes').')', + 'tthoptions' + => ''.&mt('Default set of options to pass to tth/m when converting tex').'' ); - my @Display_Order = ('url','description','courseid','grading', + my @Display_Order = ('url','description','courseid','cloners','grading', 'default_xml_style','pageseparators', 'question.email','comment.email','policy.email', + 'student_classlist_view', 'plc.roles.denied','plc.users.denied', 'pch.roles.denied','pch.users.denied', 'allow_limited_html_in_feedback', + 'allow_discussion_post_editing', 'languages', + 'nothideprivileged', 'rndseed', + 'receiptalg', 'problem_stream_switch', + 'suppress_tries', + 'default_paper_size', 'disable_receipt_display', 'spreadsheet_default_classcalc', 'spreadsheet_default_studentcalc', @@ -1614,6 +1830,8 @@ sub crsenv { 'hideemptyrows', 'default_enrollment_start_date', 'default_enrollment_end_date', + 'tthoptions', + 'disablesigfigs' ); foreach my $parameter (sort(keys(%values))) { unless ($parameter =~ m/^internal\./) { @@ -1658,54 +1876,44 @@ sub crsenv { $onchange.' />'. ''; } + my %lt=&Apache::lonlocal::texthash( + 'par' => 'Parameter', + 'val' => 'Value', + 'set' => 'Set', + 'sce' => 'Set Course Environment' + ); + my $Parameter=&mt('Parameter'); my $Value=&mt('Value'); my $Set=&mt('Set'); - $r->print(< + my $browse_js=&Apache::loncommon::browser_and_searcher_javascript('parmset'); + my $html=&Apache::lonxml::xmlbegin(); + $r->print(< - LON-CAPA Course Environment $bodytag -

+$breadcrumbs + $setoutput

- + $output
$Parameter$Value$Set?
$lt{'par'}$lt{'val'}$lt{'set'}?
- +

-ENDENV +ENDenv } ################################################## - +# Overview mode +################################################## my $tableopen; sub tablestart { @@ -1727,43 +1935,106 @@ sub tableend { } } -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'}; - $r->print(< - -LON-CAPA Course Environment - -$bodytag -
- -ENDOVER +sub readdata { + my ($crs,$dom)=@_; +# Read coursedata + my $resourcedata=&Apache::lonnet::get_courseresdata($crs,$dom); +# Read userdata + + my $classlist=&Apache::loncoursedata::get_classlist(); + foreach (keys %$classlist) { + # the following undefs are for 'domain', and 'username' respectively. + if ($_=~/^(\w+)\:(\w+)$/) { + my ($tuname,$tudom)=($1,$2); + my $useropt=&Apache::lonnet::get_userresdata($tuname,$tudom); + foreach my $userkey (keys %{$useropt}) { + if ($userkey=~/^$env{'request.course.id'}/) { + my $newkey=$userkey; + $newkey=~s/^($env{'request.course.id'}\.)/$1\[useropt\:$tuname\:$tudom\]\./; + $$resourcedata{$newkey}=$$useropt{$userkey}; + } + } + } + } + return $resourcedata; +} + + # Setting - my %olddata=&Apache::lonnet::dump('resourcedata',$dom,$crs); + +sub storedata { + my ($r,$crs,$dom)=@_; +# Set userlevel immediately +# Do an intermediate store of course level + my $olddata=&readdata($crs,$dom); my %newdata=(); undef %newdata; my @deldata=(); undef @deldata; - foreach (keys %ENV) { + foreach (keys %env) { if ($_=~/^form\.([a-z]+)\_(.+)$/) { my $cmd=$1; my $thiskey=$2; + my ($tuname,$tudom)=&extractuser($thiskey); + my $tkey=$thiskey; + if ($tuname) { + $tkey=~s/\.\[useropt\:$tuname\:$tudom\]\./\./; + } if ($cmd eq 'set') { - my $data=$ENV{$_}; - if ($olddata{$thiskey} ne $data) { $newdata{$thiskey}=$data; } + my $data=$env{$_}; + my $typeof=$env{'form.typeof_'.$thiskey}; + if ($$olddata{$thiskey} ne $data) { + if ($tuname) { + if (&Apache::lonnet::put('resourcedata',{$tkey=>$data, + $tkey.'.type' => $typeof}, + $tudom,$tuname) eq 'ok') { + $r->print('
'.&mt('Stored modified parameter for').' '. + &Apache::loncommon::plainname($tuname,$tudom)); + } else { + $r->print('

'. + &mt('Error storing parameters').'

'); + } + &Apache::lonnet::devalidateuserresdata($tuname,$tudom); + } else { + $newdata{$thiskey}=$data; + $newdata{$thiskey.'.type'}=$typeof; + } + } } elsif ($cmd eq 'del') { - push (@deldata,$thiskey); + if ($tuname) { + if (&Apache::lonnet::del('resourcedata',[$tkey],$tudom,$tuname) eq 'ok') { + $r->print('
'.&mt('Deleted parameter for').' '.&Apache::loncommon::plainname($tuname,$tudom)); + } else { + $r->print('

'. + &mt('Error deleting parameters').'

'); + } + &Apache::lonnet::devalidateuserresdata($tuname,$tudom); + } else { + push (@deldata,$thiskey); + } } elsif ($cmd eq 'datepointer') { - my $data=&Apache::lonhtmlcommon::get_date_from_form($ENV{$_}); - if ($olddata{$thiskey} ne $data) { $newdata{$thiskey}=$data; } + my $data=&Apache::lonhtmlcommon::get_date_from_form($env{$_}); + my $typeof=$env{'form.typeof_'.$thiskey}; + if (defined($data) and $$olddata{$thiskey} ne $data) { + if ($tuname) { + if (&Apache::lonnet::put('resourcedata',{$tkey=>$data, + $tkey.'.type' => $typeof}, + $tudom,$tuname) eq 'ok') { + $r->print('
'.&mt('Stored modified date for').' '.&Apache::loncommon::plainname($tuname,$tudom)); + } else { + $r->print('

'. + &mt('Error storing parameters').'

'); + } + &Apache::lonnet::devalidateuserresdata($tuname,$tudom); + } else { + $newdata{$thiskey}=$data; + $newdata{$thiskey.'.type'}=$typeof; + } + } } } } -# Store +# Store all course level my $delentries=$#deldata+1; my @newdatakeys=keys %newdata; my $putentries=$#newdatakeys+1; @@ -1774,52 +2045,95 @@ ENDOVER $r->print('

'. &mt('Error deleting parameters').'

'); } + &Apache::lonnet::devalidatecourseresdata($crs,$dom); } if ($putentries) { if (&Apache::lonnet::put('resourcedata',\%newdata,$dom,$crs) eq 'ok') { - $r->print('

'.&mt('Stored [_1] parameter(s)

',$putentries)); + $r->print('

'.&mt('Stored [_1] parameter(s)',$putentries/2).'

'); } else { $r->print('

'. &mt('Error storing parameters').'

'); } + &Apache::lonnet::devalidatecourseresdata($crs,$dom); } -# Read and display - my %resourcedata=&Apache::lonnet::dump('resourcedata',$dom,$crs); +} + +sub extractuser { + my $key=shift; + return ($key=~/^$env{'request.course.id'}.\[useropt\:(\w+)\:(\w+)\]\./); +} + +sub listdata { + my ($r,$resourcedata,$listdata,$sortorder)=@_; +# Start list output + my $oldsection=''; my $oldrealm=''; my $oldpart=''; my $pointer=0; $tableopen=0; my $foundkeys=0; - foreach my $thiskey (sort keys %resourcedata) { - if ($resourcedata{$thiskey.'.type'}) { - my ($course,$middle,$part,$name)= - ($thiskey=~/^(\w+)\.(?:(.+)\.)*([\w\s]+)\.(\w+)$/); + foreach my $thiskey (sort { + if ($sortorder eq 'realmstudent') { + my ($astudent,$arealm)=($a=~/^$env{'request.course.id'}\.([^\.]+)\.(.+)\.[^\.]+$/); + my ($bstudent,$brealm)=($b=~/^$env{'request.course.id'}\.([^\.]+)\.(.+)\.[^\.]+$/); + ($arealm cmp $brealm) || ($astudent cmp $bstudent); + } else { + $a cmp $b; + } + } keys %{$listdata}) { + if ($$listdata{$thiskey.'.type'}) { + my $thistype=$$listdata{$thiskey.'.type'}; + if ($$resourcedata{$thiskey.'.type'}) { + $thistype=$$resourcedata{$thiskey.'.type'}; + } + my ($middle,$part,$name)= + ($thiskey=~/^$env{'request.course.id'}\.(?:(.+)\.)*([\w\s]+)\.(\w+)$/); my $section=&mt('All Students'); - if ($middle=~/^\[(.*)\]\./) { - $section=&mt('Group/Section').': '.$1; - $middle=~s/^\[(.*)\]\.//; + if ($middle=~/^\[(.*)\]/) { + my $issection=$1; + if ($issection=~/^useropt\:(\w+)\:(\w+)/) { + $section=&mt('User').": ".&Apache::loncommon::plainname($1,$2); + } else { + $section=&mt('Group/Section').': '.$issection; + } + $middle=~s/^\[(.*)\]//; } - $middle=~s/\.$//; + $middle=~s/\.+$//; + $middle=~s/^\.+//; my $realm=''.&mt('All Resources').''; if ($middle=~/^(.+)\_\_\_\(all\)$/) { - $realm=''.&mt('Folder/Map').': '.&Apache::lonnet::gettitle($1).''; + $realm=''.&mt('Folder/Map').': '.&Apache::lonnet::gettitle($1).'
('.$1.')
'; } elsif ($middle) { - $realm=''.&mt('Resource').': '.&Apache::lonnet::gettitle($middle).''; + my ($map,$id,$url)=&Apache::lonnet::decode_symb($middle); + $realm=''.&mt('Resource').': '.&Apache::lonnet::gettitle($middle).'
('.$url.' in '.$map.' id: '.$id.')
'; } - if ($section ne $oldsection) { - $r->print(&tableend()."\n

$section

"); - $oldsection=$section; - $oldrealm=''; - } - if ($realm ne $oldrealm) { - $r->print(&tableend()."\n

$realm

"); - $oldrealm=$realm; - $oldpart=''; + if ($sortorder eq 'realmstudent') { + if ($realm ne $oldrealm) { + $r->print(&tableend()."\n

$realm

"); + $oldrealm=$realm; + $oldsection=''; + } + if ($section ne $oldsection) { + $r->print(&tableend()."\n

$section

"); + $oldsection=$section; + $oldpart=''; + } + } else { + if ($section ne $oldsection) { + $r->print(&tableend()."\n

$section

"); + $oldsection=$section; + $oldrealm=''; + } + if ($realm ne $oldrealm) { + $r->print(&tableend()."\n

$realm

"); + $oldrealm=$realm; + $oldpart=''; + } } if ($part ne $oldpart) { $r->print(&tableend(). - "\n

".&mt('Part').": $part

"); + "\n".&mt('Part').": $part"); $oldpart=$part; } # @@ -1829,26 +2143,421 @@ ENDOVER ':
'); $foundkeys++; - if ($resourcedata{$thiskey.'.type'}=~/^date/) { + if (&isdateparm($thistype)) { my $jskey='key_'.$pointer; $pointer++; $r->print( &Apache::lonhtmlcommon::date_setter('overviewform', $jskey, - $resourcedata{$thiskey}). + $$resourcedata{$thiskey}, + '',1). '' ); + } elsif ($thistype eq 'string_yesno') { + $r->print(' '); + $r->print(''); } else { - $r->print( - ''); + $r->print(''); } + $r->print(''); $r->print(''); } } - + return $foundkeys; +} + +sub newoverview { + my $r=shift; + my $bodytag=&Apache::loncommon::bodytag('Set 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 + my @ids=(); + my %typep=(); + my %keyp=(); + my %allparms=(); + my %allparts=(); + my %allmaps=(); + my %mapp=(); + my %symbp=(); + my %maptitles=(); + my %uris=(); + my %keyorder=&standardkeyorder(); + my %defkeytype=(); + + my %alllevs=(); + $alllevs{'Resource Level'}='full'; + $alllevs{'Map/Folder Level'}='map'; + $alllevs{'Course Level'}='general'; + + my $csec=$env{'form.csec'}; + + my @pscat=&Apache::loncommon::get_env_multiple('form.pscat'); + my $pschp=$env{'form.pschp'}; + my @psprt=&Apache::loncommon::get_env_multiple('form.psprt'); + if (!@psprt) { $psprt[0]='0'; } + + my @selected_sections = + &Apache::loncommon::get_env_multiple('form.Section'); + @selected_sections = ('all') if (! @selected_sections); + foreach (@selected_sections) { + if ($_ eq 'all') { + @selected_sections = ('all'); + } + } + + my $pssymb=''; + my $parmlev=''; + + unless ($env{'form.parmlev'}) { + $parmlev = 'map'; + } else { + $parmlev = $env{'form.parmlev'}; + } + + &extractResourceInformation(\@ids, \%typep,\%keyp, \%allparms, \%allparts, \%allmaps, + \%mapp, \%symbp,\%maptitles,\%uris, + \%keyorder,\%defkeytype); + +# Menu to select levels, etc + + $r->print(''); + } + $r->print('
'); + &levelmenu($r,\%alllevs,$parmlev); + if ($parmlev ne 'general') { + $r->print(''); + &mapmenu($r,\%allmaps,$pschp,\%maptitles); + $r->print('
'); + + $r->print('
'); + &parmmenu($r,\%allparms,\@pscat,\%keyorder); + $r->print(''); + &partmenu($r,\%allparts,\@psprt); + $r->print(''); + §ionmenu($r,\@selected_sections); + + $r->print('
'); + + my $sortorder=$env{'form.sortorder'}; + unless ($sortorder) { $sortorder='realmstudent'; } + &sortmenu($r,$sortorder); + + $r->print('

'); + +# Build the list data hash from the specified parms + + my $listdata; + %{$listdata}=(); + + foreach my $cat (@pscat) { + foreach my $section (@selected_sections) { + foreach my $part (@psprt) { + my $rootparmkey=$env{'request.course.id'}; + if (($section ne 'all') && ($section ne 'none') && ($section)) { + $rootparmkey.='.['.$section.']'; + } + if ($parmlev eq 'general') { +# course-level parameter + my $newparmkey=$rootparmkey.'.'.$part.'.'.$cat; + $$listdata{$newparmkey}=1; + $$listdata{$newparmkey.'.type'}=$defkeytype{$cat}; + } elsif ($parmlev eq 'map') { +# map-level parameter + foreach my $mapid (keys %allmaps) { + if (($pschp ne 'all') && ($pschp ne $mapid)) { next; } + my $newparmkey=$rootparmkey.'.'.$allmaps{$mapid}.'___(all).'.$part.'.'.$cat; + $$listdata{$newparmkey}=1; + $$listdata{$newparmkey.'.type'}=$defkeytype{$cat}; + } + } else { +# resource-level parameter + foreach my $rid (@ids) { + my ($map,$resid,$url)=&Apache::lonnet::decode_symb($symbp{$rid}); + if (($pschp ne 'all') && ($allmaps{$pschp} ne $map)) { next; } + my $newparmkey=$rootparmkey.'.'.$symbp{$rid}.'.'.$part.'.'.$cat; + $$listdata{$newparmkey}=1; + $$listdata{$newparmkey.'.type'}=$defkeytype{$cat}; + } + } + } + } + } + + if (($env{'form.store'}) || ($env{'form.dis'})) { + + if ($env{'form.store'}) { &storedata($r,$crs,$dom); } + +# Read modified data + + my $resourcedata=&readdata($crs,$dom); + +# List data + + &listdata($r,$resourcedata,$listdata,$sortorder); + } + $r->print(&tableend(). + ((($env{'form.store'}) || ($env{'form.dis'}))?'

':''). + ''); +} + +sub overview { + my $r=shift; + my $bodytag=&Apache::loncommon::bodytag('Modify 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); + + + my $sortorder=$env{'form.sortorder'}; + unless ($sortorder) { $sortorder='realmstudent'; } + &sortmenu($r,$sortorder); + +# List data + + my $foundkeys=&listdata($r,$resourcedata,$resourcedata,$sortorder); + $r->print(&tableend().'

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

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

'); +} + +################################################## +################################################## + +=pod + +=item change clone + +Modifies the list of courses a user can clone (stored +in the user's environemnt.db file), called when a +change is made to the list of users allowed to clone +a course. + +Inputs: $action,$cloner +where $action is add or drop, and $cloner is identity of +user for whom cloning ability is to be changed in course. + +Returns: + +=cut + +################################################## +################################################## + + +sub change_clone { + my ($clonelist,$oldcloner) = @_; + my ($uname,$udom); + my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; + my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; + my $clone_crs = $cnum.':'.$cdom; + + if ($cnum && $cdom) { + my @allowclone = (); + if ($clonelist =~ /,/) { + @allowclone = split/,/,$clonelist; + } else { + $allowclone[0] = $clonelist; + } + foreach my $currclone (@allowclone) { + if (!grep/^$currclone$/,@$oldcloner) { + ($uname,$udom) = split/:/,$currclone; + if ($uname && $udom) { + unless (&Apache::lonnet::homeserver($uname,$udom) eq 'no_host') { + my %currclonecrs = &Apache::lonnet::dump('environment',$udom,$uname,'cloneable'); + if ($currclonecrs{'cloneable'} !~ /\Q$clone_crs\E/) { + if ($currclonecrs{'cloneable'} eq '') { + $currclonecrs{'cloneable'} = $clone_crs; + } else { + $currclonecrs{'cloneable'} .= ','.$clone_crs; + } + &Apache::lonnet::put('environment',\%currclonecrs,$udom,$uname); + } + } + } + } + } + foreach my $oldclone (@$oldcloner) { + if (!grep/^$oldclone$/,@allowclone) { + ($uname,$udom) = split/:/,$oldclone; + if ($uname && $udom) { + unless (&Apache::lonnet::homeserver($uname,$udom) eq 'no_host') { + my %currclonecrs = &Apache::lonnet::dump('environment',$udom,$uname,'cloneable'); + my %newclonecrs = (); + if ($currclonecrs{'cloneable'} =~ /\Q$clone_crs\E/) { + if ($currclonecrs{'cloneable'} =~ /,/) { + my @currclonecrs = split/,/,$currclonecrs{'cloneable'}; + foreach (@currclonecrs) { + unless ($_ eq $clone_crs) { + $newclonecrs{'cloneable'} .= $_.','; + } + } + $newclonecrs{'cloneable'} =~ s/,$//; + } else { + $newclonecrs{'cloneable'} = ''; + } + &Apache::lonnet::put('environment',\%newclonecrs,$udom,$uname); + } + } + } + } + } + } +} + + +################################################## +################################################## + +=pod + +=item * header + +Output html header for page + +=cut + +################################################## +################################################## +sub header { + my $html=&Apache::lonxml::xmlbegin(); + my $bodytag=&Apache::loncommon::bodytag('Parameter Manager'); + my $title = &mt('LON-CAPA Parameter Manager'); + return(< +$title + +$bodytag +ENDHEAD +} +################################################## +################################################## +sub print_main_menu { + my ($r,$parm_permission)=@_; + # + $r->print(< +ENDMAINFORMHEAD +# + my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; + my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; + my @menu = + ( + { text => 'Set Course Environment Parameters', + action => 'crsenv', + permission => $parm_permission, + }, + { text => 'Set/Modify Resource Parameters - Helper Mode', + url => '/adm/helper/parameter.helper', + permission => $parm_permission, + }, + { text => 'Modify Resource Parameters - Overview Mode', + action => 'setoverview', + permission => $parm_permission, + }, + { text => 'Set Resource Parameters - Overview Mode', + action => 'newoverview', + permission => $parm_permission, + }, + { text => 'Set/Modify Resource Parameters - Table Mode', + action => 'settable', + permission => $parm_permission, + help => 'Cascading_Parameters', + }, + { text => 'Set Parameter Setting Default Actions', + action => 'setdefaults', + permission => $parm_permission, + }, + ); + my $menu_html = ''; + foreach my $menu_item (@menu) { + next if (! $menu_item->{'permission'}); + $menu_html.='

'; + $menu_html.=''; + if (exists($menu_item->{'url'})) { + $menu_html.=qq{}; + } else { + $menu_html.= + qq{}; + } + $menu_html.= &mt($menu_item->{'text'}).''; + if (exists($menu_item->{'help'})) { + $menu_html.= + &Apache::loncommon::help_open_topic($menu_item->{'help'}); + } + $menu_html.='

'.$/; + } + $r->print($menu_html); + return; +} + + +################################################## + +sub defaultsetter { + my $r=shift; + my $bodytag=&Apache::loncommon::bodytag('Parameter Setting Default Actions'); + my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'}; + my $crs = $env{'course.'.$env{'request.course.id'}.'.num'}; + my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs(undef,'Defaults'); + my $html=&Apache::lonxml::xmlbegin(); + $r->print(< +LON-CAPA Parameters + +$bodytag +$breadcrumbs +
+ENDDEFHEAD + my %rules=&Apache::lonnet::dump('parmdefactions',$dom,$crs); + if ($env{'form.storerules'}) { + %rules=&Apache::lonnet::dump('parmdefactions',$dom,$crs); + } + + + return; } ################################################## @@ -1861,10 +2570,10 @@ ENDOVER Main handler. Calls &assessparms and &crsenv subroutines. =cut - ################################################## ################################################## - use Data::Dumper; +# use Data::Dumper; + sub handler { my $r=shift; @@ -1873,46 +2582,78 @@ sub handler { $r->send_http_header; return OK; } - &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}); + &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, + ['action','state', + 'pres_marker', + 'pres_value', + 'pres_type', + 'udom','uname','symb']); -# ----------------------------------------------------------- Clear out garbage - - %courseopt=(); - %useropt=(); - %parmhash=(); - - @ids=(); - %symbp=(); - %mapp=(); - %typep=(); - %keyp=(); - %maptitles=(); + &Apache::lonhtmlcommon::clear_breadcrumbs(); + &Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/parmset", + text=>"Parameter Manager", + faq=>10, + bug=>'Instructor Interface'}); # ----------------------------------------------------- Needs to be in a course + my $parm_permission = + (&Apache::lonnet::allowed('opa',$env{'request.course.id'}) || + &Apache::lonnet::allowed('opa',$env{'request.course.id'}.'/'. + $env{'request.course.sec'})); + if ($env{'request.course.id'} && $parm_permission) { - if (($ENV{'request.course.id'}) && - (&Apache::lonnet::allowed('opa',$ENV{'request.course.id'}))) { - + # Start Page &Apache::loncommon::content_type($r,'text/html'); $r->send_http_header; - - $coursename=$ENV{'course.'.$ENV{'request.course.id'}.'.description'}; - if (($ENV{'form.crsenv'}) || (!$ENV{'request.course.fn'})) { -# ---------------------------------------------- This is for course environment -# -------------------------- also call if toplevel map coudl not be initialized - &crsenv($r); - } elsif ($ENV{'form.overview'}) { -# --------------------------------------------------------------- Overview mode + + # id numbers can change on re-ordering of folders + + &resetsymbcache(); + + # + # Main switch on form.action and form.state, as appropriate + # + # Check first if coming from someone else headed directly for + # the table mode + if ((($env{'form.command'} eq 'set') && ($env{'form.url'}) + && (!$env{'form.dis'})) || ($env{'form.symb'})) { + &assessparms($r); + + } elsif (! exists($env{'form.action'})) { + $r->print(&header()); + $r->print(&Apache::lonhtmlcommon::breadcrumbs(undef, + 'Parameter Manager')); + &print_main_menu($r,$parm_permission); + } elsif ($env{'form.action'} eq 'crsenv' && $parm_permission) { + &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=crsenv', + text=>"Course Environment"}); + $r->print(&Apache::lonhtmlcommon::breadcrumbs(undef, + 'Edit Course Environment')); + &crsenv($r); + } elsif ($env{'form.action'} eq 'setoverview' && $parm_permission) { + &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setoverview', + text=>"Overview Mode"}); &overview($r); - } else { -# --------------------------------------------------------- Bring up assessment + } 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 'setdefaults' && $parm_permission) { + &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setdefaults', + text=>"Set Defaults"}); + &defaultsetter($r); + } elsif ($env{'form.action'} eq 'settable' && $parm_permission) { + &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=settable', + text=>"Table Mode", + help => 'Course_Setting_Parameters'}); &assessparms($r); - } + } + } else { # ----------------------------- Not in a course, or not allowed to modify parms - $ENV{'user.error.msg'}= + $env{'user.error.msg'}= "/adm/parmset:opa:0:0:Cannot modify assessment parameters"; return HTTP_NOT_ACCEPTABLE; }