version 1.40.2.3, 2020/05/22 20:55:45
|
version 1.45, 2020/07/01 20:09:03
|
Line 80 use strict;
|
Line 80 use strict;
|
# <clonedom>msu</clonedom> |
# <clonedom>msu</clonedom> |
# <datemode>shift</datemode> |
# <datemode>shift</datemode> |
# <dateshift>365</dateshift> |
# <dateshift>365</dateshift> |
|
# <tinyurls>create</tinyurls> |
# <showphotos></showphotos> |
# <showphotos></showphotos> |
# <setpolicy>1</setpolicy> |
# <setpolicy>1</setpolicy> |
# <setcontent>1</setcontent> |
# <setcontent>1</setcontent> |
Line 165 use strict;
|
Line 166 use strict;
|
# 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. |
# no entry respectively. |
# |
# |
# crstype can be Course or Community |
# crstype can be Course, Community or Placement |
# |
# |
# crsquota is the total disk space permitted for course group portfolio files |
# crsquota is the total disk space permitted for course group portfolio files |
# in all course groups. |
# in all course groups. |
Line 189 use strict;
|
Line 190 use strict;
|
# uname - username of DC who is requesting course creation |
# uname - username of DC who is requesting course creation |
# udom - domain of DC who is requesting course creation |
# udom - domain of DC who is requesting course creation |
# |
# |
# outputs (four) - output - text recording user roles added etc. |
# outputs (six) - output - text recording user roles added etc. |
# logmsg - text to be logged |
# logmsg - text to be logged |
# keysmsg - text containing link(s) to manage keys page(s) |
# cloneinfo - text output from cloning |
# codehash - reference to hash containing courseID => unique code |
# keysmsg - text containing link(s) to manage keys page(s) |
# where unique code is a 6 character code, to distribute |
# codehash - reference to hash containing courseID => unique code |
# to students as a shortcut to the course. |
# where unique code is a 6 character code, to distribute |
|
# to students as a shortcut to the course. |
|
# instcodes - references to hash of an array, where keys are |
|
# institutional codes and values are an array of |
|
# courseIDs of courses with that code. |
############################################################# |
############################################################# |
|
|
sub create_courses { |
sub create_courses { |
Line 212 sub create_courses {
|
Line 217 sub create_courses {
|
$longroles{'Community'}{$1} = $3; |
$longroles{'Community'}{$1} = $3; |
} |
} |
} |
} |
my ($logmsg,$keysmsg,$newusermsg,$addresult,%codehash,%instcodes); |
my ($logmsg,$cloneinfo,$keysmsg,$newusermsg,$addresult,$user_lh, |
|
%codehash,%instcodes); |
my %enrollcount = (); |
my %enrollcount = (); |
my $newcoursedir = LONCAPA::tempdir().'/addcourse/'.$dom.'/'.$context; |
my $newcoursedir = LONCAPA::tempdir().'/addcourse/'.$dom.'/'.$context; |
if ($context eq 'auto') { |
if ($context eq 'auto') { |
|
$user_lh = &Apache::loncommon::user_lang($uname,$udom); |
$newcoursedir .= '/pending'; |
$newcoursedir .= '/pending'; |
} else { |
} else { |
if ($uname && $udom) { |
if ($uname && $udom) { |
Line 227 sub create_courses {
|
Line 234 sub create_courses {
|
if (@{$requests} > 0) { |
if (@{$requests} > 0) { |
foreach my $request (@{$requests}) { |
foreach my $request (@{$requests}) { |
my %details = (); |
my %details = (); |
|
my $clonemsg = []; |
if (-e $newcoursedir.'/'.$request) { |
if (-e $newcoursedir.'/'.$request) { |
&parse_coursereqs($newcoursedir.'/'.$request, \%details); |
&parse_coursereqs($newcoursedir.'/'.$request, \%details); |
foreach my $num (sort(keys(%details))) { |
foreach my $num (sort(keys(%details))) { |
my $reqdetails = $details{$num}; |
my $reqdetails = $details{$num}; |
my $code; |
my $code; |
my $courseid = |
my $courseid = |
&build_course($dom,$num,$context,$reqdetails,\%longroles,\$logmsg,\$newusermsg, |
&build_course($dom,$num,$context,$reqdetails,\%longroles,\$logmsg, |
\$addresult,\%enrollcount,\$output,\$keysmsg,undef,undef,undef,undef,\$code); |
$clonemsg,\$newusermsg,\$addresult,\%enrollcount, |
|
\$output,\$keysmsg,undef,undef,undef,undef,\$code); |
if ($courseid =~m{^/$match_domain/$match_courseid}) { |
if ($courseid =~m{^/$match_domain/$match_courseid}) { |
$$courseids{$courseid} = $details{$num}{'class'}; |
$$courseids{$courseid} = $details{$num}{'class'}; |
if ($code) { |
if ($code) { |
Line 244 sub create_courses {
|
Line 253 sub create_courses {
|
push(@{$instcodes{$details{$num}{'coursecode'}}},$courseid); |
push(@{$instcodes{$details{$num}{'coursecode'}}},$courseid); |
} |
} |
} |
} |
|
if (@{$clonemsg}) { |
|
if ($context eq 'web') { |
|
$cloneinfo .= '<p class="LC_info">'; |
|
} |
|
foreach my $item (@{$clonemsg}) { |
|
if (ref($item) eq 'HASH') { |
|
if ($context eq 'auto') { |
|
$cloneinfo .= &mt_user($user_lh,$item->{mt}, |
|
@{$item->{args}}); |
|
} else { |
|
$cloneinfo .= &mt($item->{mt},@{$item->{args}}); |
|
} |
|
} |
|
if ($context eq 'web') { |
|
$cloneinfo .= '<br />'; |
|
} |
|
$cloneinfo .= "\n"; |
|
} |
|
if ($context eq 'web') { |
|
$cloneinfo .= '</p>'; |
|
} |
|
} |
} |
} |
} |
} |
} |
} |
} |
} |
return ($output,$logmsg,$keysmsg,\%codehash,\%instcodes); |
return ($output,$logmsg,$cloneinfo,$keysmsg,\%codehash,\%instcodes); |
} |
} |
|
|
############################################################# |
############################################################# |
Line 271 sub parse_coursereqs {
|
Line 302 sub parse_coursereqs {
|
my $xlist = 0; |
my $xlist = 0; |
my $userkey = ''; |
my $userkey = ''; |
my $role = ''; |
my $role = ''; |
my @items = ('title','optional_id','coursecode','defaultcredits','coursehome','reshome','nonstandard','adds','drops','topmap','firstres','clonecrs','clonedom','datemode','dateshift','showphotos','setpolicy','setcontent','setcomment','setkeys','keyauth','disresdis','disablechat','openall','notify_owner','notify_dc','crstype','crsquota','uniquecode'); |
my @items = ('title','optional_id','coursecode','defaultcredits','coursehome','reshome','nonstandard','adds','drops','topmap','firstres','clonecrs','clonedom','datemode','dateshift','tinyurls','showphotos','setpolicy','setcontent','setcomment','setkeys','keyauth','disresdis','disablechat','openall','notify_owner','notify_dc','crstype','crsquota','uniquecode'); |
my @possroles = qw(st ad ep ta in cc co); |
my @possroles = qw(st ad ep ta in cc co); |
my @dateitems = ('enrollstart','enrollend','accessstart','accessend','openallfrom'); |
my @dateitems = ('enrollstart','enrollend','accessstart','accessend','openallfrom'); |
my @useritems = ('autharg','authtype','firstname','generation','lastname','middlename','studentID'); |
my @useritems = ('autharg','authtype','firstname','generation','lastname','middlename','studentID'); |
Line 397 sub parse_coursereqs {
|
Line 428 sub parse_coursereqs {
|
# ref to hash of course creation information |
# ref to hash of course creation information |
# ref to hash of role descriptions |
# ref to hash of role descriptions |
# ref to scalar used to accumulate log messages |
# ref to scalar used to accumulate log messages |
|
# ref to array used to accumulate messages about cloning |
# ref to scalar used to accumulate messages sent to new users |
# ref to scalar used to accumulate messages sent to new users |
# ref to scalar used to accumulate results of new user additions |
# ref to scalar used to accumulate results of new user additions |
# ref to hash of enrollment counts for different roles |
# ref to hash of enrollment counts for different roles |
Line 408 sub parse_coursereqs {
|
Line 440 sub parse_coursereqs {
|
# course requests submitted via course request form. |
# course requests submitted via course request form. |
# optional category |
# optional category |
# optional ref to scalar for six character unique identifier |
# optional ref to scalar for six character unique identifier |
|
# caller context (e.g., auto) |
|
# user language handle, if caller context is 'auto' |
# |
# |
# outputs |
# outputs |
# LON-CAPA courseID for new (created) course |
# LON-CAPA courseID for new (created) course |
Line 415 sub parse_coursereqs {
|
Line 449 sub parse_coursereqs {
|
######################################################### |
######################################################### |
|
|
sub build_course { |
sub build_course { |
my ($cdom,$num,$context,$details,$longroles,$logmsg,$newusermsg,$addresult, |
my ($cdom,$num,$context,$details,$longroles,$logmsg,$clonemsg,$newusermsg, |
$enrollcount,$output,$keysmsg,$udom,$uname,$cnum,$category,$coderef) = @_; |
$addresult,$enrollcount,$output,$keysmsg,$udom,$uname,$cnum,$category, |
|
$coderef,$callercontext,$user_lh) = @_; |
return unless (ref($details) eq 'HASH'); |
return unless (ref($details) eq 'HASH'); |
my $owner_uname = $details->{'owner'}; |
my $owner_uname = $details->{'owner'}; |
my $owner_domain = $details->{'domain'}; |
my $owner_domain = $details->{'domain'}; |
Line 433 sub build_course {
|
Line 468 sub build_course {
|
$rolenames = $longroles->{'Community'}; |
$rolenames = $longroles->{'Community'}; |
} |
} |
} else { |
} else { |
$crstype = 'Course'; |
if ($details->{'crstype'} eq 'Placement') { |
|
$crstype = $details->{'crstype'}; |
|
} else { |
|
$crstype = 'Course'; |
|
} |
$ccrole = 'cc'; |
$ccrole = 'cc'; |
if (ref($longroles) eq 'HASH') { |
if (ref($longroles) eq 'HASH') { |
$rolenames = $longroles->{'Course'}; |
$rolenames = $longroles->{'Course'}; |
Line 456 sub build_course {
|
Line 495 sub build_course {
|
if ($firstres eq '') { |
if ($firstres eq '') { |
if ($crstype eq 'Community') { |
if ($crstype eq 'Community') { |
$firstres = 'nav'; |
$firstres = 'nav'; |
|
} elsif ($crstype eq 'Placement') { |
|
$firstres = 'blank'; |
} else { |
} else { |
$firstres = 'syl'; |
$firstres = 'syl'; |
} |
} |
Line 504 sub build_course {
|
Line 545 sub build_course {
|
$details->{'datemode'} = 'shift'; |
$details->{'datemode'} = 'shift'; |
$details->{'dateshift'} = 365; |
$details->{'dateshift'} = 365; |
} |
} |
|
if ($details->{'tinyurls'} !~ /^(delete|transfer|create)$/) { |
|
$details->{'tinyurls'} = 'create'; |
|
} |
my $courseargs = { |
my $courseargs = { |
ccuname => $details->{'owner'}, |
ccuname => $details->{'owner'}, |
ccdomain => $details->{'domain'}, |
ccdomain => $details->{'domain'}, |
Line 521 sub build_course {
|
Line 565 sub build_course {
|
clonedomain => $details->{'clonedom'}, |
clonedomain => $details->{'clonedom'}, |
datemode => $details->{'datemode'}, |
datemode => $details->{'datemode'}, |
dateshift => $details->{'dateshift'}, |
dateshift => $details->{'dateshift'}, |
|
tinyurls => $details->{'tinyurls'}, |
crsid => $details->{'optional_id'}, |
crsid => $details->{'optional_id'}, |
curruser => $details->{'owner'}, |
curruser => $details->{'owner'}, |
crssections => $sectionstr, |
crssections => $sectionstr, |
Line 557 sub build_course {
|
Line 602 sub build_course {
|
$$logmsg .= &mt('Invalid home server for course').': '.$details->{'coursehome'}; |
$$logmsg .= &mt('Invalid home server for course').': '.$details->{'coursehome'}; |
return; |
return; |
} |
} |
my ($success, $msg) = |
my ($success,$msg,$cloneinfo) = |
&Apache::loncommon::construct_course($courseargs,$logmsg,\$courseid,\$crsudom,\$crsunum, |
&Apache::loncommon::construct_course($courseargs,$logmsg,\$courseid,\$crsudom,\$crsunum, |
$udom,$uname,$context,$cnum,$category,$coderef); |
$udom,$uname,$context,$cnum,$category,$coderef, |
|
$callercontext,$user_lh); |
$$logmsg .= $msg; |
$$logmsg .= $msg; |
|
if ((ref($clonemsg) eq 'ARRAY') && (ref($cloneinfo) eq 'ARRAY')) { |
|
push(@{$clonemsg},@{$cloneinfo}); |
|
} |
if (!$success) { |
if (!$success) { |
return; |
return; |
} |
} |
} else { |
} else { |
return; |
return; |
} |
} |
|
|
# |
# |
# Make owner a coordinator |
# Make owner a coordinator |
# |
# |