--- loncom/interface/loncreatecourse.pm 2003/12/05 15:57:37 1.40
+++ loncom/interface/loncreatecourse.pm 2004/01/19 23:05:52 1.45.2.1
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Create a course
#
-# $Id: loncreatecourse.pm,v 1.40 2003/12/05 15:57:37 raeburn Exp $
+# $Id: loncreatecourse.pm,v 1.45.2.1 2004/01/19 23:05:52 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -48,6 +48,9 @@ use Apache::loncommon;
use Apache::lonratedt;
use Apache::londocs;
use Apache::lonlocal;
+use Apache::londropadd;
+use lib '/home/httpd/lib/perl';
+use localenroll;
# ================================================ Get course directory listing
@@ -243,10 +246,12 @@ sub print_course_creation_page {
&Apache::loncommon::selectcourse_link
('ccrs','clonecourse','clonedomain');
my $coursebrowserjs=&Apache::loncommon::coursebrowser_javascript();
- my $date_table = &date_setting_table();
+ my $starttime = time;
+ my $endtime = time+(6*30*24*60*60); # 6 months from now, approx
+ my $date_table = &Apache::londropadd::date_setting_table($starttime,$endtime,'createcourse');
my ($krbdef,$krbdefdom) =
&Apache::loncommon::get_kerberos_defaults($defdom);
- my $javascript_validations=&javascript_validations($krbdefdom);
+ my $javascript_validations=&Apache::londropadd::javascript_validations('createcourse',$krbdefdom);
my %param = ( formname => 'document.ccrs',
kerb_def_dom => $krbdefdom,
kerb_def_auth => $krbdef
@@ -274,6 +279,7 @@ function openbrowser(formname,elementnam
editbrowser = open(url,title,options,'1');
editbrowser.focus();
}
+$javascript_validations
$coursebrowserjs
@@ -378,10 +384,10 @@ on information available for this specif
Automated adds
-Yes No
+Yes No
Automated drops
-Yes No
+Yes No
Duration of automated classlist updates
$date_table
@@ -398,12 +404,12 @@ $locform
Notification of enrollment changes
Notification to course coordinator via LON-CAPA message when enrollment changes occur during the automated update?
Yes No
+value="0" checked="true" />No
Include retrieval of student photographs? Yes No
-
+
@@ -411,68 +417,6 @@ value="0" />No
ENDDOCUMENT
}
-sub javascript_validations {
- my ($krbdefdom)=@_;
- my %param = ( formname => 'ccrs',
- kerb_def_dom => $krbdefdom );
- my $authheader = &Apache::loncommon::authform_header(%param);
- my $pjump_def = &Apache::lonhtmlcommon::pjump_javascript_definition();
- return (< no ending date';
- my $result = '';
- $result .= "
\n";
- $result .= '
Starting Date
'.
- '
'.$startform.'
'.
- '
'."
\n";
- $result .= '
Ending Date
'.
- '
'.$endform.'
'.
- '
'.$perpetual.'
'."
\n";
- $result .= "
\n";
- return $result;
-}
-
# ====================================================== Phase two: make course
sub create_course {
@@ -556,6 +500,7 @@ ENDENHEAD
#
# Set environment (will override cloned, if existing)
#
+ my @affiliates = (); # Used to accumulate sections and crosslistings
if ($ENV{'form.crsid'}) {
$cenv{'courseid'}=$ENV{'form.crsid'};
}
@@ -564,9 +509,33 @@ ENDENHEAD
}
if ($ENV{'form.crssections'}) {
$cenv{'internal.sectionnums'}=$ENV{'form.crssections'};
+ my @sections = ();
+ if ($cenv{'internal.sectionnums'} =~ m/,/) {
+ @sections = split/,/,$cenv{'internal.sectionnums'};
+ } else {
+ $sections[0] = $cenv{'internal.sectionnums'};
+ }
+ if (@sections > 0) {
+ foreach (@sections) {
+ my ($sec,$gp) = split/:/,$_;
+ push @affiliates,$ENV{'form.crscode'}.$sec;
+ }
+ }
}
if ($ENV{'form.crsxlist'}) {
- $cenv{'internal.crosslistings'}=$ENV{'form.crsxlist'};
+ $cenv{'internal.crosslistings'}=$ENV{'form.crsxlist'};
+ my @xlists = ();
+ if ($cenv{'internal.crosslistings'} =~ m/,/) {
+ @xlists = split/,/,$cenv{'internal.crosslistings'};
+ } else {
+ $xlists[0] = $cenv{'internal.crosslistings'};
+ }
+ if (@xlists > 0) {
+ foreach (@xlists) {
+ my ($xl,$gp) = split/:/,$_;
+ push @affiliates,$xl;
+ }
+ }
}
if ($ENV{'form.autoadds'}) {
$cenv{'internal.autoadds'}=$ENV{'form.autoadds'};
@@ -581,6 +550,25 @@ ENDENHEAD
}
if ($ccuname) {
$cenv{'internal.courseowner'} = $ccuname;
+ } else {
+ $cenv{'internal.courseowner'} = $ENV{'user.name'};
+ }
+ if (@affiliates > 0) {
+ my @badclasses = ();
+ foreach my $class (@affiliates) {
+ my $addcheck = &localenroll::new_course($class,$cenv{'internal.courseowner'});
+ unless ($addcheck eq 'ok') {
+ push @badclasses, $class;
+ }
+ }
+ if (@badclasses > 0) {
+ $r->print(''.
+ "The courses listed below were included as sections or crosslistings affiliated with your new LON-CAPA course. 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 ($cenv{'internal.courseowner'}) - does not have rights to access enrollment in these classes (as determined by your instititution's policies on access to official classlists).
\n");
+ foreach (@badclasses) {
+ $r->print("
$_
\n");
+ }
+ $r->print ("
\n");
+ }
}
my $startdate = &Apache::lonhtmlcommon::get_date_from_form('startdate');
my $enddate = &Apache::lonhtmlcommon::get_date_from_form('enddate');
@@ -697,6 +685,8 @@ ENDENHEAD
$r->print(
'