--- loncom/interface/lonparmset.pm 2004/01/15 03:18:19 1.148 +++ loncom/interface/lonparmset.pm 2005/03/17 20:01:11 1.185 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Handler to set parameters for assessments # -# $Id: lonparmset.pm,v 1.148 2004/01/15 03:18:19 www Exp $ +# $Id: lonparmset.pm,v 1.185 2005/03/17 20:01:11 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -96,10 +96,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 @@ -129,32 +129,35 @@ sub parmval { my $courselevelr=$ENV{'request.course.id'}.'.'.$symbparm; my $courselevelm=$ENV{'request.course.id'}.'.'.$mapparm; -# -------------------------------------------------------- first, check default - if (defined($def)) { $outpar[11]=$def; $result=11; } -# ----------------------------------------------------- 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; + $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 +174,7 @@ sub parmval { } } -# ---------------------------------------------------------- fourth, check user +# ---------------------------------------------------------- fifth, check user if (defined($uname)) { if (defined($useropt{$courselevel})) { @@ -307,12 +310,11 @@ sub startpage { 'ad' => "at Domain" ); my $overallhelp= - &Apache::loncommon::help_open_topic("Course_Setting_Parameters"). - &Apache::loncommon::help_open_faq(10). - &Apache::loncommon::help_open_bug('Instructor Interface'); + &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'); @@ -1119,8 +1147,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("". @@ -1129,8 +1158,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{'femof'} +$lt{'def'}$lt{'foremf'}$lt{'fr'} ENDTABLEHEADFOUR if ($csec) { @@ -1151,18 +1180,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= (); @@ -1189,14 +1220,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"); @@ -1331,6 +1362,7 @@ 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); @@ -1408,6 +1440,7 @@ 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); # $r->print("resource.$part{$_}.$name{$_},$symbp{$mapid}\n"); @@ -1494,13 +1527,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.'.
'; @@ -1526,14 +1580,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').'
'. @@ -1587,33 +1640,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').'', + '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', @@ -1621,6 +1701,8 @@ sub crsenv { 'hideemptyrows', 'default_enrollment_start_date', 'default_enrollment_end_date', + 'tthoptions', + 'disablesigfigs' ); foreach my $parameter (sort(keys(%values))) { unless ($parameter =~ m/^internal\./) { @@ -1665,36 +1747,24 @@ 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'); + my $browse_js=&Apache::loncommon::browser_and_searcher_javascript('parmset'); + my $html=&Apache::lonxml::xmlbegin(); $r->print(< +$html + - LON-CAPA Course Environment $bodytag @@ -1702,10 +1772,10 @@ $bodytag $setoutput

- + $output
$Parameter$Value$Set?
$lt{'par'}$lt{'val'}$lt{'set'}?
- + @@ -1740,8 +1810,9 @@ sub overview { 'Set/Modify Course Assessment Parameters'); my $dom = $ENV{'course.'.$ENV{'request.course.id'}.'.domain'}; my $crs = $ENV{'course.'.$ENV{'request.course.id'}.'.num'}; + my $html=&Apache::lonxml::xmlbegin(); $r->print(< +$html LON-CAPA Course Environment @@ -1766,7 +1837,7 @@ ENDOVER push (@deldata,$thiskey); } elsif ($cmd eq 'datepointer') { my $data=&Apache::lonhtmlcommon::get_date_from_form($ENV{$_}); - if ($olddata{$thiskey} ne $data) { $newdata{$thiskey}=$data; } + if (defined($data) and $olddata{$thiskey} ne $data) { $newdata{$thiskey}=$data; } } } } @@ -1810,9 +1881,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

"); @@ -1860,6 +1932,90 @@ ENDOVER ################################################## ################################################## + +=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 @@ -1899,7 +2055,10 @@ sub handler { # ----------------------------------------------------- Needs to be in a course if (($ENV{'request.course.id'}) && - (&Apache::lonnet::allowed('opa',$ENV{'request.course.id'}))) { + (&Apache::lonnet::allowed('opa',$ENV{'request.course.id'}) || + &Apache::lonnet::allowed('opa',$ENV{'request.course.id'}.'/'. + $ENV{'request.course.sec'}) + )) { &Apache::loncommon::content_type($r,'text/html'); $r->send_http_header;