--- loncom/automation/batchcreatecourse.pm 2006/08/11 19:30:52 1.17
+++ loncom/automation/batchcreatecourse.pm 2008/05/01 02:48:49 1.26
@@ -1,5 +1,5 @@
#
-# $Id: batchcreatecourse.pm,v 1.17 2006/08/11 19:30:52 albertel Exp $
+# $Id: batchcreatecourse.pm,v 1.26 2008/05/01 02:48:49 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -31,9 +31,8 @@ use HTML::Parser;
use Time::Local;
use Apache::lonnet;
use Apache::loncommon;
-use Apache::loncreatecourse;
-use Apache::loncreateuser;
use Apache::lonlocal;
+use LONCAPA qw(:match);
use strict;
@@ -81,7 +80,7 @@ use strict;
# 1
# 1
# 0
-# keyadmin@msu
+# keyadmin:msu
# 1
# 1
#
@@ -220,7 +219,9 @@ sub create_courses {
&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} = $details{$num}{'class'};
+ if ($courseid =~m{^/$match_domain/$match_courseid}) {
+ $$courseids{$courseid} = $details{$num}{'class'};
+ }
}
}
}
@@ -445,7 +446,7 @@ sub build_course {
'linefeed' => $linefeed,
'role' => 'cc',
};
- $outcome = &LONCAPA::Enrollment::create_newuser($ownerargs,$logmsg,$newusermsg,$enrollcount,$addresult,$longroles,\%courseinfo);
+ $outcome = &LONCAPA::Enrollment::create_newuser($ownerargs,$logmsg,$newusermsg,$enrollcount,$addresult,$longroles,\%courseinfo,$context);
} else {
$outcome = 'ok';
}
@@ -491,13 +492,16 @@ sub build_course {
firstres => $firstres
};
- my %host_servers = &Apache::loncommon::get_library_servers($cdom);
+ 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;
}
-
- &Apache::loncreatecourse::construct_course($courseargs,$logmsg,\$courseid,\$crsudom,\$crsunum,$udom,$uname);
+ my ($success, $msg) = &Apache::loncommon::construct_course($courseargs,$logmsg,\$courseid,\$crsudom,\$crsunum,$udom,$uname,$context);
+ $$logmsg .= $msg;
+ if (!$success) {
+ return;
+ }
} else {
return;
}
@@ -506,7 +510,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);
}
#
@@ -542,7 +546,7 @@ sub build_course {
'linefeed' => $linefeed,
'role' => $$details{$num}{'users'}{$userkey}{'roles'}[0],
};
- $outcome = &LONCAPA::Enrollment::create_newuser($userargs,$logmsg,$newusermsg,$enrollcount,$addresult,$longroles,\%courseinfo);
+ $outcome = &LONCAPA::Enrollment::create_newuser($userargs,$logmsg,$newusermsg,$enrollcount,$addresult,$longroles,\%courseinfo,$context);
# now add other roles and other sections.
if ($outcome eq 'ok') {
if (($firstrole ne 'st') && (@{$$details{$num}{'users'}{$userkey}{$firstrole}{'usec'}} > 1)) {
@@ -555,7 +559,7 @@ sub build_course {
if ($usec ne '') {
$url .= '/'.$usec;
}
- $$output .= &Apache::loncreateuser::commit_standardrole($userdom,$username,$url,$curr_role,$start,$end,$crsudom,$crsunum,$usec);
+ $$output .= &Apache::loncommon::commit_standardrole($userdom,$username,$url,$curr_role,$start,$end,$crsudom,$crsunum,$usec,$context);
}
}
if (@{$$details{$num}{'users'}{$userkey}{'roles'}} > 1) {
@@ -569,14 +573,14 @@ sub build_course {
if ($usec ne '') {
$url .= '/'.$usec;
}
- $$output .= &Apache::loncreateuser::commit_studentrole(\$stulogmsg,$userdom,$username,$url,$curr_role,$start,$end,$crsudom,$crsunum,$usec);
+ $$output .= &Apache::loncommon::commit_studentrole(\$stulogmsg,$userdom,$username,$url,$curr_role,$start,$end,$crsudom,$crsunum,$usec,$context);
} else {
foreach my $usec (@{$$details{$num}{'users'}{$userkey}{$curr_role}{'usec'}}) {
$url = '/'.$crsudom.'/'.$crsunum;
if ($usec ne '') {
$url .= '/'.$usec;
}
- $$output .= &Apache::loncreateuser::commit_standardrole($userdom,$username,$url,$curr_role,$start,$end,$crsudom,$crsunum,$usec);
+ $$output .= &Apache::loncommon::commit_standardrole($userdom,$username,$url,$curr_role,$start,$end,$crsudom,$crsunum,$usec,$context);
}
}
}
@@ -592,7 +596,7 @@ sub build_course {
if ($usec ne '') {
$url .= '/'.$usec;
}
- $$output .= &Apache::loncreateuser::commit_studentrole(\$stulogmsg,$userdom,$username,$url,$curr_role,$start,$end,$crsudom,$crsunum,$usec);
+ $$output .= &Apache::loncommon::commit_studentrole(\$stulogmsg,$userdom,$username,$url,$curr_role,$start,$end,$crsudom,$crsunum,$usec,$context);
} else {
if (@{$$details{$num}{'users'}{$userkey}{$curr_role}{'usec'}} > 0) {
foreach my $usec (@{$$details{$num}{'users'}{$userkey}{$curr_role}{'usec'}}) {
@@ -600,12 +604,12 @@ sub build_course {
if ($usec ne '') {
$url .= '/'.$usec;
}
- my $stdresult = &Apache::loncreateuser::commit_standardrole($userdom,$username,$url,$curr_role,$start,$end,$crsudom,$crsunum,$usec);
+ my $stdresult = &Apache::loncommon::commit_standardrole($userdom,$username,$url,$curr_role,$start,$end,$crsudom,$crsunum,$usec,$context);
$$output .= $stdresult;
}
} else {
$url = '/'.$crsudom.'/'.$crsunum;
- $$output .= &Apache::loncreateuser::commit_standardrole($userdom,$username,$url,$curr_role,$start,$end,$crsudom,$crsunum,'');
+ $$output .= &Apache::loncommon::commit_standardrole($userdom,$username,$url,$curr_role,$start,$end,$crsudom,$crsunum,'',$context);
}
}
}