--- loncom/interface/lonmodifycourse.pm 2010/03/08 22:31:27 1.50
+++ loncom/interface/lonmodifycourse.pm 2010/03/31 20:09:07 1.53
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# handler for DC-only modifiable course settings
#
-# $Id: lonmodifycourse.pm,v 1.50 2010/03/08 22:31:27 raeburn Exp $
+# $Id: lonmodifycourse.pm,v 1.53 2010/03/31 20:09:07 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -779,10 +779,10 @@ sub modify_course {
my $outcome = &Apache::lonnet::auto_new_course($cnum,$cdom,$inst_course_id,$newattr{'courseowner'});
unless ($outcome eq 'ok') {
- push(@warnings,&mt('If automatic enrollment is enabled for "[_1]" automated enrollment may fail for "[_2]" - section: [_3], for the following reason: "[_4]"',$description,$newattr{'coursecode'},$instsec,$outcome).'
');
+ push(@warnings,&mt('If automatic enrollment is enabled for "[_1]", automated enrollment may fail for "[_2]" - section: [_3] for the following reason: "[_4]".',$description,$newattr{'coursecode'},$instsec,$outcome).'
');
}
} else {
- push(@warnings,&mt('If automatic enrollment is enabled for "[_1]" automated enrollment may fail for "[_2]" - section: [_3], for the following reason: "[_4]"',$description,$newattr{'coursecode'},$instsec,$course_check));
+ push(@warnings,&mt('If automatic enrollment is enabled for "[_1]", automated enrollment may fail for "[_2]" - section: [_3] for the following reason: "[_4]".',$description,$newattr{'coursecode'},$instsec,$course_check));
}
} else {
push(@warnings,&mt('If automatic enrollment is enabled for "[_1]", automated enrollment may fail for "[_2]" - section: [_3], because this is not a valid section entry.',$description,$newattr{'coursecode'},$sec));
@@ -795,15 +795,15 @@ sub modify_course {
my $inst_course_id = $newattr{'coursecode'}.$instsec;
my $outcome = &Apache::lonnet::auto_new_course($cnum,$cdom,$inst_course_id,$newattr{'courseowner'});
unless ($outcome eq 'ok') {
- push(@warnings,&mt('If automatic enrollment is enabled for "[_1]", automated enrollment may fail for "[_2]" - section [_3] for the following reason: "[_4]".',$description,$newattr{'coursecode'},$instsec,$outcome));
+ push(@warnings,&mt('If automatic enrollment is enabled for "[_1]", automated enrollment may fail for "[_2]" - section: [_3] for the following reason: "[_4]".',$description,$newattr{'coursecode'},$instsec,$outcome));
}
} else {
- push(@warnings,&mt('If automatic enrollment is enabled for "[_1]", automated enrollment may fail for "[_2]" - section [_3] because this is not a valid section entry.',$description,$newattr{'coursecode'},$sec));
+ push(@warnings,&mt('If automatic enrollment is enabled for "[_1]", automated enrollment may fail for "[_2]" - section: [_3], because this is not a valid section entry.',$description,$newattr{'coursecode'},$sec));
}
}
}
} else {
- push(@warnings,&mt('As no section numbers are currently listed for "[_1]" automated enrollment will not occur for any sections of institutional course code: "[_2]".',$description,$newattr{'coursecode'}));
+ push(@warnings,&mt('As no section numbers are currently listed for "[_1]", automated enrollment will not occur for any sections of institutional course code: "[_2]".',$description,$newattr{'coursecode'}));
}
if ( (@xlists > 0) && ($changed{'owner'}) ) {
foreach my $xlist (@xlists) {
@@ -877,20 +877,26 @@ sub update_coowners {
}
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'}) {
- if ($settings->{'internal.co-owner'}) {
- my @current = split(',',$settings->{'internal.co-owners'});
- unless (grep(/^\Q$oldowner\E$/,@current)) {
+ 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 {
- $oldowner_to_coowner = 1;
}
}
+ } else {
+ push(@types,'pendingco-owners');
}
- foreach my $type ('co-owners','pendingco-owners') {
+ foreach my $type (@types) {
if ($settings->{'internal.'.$type}) {
my @current = split(',',$settings->{'internal.'.$type});
my $newowner = $newattr->{'courseowner'};
@@ -925,10 +931,10 @@ sub update_coowners {
my %pendinghash = (
'internal.pendingco-owners' => $pendingcoowners,
);
- my $putresult = &put('environment',\%pendinghash,$cdom,$cnum);
+ my $putresult = &Apache::lonnet::put('environment',\%pendinghash,$cdom,$cnum);
if ($putresult eq 'ok') {
if ($env{'course.'.$cid.'.num'} eq $cnum) {
- &appenv({'course.'.$cid.'.internal.pendingco-owners' => $pendingcoowners});
+ &Apache::lonnet::appenv({'course.'.$cid.'.internal.pendingco-owners' => $pendingcoowners});
}
}
} else {
@@ -960,15 +966,19 @@ sub update_coowners {
my @currcoown = split(',',$settings->{'internal.coowners'});
my ($updatecoowners,$delcoowners);
foreach my $person (@currcoown) {
- my ($result,$desc) = &Apache::lonnet::valid_instcode();
+ 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)) {
- push(@newcoowners,$uname.':'.$udom);
+ my ($result,$desc) = &Apache::lonnet::auto_validate_instcode($cnum,$cdom,$newattr->{'coursecode'},$uname.':'.$udom);
+ if ($result eq 'valid') {
+ push(@newcoowners,$uname.':'.$udom);
+ }
}
}
if (@newcoowners) {