--- loncom/interface/loncreatecourse.pm 2005/01/20 16:30:52 1.75 +++ loncom/interface/loncreatecourse.pm 2005/11/15 20:17:00 1.84 @@ -1,7 +1,7 @@ # The LearningOnline Network # Create a course # -# $Id: loncreatecourse.pm,v 1.75 2005/01/20 16:30:52 albertel Exp $ +# $Id: loncreatecourse.pm,v 1.84 2005/11/15 20:17:00 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -86,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); } @@ -215,11 +214,17 @@ sub copyuserfiles { sub copydbfiles { my ($origcrsid,$newcrsid)=@_; + + my ($origcrs_discussion) = ($origcrsid=~m|^/(.*)|); + $origcrs_discussion=~s|/|_|g; foreach (&crsdirlist($origcrsid)) { if ($_=~/\.db$/) { 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,$_); + my $histfile=$_; + $histfile=~s/\.db$/\.hist/; + ©file($origcrsid,$newcrsid,$histfile); } } } @@ -238,7 +243,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{'yes'} + $lt{'yes'} +
+$lt{'ndcl'}
+ +

$lt{'irsp'} @@ -547,11 +562,6 @@ $lt{'nccl'}
-

-

@@ -567,8 +577,8 @@ ENDDOCUMENT sub create_course { my $r=shift; - 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; @@ -580,26 +590,27 @@ sub create_course { my $autharg; my $authtype; - if ($ENV{'form.login'} eq 'krb') { + if ($env{'form.login'} eq 'krb') { $authtype = 'krb'; - $authtype .=$ENV{'form.krbver'}; - $autharg = $ENV{'form.krbarg'}; - } elsif ($ENV{'form.login'} eq 'int') { + $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'}; + if ((defined($env{'form.intarg'})) && ($env{'form.intarg'})) { + $autharg = $env{'form.intarg'}; } - } elsif ($ENV{'form.login'} eq 'loc') { + } elsif ($env{'form.login'} eq 'loc') { $authtype = 'localauth'; - if ((defined($ENV{'form.locarg'})) && ($ENV{'form.locarg'})) { - $autharg = $ENV{'form.locarg'}; + 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 @@ -609,38 +620,39 @@ 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 => $ENV{'form.notify'}, - no_end_date => $ENV{'form.no_end_date'}, - showphotos => $ENV{'form.showphotos'}, + 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'} + 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'} }; # @@ -662,33 +674,24 @@ 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'}.''); + $env{'form.course_home'}.''); return; } my ($courseid,$crsudom,$crsunum); - $r->print(&construct_course($args,\$logmsg,\$courseid,\$crsudom,\$crsunum)); + $r->print(&construct_course($args,\$logmsg,\$courseid,\$crsudom,\$crsunum,$env{'user.domain'},$env{'user.name'})); # -# Make current user course adminstrator -# - my $end=undef; - my $addition=''; - if ($ENV{'form.expireown'}) { $end=time+5; $addition='expired'; } - $r->print(&mt('Assigning').' '.$addition.' '.&mt('role of course coordinator to self').': '. - &Apache::lonnet::assignrole( - $ENV{'user.domain'},$ENV{'user.name'},$courseid,'cc',$end).'
'); -# -# Make additional user course administrator +# Make the requested user a course coordinator # if (($ccdomain) && ($ccuname)) { $r->print(&mt('Assigning role of course coordinator to').' '. $ccuname.' at '.$ccdomain.': '. &Apache::lonnet::assignrole($ccdomain,$ccuname,$courseid,'cc').'

'); } - if ($ENV{'form.setkeys'}) { + if ($env{'form.setkeys'}) { $r->print( '

'.&mt('Manage Access Keys').'

'); } @@ -698,7 +701,7 @@ ENDENHEAD } sub construct_course { - my ($args,$logmsg,$courseid,$crsudom,$crsunum) = @_; + my ($args,$logmsg,$courseid,$crsudom,$crsunum,$udom,$uname) = @_; my $outcome; # @@ -784,7 +787,7 @@ sub construct_course { 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'}); + my $addcheck = &Apache::lonnet::auto_new_course($$crsunum,$$crsudom,$class,$cenv{'internal.courseowner'}); $cenv{'internal.sectionnums'} .= $item.','; unless ($addcheck eq 'ok') { push @badclasses, $class; @@ -822,10 +825,26 @@ sub construct_course { if ($args->{'autodrops'}) { $cenv{'internal.autodrops'}=$args->{'autodrops'}; } - if ($args->{'notify'}) { - if ($args->{'ccuname'}) { - $cenv{'internal.notifylist'} = $args->{'ccuname'}.'@'.$args->{'ccdomain'}; - } +# 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( @@ -956,17 +975,17 @@ sub handler { 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'); $r->send_http_header; - if ($ENV{'form.phase'} eq 'two') { + if ($env{'form.phase'} eq 'two') { &create_course($r); } else { &print_course_creation_page($r); } } else { - $ENV{'user.error.msg'}= + $env{'user.error.msg'}= "/adm/createcourse:ccc:0:0:Cannot create courses"; return HTTP_NOT_ACCEPTABLE; }