--- loncom/automation/batchcreatecourse.pm 2011/07/04 09:24:46 1.37
+++ loncom/automation/batchcreatecourse.pm 2013/03/01 04:49:15 1.38
@@ -1,5 +1,5 @@
#
-# $Id: batchcreatecourse.pm,v 1.37 2011/07/04 09:24:46 foxr Exp $
+# $Id: batchcreatecourse.pm,v 1.38 2013/03/01 04:49:15 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -56,6 +56,7 @@ use strict;
#
Underwater Basket Weaving
# Course
# ss05ubw101
+# 3
# msul1
# msu
# /res/msu/
@@ -122,6 +123,7 @@ use strict;
# Spartanx
#
#
+#
#
#
#
@@ -253,7 +255,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','datemode','dateshift','showphotos','setpolicy','setcontent','setkeys','keyauth','disresdis','disablechat','openall','notify_owner','notify_dc','crstype','crsquota');
+ my @items = ('title','optional_id','coursecode','defaultcredits','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 @possroles = qw(st ad ep ta in cc co);
my @dateitems = ('enrollstart','enrollend','accessstart','accessend');
my @useritems = ('autharg','authtype','firstname','generation','lastname','middlename','studentID');
@@ -494,6 +496,7 @@ sub build_course {
course_home => $details->{'coursehome'},
nonstandard => $details->{'nonstandard'},
crscode => $details->{'coursecode'},
+ defaultcredits => $details->{'defaultcredits'},
crsquota => $details->{'crsquota'},
clonecourse => $details->{'clonecrs'},
clonedomain => $details->{'clonedom'},
@@ -611,8 +614,14 @@ sub build_course {
'cdom' => $crsudom,
'context' => 'createcourse',
'linefeed' => $linefeed,
- 'role' => $details->{'users'}{$userkey}{'roles'}[0],
+ 'role' => $details->{'users'}{$userkey}{'roles'}[0],
};
+ if ($userargs->{'role'} eq 'st') {
+ if (exists($details->{'users'}{$userkey}{'credits'})) {
+ $userargs->{'credits'} = $details->{'users'}{$userkey}{'credits'};
+ $userargs->{'credits'} =~ s/[^\d\.]//g;
+ }
+ }
$outcome = &LONCAPA::Enrollment::create_newuser($userargs,$logmsg,$newusermsg,$enrollcount,$addresult,$longroles,\%courseinfo,$context);
# now add other roles and other sections.
if ($outcome eq 'ok') {
@@ -643,7 +652,12 @@ sub build_course {
if ($usec ne '') {
$url .= '/'.$usec;
}
- $$output .= &Apache::loncommon::commit_studentrole(\$stulogmsg,$userdom,$username,$url,$curr_role,$start,$end,$crsudom,$crsunum,$usec,$context);
+ my $credits;
+ if (exists($details->{'users'}{$userkey}{'credits'})) {
+ $credits = $details->{'users'}{$userkey}{'credits'};
+ $credits =~ s/[^\d\.]//g;
+ }
+ $$output .= &Apache::loncommon::commit_studentrole(\$stulogmsg,$userdom,$username,$url,$curr_role,$start,$end,$crsudom,$crsunum,$usec,$context,$credits);
} elsif ($curr_role eq $ccrole) {
$url = '/'.$crsudom.'/'.$crsunum;
my $usec = '';
@@ -684,7 +698,12 @@ sub build_course {
if ($usec ne '') {
$url .= '/'.$usec;
}
- $$output .= &Apache::loncommon::commit_studentrole(\$stulogmsg,$userdom,$username,$url,$curr_role,$start,$end,$crsudom,$crsunum,$usec,$context);
+ my $credits;
+ if (exists($details->{'users'}{$userkey}{'credits'})) {
+ $credits = $details->{'users'}{$userkey}{'credits'};
+ $credits =~ s/[^\d\.]//g;
+ }
+ $$output .= &Apache::loncommon::commit_studentrole(\$stulogmsg,$userdom,$username,$url,$curr_role,$start,$end,$crsudom,$crsunum,$usec,$context,$credits);
} elsif ((grep(/^\Q$curr_role\E$/,@courseroles)) ||
($curr_role =~ m{^cr/$match_domain/$match_username/[^/]+$})) {
if (@{$details->{'users'}{$userkey}{$curr_role}{'usec'}} > 0) {