--- loncom/automation/batchcreatecourse.pm 2005/08/31 06:31:22 1.8 +++ loncom/automation/batchcreatecourse.pm 2006/07/08 17:29:24 1.16 @@ -1,5 +1,5 @@ # -# $Id: batchcreatecourse.pm,v 1.8 2005/08/31 06:31:22 raeburn Exp $ +# $Id: batchcreatecourse.pm,v 1.16 2006/07/08 17:29:24 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -36,6 +36,8 @@ use Apache::loncreatecourse; use Apache::loncreateuser; use Apache::lonlocal; +use strict; + # Collection of routines used for batch creation of courses and users. # &create_courses() should be called by an Autocreate.pl # script via a cron entry, or alternatively from a web page, after upload @@ -54,6 +56,7 @@ use Apache::lonlocal; # # # Underwater Basket Weaving +# Course # ss05ubw101 # msul1 # msu @@ -72,6 +75,7 @@ use Apache::lonlocal; # # # nav +# 20 # 466011437c34194msul1 # msu # @@ -152,8 +156,14 @@ use Apache::lonlocal; # A value of 0 or blank is equivalent to an unchecked box or 'No' # response. Dates are in format YYYY:MM:DD:HH:MM:SS (:separators required) # -# firstres can be nav, syl , or blank for "Navigate Contents", Syllabus, or +# firstres can be nav, syl, or blank for "Navigate Contents", Syllabus, or # no entry respectively. +# +# crstype can be Course or Group +# +# crsquota is the total disk space permitted for course group portfolio files +# in all course groups. +# # For format of other parameters, refer to the interactive CCRS page # and view how the equivalent parameter is displayed in the web form. # @@ -164,7 +174,7 @@ use Apache::lonlocal; # # 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 +# /home/httpd/perl/tmp/addcourse/$dom/web/$uname_$udom/pending 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 @@ -184,7 +194,7 @@ sub create_courses { my $perlvarref = LONCAPA::Configuration::read_conf('loncapa.conf'); # Get role names my %longroles = (); - open(FILE,"<$perlvarref{'lonTabDir'}.'/rolesplain.tab"); + open(FILE,"<$$perlvarref{'lonTabDir'}.'/rolesplain.tab"); my @rolesplain = ; close(FILE); foreach (@rolesplain) { @@ -199,7 +209,7 @@ sub create_courses { $newcoursedir .= '/pending'; } else { if ($uname && $udom) { - $newcoursedir .= '/'.$udom.'_'.$uname; + $newcoursedir .= '/'.$uname.'_'.$udom.'/pending'; } else { $logmsg = "batchcreatecourse::create_courses() called without username and/or domain of requesting Domain Coordinator"; } @@ -239,7 +249,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'); + 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 @dateitems = ('enrollstart','enrollend','accessstart','accessend'); my @useritems = ('autharg','authtype','firstname','generation','lastname','middlename','studentID'); my $p = HTML::Parser->new @@ -376,7 +386,7 @@ sub parse_coursereqs { ######################################################### sub build_course { - my ($cdom,$num,$context,$details,$longoles,$logmsg,$newusermsg,$addresult,$enrollcount,$output,$keysmsg,$udom,$uname) = @_; + my ($cdom,$num,$context,$details,$longroles,$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; @@ -422,11 +432,11 @@ sub build_course { 'emailenc' => $$details{$num}{'emailenc'}, 'udom' => $$details{$num}{'domain'}, 'uname' => $$details{$num}{'owner'}, - 'pid' => '', - 'first' => $$details{$num}{'users'}{$owner}{'first'}, - 'middle' => $$details{$num}{'users'}{$owner}{'middle'}, - 'last' => $$details{$num}{'users'}{$owner}{'last'}, - 'gene' => $$details{$num}{'users'}{$owner}{'gene'}, + 'pid' => $$details{$num}{'users'}{$owner}{'studentID'}, + 'first' => $$details{$num}{'users'}{$owner}{'firstname'}, + 'middle' => $$details{$num}{'users'}{$owner}{'middlename'}, + 'last' => $$details{$num}{'users'}{$owner}{'lastname'}, + 'gene' => $$details{$num}{'users'}{$owner}{'generation'}, 'usec' => '', 'end' => '', 'start' => '', @@ -446,11 +456,13 @@ sub build_course { ccuname => $$details{$num}{'owner'}, ccdomain => $$details{$num}{'domain'}, cdescr => $$details{$num}{'title'}, + crstype => $$details{$num}{'crstype'}, curl => $$details{$num}{'topmap'}, course_domain => $cdom, course_home => $$details{$num}{'coursehome'}, nonstandard => $$details{$num}{'nonstandard'}, crscode => $$details{$num}{'coursecode'}, + crsquota => $$details{$num}{'crsquota'}, clonecourse => $$details{$num}{'clonecrs'}, clonedomain => $$details{$num}{'clonedom'}, crsid => $$details{$num}{'optional_id'}, @@ -469,7 +481,7 @@ sub build_course { enrollend => $$details{$num}{'enrollend'}, startaccess => $$details{$num}{'accessstart'}, endaccess => $$details{$num}{'accessend'}, - setpolicy => $Sdetails{$num}{'setpolicy'}, + setpolicy => $$details{$num}{'setpolicy'}, setcontent => $$details{$num}{'setcontent'}, reshome => $reshome, setkeys => $$details{$num}{'setkeys'}, @@ -627,15 +639,53 @@ sub process_date { if ($timestr !~ /:/) { $timestamp = ''; } else { - my @entries = split/:/,$timestr; + my @entries = split(/:/,$timestr); for (my $j=0; $j<@entries; $j++) { if ( length($entries[$j]) > 1 ) { $entries[$j] =~ s/^0//; } + $entries[$j] =~ s/\D//g; + if ($entries[$j] < 0) { + $entries[$j] = 0; + } } if ($entries[1] > 0) { $entries[1] = $entries[1] - 1; } + if ($entries[5] > 60) { + $entries[5] = 60; + } + if ($entries[4] > 59) { + $entries[4] = 59; + } + if ($entries[3] > 23) { + $entries[3] = 23; + } + if ($entries[2] > 31) { + $entries[2] = 31; + } + if ($entries[1] > 11) { + $entries[1] = 11; + } + if ($entries[2] == 31) { + if (($entries[1] == 3) || ($entries[1] == 5) || + ($entries[1] == 8) || ($entries[1] == 10)) { + $entries[2] = 30; + } + } + if ($entries[1] == 1) { + if ($entries[2] > 29) { + $entries[2] = 29; + } + if ($entries[2] == 29) { + if ($entries[0]%4 != 0) { + $entries[2] = 28; + } elsif ( $entries[0]%100 == 0 + && $entries[0]%400 != 0) { + $entries[2] = 28; + } + } + } $timestamp = timelocal($entries[5],$entries[4],$entries[3],$entries[2],$entries[1],$entries[0]); } return $timestamp;