--- loncom/automation/batchcreatecourse.pm 2008/02/07 01:43:21 1.25 +++ loncom/automation/batchcreatecourse.pm 2009/08/08 19:55:15 1.28 @@ -1,5 +1,5 @@ # -# $Id: batchcreatecourse.pm,v 1.25 2008/02/07 01:43:21 raeburn Exp $ +# $Id: batchcreatecourse.pm,v 1.28 2009/08/08 19:55:15 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -76,6 +76,8 @@ use strict; # 20 # 466011437c34194msul1 # msu +# shift +# 365 # # 1 # 1 @@ -249,7 +251,7 @@ sub parse_coursereqs { my $xlist = 0; my $userkey = ''; my $role = ''; - my @items = ('title','optional_id','coursecode','coursehome','reshome','nonstandard','adds','drops','topmap','firstres','clonecrs','clonedom','showphotos','setpolicy','setcontent','setkeys','keyauth','disresdis','disablechat','openall','notify_owner','notify_dc','crstype','crsquota'); + my @items = ('title','optional_id','coursecode','coursehome','reshome','nonstandard','adds','drops','topmap','firstres','clonecrs','clonedom','datemode','dateshift','showphotos','setpolicy','setcontent','setkeys','keyauth','disresdis','disablechat','openall','notify_owner','notify_dc','crstype','crsquota'); my @dateitems = ('enrollstart','enrollend','accessstart','accessend'); my @useritems = ('autharg','authtype','firstname','generation','lastname','middlename','studentID'); my $p = HTML::Parser->new @@ -368,7 +370,7 @@ sub parse_coursereqs { # build_course() # # inputs -# domain +# course domain # course request number # context - auto if called from command line, web if called from DC web interface # ref to hash of course creation information @@ -377,8 +379,13 @@ sub parse_coursereqs { # ref to scalar used to accumulate messages sent to new users # ref to scalar used to accumulate results of new user additions # ref to hash of enrollment counts for different roles -# ref to scalar used to accumulate iformation about added roles -# ref to scalar used to accumulate +# ref to scalar used to accumulate information about added roles +# ref to scalar used to accumulate +# ref to scalar used to accumulate information about access keys +# domain of DC creating course +# username of DC creating course +# optional course number, if unique course number already obtained (e.g., for +# course requests submitted via course request form. # # outputs # LON-CAPA courseID for new (created) course @@ -386,7 +393,7 @@ sub parse_coursereqs { ######################################################### sub build_course { - my ($cdom,$num,$context,$details,$longroles,$logmsg,$newusermsg,$addresult,$enrollcount,$output,$keysmsg,$udom,$uname) = @_; + my ($cdom,$num,$context,$details,$longroles,$logmsg,$newusermsg,$addresult,$enrollcount,$output,$keysmsg,$udom,$uname,$cnum) = @_; my $owner_uname = $$details{$num}{'owner'}; my $owner_domain = $$details{$num}{'domain'}; my $owner = $owner_uname.':'.$owner_domain; @@ -452,6 +459,10 @@ sub build_course { } if ($outcome eq 'ok') { + if ($$details{$num}{'datemode'} !~ /^(preserve|shift|delete)$/) { + $$details{$num}{'datemode'} = 'shift'; + $$details{$num}{'dateshift'} = 365; + } my $courseargs = { ccuname => $$details{$num}{'owner'}, ccdomain => $$details{$num}{'domain'}, @@ -465,6 +476,8 @@ sub build_course { crsquota => $$details{$num}{'crsquota'}, clonecourse => $$details{$num}{'clonecrs'}, clonedomain => $$details{$num}{'clonedom'}, + datemode => $$details{$num}{'datemode'}, + dateshift => $$details{$num}{'dateshift'}, crsid => $$details{$num}{'optional_id'}, curruser => $$details{$num}{'owner'}, crssections => $sectionstr, @@ -491,13 +504,12 @@ sub build_course { openall => $$details{$num}{'openall'}, firstres => $firstres }; - my %host_servers = &Apache::lonnet::get_servers($cdom,'library'); if (! exists($host_servers{$$details{$num}{'coursehome'}})) { $$logmsg .= &mt('Invalid home server for course').': '.$$details{$num}{'coursehome'}; return; } - my ($success, $msg) = &Apache::loncommon::construct_course($courseargs,$logmsg,\$courseid,\$crsudom,\$crsunum,$udom,$uname,$context); + my ($success, $msg) = &Apache::loncommon::construct_course($courseargs,$logmsg,\$courseid,\$crsudom,\$crsunum,$udom,$uname,$context,$cnum); $$logmsg .= $msg; if (!$success) { return; @@ -510,7 +522,7 @@ sub build_course { # Make owner a course coordinator # if (($owner_domain) && ($owner_uname)) { - &Apache::lonnet::assignrole($owner_domain,$owner_uname,$courseid,'cc'); + &Apache::lonnet::assignrole($owner_domain,$owner_uname,$courseid,'cc','','','','',$context); } #