--- loncom/interface/lonparmset.pm 2003/11/17 20:56:30 1.135 +++ loncom/interface/lonparmset.pm 2005/06/01 02:02:41 1.196 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Handler to set parameters for assessments # -# $Id: lonparmset.pm,v 1.135 2003/11/17 20:56:30 albertel Exp $ +# $Id: lonparmset.pm,v 1.196 2005/06/01 02:02:41 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -72,15 +72,9 @@ my %symbp; my %mapp; my %typep; my %keyp; - +my %uris; my %maptitles; -my $uname; -my $udom; -my $uhome; -my $csec; -my $coursename; - ################################################## ################################################## @@ -96,10 +90,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 @@ -113,7 +107,7 @@ Returns: A list, the first item is the ################################################## ################################################## sub parmval { - my ($what,$id,$def)=@_; + my ($what,$id,$def,$uname,$udom,$csec)=@_; my $result=''; my @outpar=(); # ----------------------------------------------------- Cascading lookup scheme @@ -121,40 +115,43 @@ sub parmval { 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 $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 $courselevel=$env{'request.course.id'}.'.'.$what; + my $courselevelr=$env{'request.course.id'}.'.'.$symbparm; + my $courselevelm=$env{'request.course.id'}.'.'.$mapparm; -# -------------------------------------------------------- first, check default - if ($def) { $outpar[11]=$def; $result=11; } -# ----------------------------------------------------- second, check map parms - - my $thisparm=$parmhash{$symbparm}; - if ($thisparm) { $outpar[10]=$thisparm; $result=10; } - -# --------------------------------------------------------- third, check course +# --------------------------------------------------------- first, check course if (defined($courseopt{$courselevel})) { - $outpar[9]=$courseopt{$courselevel}; - $result=9; + $outpar[11]=$courseopt{$courselevel}; + $result=11; } if (defined($courseopt{$courselevelm})) { - $outpar[8]=$courseopt{$courselevelm}; - $result=8; + $outpar[10]=$courseopt{$courselevelm}; + $result=10; } +# ------------------------------------------------------- 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}; @@ -171,7 +168,7 @@ sub parmval { } } -# ---------------------------------------------------------- fourth, check user +# ---------------------------------------------------------- fifth, check user if (defined($uname)) { if (defined($useropt{$courselevel})) { @@ -192,6 +189,105 @@ sub parmval { return ($result,@outpar); } + +################################################## +################################################## +# +# Store a parameter +# +# Takes +# - resource id +# - name of parameter +# - level +# - new value +# - new type +# - username +# - userdomain + +sub storeparm { + my ($sresid,$spnam,$snum,$nval,$ntype,$uname,$udom,$csec)=@_; + $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==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 +# +# 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); + } + &Apache::lonnet::devalidateuserresdata($uname,$udom); + } + + if ($reply=~/^error\:(.*)/) { + return "Write Error: $1"; + } + return ''; +} + ################################################## ################################################## @@ -272,9 +368,9 @@ sub plink { my $winvalue=$value; unless ($winvalue) { if ($type=~/^date/) { - $winvalue=$ENV{'form.recent_'.$type}; + $winvalue=$env{'form.recent_'.$type}; } else { - $winvalue=$ENV{'form.recent_'.(split(/\_/,$type))[0]}; + $winvalue=$env{'form.recent_'.(split(/\_/,$type))[0]}; } } return @@ -285,10 +381,11 @@ sub plink { sub startpage { - my ($r,$id,$udom,$csec,$uname,$have_assesments)=@_; + my ($r,$id,$udom,$csec,$uname,$have_assesments,$trimheader)=@_; my $bodytag=&Apache::loncommon::bodytag('Set/Modify Course Parameters','', 'onUnload="pclose()"'); + my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs(undef,'Table'); my $chooseopt=&Apache::loncommon::select_dom_form($udom,'udom').' '. &Apache::loncommon::selectstudent_link('parmform','uname','udom'); my $selscript=&Apache::loncommon::studentbrowser_javascript(); @@ -306,8 +403,12 @@ sub startpage { 'oi' => "or ID", 'ad' => "at Domain" ); + my $overallhelp= + &Apache::loncommon::help_open_menu('','Setting Parameters','Course_Setting_Parameters','',10,'Instructor Interface'); + my $assessparmhelp=&Apache::loncommon::help_open_topic("Cascading_Parameters","Assessment Parameters"); + my $html=&Apache::lonxml::xmlbegin(); $r->print(< +$html LON-CAPA Course Parameters + + + + +'); $r->print(''); # $r->print('Select Parts'); @@ -1070,8 +1143,8 @@ sub assessparms { if (($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') { my $coursespan=$csec?8:5; @@ -1102,8 +1175,9 @@ sub assessparms { $r->print(<$lt{'pie'} $lt{'csv'}
($csuname $lt{'at'} $csudom) -$lt{'rl'} -$lt{'ic'} +$lt{'ic'}$lt{'rl'} +$lt{'ic'} + ENDTABLETWO if ($csec) { $r->print("". @@ -1112,8 +1186,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'} ENDTABLEHEADFOUR if ($csec) { @@ -1134,18 +1208,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= (); @@ -1154,7 +1230,7 @@ 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})) { my $tempkeyp = $_; @@ -1172,14 +1248,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(''. join(' / ',split(/\//,$uri)). '

'. - "$title"); @@ -1209,7 +1285,7 @@ ENDTABLEHEADFOUR &print_row($r,$_,\%part,\%name,$rid,\%default, \%type,\%display,$defbgone,$defbgtwo, - $parmlev); + $parmlev,$uname,$udom,$csec); } } } @@ -1253,7 +1329,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"); #-------------------------------------------------------------------- @@ -1314,9 +1390,10 @@ ENDMAPONE $r->print(''.&mt('Parameter in Effect').''); foreach (sort keys %name) { + $r->print(''); &print_row($r,$_,\%part,\%name,$mapid,\%default, \%type,\%display,$defbgone,$defbgtwo, - $parmlev); + $parmlev,$uname,$udom,$csec); # $r->print("resource.$part{$_}.$name{$_},$symbp{$mapid}\n"); } $r->print(""); @@ -1340,7 +1417,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 @@ -1391,15 +1468,15 @@ ENDMAPONE $r->print(''.&mt('Parameter in Effect').''); foreach (sort keys %name) { + $r->print(''); &print_row($r,$_,\%part,\%name,$mapid,\%default, - \%type,\%display,$defbgone,$defbgtwo,$parmlev); + \%type,\%display,$defbgone,$defbgtwo,$parmlev,$uname,$udom,$csec); # $r->print("resource.$part{$_}.$name{$_},$symbp{$mapid}\n"); } $r->print(""); } # end of $parmlev eq general } $r->print(''); - untie(%bighash); untie(%parmhash); } # end sub assessparms @@ -1427,17 +1504,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\///; @@ -1477,13 +1556,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.'.
'; @@ -1492,109 +1592,137 @@ 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 my %values=&Apache::lonnet::dump('environment',$dom,$crs); + my $SelectStyleFile=&mt('Select Style File'); + my $SelectSpreadsheetFile=&mt('Select Spreadsheet File'); my $output=''; if (! exists($values{'con_lost'})) { my %descriptions= - ('url' => 'Top Level Map '. + ('url' => ''.&mt('Top Level Map').' '. '
". - 'Select Map
'. - 'Modification may make assessment data '. - 'inaccessible', - 'description' => 'Course Description', - 'courseid' => 'Course ID or number
'. - '(internal, optional)', - 'grading' => 'Grading'. - '"standard" or any other value. '. - 'Default for new courses is "standard".', - - 'default_xml_style' => 'Default XML Style File '. + &mt('Select Map').'
'. + &mt('Modification may make assessment data inaccessible'). + '', + 'description' => ''.&mt('Course Description').'', + 'courseid' => ''.&mt('Course ID or number'). + '
'. + '('.&mt('internal').', '.&mt('optional').')', + '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').' '. 'Select Style File
", - 'question.email' => 'Feedback Addresses for Resource Content '. - 'Questions
(user:domain,'. + ",'sty')\">$SelectStyleFile
", + 'question.email' => ''.&mt('Feedback Addresses for Resource Content Question'). + '
(user:domain,'. 'user:domain(section;section;...;*;...),...)', - 'comment.email' => 'Feedback Addresses for Course Content Comments
'. + 'comment.email' => ''.&mt('Feedback Addresses for Course Content Comments').'
'. '(user:domain,user:domain(section;section;...;*;...),...)', - 'policy.email' => 'Feedback Addresses for Course Policy'. + 'policy.email' => ''.&mt('Feedback Addresses for Course Policy').''. '
(user:domain,user:domain(section;section;...;*;...),...)', - 'hideemptyrows' => 'Hide Empty Rows in Spreadsheets
'. - '("yes" for default hiding)', - 'pageseparators' => 'Visibly Separate Items on Pages
'. - '("yes" for visible separation, '. - 'changes will not show until next login)', - - 'plc.roles.denied'=> 'Disallow live chatroom use for '. - 'Roles
"st": '. - 'student, "ta": '. + 'hideemptyrows' => ''.&mt('Hide Empty Rows in Spreadsheets').'
'. + '('.&mt('"[_1]" for default hiding','yes').')', + 'pageseparators' => ''.&mt('Visibly Separate Items on Pages').'
'. + '('.&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": '. + &mt('student').', "ta": '. 'TA, "in": '. - 'instructor;
role,role,...) '. + &mt('instructor').';
'.&mt('role,role,...').') '. Apache::loncommon::help_open_topic("Course_Disable_Discussion"), 'plc.users.denied' => - 'Disallow live chatroom use for Users
'. + ''.&mt('Disallow live chatroom use for Users').'
'. '(user:domain,user:domain,...)', - 'pch.roles.denied'=> 'Disallow Resource Discussion for '. - 'Roles
"st": '. + 'pch.roles.denied'=> ''.&mt('Disallow Resource Discussion for Roles'). + '
"st": '. 'student, "ta": '. 'TA, "in": '. 'instructor;
role,role,...) '. Apache::loncommon::help_open_topic("Course_Disable_Discussion"), 'pch.users.denied' => - 'Disallow Resource Discussion for Users
'. + ''.&mt('Disallow Resource Discussion for Users').'
'. '(user:domain,user:domain,...)', 'spreadsheet_default_classcalc' - => 'Default Course Spreadsheet '. + => ''.&mt('Default Course Spreadsheet').' '. 'Select Spreadsheet File
", + ",'spreadsheet')\">$SelectSpreadsheetFile
", 'spreadsheet_default_studentcalc' - => 'Default Student Spreadsheet '. + => ''.&mt('Default Student Spreadsheet').' '. 'Select Spreadsheet File
", + ",'spreadsheet')\">$SelectSpreadsheetFile
", 'spreadsheet_default_assesscalc' - => 'Default Assessment Spreadsheet '. + => ''.&mt('Default Assessment Spreadsheet').' '. 'Select Spreadsheet File
", + ",'spreadsheet')\">$SelectSpreadsheetFile
", 'allow_limited_html_in_feedback' - => 'Allow limited HTML in discussion posts
'. - '(Set value to "yes" to allow)', + => ''.&mt('Allow limited HTML in discussion posts').'
'. + '('.&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' - => 'Randomization algorithm used
'. - 'Modifying this will make problems '. - 'have different numbers and answers', + => ''.&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' - => 'Allow problems to be split over pages
'. - ' ("yes" if allowed, anything else if not)', + => ''.&mt('Allow problems to be split over pages').'
'. + ' ('.&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' - => 'Anonimous quiz/exam
'. - ' (yes to avoid print students names )', - 'default_enrollment_start_date' => 'Default beginning date '. - 'when enrolling students', - 'default_enrollment_end_date' => 'Default ending date '. - 'when enrolling students', - 'languages' => 'Languages used', + => ''.&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').'', + 'nothideprivileged' => ''.&mt('Privileged users that should not be hidden on staff listings').''. + '
(user:domain,user:domain,...)', + 'languages' => ''.&mt('Languages used').'', 'disable_receipt_display' - => 'Disable display of problem receipts
'. - ' ("yes" to disable, anything else if not)' + => ''.&mt('Disable display of problem receipts').'
'. + ' ('.&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', @@ -1602,12 +1730,16 @@ sub crsenv { 'hideemptyrows', 'default_enrollment_start_date', 'default_enrollment_end_date', + 'tthoptions', + 'disablesigfigs' ); foreach my $parameter (sort(keys(%values))) { - if (! $descriptions{$parameter}) { - $descriptions{$parameter}=$parameter; - push(@Display_Order,$parameter); - } + unless ($parameter =~ m/^internal\./) { + if (! $descriptions{$parameter}) { + $descriptions{$parameter}=$parameter; + push(@Display_Order,$parameter); + } + } } foreach my $parameter (@Display_Order) { my $description = $descriptions{$parameter}; @@ -1644,48 +1776,40 @@ sub crsenv { $onchange.' />'. ''; } - $r->print(< + 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'); + 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
ParameterValueSet?
$lt{'par'}$lt{'val'}$lt{'set'}?
- +

-ENDENV +ENDenv } ################################################## @@ -1714,15 +1838,18 @@ 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 $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(< +$html LON-CAPA Course Environment $bodytag -
+$breadcrumbs + ENDOVER # Setting @@ -1731,24 +1858,41 @@ ENDOVER undef %newdata; my @deldata=(); undef @deldata; - foreach (keys %ENV) { + foreach (keys %env) { if ($_=~/^form\.([a-z]+)\_(.+)$/) { my $cmd=$1; my $thiskey=$2; if ($cmd eq 'set') { - my $data=$ENV{$_}; + my $data=$env{$_}; if ($olddata{$thiskey} ne $data) { $newdata{$thiskey}=$data; } } elsif ($cmd eq 'del') { 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{$_}); + if (defined($data) and $olddata{$thiskey} ne $data) { $newdata{$thiskey}=$data; } } } } # Store - &Apache::lonnet::del('resourcedata',\@deldata,$dom,$crs); - &Apache::lonnet::put('resourcedata',\%newdata,$dom,$crs); + my $delentries=$#deldata+1; + my @newdatakeys=keys %newdata; + my $putentries=$#newdatakeys+1; + if ($delentries) { + if (&Apache::lonnet::del('resourcedata',\@deldata,$dom,$crs) eq 'ok') { + $r->print('

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

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

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

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

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

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

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

'); + } + } # Read and display my %resourcedata=&Apache::lonnet::dump('resourcedata',$dom,$crs); my $oldsection=''; @@ -1756,6 +1900,7 @@ ENDOVER 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)= @@ -1768,9 +1913,10 @@ ENDOVER $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

"); @@ -1793,6 +1939,7 @@ ENDOVER $r->print(&tablestart().''.$name. ':'); + $foundkeys++; if ($resourcedata{$thiskey.'.type'}=~/^date/) { my $jskey='key_'.$pointer; $pointer++; @@ -1811,12 +1958,184 @@ ENDOVER } } - $r->print(&tableend(). - '

'); + $r->print(&tableend().'

'. + ($foundkeys?'':&mt('There are no course or section 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', + help => 'Course_Setting_Parameters', + action => 'crsenv', + permission => $parm_permission, + }, + { text => 'Set/Modify Course Assessment Parameters - Helper Mode', + url => '/adm/helper/parameter.helper', + permission => $parm_permission, + }, + { text => 'Modify Course Assessment Parameters - Overview Mode', + action => 'setoverview', + permission => $parm_permission, + }, + { text => 'Set/Modify Course Assessment Parameters - Table Mode', + action => 'settable', + permission => $parm_permission, + }, +# { text => 'Set Parameter Default Preferences', +# help => 'Course_View_Class_List', +# 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; +} + + + + +################################################## +################################################## =pod @@ -1825,7 +2144,6 @@ ENDOVER Main handler. Calls &assessparms and &crsenv subroutines. =cut - ################################################## ################################################## use Data::Dumper; @@ -1837,7 +2155,8 @@ 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']); # ----------------------------------------------------------- Clear out garbage @@ -1853,30 +2172,55 @@ sub handler { %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'}) || + &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 + # + # 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 'settable' && $parm_permission) { + &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=settable', + text=>"Table Mode"}); &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; }