--- loncom/interface/lonmodifycourse.pm 2003/12/30 15:46:18 1.5
+++ loncom/interface/lonmodifycourse.pm 2004/08/10 14:29:07 1.12
@@ -34,7 +34,7 @@ use localenroll;
sub print_course_selection_page {
my ($r,$tasklongref) = @_;
- my $dom = $ENV{'user.domain'};
+ my $dom = $ENV{'request.role.domain'};
my %lt=&Apache::lonlocal::texthash(
'csae' => "Course settings for automated enrollment",
'unst' => "Unlike standard LON-CAPA course parameters, such as course description, feedback addresses, and top level map, which are displayed and/or modified using the 'Course Environment Parameters' screen, settings that control automated enrollment based on classlist data available from your institution's student information system are handled differently. Automated enrollment settings fall into two groups: (a) settings that can be modified by a Course Coordinator using the Automated Enrollment Manager and (b) settings that may only be modified by a Domain Coordinator via the 'View/Modify Course settings' menu accessed from this page.",
@@ -100,7 +100,11 @@ ENDBLOCK
unless ($code =~m/^___\d+$/) { $showcode = $code; }
if ($item =~ m/^($dom)_(\w+)$/) {
$crs = $2;
- $description = $courseIDs{$item};
+ if ($courseIDs{$item} =~ /^([^:]*):/) {
+ $description = &Apache::lonnet::unescape($1);
+ } else {
+ $description = &Apache::lonnet::unescape($courseIDs{$item});
+ }
# Get course owner
my %settings = &Apache::lonnet::get('environment',['internal.courseowner'],$dom,$crs);
if ( defined($settings{'internal.courseowner'}) ) {
@@ -197,9 +201,17 @@ all settings except course code, course
} else {
$enrollvar{$1} = localtime($settings{$item});
}
- } else {
+ } elsif ($1 eq "courseowner" || $1 eq "authtype" || $1 eq "autharg" || $1 eq "sectionnums" || $1 eq "coursecode" || $1 eq "crosslistings") {
$enrollvar{$1} = $settings{$item};
}
+ } elsif ($item =~ m/^default_enrollment_(start|end)_date$/) {
+ if ( ($1 eq 'end') && ($settings{$item} == 0) ) {
+ $enrollvar{$item} = $lt{'noen'};
+ } elsif ( ($1 eq 'start') && ($settings{$item} eq '') ) {
+ $enrollvar{$item} = 'When enrolled';
+ } else {
+ $enrollvar{$item} = localtime($settings{$item});
+ }
}
}
@@ -222,7 +234,7 @@ all settings except course code, course
}
}
unless ( (grep/^$enrollvar{'courseowner'}$/,@local_ccs) || ($enrollvar{'courseowner'} eq '') ) {
- push @local_ccs, $enrollvar{'coursecode'};
+ push @local_ccs, $enrollvar{'courseowner'};
$pname{$enrollvar{'courseowner'}} = &Apache::loncommon::plainname($enrollvar{'courseowner'},$dom);
$active_cc = &LONCAPA::Enrollment::check_user_status($dom,$enrollvar{'coursecode'},$dom,$course,'cc');
if ($active_cc eq 'ok') {
@@ -279,7 +291,7 @@ all settings except course code, course
$$typeref{$key} |
$enrollvar{$key} |
";
- $iter ++;
+ $iter ++;
}
$disp_table .= "
@@ -425,7 +437,6 @@ sub modify_course {
my ($r,$tasklongref,$typeref) = @_;
my $dom = $ENV{'user.domain'};
my $crs = $ENV{'form.course'};
-
unless ( &check_course($dom,$crs) eq 'ok' ) {
&print_header($r,$tasklongref);
my $reply = "
".&mt("The LON-CAPA course selected was not a valid course for this domain");
@@ -477,7 +488,6 @@ sub modify_course {
$newattr{'authtype'} = $ENV{'form.login'};
$newattr{'authtype'} .= $ENV{'form.krbver'};
$newattr{'autharg'} = $ENV{'form.krbarg'};
- $newattr{'autharg'} =~ tr/a-z/A-Z/;
} elsif ($ENV{'form.login'} eq 'int') {
$newattr{'authtype'} ='internal';
if ((defined($ENV{'form.intarg'})) && ($ENV{'form.intarg'})) {
@@ -510,6 +520,8 @@ sub modify_course {
$newattr{'coursecode'}=$ENV{'form.coursecode'};
unless ( $newattr{'coursecode'} eq $currattr{'coursecode'} ) {
$changecode = 1;
+ my $courseid_entry = &Apache::lonnet::escape($dom.'_'.$crs).'='.&Apache::lonnet::escape($description).'='.&Apache::lonnet::escape($ENV{'form.coursecode'});
+ &Apache::lonnet::courseidput($dom,$courseid_entry,&Apache::lonnet::homeserver($crs,$dom));
}
}
@@ -549,10 +561,10 @@ sub modify_course {
if ($changecode) {
foreach my $sec (@sections) {
if ($sec =~ m/^(.+):/) {
- my $course_id = $newattr{'coursecode'}.$1;
- my $course_check = &localenroll::validate_courseID($course_id);
- if ($course_check eq 'ok') {
- my $outcome = &localenroll::new_course($course_id,$newattr{'courseowner'});
+ my $inst_course_id = $newattr{'coursecode'}.$1;
+ my $course_check = &Apache::lonnet::auto_validate_courseID($crs,$dom,$inst_course_id);
+ if ($course_check eq 'ok') {
+ my $outcome = &Apache::lonnet::auto_new_course($crs,$dom,$inst_course_id,$newattr{'courseowner'});
unless ($outcome eq 'ok') {
$warning .= &mt("If automatic enrollment is enabled for LON-CAPA course: ").$description.&mt(", automated enrollment may fail for ").$newattr{'coursecode'}.&mt(" - section $1 for the following reason: $outcome.
");
}
@@ -566,8 +578,8 @@ sub modify_course {
} elsif ($changeowner) {
foreach my $sec (@sections) {
if ($sec =~ m/^(.+):/) {
- my $course_id = $newattr{'coursecode'}.$1;
- my $outcome = &localenroll::new_course($course_id,$newattr{'courseowner'});
+ my $inst_course_id = $newattr{'coursecode'}.$1;
+ my $outcome = &Apache::lonnet::auto_new_course($crs,$dom,$inst_course_id,$newattr{'courseowner'});
unless ($outcome eq 'ok') {
$warning .= &mt("If automatic enrollment is enabled for LON-CAPA course: ").$description.&mt(", automated enrollment may fail for ").$newattr{'coursecode'}.&mt(" - section $1 for the following reason: $outcome.
");
}
@@ -582,7 +594,7 @@ sub modify_course {
if ( (@xlists > 0) && ($changeowner) ) {
foreach my $xlist (@xlists) {
if ($xlist =~ m/^(.+):/) {
- my $outcome = &localenroll::new_course($1,$newattr{'courseowner'});
+ my $outcome = &Apache::lonnet::auto_new_course($crs,$dom,$1,$newattr{'courseowner'});
unless ($outcome eq 'ok') {
$warning .= &mt("If automatic enrollment is enabled for LON-CAPA course: ").$description.&mt(", automated enrollment may fail for crosslisted class: ").$1.&mt(" for the following reason: $outcome.
");
}
@@ -594,7 +606,7 @@ sub modify_course {
}
} else {
foreach my $attr (@params) {
- $nochgresponse .= "$$typeref{$attr} ".&mt("still set to \"").$currattr{$attr}."\".";
+ $nochgresponse .= "$$typeref{$attr} ".&mt("still set to")." \"".$currattr{$attr}."\".";
}
}
@@ -718,8 +730,10 @@ sub handler {
'autharg' => 'Default authentication parameter',
'autoadds' => 'Automated adds',
'autodrops' => 'Automated drops',
- 'autostart' => 'Date of first enrollment',
- 'autoend' => 'Date of last enrollment',
+ 'autostart' => 'Date of first automated enrollment',
+ 'autoend' => 'Date of last automated enrollment',
+ 'default_enrollment_start_date' => 'Date of first student access',
+ 'default_enrollment_end_date' => 'Date of last student access',
'coursecode' => 'Official course code',
'courseowner' => "Username of course owner (\@$dom)",
'notifylist' => 'Course Coordinators to be notified of enrollment changes',