+
+ENDDOCUMENT
+ }
+ $r->print($end_page);
}
# ====================================================== Phase two: make course
sub create_course {
my $r=shift;
- my $ccuname=$env{'form.ccuname'};
- my $ccdomain=$env{'form.ccdomain'};
- $ccuname=~s/\W//g;
- $ccdomain=~s/\W//g;
-
- my $enrollstart = &Apache::lonhtmlcommon::get_date_from_form('startenroll');
- my $enrollend = &Apache::lonhtmlcommon::get_date_from_form('endenroll');
- my $startaccess = &Apache::lonhtmlcommon::get_date_from_form('startaccess');
- my $endaccess = &Apache::lonhtmlcommon::get_date_from_form('endaccess');
+ my $ccuname =&LONCAPA::clean_username($env{'form.ccuname'});
+ my $ccdomain=&LONCAPA::clean_domain($env{'form.ccdomain'});
+ my $crstype = 'Group';
+ my ($enrollstart,$enrollend,$startaccess,$endaccess);
+
+ if ($env{'form.phase'} eq 'coursetwo') {
+ $crstype='Course';
+ $enrollstart=&Apache::lonhtmlcommon::get_date_from_form('startenroll');
+ $enrollend=&Apache::lonhtmlcommon::get_date_from_form('endenroll');
+
+ }
+ $startaccess = &Apache::lonhtmlcommon::get_date_from_form('startaccess');
+ $endaccess = &Apache::lonhtmlcommon::get_date_from_form('endaccess');
my $autharg;
my $authtype;
@@ -621,12 +599,14 @@ sub create_course {
$autharg = $env{'form.locarg'};
}
}
-
my $logmsg;
- my $start_page=&Apache::loncommon::start_page('Create a New Course');
- $r->print($start_page);
+ my $start_page=&Apache::loncommon::start_page('Create a New '.$crstype);
+ my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('Creation Outcome','Create_Course',undef,'Create_Courses');
+
+ $r->print($start_page.$crumbs);
my $args = {
+ crstype => $crstype,
ccuname => $ccuname,
ccdomain => $ccdomain,
cdescr => $env{'form.title'},
@@ -635,10 +615,11 @@ sub create_course {
course_home => $env{'form.course_home'},
nonstandard => $env{'form.nonstandard'},
crscode => $env{'form.crscode'},
+ crsquota => $env{'form.crsquota'},
clonecourse => $env{'form.clonecourse'},
clonedomain => $env{'form.clonedomain'},
crsid => $env{'form.crsid'},
- curruser => $env{'user.name'},
+ curruser => $env{'user.name'}.':'.$env{'user.domain'},
crssections => $env{'form.crssections'},
crsxlist => $env{'form.crsxlist'},
autoadds => $env{'form.autoadds'},
@@ -682,24 +663,25 @@ sub create_course {
return;
}
# Check the proposed home server for the course
- my %host_servers = &Apache::loncommon::get_library_servers
- ($env{'request.role.domain'});
+ my %host_servers =
+ &Apache::lonnet::get_servers($env{'request.role.domain'},'library');
if (! exists($host_servers{$env{'form.course_home'}})) {
$r->print(&mt('Invalid home server for course').': '.
$env{'form.course_home'}.&Apache::loncommon::end_page());
return;
}
my ($courseid,$crsudom,$crsunum);
- $r->print(&construct_course($args,\$logmsg,\$courseid,\$crsudom,\$crsunum,$env{'user.domain'},$env{'user.name'}));
+ $r->print(&Apache::loncommon::construct_course($args,\$logmsg,\$courseid,\$crsudom,\$crsunum,$env{'user.domain'},$env{'user.name'}));
#
-# Make the requested user a course coordinator
+# Make the requested user a course coordinator or group coordinator
#
- if (($ccdomain) && ($ccuname)) {
- $r->print(&mt('Assigning role of course coordinator to').' '.
- $ccuname.' at '.$ccdomain.': '.
- &Apache::lonnet::assignrole($ccdomain,$ccuname,$courseid,'cc').'
');
- }
+ if (($ccdomain) && ($ccuname)) {
+ $r->print(&mt('Assigning role of [_1] Coordinator to [_2] at [_3]:',
+ $crstype,$ccuname,$ccdomain).
+ &Apache::lonnet::assignrole($ccdomain,$ccuname,$courseid,
+ 'cc').'
'.
+ $choice->{'name'}.'';
+ if (exists($choice->{'help'})) {
+ $options .= &Apache::loncommon::help_open_topic($choice->{'help'});
}
- if (@sections > 0) {
- foreach my $item (@sections) {
- my ($sec,$gp) = split/:/,$item;
- my $class = $args->{'crscode'}.$sec;
- my $addcheck = &Apache::lonnet::auto_new_course($$crsunum,$$crsudom,$class,$cenv{'internal.courseowner'});
- $cenv{'internal.sectionnums'} .= $item.',';
- unless ($addcheck eq 'ok') {
- push @badclasses, $class;
- }
- }
- $cenv{'internal.sectionnums'} =~ s/,$//;
- }
- }
-# do not hide course coordinator from staff listing,
-# even if privileged
- $cenv{'nothideprivileged'}=$args->{'ccuname'}.':'.$args->{'ccdomain'};
-# add crosslistings
- if ($args->{'crsxlist'}) {
- $cenv{'internal.crosslistings'}='';
- if ($args->{'crsxlist'} =~ m/,/) {
- @xlists = split/,/,$args->{'crsxlist'};
- } else {
- $xlists[0] = $args->{'crsxlist'};
- }
- if (@xlists > 0) {
- foreach my $item (@xlists) {
- my ($xl,$gp) = split/:/,$item;
- my $addcheck = &Apache::lonnet::auto_new_course($$crsunum,$$crsudom,$xl,$cenv{'internal.courseowner'});
- $cenv{'internal.crosslistings'} .= $item.',';
- unless ($addcheck eq 'ok') {
- push @badclasses, $xl;
- }
- }
- $cenv{'internal.crosslistings'} =~ s/,$//;
- }
- }
- if ($args->{'autoadds'}) {
- $cenv{'internal.autoadds'}=$args->{'autoadds'};
- }
- if ($args->{'autodrops'}) {
- $cenv{'internal.autodrops'}=$args->{'autodrops'};
- }
-# check for notification of enrollment changes
- my @notified = ();
- if ($args->{'notify_owner'}) {
- if ($args->{'ccuname'} ne '') {
- push(@notified,$args->{'ccuname'}.'@'.$args->{'ccdomain'});
- }
- }
- if ($args->{'notify_dc'}) {
- if ($uname ne '') {
- push(@notified,$uname.'@'.$udom);
- }
- }
- if (@notified > 0) {
- my $notifylist;
- if (@notified > 1) {
- $notifylist = join(',',@notified);
- } else {
- $notifylist = $notified[0];
- }
- $cenv{'internal.notifylist'} = $notifylist;
- }
- if (@badclasses > 0) {
- my %lt=&Apache::lonlocal::texthash(
- 'tclb' => 'The courses listed below were included as sections or crosslistings affiliated with your new LON-CAPA course. However, if automated course roster updates are enabled for this class, these particular sections/crosslistings will not contribute towards enrollment, because the user identified as the course owner for this LON-CAPA course',
- 'dnhr' => 'does not have rights to access enrollment in these classes',
- 'adby' => 'as determined by the policies of your institution on access to official classlists'
- );
- $outcome .= ''.$lt{'tclb'}.' ('.$cenv{'internal.courseowner'}.') - '.$lt{'dnhr'}.' ('.$lt{'adby'}.').
'."\n";
- foreach (@badclasses) {
- $outcome .= "
$_
\n";
- }
- $outcome .= "
\n";
- }
- if ($args->{'no_end_date'}) {
- $args->{'endaccess'} = 0;
- }
- $cenv{'internal.autostart'}=$args->{'enrollstart'};
- $cenv{'internal.autoend'}=$args->{'enrollend'};
- $cenv{'default_enrollment_start_date'}=$args->{'startaccess'};
- $cenv{'default_enrollment_end_date'}=$args->{'endaccess'};
- if ($args->{'showphotos'}) {
- $cenv{'internal.showphotos'}=$args->{'showphotos'};
- }
- $cenv{'internal.authtype'} = $args->{'authtype'};
- $cenv{'internal.autharg'} = $args->{'autharg'};
- if ( ($cenv{'internal.authtype'} =~ /^krb/) && ($cenv{'internal.autoadds'} == 1)) {
- if (! defined($cenv{'internal.autharg'}) || $cenv{'internal.autharg'} eq '') {
- $outcome .= ''.
- &mt('As you did not include the default Kerberos domain to be used for authentication in this class, the institutional data used by the automated enrollment process must include the Kerberos domain for each new student').'';
- }
- }
- if (($args->{'ccdomain'}) && ($args->{'ccuname'})) {
- if ($args->{'setpolicy'}) {
- $cenv{'policy.email'}=$args->{'ccuname'}.':'.$args->{'ccdomain'};
- }
- if ($args->{'setcontent'}) {
- $cenv{'question.email'}=$args->{'ccuname'}.':'.$args->{'ccdomain'};
- }
- }
- if ($args->{'reshome'}) {
- $cenv{'reshome'}=$args->{'reshome'}.'/';
- $cenv{'reshome'}=~s/\/+$/\//;
- }
-#
-# course has keyed access
-#
- if ($args->{'setkeys'}) {
- $cenv{'keyaccess'}='yes';
- }
-# if specified, key authority is not course, but user
-# only active if keyaccess is yes
- if ($args->{'keyauth'}) {
- $args->{'keyauth'}=~s/[^\w\@]//g;
- if ($args->{'keyauth'}) {
- $cenv{'keyauth'}=$args->{'keyauth'};
- }
+ $options .= "