[LON-CAPA-cvs] cvs: loncom /automation batchcreatecourse.pm
raeburn
lon-capa-cvs@mail.lon-capa.org
Wed, 01 Jun 2005 19:20:34 -0000
raeburn Wed Jun 1 15:20:34 2005 EDT
Modified files:
/loncom/automation batchcreatecourse.pm
Log:
Bug fixes and inclusion of class ID information for better integration with automated course creation.
Index: loncom/automation/batchcreatecourse.pm
diff -u loncom/automation/batchcreatecourse.pm:1.4 loncom/automation/batchcreatecourse.pm:1.5
--- loncom/automation/batchcreatecourse.pm:1.4 Wed Apr 6 23:58:02 2005
+++ loncom/automation/batchcreatecourse.pm Wed Jun 1 15:20:32 2005
@@ -1,5 +1,5 @@
#
-# $Id: batchcreatecourse.pm,v 1.4 2005/04/07 03:58:02 albertel Exp $
+# $Id: batchcreatecourse.pm,v 1.5 2005/06/01 19:20:32 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -211,7 +211,7 @@
&parse_coursereqs($newcoursedir.'/'.$request, \%details);
foreach my $num (sort keys %details) {
my $courseid = &build_course($dom,$num,$context,\%details,\%longroles,\$logmsg,\$newusermsg,\$addresult,\%enrollcount,\$output,\$keysmsg);
- $$courseids{$courseid} = $enrollcount;
+ $$courseids{$courseid} = $details{$num}{'class'};
}
}
}
@@ -292,7 +292,7 @@
} elsif ("@state" eq "class owner authtype") {
$$details{$num}{'ownerauthtype'} = $text;
} elsif ("@state" eq "class owner autharg") {
- $$details{$num}{'ownerautharg'} = $text;
+ $$details{$num}{'ownerauthparam'} = $text;
} elsif ("@state" eq "class authentication method") {
$$details{$num}{'authtype'} = $text;
} elsif ("@state" eq "class authentication param") {
@@ -350,9 +350,6 @@
$p->parse_file($coursefile);
$p->eof;
- if (-e "$coursefile") {
-# unlink $coursefile;
- }
return;
}
@@ -406,19 +403,21 @@
$firstres = 'syl';
}
foreach my $secid (sort keys %{$$details{$num}{'sections'}}) {
- $sectionstr .= $$details{$num}{'sections'}{$secid}{'inst'}.':'.$$details{$num}{'sections'}{$secid}{'loncapa'};
+ $sectionstr .= $$details{$num}{'sections'}{$secid}{'inst'}.':'.$$details{$num}{'sections'}{$secid}{'loncapa'}.',';
}
+ $sectionstr =~ s/,$//;
foreach my $xlist (sort keys %{$$details{$num}{'crosslists'}}) {
- $xliststr .= $$details{$num}{'crosslists'}{$xlist}{'inst'}.':'.$$details{$num}{'crosslists'}{$xlist}{'loncapa'};
+ $xliststr .= $$details{$num}{'crosslists'}{$xlist}{'inst'}.':'.$$details{$num}{'crosslists'}{$xlist}{'loncapa'}.',';
}
+ $xliststr =~ s/,$//;
my %courseinfo = (
inst_code => $$details{$num}{'coursecode'},
description => $$details{$num}{'title'}
);
if (&Apache::lonnet::homeserver($$details{$num}{'owner'},$$details{$num}{'domain'}) eq 'no_host') { # Add user if no account
- my $ownerargs = ('auth' => $$details{$num}{'ownerauthtype'},
+ my $ownerargs = {'auth' => $$details{$num}{'ownerauthtype'},
'authparam' => $$details{$num}{'ownerauthparam'},
'emailenc' => $$details{$num}{'emailenc'},
'dom' => $$details{$num}{'domain'},
@@ -435,8 +434,8 @@
'cid' => '',
'context' => 'createowner',
'linefeed' => $linefeed,
- 'role' => 'cc'
- );
+ 'role' => 'cc',
+ };
$outcome = &LONCAPA::Enrollment::create_newuser($ownerargs,$logmsg,$newusermsg,$enrollcount,$addresult,$longroles,$courseinfo);
} else {
$outcome = 'ok';
@@ -510,8 +509,9 @@
if (&Apache::lonnet::homeserver($username,$userdom) eq 'no_host') { # Add user if no account
my $firstrole = $$details{$num}{'users'}{$userkey}{'roles'}[0];
my $firssec = $$details{$num}{'users'}{$userkey}{$firstrole}{'usec'}[0];
- my $userargs = ('auth' => $$details{$num}{'users'}{$userkey}{'authtype'},
- 'authparam' => $$details{$num}{'users'}{$userkey}{'authparam'},
+ my $userargs = {
+ 'auth' => $$details{$num}{'users'}{$userkey}{'authtype'},
+ 'authparam' => $$details{$num}{'users'}{$userkey}{'autharg'},
'emailenc' => $$details{$num}{'users'}{$userkey}{'emailenc'},
'dom' => $userdom,
'uname' => $username,
@@ -528,7 +528,7 @@
'context' => 'createcourse',
'linefeed' => $linefeed,
'role' => $$details{$num}{'users'}{$userkey}{'roles'}[0],
- );
+ };
$outcome = &LONCAPA::Enrollment::create_newuser($userargs,$logmsg,$newusermsg,$enrollcount,$addresult,$longroles,$courseinfo);
# now add other roles and other sections.
if ($outcome eq 'ok') {
@@ -587,13 +587,11 @@
if ($usec ne '') {
$url .= '/'.$usec;
}
- $$output .= &Apache::loncreateuser::commit_standardrole($userdom,$username,$url,$curr_role,$start,$end,$crsudom,$crsunum,$usec);
- $url = '/'.$crsudom.'/'.$crsunum;
- if ($usec ne '') {
- $url .= '/'.$usec;
- }
+ my $stdresult = &Apache::loncreateuser::commit_standardrole($userdom,$username,$url,$curr_role,$start,$end,$crsudom,$crsunum,$usec);
+ $$output .= $stdresult;
}
} else {
+ $url = '/'.$crsudom.'/'.$crsunum;
$$output .= &Apache::loncreateuser::commit_standardrole($userdom,$username,$url,$curr_role,$start,$end,$crsudom,$crsunum,'');
}
}
@@ -624,7 +622,7 @@
sub process_date {
my $timestr = shift;
my $timestamp = '';
- if ($timestr eq "No end date") {
+ if ($timestr !~ /:/) {
$timestamp = '';
} else {
my @entries = split/:/,$timestr;
@@ -633,7 +631,9 @@
$entries[$j] =~ s/^0//;
}
}
- $entries[1] = $entries[1] - 1;
+ if ($entries[1] > 0) {
+ $entries[1] = $entries[1] - 1;
+ }
$timestamp = timelocal($entries[5],$entries[4],$entries[3],$entries[2],$entries[1],$entries[0]);
}
return $timestamp;