--- loncom/automation/batchcreatecourse.pm 2005/03/02 19:50:52 1.2 +++ loncom/automation/batchcreatecourse.pm 2005/04/07 03:58:02 1.4 @@ -1,3 +1,29 @@ +# +# $Id: batchcreatecourse.pm,v 1.4 2005/04/07 03:58:02 albertel Exp $ +# +# Copyright Michigan State University Board of Trustees +# +# This file is part of the LearningOnline Network with CAPA (LON-CAPA). +# +# LON-CAPA is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# LON-CAPA is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with LON-CAPA; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# /home/httpd/html/adm/gpl.txt +# +# http://www.lon-capa.org/ +# + package LONCAPA::batchcreatecourse; use LONCAPA::Configuration; use LONCAPA::Enrollment; @@ -16,8 +42,7 @@ use Apache::lonlocal; # of a file containing an XML description of a course request (lonbatchccrs.pm). # # XML file(s) describing courses that are to be created in domain $dom are stored in -# /home/httpd/perl/tmp/addcourse/$dom. Each XML file is deleted after it has been -# parsed. +# /home/httpd/perl/tmp/addcourse/$dom # # &create_courses() will create an account for the course owner # (if one does not currently exist), will create the course (cloning if necessary), @@ -137,15 +162,16 @@ use Apache::lonlocal; # files listed in @$requests are deleted # after the files have been parsed. # -# Directory searched for files listed in @$requests -# is /home/httpd/perl/tmp/addcourse/$dom/auto if $context is auto -# and /home/httpd/perl/tmp/addcourse/$dom/web/$uname if $context is web +# Directory for retrieval of files listed in @$requests is: +# /home/httpd/perl/tmp/addcourse/$dom/auto/pending if $context = auto +# /home/httpd/perl/tmp/addcourse/$dom/web/$udom_$uname if $context = web # # inputs (five) - requests - ref to array of filename(s) containing course requests # courseids - ref to hash to store LON-CAPA course ids of new courses # context - auto if called from command line, web if called from browser # dom - domain for which the course is being created -# uname - username of DC who is requesting course creation from browser +# uname - username of DC who is requesting course creation +# udom - domain of DC who is requesting course creation # # outputs (three) - output - text recording user roles added etc. # logmsg - text to be logged @@ -153,7 +179,7 @@ use Apache::lonlocal; ############################################################# sub create_courses { - my ($requests,$courseids,$context,$dom,$uname) = @_; + my ($requests,$courseids,$context,$dom,$uname,$udom) = @_; my $output; my $perlvarref = LONCAPA::Configuration::read_conf('loncapa.conf'); # Get role names @@ -169,9 +195,13 @@ sub create_courses { my ($logmsg,$keysmsg,$newusermsg,$addresult); my %enrollcount = (); my $newcoursedir = $$perlvarref{'lonDaemons'}.'/tmp/addcourse/'.$dom.'/'.$context; - if ($uname) { - unless ($context eq 'auto') { - $newcoursedir .= '/'.$uname; + if ($context eq 'auto') { + $newcoursedir .= '/pending'; + } else { + if ($uname && $udom) { + $newcoursedir .= '/'.$udom.'_'.$uname; + } else { + $logmsg = "batchcreatecourse::create_courses() called without username and/or domain of requesting Domain Coordinator"; } } if (@{$requests} > 0) { @@ -349,7 +379,7 @@ sub parse_coursereqs { ######################################################### sub build_course { - my ($cdom,$num,$context,$details,$longoles,$logmsg,$newusermsg,$addresult,$enrollcount,$output,$keysmsg) = @_; + my ($cdom,$num,$context,$details,$longoles,$logmsg,$newusermsg,$addresult,$enrollcount,$output,$keysmsg,$udom,$uname) = @_; my $owner_uname = $$details{$num}{'owner'}; my $owner_domain = $$details{$num}{'domain'}; my $owner = $owner_uname.':'.$owner_domain; @@ -457,7 +487,7 @@ sub build_course { return; } - &Apache::loncreatecourse::construct_course($courseargs,$logmsg,\$courseid,\$crsudom,\$crsunum); + &Apache::loncreatecourse::construct_course($courseargs,$logmsg,\$courseid,\$crsudom,\$crsunum,$udom,$uname); } else { return; }