version 1.49, 2009/11/23 21:45:18
|
version 1.51, 2010/03/15 19:10:59
|
Line 49 sub get_dc_settable {
|
Line 49 sub get_dc_settable {
|
|
|
sub autoenroll_keys { |
sub autoenroll_keys { |
my $internals = ['coursecode','courseowner','authtype','autharg','autoadds','autodrops', |
my $internals = ['coursecode','courseowner','authtype','autharg','autoadds','autodrops', |
'autostart','autoend','sectionnums','crosslistings']; |
'autostart','autoend','sectionnums','crosslistings', |
|
'co-owners']; |
my $accessdates = ['default_enrollment_start_date','default_enrollment_end_date']; |
my $accessdates = ['default_enrollment_start_date','default_enrollment_end_date']; |
return ($internals,$accessdates); |
return ($internals,$accessdates); |
} |
} |
Line 106 sub get_enrollment_settings {
|
Line 107 sub get_enrollment_settings {
|
} else { |
} else { |
$enrollvar{$type} = &Apache::lonlocal::locallocaltime($settings{$item}); |
$enrollvar{$type} = &Apache::lonlocal::locallocaltime($settings{$item}); |
} |
} |
} elsif ($type eq "sectionnums") { |
} elsif (($type eq 'sectionnums') || ($type eq 'co-owners')) { |
$enrollvar{$type} = $settings{$item}; |
$enrollvar{$type} = $settings{$item}; |
$enrollvar{$type} =~ s/,/, /g; |
$enrollvar{$type} =~ s/,/, /g; |
} elsif ($type eq "authtype" |
} elsif ($type eq "authtype" |
Line 335 sub print_settings_display {
|
Line 336 sub print_settings_display {
|
"<td><b>$longtype{$item}</b></td>\n". |
"<td><b>$longtype{$item}</b></td>\n". |
"<td>$enrollvar{$item}</td>\n"; |
"<td>$enrollvar{$item}</td>\n"; |
if (grep(/^\Q$item\E$/,@modifiable_params)) { |
if (grep(/^\Q$item\E$/,@modifiable_params)) { |
$disp_table .= '<td align="right">'.&mt('Yes').'</td>'."\n"; |
$disp_table .= '<td align="right">'.&mt('Yes').'</td>'."\n"; |
} else { |
} else { |
$disp_table .= '<td align="right">'.&mt('No').'</td>'."\n"; |
$disp_table .= '<td align="right">'.&mt('No').'</td>'."\n"; |
} |
} |
Line 635 sub gather_authenitems {
|
Line 636 sub gather_authenitems {
|
sub modify_course { |
sub modify_course { |
my ($r,$cdom,$cnum,$cdesc,$domdesc,$type) = @_; |
my ($r,$cdom,$cnum,$cdesc,$domdesc,$type) = @_; |
my %longtype = &course_settings_descrip($type); |
my %longtype = &course_settings_descrip($type); |
my @items = ('internal.courseowner','description'); |
my @items = ('internal.courseowner','description','internal.co-owners', |
|
'internal.pendingco-owners'); |
unless ($type eq 'Community') { |
unless ($type eq 'Community') { |
push(@items,('internal.coursecode','internal.authtype','internal.autharg', |
push(@items,('internal.coursecode','internal.authtype','internal.autharg', |
'internal.sectionnums','internal.crosslistings')); |
'internal.sectionnums','internal.crosslistings')); |
Line 711 sub modify_course {
|
Line 713 sub modify_course {
|
} |
} |
} |
} |
|
|
if ($changed{'owner'} || $changed{'code'}) { |
if ($changed{'owner'} || $changed{'code'}) { |
my %crsinfo = &Apache::lonnet::courseiddump($cdom,'.',1,'.','.',$cnum, |
my %crsinfo = &Apache::lonnet::courseiddump($cdom,'.',1,'.','.',$cnum, |
undef,undef,'.'); |
undef,undef,'.'); |
if (ref($crsinfo{$env{'form.pickedcourse'}}) eq 'HASH') { |
if (ref($crsinfo{$env{'form.pickedcourse'}}) eq 'HASH') { |
Line 723 sub modify_course {
|
Line 725 sub modify_course {
|
} |
} |
my $chome = &Apache::lonnet::homeserver($cnum,$cdom); |
my $chome = &Apache::lonnet::homeserver($cnum,$cdom); |
my $putres = &Apache::lonnet::courseidput($cdom,\%crsinfo,$chome,'notime'); |
my $putres = &Apache::lonnet::courseidput($cdom,\%crsinfo,$chome,'notime'); |
|
if ($putres eq 'ok') { |
|
&update_coowners($cdom,$cnum,$chome,\%settings,\%newattr); |
|
} |
} |
} |
} |
} |
foreach my $param (@modifiable_params) { |
foreach my $param (@modifiable_params) { |
Line 861 sub modify_course {
|
Line 866 sub modify_course {
|
return; |
return; |
} |
} |
|
|
|
sub update_coowners { |
|
my ($cdom,$cnum,$chome,$settings,$newattr) = @_; |
|
return unless ((ref($settings) eq 'HASH') && (ref($newattr) eq 'HASH')); |
|
my %designhash = &Apache::loncommon::get_domainconf($cdom); |
|
my (%cchash,$autocoowners); |
|
if ($designhash{$cdom.'.autoassign.co-owners'}) { |
|
$autocoowners = 1; |
|
%cchash = &Apache::lonnet::get_my_roles($cnum,$cdom,undef,undef,['cc']); |
|
} |
|
if ($settings->{'internal.courseowner'} ne $newattr->{'courseowner'}) { |
|
my $oldowner_to_coowner; |
|
my @types = ('co-owners'); |
|
if (($newattr->{'coursecode'}) && ($autocoowners)) { |
|
my $oldowner = $settings->{'internal.courseowner'}; |
|
if ($cchash{$oldowner.':cc'}) { |
|
my ($result,$desc) = &Apache::lonnet::auto_validate_instcode($cnum,$cdom,$newattr->{'coursecode'},$oldowner); |
|
if ($result eq 'valid') { |
|
if ($settings->{'internal.co-owner'}) { |
|
my @current = split(',',$settings->{'internal.co-owners'}); |
|
unless (grep(/^\Q$oldowner\E$/,@current)) { |
|
$oldowner_to_coowner = 1; |
|
} |
|
} else { |
|
$oldowner_to_coowner = 1; |
|
} |
|
} |
|
} |
|
} else { |
|
push(@types,'pendingco-owners'); |
|
} |
|
foreach my $type (@types) { |
|
if ($settings->{'internal.'.$type}) { |
|
my @current = split(',',$settings->{'internal.'.$type}); |
|
my $newowner = $newattr->{'courseowner'}; |
|
my @newvalues = (); |
|
if (($newowner ne '') && (grep(/^\Q$newowner\E$/,@current))) { |
|
foreach my $person (@current) { |
|
unless ($person eq $newowner) { |
|
push(@newvalues,$person); |
|
} |
|
} |
|
} else { |
|
@newvalues = @current; |
|
} |
|
if ($oldowner_to_coowner) { |
|
push(@newvalues,$settings->{'internal.courseowner'}); |
|
@newvalues = sort(@newvalues); |
|
} |
|
my $newownstr = join(',',@newvalues); |
|
if ($newownstr ne $settings->{'internal.'.$type}) { |
|
if ($type eq 'co-owners') { |
|
my $deleted = ''; |
|
unless (@newvalues) { |
|
$deleted = 1; |
|
} |
|
&Apache::lonnet::store_coowners($cdom,$cnum,$chome, |
|
$deleted,@newvalues); |
|
} else { |
|
my $pendingcoowners; |
|
my $cid = $cdom.'_'.$cnum; |
|
if (@newvalues) { |
|
$pendingcoowners = join(',',@newvalues); |
|
my %pendinghash = ( |
|
'internal.pendingco-owners' => $pendingcoowners, |
|
); |
|
my $putresult = &put('environment',\%pendinghash,$cdom,$cnum); |
|
if ($putresult eq 'ok') { |
|
if ($env{'course.'.$cid.'.num'} eq $cnum) { |
|
&appenv({'course.'.$cid.'.internal.pendingco-owners' => $pendingcoowners}); |
|
} |
|
} |
|
} else { |
|
my $delresult = &Apache::lonnet::del('environment',['internal.pendingco-owners'],$cdom,$cnum); |
|
if ($delresult eq 'ok') { |
|
if ($env{'course.'.$cid.'.internal.pendingco-owners'}) { |
|
&Apache::lonnet::delenv('course.'.$cid.'.internal.pendingco-owners'); |
|
} |
|
} |
|
} |
|
} |
|
} elsif ($oldowner_to_coowner) { |
|
&Apache::lonnet::store_coowners($cdom,$cnum,$chome,'', |
|
$settings->{'internal.courseowner'}); |
|
|
|
} |
|
} elsif ($oldowner_to_coowner) { |
|
&Apache::lonnet::store_coowners($cdom,$cnum,$chome,'', |
|
$settings->{'internal.courseowner'}); |
|
} |
|
} |
|
} |
|
if ($settings->{'internal.coursecode'} ne $newattr->{'coursecode'}) { |
|
if ($newattr->{'coursecode'} ne '') { |
|
my %designhash = &Apache::loncommon::get_domainconf($cdom); |
|
if ($designhash{$cdom.'.autoassign.co-owners'}) { |
|
my @newcoowners = (); |
|
if ($settings->{'internal.co-owners'}) { |
|
my @currcoown = split(',',$settings->{'internal.coowners'}); |
|
my ($updatecoowners,$delcoowners); |
|
foreach my $person (@currcoown) { |
|
my ($result,$desc) = &Apache::lonnet::auto_validate_instcode($cnum,$cdom,$newattr->{'coursecode'},$person); |
|
if ($result eq 'valid') { |
|
push(@newcoowners,$person); |
|
} |
|
} |
|
foreach my $item (sort(keys(%cchash))) { |
|
my ($uname,$udom,$urole) = split(':',$item); |
|
next if ($uname.':'.$udom eq $newattr->{'courseowner'}); |
|
unless (grep(/^\Q$uname\E:\Q$udom\E$/,@newcoowners)) { |
|
my ($result,$desc) = &Apache::lonnet::auto_validate_instcode($cnum,$cdom,$newattr->{'coursecode'},$uname.':'.$udom); |
|
if ($result eq 'valid') { |
|
push(@newcoowners,$uname.':'.$udom); |
|
} |
|
} |
|
} |
|
if (@newcoowners) { |
|
my $coowners = join(',',sort(@newcoowners)); |
|
unless ($coowners eq $settings->{'internal.co-owners'}) { |
|
$updatecoowners = 1; |
|
} |
|
} else { |
|
$delcoowners = 1; |
|
} |
|
if ($updatecoowners || $delcoowners) { |
|
&Apache::lonnet::store_coowners($cdom,$cnum,$chome, |
|
$delcoowners,@newcoowners); |
|
} |
|
} else { |
|
foreach my $item (sort(keys(%cchash))) { |
|
my ($uname,$udom,$urole) = split(':',$item); |
|
push(@newcoowners,$uname.':'.$udom); |
|
} |
|
if (@newcoowners) { |
|
&Apache::lonnet::store_coowners($cdom,$cnum,$chome,'', |
|
@newcoowners); |
|
} |
|
} |
|
} |
|
} |
|
} |
|
return; |
|
} |
|
|
sub modify_quota { |
sub modify_quota { |
my ($r,$cdom,$cnum,$cdesc,$domdesc,$type) = @_; |
my ($r,$cdom,$cnum,$cdesc,$domdesc,$type) = @_; |
&print_header($r,$type); |
&print_header($r,$type); |
Line 1168 sub course_settings_descrip {
|
Line 1316 sub course_settings_descrip {
|
if ($type eq 'Community') { |
if ($type eq 'Community') { |
%longtype = &Apache::lonlocal::texthash( |
%longtype = &Apache::lonlocal::texthash( |
'courseowner' => "Username:domain of community owner", |
'courseowner' => "Username:domain of community owner", |
|
'co-owners' => "Username:domain of each co-owner", |
); |
); |
|
|
} else { |
} else { |
%longtype = &Apache::lonlocal::texthash( |
%longtype = &Apache::lonlocal::texthash( |
'authtype' => 'Default authentication method', |
'authtype' => 'Default authentication method', |
Line 1182 sub course_settings_descrip {
|
Line 1330 sub course_settings_descrip {
|
'default_enrollment_end_date' => 'Date of last student access', |
'default_enrollment_end_date' => 'Date of last student access', |
'coursecode' => 'Official course code', |
'coursecode' => 'Official course code', |
'courseowner' => "Username:domain of course owner", |
'courseowner' => "Username:domain of course owner", |
|
'co-owners' => "Username:domain of each co-owner", |
'notifylist' => 'Course Coordinators to be notified of enrollment changes', |
'notifylist' => 'Course Coordinators to be notified of enrollment changes', |
'sectionnums' => 'Course section number:LON-CAPA section', |
'sectionnums' => 'Course section number:LON-CAPA section', |
'crosslistings' => 'Crosslisted class:LON-CAPA section', |
'crosslistings' => 'Crosslisted class:LON-CAPA section', |