version 1.77, 2005/03/03 21:24:24
|
version 1.84, 2005/11/15 20:17:00
|
Line 86 sub readfile {
|
Line 86 sub readfile {
|
# ============================================================ Write a userfile |
# ============================================================ Write a userfile |
|
|
sub writefile { |
sub writefile { |
(my $courseid, my $which,$ENV{'form.output'})=@_; |
(my $courseid, my $which,$env{'form.output'})=@_; |
my %crsdata=&Apache::lonnet::coursedescription($courseid); |
my %crsdata=&Apache::lonnet::coursedescription($courseid); |
return &Apache::lonnet::finishuserfileupload( |
return &Apache::lonnet::finishuserfileupload( |
$crsdata{'num'},$crsdata{'domain'}, |
$crsdata{'num'},$crsdata{'domain'}, |
$crsdata{'home'}, |
|
'output',$which); |
'output',$which); |
} |
} |
|
|
Line 215 sub copyuserfiles {
|
Line 214 sub copyuserfiles {
|
|
|
sub copydbfiles { |
sub copydbfiles { |
my ($origcrsid,$newcrsid)=@_; |
my ($origcrsid,$newcrsid)=@_; |
|
|
|
my ($origcrs_discussion) = ($origcrsid=~m|^/(.*)|); |
|
$origcrs_discussion=~s|/|_|g; |
foreach (&crsdirlist($origcrsid)) { |
foreach (&crsdirlist($origcrsid)) { |
if ($_=~/\.db$/) { |
if ($_=~/\.db$/) { |
unless |
unless |
($_=~/^(nohist\_|discussiontimes|classlist|versionupdate|resourcedata)/) { |
($_=~/^(nohist\_|discussiontimes|classlist|versionupdate|resourcedata|\Q$origcrs_discussion\E|slots|slot_reservations|(grading|review)queue|CODEs)/) { |
©db($origcrsid,$newcrsid,$_); |
©db($origcrsid,$newcrsid,$_); |
|
my $histfile=$_; |
|
$histfile=~s/\.db$/\.hist/; |
|
©file($origcrsid,$newcrsid,$histfile); |
} |
} |
} |
} |
} |
} |
Line 238 sub copycoursefiles {
|
Line 243 sub copycoursefiles {
|
|
|
sub print_course_creation_page { |
sub print_course_creation_page { |
my $r=shift; |
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 %host_servers = &Apache::loncommon::get_library_servers($defdom); |
my $course_home = '<select name="course_home" size="1">'."\n"; |
my $course_home = '<select name="course_home" size="1">'."\n"; |
foreach my $server (sort(keys(%host_servers))) { |
foreach my $server (sort(keys(%host_servers))) { |
Line 253 sub print_course_creation_page {
|
Line 258 sub print_course_creation_page {
|
my $bodytag=&Apache::loncommon::bodytag('Create a New Course'); |
my $bodytag=&Apache::loncommon::bodytag('Create a New Course'); |
my $helplink=&Apache::loncommon::help_open_topic('Create_Course',&mt('Help on Creating Courses')); |
my $helplink=&Apache::loncommon::help_open_topic('Create_Course',&mt('Help on Creating Courses')); |
my $cloneform=&Apache::loncommon::select_dom_form |
my $cloneform=&Apache::loncommon::select_dom_form |
($ENV{'request.role.domain'},'clonedomain'). |
($env{'request.role.domain'},'clonedomain'). |
&Apache::loncommon::selectcourse_link |
&Apache::loncommon::selectcourse_link |
('ccrs','clonecourse','clonedomain'); |
('ccrs','clonecourse','clonedomain'); |
my $coursebrowserjs=&Apache::loncommon::coursebrowser_javascript($ENV{'request.role.domain'}); |
my $coursebrowserjs=&Apache::loncommon::coursebrowser_javascript($env{'request.role.domain'}); |
my $starttime = time; |
my $starttime = time; |
my $endtime = time+(6*30*24*60*60); # 6 months from now, approx |
my $endtime = time+(6*30*24*60*60); # 6 months from now, approx |
my $enroll_table = &Apache::londropadd::date_setting_table($starttime,$endtime,'create_enrolldates'); |
my $enroll_table = &Apache::londropadd::date_setting_table($starttime,$endtime,'create_enrolldates'); |
Line 572 ENDDOCUMENT
|
Line 577 ENDDOCUMENT
|
|
|
sub create_course { |
sub create_course { |
my $r=shift; |
my $r=shift; |
my $ccuname=$ENV{'form.ccuname'}; |
my $ccuname=$env{'form.ccuname'}; |
my $ccdomain=$ENV{'form.ccdomain'}; |
my $ccdomain=$env{'form.ccdomain'}; |
$ccuname=~s/\W//g; |
$ccuname=~s/\W//g; |
$ccdomain=~s/\W//g; |
$ccdomain=~s/\W//g; |
|
|
Line 585 sub create_course {
|
Line 590 sub create_course {
|
my $autharg; |
my $autharg; |
my $authtype; |
my $authtype; |
|
|
if ($ENV{'form.login'} eq 'krb') { |
if ($env{'form.login'} eq 'krb') { |
$authtype = 'krb'; |
$authtype = 'krb'; |
$authtype .=$ENV{'form.krbver'}; |
$authtype .=$env{'form.krbver'}; |
$autharg = $ENV{'form.krbarg'}; |
$autharg = $env{'form.krbarg'}; |
} elsif ($ENV{'form.login'} eq 'int') { |
} elsif ($env{'form.login'} eq 'int') { |
$authtype ='internal'; |
$authtype ='internal'; |
if ((defined($ENV{'form.intarg'})) && ($ENV{'form.intarg'})) { |
if ((defined($env{'form.intarg'})) && ($env{'form.intarg'})) { |
$autharg = $ENV{'form.intarg'}; |
$autharg = $env{'form.intarg'}; |
} |
} |
} elsif ($ENV{'form.login'} eq 'loc') { |
} elsif ($env{'form.login'} eq 'loc') { |
$authtype = 'localauth'; |
$authtype = 'localauth'; |
if ((defined($ENV{'form.locarg'})) && ($ENV{'form.locarg'})) { |
if ((defined($env{'form.locarg'})) && ($env{'form.locarg'})) { |
$autharg = $ENV{'form.locarg'}; |
$autharg = $env{'form.locarg'}; |
} |
} |
} |
} |
|
|
Line 615 ENDENHEAD
|
Line 620 ENDENHEAD
|
my $args = { |
my $args = { |
ccuname => $ccuname, |
ccuname => $ccuname, |
ccdomain => $ccdomain, |
ccdomain => $ccdomain, |
cdescr => $ENV{'form.title'}, |
cdescr => $env{'form.title'}, |
curl => $ENV{'form.topmap'}, |
curl => $env{'form.topmap'}, |
course_domain => $ENV{'request.role.domain'}, |
course_domain => $env{'request.role.domain'}, |
course_home => $ENV{'form.course_home'}, |
course_home => $env{'form.course_home'}, |
nonstandard => $ENV{'form.nonstandard'}, |
nonstandard => $env{'form.nonstandard'}, |
crscode => $ENV{'form.crscode'}, |
crscode => $env{'form.crscode'}, |
clonecourse => $ENV{'form.clonecourse'}, |
clonecourse => $env{'form.clonecourse'}, |
clonedomain => $ENV{'form.clonedomain'}, |
clonedomain => $env{'form.clonedomain'}, |
crsid => $ENV{'form.crsid'}, |
crsid => $env{'form.crsid'}, |
curruser => $ENV{'user.name'}, |
curruser => $env{'user.name'}, |
crssections => $ENV{'form.crssections'}, |
crssections => $env{'form.crssections'}, |
crsxlist => $ENV{'form.crsxlist'}, |
crsxlist => $env{'form.crsxlist'}, |
autoadds => $ENV{'form.autoadds'}, |
autoadds => $env{'form.autoadds'}, |
autodrops => $ENV{'form.autodrops'}, |
autodrops => $env{'form.autodrops'}, |
notify_owner => $ENV{'form.notify_owner'}, |
notify_owner => $env{'form.notify_owner'}, |
notify_dc => $ENV{'form.notify_dc'}, |
notify_dc => $env{'form.notify_dc'}, |
no_end_date => $ENV{'form.no_end_date'}, |
no_end_date => $env{'form.no_end_date'}, |
showphotos => $ENV{'form.showphotos'}, |
showphotos => $env{'form.showphotos'}, |
authtype => $authtype, |
authtype => $authtype, |
autharg => $autharg, |
autharg => $autharg, |
enrollstart => $enrollstart, |
enrollstart => $enrollstart, |
enrollend => $enrollend, |
enrollend => $enrollend, |
startaccess => $startaccess, |
startaccess => $startaccess, |
endaccess => $endaccess, |
endaccess => $endaccess, |
setpolicy => $ENV{'form.setpolicy'}, |
setpolicy => $env{'form.setpolicy'}, |
setcontent => $ENV{'form.setcontent'}, |
setcontent => $env{'form.setcontent'}, |
reshome => $ENV{'form.reshome'}, |
reshome => $env{'form.reshome'}, |
setkeys => $ENV{'form.setkeys'}, |
setkeys => $env{'form.setkeys'}, |
keyauth => $ENV{'form.keyauth'}, |
keyauth => $env{'form.keyauth'}, |
disresdis => $ENV{'form.disresdis'}, |
disresdis => $env{'form.disresdis'}, |
disablechat => $ENV{'form.disablechat'}, |
disablechat => $env{'form.disablechat'}, |
openall => $ENV{'form.openall'}, |
openall => $env{'form.openall'}, |
firstres => $ENV{'form.firstres'} |
firstres => $env{'form.firstres'} |
}; |
}; |
|
|
# |
# |
Line 669 ENDENHEAD
|
Line 674 ENDENHEAD
|
} |
} |
# Check the proposed home server for the course |
# Check the proposed home server for the course |
my %host_servers = &Apache::loncommon::get_library_servers |
my %host_servers = &Apache::loncommon::get_library_servers |
($ENV{'request.role.domain'}); |
($env{'request.role.domain'}); |
if (! exists($host_servers{$ENV{'form.course_home'}})) { |
if (! exists($host_servers{$env{'form.course_home'}})) { |
$r->print(&mt('Invalid home server for course').': '. |
$r->print(&mt('Invalid home server for course').': '. |
$ENV{'form.course_home'}.'</body></html>'); |
$env{'form.course_home'}.'</body></html>'); |
return; |
return; |
} |
} |
my ($courseid,$crsudom,$crsunum); |
my ($courseid,$crsudom,$crsunum); |
$r->print(&construct_course($args,\$logmsg,\$courseid,\$crsudom,\$crsunum,$ENV{'user.domain'},$ENV{'user.name'})); |
$r->print(&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 |
Line 686 ENDENHEAD
|
Line 691 ENDENHEAD
|
$ccuname.' at '.$ccdomain.': '. |
$ccuname.' at '.$ccdomain.': '. |
&Apache::lonnet::assignrole($ccdomain,$ccuname,$courseid,'cc').'<p>'); |
&Apache::lonnet::assignrole($ccdomain,$ccuname,$courseid,'cc').'<p>'); |
} |
} |
if ($ENV{'form.setkeys'}) { |
if ($env{'form.setkeys'}) { |
$r->print( |
$r->print( |
'<p><a href="/adm/managekeys?cid='.$crsudom.'_'.$crsunum.'">'.&mt('Manage Access Keys').'</a></p>'); |
'<p><a href="/adm/managekeys?cid='.$crsudom.'_'.$crsunum.'">'.&mt('Manage Access Keys').'</a></p>'); |
} |
} |
Line 782 sub construct_course {
|
Line 787 sub construct_course {
|
foreach my $item (@sections) { |
foreach my $item (@sections) { |
my ($sec,$gp) = split/:/,$item; |
my ($sec,$gp) = split/:/,$item; |
my $class = $args->{'crscode'}.$sec; |
my $class = $args->{'crscode'}.$sec; |
my $addcheck = &Apache::lonnet::auto_new_course($crsunum,$crsudom,$class,$cenv{'internal.courseowner'}); |
my $addcheck = &Apache::lonnet::auto_new_course($$crsunum,$$crsudom,$class,$cenv{'internal.courseowner'}); |
$cenv{'internal.sectionnums'} .= $item.','; |
$cenv{'internal.sectionnums'} .= $item.','; |
unless ($addcheck eq 'ok') { |
unless ($addcheck eq 'ok') { |
push @badclasses, $class; |
push @badclasses, $class; |
Line 970 sub handler {
|
Line 975 sub handler {
|
return OK; |
return OK; |
} |
} |
|
|
if (&Apache::lonnet::allowed('ccc',$ENV{'request.role.domain'})) { |
if (&Apache::lonnet::allowed('ccc',$env{'request.role.domain'})) { |
&Apache::loncommon::content_type($r,'text/html'); |
&Apache::loncommon::content_type($r,'text/html'); |
$r->send_http_header; |
$r->send_http_header; |
|
|
if ($ENV{'form.phase'} eq 'two') { |
if ($env{'form.phase'} eq 'two') { |
&create_course($r); |
&create_course($r); |
} else { |
} else { |
&print_course_creation_page($r); |
&print_course_creation_page($r); |
} |
} |
} else { |
} else { |
$ENV{'user.error.msg'}= |
$env{'user.error.msg'}= |
"/adm/createcourse:ccc:0:0:Cannot create courses"; |
"/adm/createcourse:ccc:0:0:Cannot create courses"; |
return HTTP_NOT_ACCEPTABLE; |
return HTTP_NOT_ACCEPTABLE; |
} |
} |