--- loncom/interface/lonparmset.pm 2007/06/06 20:19:38 1.366 +++ loncom/interface/lonparmset.pm 2007/10/06 04:32:49 1.382 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Handler to set parameters for assessments # -# $Id: lonparmset.pm,v 1.366 2007/06/06 20:19:38 albertel Exp $ +# $Id: lonparmset.pm,v 1.382 2007/10/06 04:32:49 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -67,16 +67,6 @@ use Apache::longroup; use Apache::lonrss; use LONCAPA qw(:DEFAULT :match); -# --- Caches local to lonparmset - -my $parmhashid; -my %parmhash; -my $symbsid; -my %symbs; -my $rulesid; -my %rules; - -# --- end local caches ################################################## ################################################## @@ -119,8 +109,6 @@ sub parmval { sub parmval_by_symb { my ($what,$symb,$def,$uname,$udom,$csec,$cgroup,$courseopt)=@_; -# load caches - &cacheparmhash(); my $useropt; if ($uname ne '' && $udom ne '') { @@ -167,7 +155,7 @@ sub parmval_by_symb { # ------------------------------------------------------ third, check map parms - my $thisparm=$parmhash{$symbparm}; + my $thisparm=&parmhash($symbparm); if (defined($thisparm)) { $outpar[11]=$thisparm; $result=11; } if (defined($$courseopt{$courselevelr})) { @@ -228,58 +216,90 @@ sub parmval_by_symb { 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=''; +# --- Caches local to lonparmset + + +sub reset_caches { + &resetparmhash(); + &resetsymbcache(); + &resetrulescache(); } -sub symbcache { - my $id=shift; - if ($symbsid ne $env{'request.course.id'}) { - %symbs=(); +{ + my $parmhashid; + my %parmhash; + sub resetparmhash { + undef($parmhashid); + undef(%parmhash); } - 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()); + + 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'}; } - $symbsid=$env{'request.course.id'}; } - return $symbs{$id}; -} - -sub resetrulescache { - $rulesid=''; -} + + sub parmhash { + my ($id) = @_; + &cacheparmhash(); + return $parmhash{$id}; + } + } + +{ + my $symbsid; + my %symbs; + sub resetsymbcache { + undef($symbsid); + undef(%symbs); + } + + sub symbcache { + my $id=shift; + if ($symbsid ne $env{'request.course.id'}) { + undef(%symbs); + } + if (!$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}; + } + } -sub rulescache { - my $id=shift; - if ($rulesid ne $env{'request.course.id'} - && !defined($rules{$id})) { - my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'}; - my $crs = $env{'course.'.$env{'request.course.id'}.'.num'}; - %rules=&Apache::lonnet::dump('parmdefactions',$dom,$crs); - $rulesid=$env{'request.course.id'}; +{ + my $rulesid; + my %rules; + sub resetrulescache { + undef($rulesid); + undef(%rules); + } + + sub rulescache { + my $id=shift; + if ($rulesid ne $env{'request.course.id'} + && !defined($rules{$id})) { + my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'}; + my $crs = $env{'course.'.$env{'request.course.id'}.'.num'}; + %rules=&Apache::lonnet::dump('parmdefactions',$dom,$crs); + $rulesid=$env{'request.course.id'}; + } + return $rules{$id}; } - return $rules{$id}; } sub preset_defaults { @@ -345,7 +365,6 @@ sub storeparm { # - new type # - username # - userdomain - my %recstack; sub storeparm_by_symb { my ($symb,$spnam,$snum,$nval,$ntype,$uname,$udom,$csec,$recflag,$cgroup)=@_; @@ -558,6 +577,7 @@ sub valout { &date_sanity_info($value); } else { $result = $value; + $result = &HTML::Entities::encode($result,'"<>&'); } } return $result; @@ -594,10 +614,16 @@ sub plink { my ($parmname)=((split(/\&/,$marker))[1]=~/\_([^\_]+)$/); my ($hour,$min,$sec,$val)=&preset_defaults($parmname); unless (defined($winvalue)) { $winvalue=$val; } + my $valout = &valout($value,$type,1); + foreach my $item (\$type, \$dis, \$winvalue, \$marker, \$return, \$call, + \$hour, \$min, \$sec) { + $$item = &HTML::Entities::encode($$item,'"<>&'); + $$item =~ s/\'/\\\'/g; + } return '
'. ''. - &valout($value,$type,1).'
'; + $valout.''; } sub page_js { @@ -944,7 +970,7 @@ sub extractResourceInformation { # allparms is a hash of parameter names # my $name=&Apache::lonnet::metadata($srcf,$key.'.name'); - if (!exists($$allparms{$name})) { + if (!exists($$allparms{$name}) || $$allparms{$name} =~ m/^\s*$/ ) { my $display= &Apache::lonnet::metadata($srcf,$key.'.display'); my $parmdis = $display; $parmdis =~ s/\[Part.*$//g; @@ -1081,7 +1107,9 @@ ENDSCRIPT if ($$pscat[0] eq "all" || grep $_ eq $tempkey, @{$pscat}) { $r->print(' checked'); } - $r->print('>'.$$allparms{$tempkey}.''); + $r->print('>'.($$allparms{$tempkey}=~/\S/ ? $$allparms{$tempkey} + : $tempkey) + .''); $cnt++; if ($cnt==3) { $r->print("\n"); @@ -1573,7 +1601,8 @@ sub assessparms { foreach ('tolerance','date_default','date_start','date_end', 'date_interval','int','float','string') { $r->print(''); + &HTML::Entities::encode($env{'form.recent_'.$_},'"&<>'). + '" name="recent_'.$_.'" />'); } if (!$pssymb) { @@ -2047,17 +2076,24 @@ sub crsenv { # # Deal with the emails if ($name =~ /\.email$/) { - my ($user,$domain) = split(/:/,$value); - if (!defined($user) || !defined($domain)) { - $setoutput.= '
'. - &mt("Invalid email address specified, address must be of the form username:domain"). - ''; - undef($value); - } elsif (&Apache::lonnet::homeserver($user,$domain) eq 'no_host') { - $setoutput.= '
'. - &mt("Invalid email address specified, user [_1] is unknown.",$value). - ''; - undef($value); + foreach my $specifier (split(',',$value)) { + my ($user,$sections_or_groups)= + ($specifier=~/^([^\(]+)\(([^\)]+)\)/); + if (!$sections_or_groups) { + $user = $specifier; + } + my ($name,$domain) = split(':',$user); + if (!defined($user) || !defined($domain)) { + $setoutput.= '
'. + &mt("Invalid email address specified, address must be of the form username:domain what was specified was ([_1])",$user). + ''; + undef($value); + } elsif (&Apache::lonnet::homeserver($user,$domain) eq 'no_host') { + $setoutput.= '
'. + &mt("Invalid email address specified, user [_1] is unknown.",$name). + ''; + undef($value); + } } } # Get existing cloners @@ -2073,13 +2109,13 @@ sub crsenv { # # Let the user know we made the changes if ($name && defined($value)) { - my $failed_cloners; + my %failed_cloners; if ($name eq 'cloners') { $value =~ s/\s//g; $value =~ s/^,//; $value =~ s/,$//; # check requested clones are valid users. - $failed_cloners = &check_cloners(\$value,\@oldcloner); + %failed_cloners = &check_cloners(\$value,\@oldcloner); } my $put_result = &Apache::lonnet::put('environment', {$name=>$value},$dom,$crs); @@ -2088,25 +2124,52 @@ sub crsenv { if ($name eq 'cloners') { &change_clone($value,\@oldcloner); } - # Flush the course logs so course description is immediately updated + # Update environment and nohist_courseids.db if ($name eq 'description' && defined($value)) { - &Apache::lonnet::flushcourselogs(); + my %crsinfo = + &Apache::lonnet::courseiddump($dom,'.',1,'.','.', + $crs,undef,undef,'Course'); + &Apache::lonnet::appenv('course.'.$env{'request.course.id'}.'.description' => $value); + if (ref($crsinfo{$env{'request.course.id'}}) eq 'HASH') { + $crsinfo{$env{'request.course.id'}}{'description'} = $value; + my $chome = &Apache::lonnet::homeserver($crs,$dom); + my $putresult = + &Apache::lonnet::courseidput($dom,\%crsinfo, + $chome,'notime'); + } } } else { $setoutput.=&mt('Unable to set').' '.$name.' '.&mt('to'). ' '.$value.' '.&mt('due to').' '.$put_result.'.
'; } - if (($name eq 'cloners') && ($failed_cloners)) { - $setoutput.= &mt('Unable to include').' - '.$failed_cloners.', '. - &mt('reason').' - '.&mt('LON-CAPA user(s) do(es) not exist'). - '.
'.&mt('Please '). - ' '. - &mt('add the user(s)').', '. - &mt('and then return to the '). - ''. - &mt('Course Parameters page').' '. - &mt('to add the new user(s) to the list of possible cloners'). - '.
'; + if (($name eq 'cloners') && (keys(%failed_cloners) > 0)) { + $setoutput.= &mt('Unable to include').': '; + my @fails; + my $num = 0; + if (defined($failed_cloners{'format'})) { + $fails[$num] .= ''.$failed_cloners{'format'}. + ', '.&mt('reason').' - '. + &mt('Invalid format'); + $num ++; + } + if (defined($failed_cloners{'domain'})) { + $fails[$num] .= ''.$failed_cloners{'domain'}. + ', '.&mt('reason').' - '. + &mt('Domain does not exist'); + $num ++; + } + if (defined($failed_cloners{'newuser'})) { + $fails[$num] .= ''.$failed_cloners{'newuser'}. ', '.&mt('reason').' - '. + &mt('LON-CAPA user(s) do(es) not exist.'). + '.
'.&mt('Please '). + ' '. + &mt('add the user(s)').', '. + &mt('and then return to the '). + ''. + &mt('Course Parameters page').' '. + &mt('to add the new user(s) to the list of possible cloners'); + } + $setoutput .= join(';  ',@fails).'.
'; } } } @@ -2137,9 +2200,13 @@ sub crsenv { '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.'), + 'cloners' => ''.&mt('Users allowed to clone course').'
(user:domain,user:domain,*:domain)
'.&mt('Users with active Course Coordinator role in course are permitted to clone and need not be included.
+Use *:domain to allow course to be cloned by anyone in the specified domain.
+Use * to allow unrestricted cloning in all domains.'), 'grading' => ''.&mt('Grading').'
'. '"standard", "external", or "spreadsheet" '.&Apache::loncommon::help_open_topic('GradingOptions'), + 'task_grading' => ''.&mt('Bridge Task Grading').'
'. + &mt('Instructors and TAs in sections, when grading bridge tasks, should be allowed to grade other sections, "[_1]" they are allowed (this is the default), "[_2]" no, they can only grade their own section','any','section'), 'default_xml_style' => ''.&mt('Default XML Style File').' '. ' ''.&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.'), - + '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.)'), + 'student_classlist_portfiles' => ''.&mt('Include link to accessible portfolio files').'
'.&mt('"[_1]" for link to each a listing of each student\'s files.','yes'), + 'student_classlist_opt_in' => ''.&mt("Student's agreement needed for listing in student-viewable roster").'
'.&mt('"[_1]" to require students to opt-in to listing in the roster (on the roster page).','yes'), 'plc.roles.denied'=> ''.&mt('Disallow live chatroom use for Roles'). - '
"st": '. + '
("st": '. &mt('student').', "ta": '. 'TA, "in": '. &mt('instructor').';
'.&mt('role,role,...').') '. @@ -2175,7 +2243,7 @@ sub crsenv { '(user:domain,user:domain,...)', 'pch.roles.denied'=> ''.&mt('Disallow Resource Discussion for Roles'). - '
"st": '. + '
("st": '. 'student, "ta": '. 'TA, "in": '. 'instructor;
role,role,...) '. @@ -2226,10 +2294,7 @@ sub crsenv { ' Tabloid [11x17 in], Executive [7 1/2x10 in], A2 [420x594 mm],'. ' A3 [297x420 mm], A4 [210x297 mm], A5 [148x210 mm], A6 [105x148 mm])', 'print_header_format' - => 'Print header format; substitutions: %n student name %c course id %a assignment note, numbers after the % limit the field size', - 'anonymous_quiz' - => ''.&mt('Anonymous quiz/exam').'
'. - ' ('.&mt('yes').' '.&mt('to avoid print students names').' )', + => &mtn(' Print header format; substitutions : %n student name %c course id %a assignment note, numbers after the % limit the field size.').'', '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').''. @@ -2249,13 +2314,18 @@ sub crsenv { 'externalsyllabus' => ''.&mt('URL of Syllabus (not using internal handler)').'', 'tthoptions' - => ''.&mt('Default set of options to pass to tth/m when converting tex').'' + => ''.&mt('Default set of options to pass to tth/m when converting tex').'', + + 'texengine' + => ''.&mt('Force all students in the course to use a specific math rendering engine.').'
'.&mt('(Valid options are [_1].)','"tth", "jsMath", "mimetex"').'', ); my @Display_Order = ('url','description','courseid','cloners','grading', 'externalsyllabus', 'default_xml_style','pageseparators', 'question.email','question.email.text','comment.email','comment.email.text','policy.email','policy.email.text', 'student_classlist_view', + 'student_classlist_opt_in', + 'student_classlist_portfiles', 'plc.roles.denied','plc.users.denied', 'pch.roles.denied','pch.users.denied', 'allow_limited_html_in_feedback', @@ -2276,9 +2346,10 @@ sub crsenv { 'default_enrollment_start_date', 'default_enrollment_end_date', 'tthoptions', + 'texengine', 'disablesigfigs', 'disableexampointprint', - 'task_messages' + 'task_messages','task_grading', ); foreach my $parameter (sort(keys(%values))) { unless (($parameter =~ m/^internal\./)||($parameter =~ m/^metadata\./)) { @@ -2359,7 +2430,7 @@ $start_header_row $end_header_row $output $end_table - + $end_page ENDENV @@ -2521,6 +2592,26 @@ sub extractuser { return ($key=~/^$env{'request.course.id'}.\[useropt\:($match_username)\:($match_domain)\]\./); } +sub parse_listdata_key { + my ($key,$listdata) = @_; + # split into student/section affected, and + # the realm (folder/resource part and parameter + my ($student,$realm) = + ($key=~/^\Q$env{'request.course.id'}\E\.\[([^\.]+)\]\.(.+)$/); + # if course wide student would be undefined + if (!defined($student)) { + ($realm)=($key=~/^\Q$env{'request.course.id'}\E\.(.+)$/); + } + # strip off the .type if it's not the Question type parameter + if ($realm=~/\.type$/ && !exists($listdata->{$key.'.type'})) { + $realm=~s/\.type//; + } + # split into resource+part and parameter name + my ($res, $parm) = ($realm=~/^(.*)\.(.*)$/); + my ($res, $part) = ($res =~/^(.*)\.(.*)$/); + return ($student,$res,$part,$parm); +} + sub listdata { my ($r,$resourcedata,$listdata,$sortorder)=@_; # Start list output @@ -2532,40 +2623,48 @@ sub listdata { $tableopen=0; my $foundkeys=0; my %keyorder=&standardkeyorder(); + foreach my $thiskey (sort { + my ($astudent,$ares,$apart,$aparm) = &parse_listdata_key($a,$listdata); + my ($bstudent,$bres,$bpart,$bparm) = &parse_listdata_key($b,$listdata); + + # get the numerical order for the param + $aparm=$keyorder{'parameter_0_'.$aparm}; + $bparm=$keyorder{'parameter_0_'.$bparm}; + + my $result=0; + if ($sortorder eq 'realmstudent') { - my ($astudent,$arealm)=($a=~/^\Q$env{'request.course.id'}\E\.\[([^\.]+)\]\.(.+)\.[^\.]+$/); - my ($bstudent,$brealm)=($b=~/^\Q$env{'request.course.id'}\E\.\[([^\.]+)\]\.(.+)\.[^\.]+$/); - if (!defined($astudent)) { - ($arealm)=($a=~/^\Q$env{'request.course.id'}\E\.(.+)$/); - } - if (!defined($bstudent)) { - ($brealm)=($b=~/^\Q$env{'request.course.id'}\E\.(.+)$/); - } - $arealm=~s/\.type//; - my ($ares, $aparm) = ($arealm=~/^(.*)\.(.*)$/); - $aparm=$keyorder{'parameter_0_'.$aparm}; - $brealm=~s/\.type//; - my ($bres, $bparm) = ($brealm=~/^(.*)\.(.*)$/); - $bparm=$keyorder{'parameter_0_'.$bparm}; - if ($ares eq $bres) { - if (defined($aparm) && defined($bparm)) { - ($aparm <=> $bparm); - } elsif (defined($aparm)) { - -1; - } elsif (defined($bparm)) { - 1; - } else { - ($arealm cmp $brealm) || ($astudent cmp $bstudent); - } - } else { - ($arealm cmp $brealm) || ($astudent cmp $bstudent); + if ($ares ne $bres ) { + $result = ($ares cmp $bres); + } elsif ($astudent ne $bstudent) { + $result = ($astudent cmp $bstudent); + } elsif ($apart ne $bpart ) { + $result = ($apart cmp $bpart); } } else { - $a cmp $b; + if ($astudent ne $bstudent) { + $result = ($astudent cmp $bstudent); + } elsif ($ares ne $bres ) { + $result = ($ares cmp $bres); + } elsif ($apart ne $bpart ) { + $result = ($apart cmp $bpart); + } + } + + if (!$result) { + if (defined($aparm) && defined($bparm)) { + $result = ($aparm <=> $bparm); + } elsif (defined($aparm)) { + $result = -1; + } elsif (defined($bparm)) { + $result = 1; + } } + + $result; } keys %{$listdata}) { - + if ($$listdata{$thiskey.'.type'}) { my $thistype=$$listdata{$thiskey.'.type'}; if ($$resourcedata{$thiskey.'.type'}) { @@ -2714,8 +2813,8 @@ ENDOVER my @selected_sections = &Apache::loncommon::get_env_multiple('form.Section'); @selected_sections = ('all') if (! @selected_sections); - foreach (@selected_sections) { - if ($_ eq 'all') { + foreach my $sec (@selected_sections) { + if ($sec eq 'all') { @selected_sections = ('all'); } } @@ -2735,6 +2834,9 @@ ENDOVER \%mapp, \%symbp,\%maptitles,\%uris, \%keyorder,\%defkeytype); + if (grep {$_ eq 'all'} (@psprt)) { + @psprt = keys(%allparts); + } # Menu to select levels, etc $r->print(' @@ -2972,7 +3074,6 @@ sub parse_key { $data{'realm_type'} = 'folder'; $data{'realm_title'} = &Apache::lonnet::gettitle($data{'realm'}); ($data{'realm_exists'}) = &Apache::lonnet::is_on_map($data{'realm'}); - &Apache::lonnet::logthis($1." siad ". $data{'realm_exists'} ); } elsif ($middle) { $data{'realm'} = $middle; $data{'realm_type'} = 'symb'; @@ -3019,48 +3120,63 @@ where $action is add or drop, and $clone user for whom cloning ability is to be changed in course. =cut - + ################################################## ################################################## sub extract_cloners { my ($clonelist,$allowclone) = @_; if ($clonelist =~ /,/) { - @{$allowclone} = split/,/,$clonelist; + @{$allowclone} = split(/,/,$clonelist); } else { $$allowclone[0] = $clonelist; } } - sub check_cloners { my ($clonelist,$oldcloner) = @_; - my ($clean_clonelist,$disallowed); + my ($clean_clonelist,%disallowed); my @allowclone = (); &extract_cloners($$clonelist,\@allowclone); foreach my $currclone (@allowclone) { - if (!grep/^$currclone$/,@$oldcloner) { - my ($uname,$udom) = split/:/,$currclone; - if ($uname && $udom) { - if (&Apache::lonnet::homeserver($uname,$udom) eq 'no_host') { - $disallowed .= $currclone.','; + if (!grep(/^\Q$currclone\E$/,@$oldcloner)) { + if ($currclone eq '*') { + $clean_clonelist .= $currclone.','; + } else { + my ($uname,$udom) = split(/:/,$currclone); + if ($uname eq '*') { + if ($udom =~ /^$match_domain$/) { + if (!&Apache::lonnet::domain($udom)) { + $disallowed{'domain'} .= $currclone.','; + } else { + $clean_clonelist .= $currclone.','; + } + } else { + $disallowed{'format'} .= $currclone.','; + } + } elsif ($currclone !~/^($match_username)\:($match_domain)$/) { + $disallowed{'format'} .= $currclone.','; } else { - $clean_clonelist .= $currclone.','; + if (&Apache::lonnet::homeserver($uname,$udom) eq 'no_host') { + $disallowed{'newuser'} .= $currclone.','; + } else { + $clean_clonelist .= $currclone.','; + } } } } else { $clean_clonelist .= $currclone.','; } } - if ($disallowed) { - $disallowed =~ s/,$//; + foreach my $key (keys(%disallowed)) { + $disallowed{$key} =~ s/,$//; } if ($clean_clonelist) { $clean_clonelist =~ s/,$//; } $$clonelist = $clean_clonelist; - return $disallowed; -} + return %disallowed; +} sub change_clone { my ($clonelist,$oldcloner) = @_; @@ -3073,43 +3189,47 @@ sub change_clone { my @allowclone; &extract_cloners($clonelist,\@allowclone); 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; + if (!grep(/^$currclone$/,@$oldcloner)) { + if ($currclone ne '*') { + ($uname,$udom) = split(/:/,$currclone); + if ($uname && $udom && $uname ne '*') { + if (&Apache::lonnet::homeserver($uname,$udom) ne '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); } - &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'} .= $_.','; + if (!grep(/^\Q$oldclone\E$/,@allowclone)) { + if ($oldclone ne '*') { + ($uname,$udom) = split(/:/,$oldclone); + if ($uname && $udom && $uname ne '*' ) { + if (&Apache::lonnet::homeserver($uname,$udom) ne '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 my $crs (@currclonecrs) { + if ($crs ne $clone_crs) { + $newclonecrs{'cloneable'} .= $crs.','; + } } + $newclonecrs{'cloneable'} =~ s/,$//; + } else { + $newclonecrs{'cloneable'} = ''; } - $newclonecrs{'cloneable'} =~ s/,$//; - } else { - $newclonecrs{'cloneable'} = ''; + &Apache::lonnet::put('environment',\%newclonecrs,$udom,$uname); } - &Apache::lonnet::put('environment',\%newclonecrs,$udom,$uname); } } } @@ -3935,14 +4055,15 @@ sub check_for_course_info { Main handler. Calls &assessparms and &crsenv subroutines. =cut + ################################################## ################################################## -# use Data::Dumper; - sub handler { my $r=shift; + &reset_caches(); + if ($r->header_only) { &Apache::loncommon::content_type($r,'text/html'); $r->send_http_header; @@ -3977,10 +4098,6 @@ sub handler { $r->send_http_header; - # id numbers can change on re-ordering of folders - - &resetsymbcache(); - # # Main switch on form.action and form.state, as appropriate # @@ -4049,6 +4166,8 @@ sub handler { } return HTTP_NOT_ACCEPTABLE; } + &reset_caches(); + return OK; }