--- loncom/interface/lonparmset.pm 2004/08/17 20:27:04 1.173 +++ loncom/interface/lonparmset.pm 2004/12/06 21:41:01 1.180 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Handler to set parameters for assessments # -# $Id: lonparmset.pm,v 1.173 2004/08/17 20:27:04 albertel Exp $ +# $Id: lonparmset.pm,v 1.180 2004/12/06 21:41:01 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -581,6 +581,8 @@ sub extractResourceInformation { foreach (keys %$bighash) { if ($_=~/^src\_(\d+)\.(\d+)$/) { + # there are no resources in the 0 level + if ($1 eq '0') { next; } my $mapid=$1; my $resid=$2; my $id=$mapid.'.'.$resid; @@ -623,8 +625,11 @@ sub extractResourceInformation { &Apache::lonnet::declutter($$bighash{'map_id_'.$mapid}); $$mapp{$mapid}=$$mapp{$id}; $$allmaps{$mapid}=$$mapp{$id}; - $$maptitles{$mapid}= - $$bighash{'title_'.$$bighash{'ids_'.&Apache::lonnet::clutter($$mapp{$id})}}; + if ($mapid eq '1') { + $$maptitles{$mapid}='Main Course Documents'; + } else { + $$maptitles{$mapid}=&Apache::lonnet::gettitle(&Apache::lonnet::clutter($$mapp{$id})); + } $$maptitles{$$mapp{$id}}=$$maptitles{$mapid}; $$symbp{$id}=$$mapp{$id}. '___'.$resid.'___'. @@ -996,23 +1001,36 @@ sub assessparms { $r->print(''.&mt('Select Parameters to View').''); - $r->print(''); - $r->print(''); - + $r->print('
print(' checked') unless (@pscat); - $r->print('>'.&mt('All Parameters').'
'); my $cnt=0; foreach $tempkey (sort { $allparms{$a} cmp $allparms{$b} } keys %allparms ) { ++$cnt; - $r->print('') unless ($cnt%2); + $r->print('') if ($cnt%2); $r->print(''); + $r->print('>'.$allparms{$tempkey}.''); + } + $r->print(' + +'); $r->print('
print('value="'.$tempkey.'"'); if ($pscat[0] eq "all" || grep $_ eq $tempkey, @pscat) { $r->print(' checked'); } - $r->print('>'.$allparms{$tempkey}.'
+ + + + +
'); # $r->print('
Select Parts'); @@ -1200,8 +1218,7 @@ 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('
'. @@ -1508,13 +1525,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 && 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.'.
'; @@ -1543,6 +1581,7 @@ 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.'), 'grading' => ''.&mt('Grading').'
'. '"standard", "external", or "spreadsheet" '.&Apache::loncommon::help_open_topic('GradingOptions'), 'default_xml_style' => ''.&mt('Default XML Style File').' '. @@ -1638,7 +1677,7 @@ sub crsenv { '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', @@ -1838,9 +1877,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

"); @@ -1887,6 +1927,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