--- loncom/interface/loncreatecourse.pm 2004/04/16 13:33:41 1.54
+++ loncom/interface/loncreatecourse.pm 2005/06/26 15:42:52 1.79
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Create a course
#
-# $Id: loncreatecourse.pm,v 1.54 2004/04/16 13:33:41 albertel Exp $
+# $Id: loncreatecourse.pm,v 1.79 2005/06/26 15:42:52 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -38,21 +38,37 @@ use Apache::londocs;
use Apache::lonlocal;
use Apache::londropadd;
use lib '/home/httpd/lib/perl';
-use localenroll;
# ================================================ Get course directory listing
+my @output=();
+
sub crsdirlist {
my ($courseid,$which)=@_;
- unless ($which) { $which=''; }
+ @output=();
+ return &innercrsdirlist($courseid,$which);
+}
+
+sub innercrsdirlist {
+ my ($courseid,$which,$path)=@_;
+ my $dirptr=16384;
+ unless ($which) { $which=''; } else { $which.='/'; }
+ unless ($path) { $path=''; } else { $path.='/'; }
my %crsdata=&Apache::lonnet::coursedescription($courseid);
my @listing=&Apache::lonnet::dirlist
($which,$crsdata{'domain'},$crsdata{'num'},
&Apache::loncommon::propath($crsdata{'domain'},$crsdata{'num'}));
- my @output=();
foreach (@listing) {
unless ($_=~/^\./) {
- push (@output,(split(/\&/,$_))[0]);
+ my @unpackline = split (/\&/,$_);
+ if ($unpackline[3]&$dirptr) {
+# is a directory, recurse
+ &innercrsdirlist($courseid,$which.$unpackline[0],
+ $path.$unpackline[0]);
+ } else {
+# is a file, put into output
+ push (@output,$path.$unpackline[0]);
+ }
}
}
return @output;
@@ -70,11 +86,10 @@ sub readfile {
# ============================================================ Write a userfile
sub writefile {
- (my $courseid, my $which,$ENV{'form.output'})=@_;
+ (my $courseid, my $which,$env{'form.output'})=@_;
my %crsdata=&Apache::lonnet::coursedescription($courseid);
return &Apache::lonnet::finishuserfileupload(
$crsdata{'num'},$crsdata{'domain'},
- $crsdata{'home'},
'output',$which);
}
@@ -106,7 +121,9 @@ sub copyfile {
&readfile($origcrsid,$which),
(
'/uploaded/'.$origcrsdata{'domain'}.'/'.$origcrsdata{'num'}.'/'
- => '/uploaded/'. $newcrsdata{'domain'}.'/'. $newcrsdata{'num'}.'/'
+ => '/uploaded/'. $newcrsdata{'domain'}.'/'. $newcrsdata{'num'}.'/',
+ '/public/'.$origcrsdata{'domain'}.'/'.$origcrsdata{'num'}.'/'
+ => '/public/'. $newcrsdata{'domain'}.'/'. $newcrsdata{'num'}.'/'
)));
}
}
@@ -120,6 +137,9 @@ sub copydb {
my %newcrsdata= &Apache::lonnet::coursedescription($newcrsid);
my %data=&Apache::lonnet::dump
($which,$origcrsdata{'domain'},$origcrsdata{'num'});
+ foreach my $key (keys(%data)) {
+ if ($key=~/^internal./) { delete($data{$key}); }
+ }
return &Apache::lonnet::put
($which,\%data,$newcrsdata{'domain'},$newcrsdata{'num'});
}
@@ -172,7 +192,7 @@ sub copyresourcedb {
my $thiskey=$_;
$thiskey=~s/^$origcrsid/$newcrsid/;
$newdata{$thiskey}=$data{$_};
- if ($data{$_.'.type'}=~/^date/) {
+ if ($data{$_.'.type'}=~/^date_(start|end)$/) {
$newdata{$thiskey}=$newdata{$thiskey}+$delta;
}
}
@@ -185,7 +205,9 @@ sub copyresourcedb {
sub copyuserfiles {
my ($origcrsid,$newcrsid)=@_;
foreach (&crsdirlist($origcrsid,'userfiles')) {
- ©file($origcrsid,$newcrsid,$_);
+ if ($_ !~m|^scantron_|) {
+ ©file($origcrsid,$newcrsid,$_);
+ }
}
}
# ========================================================== Copy all userfiles
@@ -215,7 +237,7 @@ sub copycoursefiles {
sub print_course_creation_page {
my $r=shift;
- my $defdom=$ENV{'request.role.domain'};
+ my $defdom=$env{'request.role.domain'};
my %host_servers = &Apache::loncommon::get_library_servers($defdom);
my $course_home = '
$lt{'aadd'}
-$lt{'yes'} $lt{'no'}
+
+
$lt{'audr'}
-$lt{'yes'} $lt{'no'}
+
+
$lt{'dacu'}
-$date_table
+$enroll_table
+$lt{'dacc'}
+$access_table
+
$lt{'psam'}.
$lt{'pcda'}.
@@ -445,13 +523,43 @@ $locform
$lt{'nech'}
$lt{'nccl'}
-$lt{'yes'} $lt{'no'}
-
-$lt{'irsp'} $lt{'yes'} $lt{'no'}
-
+
+
+
+$lt{'ndcl'}
+
+
+
+$lt{'irsp'}
+
+
+
+
+$lt{'cc'}
+
+
+
+
+
+
-
+
@@ -463,21 +571,84 @@ ENDDOCUMENT
sub create_course {
my $r=shift;
- my $topurl='/res/'.&Apache::lonnet::declutter($ENV{'form.topmap'});
- my $ccuname=$ENV{'form.ccuname'};
- my $ccdomain=$ENV{'form.ccdomain'};
+ my $ccuname=$env{'form.ccuname'};
+ my $ccdomain=$env{'form.ccdomain'};
$ccuname=~s/\W//g;
$ccdomain=~s/\W//g;
- my $cdescr=$ENV{'form.title'};
- my $curl=$ENV{'form.topmap'};
+
+ 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 $autharg;
+ my $authtype;
+
+ if ($env{'form.login'} eq 'krb') {
+ $authtype = 'krb';
+ $authtype .=$env{'form.krbver'};
+ $autharg = $env{'form.krbarg'};
+ } elsif ($env{'form.login'} eq 'int') {
+ $authtype ='internal';
+ if ((defined($env{'form.intarg'})) && ($env{'form.intarg'})) {
+ $autharg = $env{'form.intarg'};
+ }
+ } elsif ($env{'form.login'} eq 'loc') {
+ $authtype = 'localauth';
+ if ((defined($env{'form.locarg'})) && ($env{'form.locarg'})) {
+ $autharg = $env{'form.locarg'};
+ }
+ }
+
+ my $logmsg;
+ my $html=&Apache::lonxml::xmlbegin();
my $bodytag=&Apache::loncommon::bodytag('Create a New Course');
$r->print(<
+$html
The LearningOnline Network with CAPA
$bodytag
ENDENHEAD
+
+ my $args = {
+ ccuname => $ccuname,
+ ccdomain => $ccdomain,
+ cdescr => $env{'form.title'},
+ curl => $env{'form.topmap'},
+ course_domain => $env{'request.role.domain'},
+ course_home => $env{'form.course_home'},
+ nonstandard => $env{'form.nonstandard'},
+ crscode => $env{'form.crscode'},
+ clonecourse => $env{'form.clonecourse'},
+ clonedomain => $env{'form.clonedomain'},
+ crsid => $env{'form.crsid'},
+ curruser => $env{'user.name'},
+ crssections => $env{'form.crssections'},
+ crsxlist => $env{'form.crsxlist'},
+ autoadds => $env{'form.autoadds'},
+ autodrops => $env{'form.autodrops'},
+ notify_owner => $env{'form.notify_owner'},
+ notify_dc => $env{'form.notify_dc'},
+ no_end_date => $env{'form.no_end_date'},
+ showphotos => $env{'form.showphotos'},
+ authtype => $authtype,
+ autharg => $autharg,
+ enrollstart => $enrollstart,
+ enrollend => $enrollend,
+ startaccess => $startaccess,
+ endaccess => $endaccess,
+ setpolicy => $env{'form.setpolicy'},
+ setcontent => $env{'form.setcontent'},
+ reshome => $env{'form.reshome'},
+ setkeys => $env{'form.setkeys'},
+ keyauth => $env{'form.keyauth'},
+ disresdis => $env{'form.disresdis'},
+ disablechat => $env{'form.disablechat'},
+ openall => $env{'form.openall'},
+ firstres => $env{'form.firstres'}
+ };
+
#
# Verify data
#
@@ -497,53 +668,84 @@ ENDENHEAD
}
# Check the proposed home server for the course
my %host_servers = &Apache::loncommon::get_library_servers
- ($ENV{'request.role.domain'});
- if (! exists($host_servers{$ENV{'form.course_home'}})) {
+ ($env{'request.role.domain'});
+ if (! exists($host_servers{$env{'form.course_home'}})) {
$r->print(&mt('Invalid home server for course').': '.
- $ENV{'form.course_home'}.'