version 1.32, 2009/10/31 17:54:51
|
version 1.40.2.1.2.1, 2020/05/22 22:01:59
|
Line 56 use strict;
|
Line 56 use strict;
|
# <title>Underwater Basket Weaving</title> |
# <title>Underwater Basket Weaving</title> |
# <crstype>Course</crstype> |
# <crstype>Course</crstype> |
# <coursecode>ss05ubw101</coursecode> |
# <coursecode>ss05ubw101</coursecode> |
|
# <defaultcredits>3</defaultcredits> |
# <coursehome>msul1</coursehome> |
# <coursehome>msul1</coursehome> |
# <coursedomain>msu</coursedomain> |
# <coursedomain>msu</coursedomain> |
# <reshome>/res/msu/</reshome> |
# <reshome>/res/msu/</reshome> |
Line 74 use strict;
|
Line 75 use strict;
|
# <topmap></topmap> |
# <topmap></topmap> |
# <firstres>nav</firstres> |
# <firstres>nav</firstres> |
# <crsquota>20</crsquota> |
# <crsquota>20</crsquota> |
|
# <uniquecode>1</uniquecode> |
# <clonecrs>466011437c34194msul1</clonecrs> |
# <clonecrs>466011437c34194msul1</clonecrs> |
# <clonedom>msu</clonedom> |
# <clonedom>msu</clonedom> |
# <datemode>shift</datemode> |
# <datemode>shift</datemode> |
Line 81 use strict;
|
Line 83 use strict;
|
# <showphotos></showphotos> |
# <showphotos></showphotos> |
# <setpolicy>1</setpolicy> |
# <setpolicy>1</setpolicy> |
# <setcontent>1</setcontent> |
# <setcontent>1</setcontent> |
|
# <setcomment>1</setcomment> |
# <setkeys>0</setkeys> |
# <setkeys>0</setkeys> |
# <keyauth>keyadmin:msu</keyauth> |
# <keyauth>keyadmin:msu</keyauth> |
# <disresdis>1</disresdis> |
# <disresdis>1</disresdis> |
# <disablechat>1</disablechat> |
# <disablechat>1</disablechat> |
# <openall></openall> |
# <openall></openall> |
|
# <openallfrom></openallfrom> |
# <notify_dc>1</notify_dc> |
# <notify_dc>1</notify_dc> |
# <notify_owner>1</notify_owner> |
# <notify_owner>1</notify_owner> |
# <owner> |
# <owner> |
Line 122 use strict;
|
Line 126 use strict;
|
# <lastname>Spartan</lastname>x |
# <lastname>Spartan</lastname>x |
# <middlename></middlename> |
# <middlename></middlename> |
# <studentID></studentID> |
# <studentID></studentID> |
|
# <credits></credits> |
# <roles></roles> |
# <roles></roles> |
# </user> |
# </user> |
# <user> |
# <user> |
Line 149 use strict;
|
Line 154 use strict;
|
# |
# |
# Many of these are binary options (corresponding to either checkboxes or |
# Many of these are binary options (corresponding to either checkboxes or |
# radio buttons in the interactive CCRS page). Examples include: |
# radio buttons in the interactive CCRS page). Examples include: |
# setpolicy, setcontent, setkeys, disableresdis, disablechat, openall |
# setpolicy, setcontent, setcomment, setkeys, disableresdis, disablechat, openall, |
|
# uniquecode |
# |
# |
# A value of 1 between opening and closing tags is equivalent to a |
# A value of 1 between opening and closing tags is equivalent to a |
# checked checkbox or 'Yes' response in the original CCRS web page. |
# checked checkbox or 'Yes' response in the original CCRS web page. |
Line 159 use strict;
|
Line 165 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 Group |
# crstype can be Course or Community |
# |
# |
# 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 176 use strict;
|
Line 182 use strict;
|
# /home/httpd/perl/tmp/addcourse/$dom/auto/pending if $context = auto |
# /home/httpd/perl/tmp/addcourse/$dom/auto/pending if $context = auto |
# /home/httpd/perl/tmp/addcourse/$dom/web/$uname_$udom/pending 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 |
# inputs (six) - requests - ref to array of filename(s) containing course requests |
# courseids - ref to hash to store LON-CAPA course ids of new courses |
# courseids - ref to hash to store LON-CAPA course ids of new courses |
# context - auto if called from command line, web if called from browser |
# context - auto if called from command line, web if called from browser |
# dom - domain for which the course is being created |
# dom - domain for which the course is being created |
# 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 (three) - output - text recording user roles added etc. |
# outputs (four) - 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) |
# keysmsg - text containing link(s) to manage keys page(s) |
|
# codehash - reference to hash containing courseID => unique code |
|
# where unique code is a 6 character code, to distribute |
|
# to students as a shortcut to the course. |
############################################################# |
############################################################# |
|
|
sub create_courses { |
sub create_courses { |
Line 203 sub create_courses {
|
Line 212 sub create_courses {
|
$longroles{'Community'}{$1} = $3; |
$longroles{'Community'}{$1} = $3; |
} |
} |
} |
} |
my ($logmsg,$keysmsg,$newusermsg,$addresult); |
my ($logmsg,$keysmsg,$newusermsg,$addresult,%codehash); |
my %enrollcount = (); |
my %enrollcount = (); |
my $newcoursedir = $$perlvarref{'lonDaemons'}.'/tmp/addcourse/'.$dom.'/'.$context; |
my $newcoursedir = LONCAPA::tempdir().'/addcourse/'.$dom.'/'.$context; |
if ($context eq 'auto') { |
if ($context eq 'auto') { |
$newcoursedir .= '/pending'; |
$newcoursedir .= '/pending'; |
} else { |
} else { |
Line 222 sub create_courses {
|
Line 231 sub create_courses {
|
&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 $courseid = &build_course($dom,$num,$context,$reqdetails,\%longroles,\$logmsg,\$newusermsg,\$addresult,\%enrollcount,\$output,\$keysmsg); |
my $code; |
|
my $courseid = |
|
&build_course($dom,$num,$context,$reqdetails,\%longroles,\$logmsg,\$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) { |
|
$codehash{$courseid} = $code; |
|
} |
} |
} |
} |
} |
} |
} |
} |
} |
} |
} |
return ($output,$logmsg,$keysmsg); |
return ($output,$logmsg,$keysmsg,\%codehash); |
} |
} |
|
|
############################################################# |
############################################################# |
Line 253 sub parse_coursereqs {
|
Line 268 sub parse_coursereqs {
|
my $xlist = 0; |
my $xlist = 0; |
my $userkey = ''; |
my $userkey = ''; |
my $role = ''; |
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','setcomment','setkeys','keyauth','disresdis','disablechat','openall','notify_owner','notify_dc','crstype','crsquota','uniquecode'); |
my @dateitems = ('enrollstart','enrollend','accessstart','accessend'); |
my @possroles = qw(st ad ep ta in cc co); |
|
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'); |
my $p = HTML::Parser->new |
my $p = HTML::Parser->new |
( |
( |
Line 273 sub parse_coursereqs {
|
Line 289 sub parse_coursereqs {
|
} |
} |
if ("@state" eq "class users user roles role") { |
if ("@state" eq "class users user roles role") { |
$role = $attr->{id}; |
$role = $attr->{id}; |
if ($role =~ /^(st|ad|ep|ta|in|cc)$/) { |
if (grep(/^\Q$role\E$/,@possroles)) { |
push(@{$$details{$num}{'users'}{$userkey}{'roles'}}, $role); |
push(@{$$details{$num}{'users'}{$userkey}{'roles'}}, $role); |
%{$$details{$num}{'users'}{$userkey}{$role}} = (); |
%{$$details{$num}{'users'}{$userkey}{$role}} = (); |
@{$$details{$num}{'users'}{$userkey}{$role}{'usec'}} = (); |
@{$$details{$num}{'users'}{$userkey}{$role}{'usec'}} = (); |
Line 319 sub parse_coursereqs {
|
Line 335 sub parse_coursereqs {
|
@{$$details{$num}{'users'}{$userkey}{'roles'}} = (); |
@{$$details{$num}{'users'}{$userkey}{'roles'}} = (); |
} elsif ("@state" eq "class users user email") { |
} elsif ("@state" eq "class users user email") { |
$$details{$num}{'users'}{$userkey}{'emailaddr'} = $text; |
$$details{$num}{'users'}{$userkey}{'emailaddr'} = $text; |
$$details{$num}{'users'}{$userkey}{'emailenc'} = &Apache::lonnet::escape($text); |
$$details{$num}{'users'}{$userkey}{'emailenc'} = &LONCAPA::escape($text); |
} elsif ("@state" eq "class users user roles role start") { |
} elsif ("@state" eq "class users user roles role start") { |
if ($role =~ /^(st|ad|ep|ta|in|cc)$/) { |
if (grep(/^\Q$role\E$/,@possroles)) { |
$$details{$num}{'users'}{$userkey}{$role}{'start'} = &process_date($text); |
$$details{$num}{'users'}{$userkey}{$role}{'start'} = &process_date($text); |
} |
} |
} elsif ("@state" eq "class users user roles role end") { |
} elsif ("@state" eq "class users user roles role end") { |
if ($role =~ /^(st|ad|ep|ta|in|cc)$/) { |
if (grep(/^\Q$role\E$/,@possroles)) { |
$$details{$num}{'users'}{$userkey}{$role}{'end'} = &process_date($text); |
$$details{$num}{'users'}{$userkey}{$role}{'end'} = &process_date($text); |
} |
} |
} elsif ("@state" eq "class users user roles role usec") { |
} elsif ("@state" eq "class users user roles role usec") { |
if ($role =~ /^(st|ad|ep|ta|in|cc)$/) { |
if (grep(/^\Q$role\E$/,@possroles)) { |
unless ($text eq '') { |
unless ($text eq '') { |
push(@{$$details{$num}{'users'}{$userkey}{$role}{'usec'}},$text); |
push(@{$$details{$num}{'users'}{$userkey}{$role}{'usec'}},$text); |
} |
} |
Line 382 sub parse_coursereqs {
|
Line 398 sub parse_coursereqs {
|
# 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 |
# ref to scalar used to accumulate information about added roles |
# ref to scalar used to accumulate information about added roles |
# ref to scalar used to accumulate |
|
# ref to scalar used to accumulate information about access keys |
# ref to scalar used to accumulate information about access keys |
# domain of DC creating course |
# domain of DC creating course |
# username of DC creating course |
# username of DC creating course |
# optional course number, if unique course number already obtained (e.g., for |
# optional course number, if unique course number already obtained (e.g., for |
# course requests submitted via course request form. |
# course requests submitted via course request form. |
|
# optional category |
|
# optional ref to scalar for six character unique identifier |
# |
# |
# outputs |
# outputs |
# LON-CAPA courseID for new (created) course |
# LON-CAPA courseID for new (created) course |
Line 395 sub parse_coursereqs {
|
Line 412 sub parse_coursereqs {
|
######################################################### |
######################################################### |
|
|
sub build_course { |
sub build_course { |
my ($cdom,$num,$context,$details,$longroles,$logmsg,$newusermsg,$addresult,$enrollcount,$output,$keysmsg,$udom,$uname,$cnum,$category) = @_; |
my ($cdom,$num,$context,$details,$longroles,$logmsg,$newusermsg,$addresult, |
|
$enrollcount,$output,$keysmsg,$udom,$uname,$cnum,$category,$coderef) = @_; |
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 451 sub build_course {
|
} |
} |
my $firstres = $details->{'firstres'}; |
my $firstres = $details->{'firstres'}; |
if ($firstres eq '') { |
if ($firstres eq '') { |
$firstres = 'syl'; |
if ($crstype eq 'Community') { |
|
$firstres = 'nav'; |
|
} else { |
|
$firstres = 'syl'; |
|
} |
} |
} |
foreach my $secid (sort(keys(%{$details->{'sections'}}))) { |
foreach my $secid (sort(keys(%{$details->{'sections'}}))) { |
$sectionstr .= $details->{'sections'}{$secid}{'inst'}.':'.$details->{'sections'}{$secid}{'loncapa'}.','; |
$sectionstr .= $details->{'sections'}{$secid}{'inst'}.':'.$details->{'sections'}{$secid}{'loncapa'}.','; |
Line 489 sub build_course {
|
Line 511 sub build_course {
|
course_home => $details->{'coursehome'}, |
course_home => $details->{'coursehome'}, |
nonstandard => $details->{'nonstandard'}, |
nonstandard => $details->{'nonstandard'}, |
crscode => $details->{'coursecode'}, |
crscode => $details->{'coursecode'}, |
|
defaultcredits => $details->{'defaultcredits'}, |
crsquota => $details->{'crsquota'}, |
crsquota => $details->{'crsquota'}, |
|
uniquecode => $details->{'uniquecode'}, |
clonecourse => $details->{'clonecrs'}, |
clonecourse => $details->{'clonecrs'}, |
clonedomain => $details->{'clonedom'}, |
clonedomain => $details->{'clonedom'}, |
datemode => $details->{'datemode'}, |
datemode => $details->{'datemode'}, |
Line 512 sub build_course {
|
Line 536 sub build_course {
|
endaccess => $details->{'accessend'}, |
endaccess => $details->{'accessend'}, |
setpolicy => $details->{'setpolicy'}, |
setpolicy => $details->{'setpolicy'}, |
setcontent => $details->{'setcontent'}, |
setcontent => $details->{'setcontent'}, |
|
setcomment => $details->{'setcomment'}, |
reshome => $reshome, |
reshome => $reshome, |
setkeys => $details->{'setkeys'}, |
setkeys => $details->{'setkeys'}, |
keyauth => $details->{'keyauth'}, |
keyauth => $details->{'keyauth'}, |
disresdis => $details->{'disresdis'}, |
disresdis => $details->{'disresdis'}, |
disablechat => $details->{'disablechat'}, |
disablechat => $details->{'disablechat'}, |
openall => $details->{'openall'}, |
openall => $details->{'openall'}, |
|
openallfrom => $details->{'openallfrom'}, |
firstres => $firstres |
firstres => $firstres |
}; |
}; |
|
if ($details->{'textbook'}) { |
|
$courseargs->{'textbook'} = $details->{'textbook'}; |
|
} |
my %host_servers = &Apache::lonnet::get_servers($cdom,'library'); |
my %host_servers = &Apache::lonnet::get_servers($cdom,'library'); |
if (! exists($host_servers{$details->{'coursehome'}})) { |
if (! exists($host_servers{$details->{'coursehome'}})) { |
$$logmsg .= &mt('Invalid home server for course').': '.$details->{'coursehome'}; |
$$logmsg .= &mt('Invalid home server for course').': '.$details->{'coursehome'}; |
return; |
return; |
} |
} |
my ($success, $msg) = &Apache::loncommon::construct_course($courseargs,$logmsg,\$courseid,\$crsudom,\$crsunum,$udom,$uname,$context,$cnum,$category); |
my ($success, $msg) = |
|
&Apache::loncommon::construct_course($courseargs,$logmsg,\$courseid,\$crsudom,\$crsunum, |
|
$udom,$uname,$context,$cnum,$category,$coderef); |
$$logmsg .= $msg; |
$$logmsg .= $msg; |
if (!$success) { |
if (!$success) { |
return; |
return; |
Line 606 sub build_course {
|
Line 637 sub build_course {
|
'cdom' => $crsudom, |
'cdom' => $crsudom, |
'context' => 'createcourse', |
'context' => 'createcourse', |
'linefeed' => $linefeed, |
'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); |
$outcome = &LONCAPA::Enrollment::create_newuser($userargs,$logmsg,$newusermsg,$enrollcount,$addresult,$longroles,\%courseinfo,$context); |
# now add other roles and other sections. |
# now add other roles and other sections. |
if ($outcome eq 'ok') { |
if ($outcome eq 'ok') { |
Line 638 sub build_course {
|
Line 675 sub build_course {
|
if ($usec ne '') { |
if ($usec ne '') { |
$url .= '/'.$usec; |
$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) { |
} elsif ($curr_role eq $ccrole) { |
$url = '/'.$crsudom.'/'.$crsunum; |
$url = '/'.$crsudom.'/'.$crsunum; |
my $usec = ''; |
my $usec = ''; |
Line 679 sub build_course {
|
Line 721 sub build_course {
|
if ($usec ne '') { |
if ($usec ne '') { |
$url .= '/'.$usec; |
$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)) || |
} elsif ((grep(/^\Q$curr_role\E$/,@courseroles)) || |
($curr_role =~ m{^cr/$match_domain/$match_username/[^/]+$})) { |
($curr_role =~ m{^cr/$match_domain/$match_username/[^/]+$})) { |
if (@{$details->{'users'}{$userkey}{$curr_role}{'usec'}} > 0) { |
if (@{$details->{'users'}{$userkey}{$curr_role}{'usec'}} > 0) { |