[LON-CAPA-cvs] cvs: loncom /enrollment localenroll.pm /interface loncoursequeueadmin.pm lonrequestcourse.pm
raeburn
raeburn at source.lon-capa.org
Tue May 6 16:42:32 EDT 2014
raeburn Tue May 6 20:42:32 2014 EDT
Modified files:
/loncom/interface lonrequestcourse.pm loncoursequeueadmin.pm
/loncom/enrollment localenroll.pm
Log:
- Post-processing for course requests.
- localenroll::crsreq_updates() can populate hash ref:
$outgoing->{'createdactions'}->{'environment'} with a course's
self-enrollment settings when processing course request.
Index: loncom/interface/lonrequestcourse.pm
diff -u loncom/interface/lonrequestcourse.pm:1.79 loncom/interface/lonrequestcourse.pm:1.80
--- loncom/interface/lonrequestcourse.pm:1.79 Tue May 6 18:09:40 2014
+++ loncom/interface/lonrequestcourse.pm Tue May 6 20:42:27 2014
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Request a course
#
-# $Id: lonrequestcourse.pm,v 1.79 2014/05/06 18:09:40 raeburn Exp $
+# $Id: lonrequestcourse.pm,v 1.80 2014/05/06 20:42:27 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -3741,15 +3741,9 @@
}
if (ref($postprocess) eq 'HASH') {
if (ref($postprocess->{'createdactions'}) eq 'HASH') {
- if (ref($postprocess->{'createdactions'}{'environment'} eq 'HASH') {
- my %newcrsenv;
- foreach my $key (%{$postprocess->{'createdactions'}{'environment'}}) {
- $newcrsenv{$key} = $postprocess->{'createdactions'}{'environment'}{$key};
- }
- if (keys(%newcrsenv)) {
- my $putresult = &Apache::lonnet::put('environment',\%newcrsenv,$dom,$cnum);
-
- }
+ if (ref($postprocess->{'createdactions'}{'environment'}) eq 'HASH') {
+ &Apache::loncoursequeueadmin::postprocess_crsenv($dom,$cnum,
+ $postprocess->{'createdactions'}{'environment'});
}
}
}
Index: loncom/interface/loncoursequeueadmin.pm
diff -u loncom/interface/loncoursequeueadmin.pm:1.47 loncom/interface/loncoursequeueadmin.pm:1.48
--- loncom/interface/loncoursequeueadmin.pm:1.47 Wed Apr 30 17:17:35 2014
+++ loncom/interface/loncoursequeueadmin.pm Tue May 6 20:42:27 2014
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Utilities to administer domain course requests and course self-enroll requests
#
-# $Id: loncoursequeueadmin.pm,v 1.47 2014/04/30 17:17:35 raeburn Exp $
+# $Id: loncoursequeueadmin.pm,v 1.48 2014/05/06 20:42:27 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -2062,6 +2062,11 @@
}
}
}
+ if (ref($postprocess->{'createdactions'}) eq 'HASH') {
+ if (ref($postprocess->{'createdactions'}{'environment'}) eq 'HASH') {
+ &postprocess_crsenv($dom,$cnum,$postprocess->{'createdactions'}{'environment'});
+ }
+ }
}
&send_selfserve_notification($owner,$approvedmsg,
$cid,$cdescr,$now,
@@ -2133,6 +2138,56 @@
return $output;
}
+sub postprocess_crsenv {
+ my ($dom,$cnum,$postprocessenv) = @_;
+ if (ref($postprocessenv) eq 'HASH') {
+ my $cid = $dom.'_'.$cnum;
+ my %settablecrsenv = (
+ 'internal.selfenroll_types' => 1,
+ 'internal.selfenroll_registered' => 1,
+ 'internal.selfenroll_section' => 1,
+ 'internal.selfenroll_start_access' => 1,
+ 'internal.selfenroll_end_access' => 1,
+ 'internal.selfenroll_limit' => 1,
+ 'internal.selfenroll_cap' => 1,
+ 'internal.selfenroll_approval' => 1,
+ 'internal.selfenroll_notifylist' => 1,
+ );
+ my %needcrsidput = (
+ 'internal.selfenroll_types' => 1,
+ 'internal.selfenroll_start_date' => 1,
+ 'internal. selfenroll_end_date' => 1,
+ );
+ my (@needupdate,%newcrsenv);
+ foreach my $key (keys(%{$postprocessenv})) {
+ if ($settablecrsenv{$key}) {
+ $newcrsenv{$key} = $postprocessenv->{$key};
+ if ($needcrsidput{$key}) {
+ push(@needupdate,$key);
+ }
+ }
+ if (keys(%newcrsenv)) {
+ my $putresult = &Apache::lonnet::put('environment',\%newcrsenv,$dom,$cnum);
+ if ($putresult eq 'ok') {
+ if (@needupdate) {
+ my %crsinfo =
+ &Apache::lonnet::courseiddump($dom,'.',1,'.','.',$cnum,undef,undef,'.');
+ if (ref($crsinfo{$cid}) eq 'HASH') {
+ foreach my $key (@needupdate) {
+ $crsinfo{$cid}{$key} = $newcrsenv{$key};
+ }
+ my $chome = &Apache::lonnet::homeserver($cnum,$dom);
+ &Apache::lonnet::courseidput($dom,\%crsinfo,$chome,'notime');
+ }
+ }
+ }
+ }
+ }
+ }
+ return;
+}
+
+
sub requestcourses_validation_types {
my @items = ('url','fields','button','markup');
my %names = &Apache::lonlocal::texthash (
Index: loncom/enrollment/localenroll.pm
diff -u loncom/enrollment/localenroll.pm:1.47 loncom/enrollment/localenroll.pm:1.48
--- loncom/enrollment/localenroll.pm:1.47 Wed Apr 30 17:17:25 2014
+++ loncom/enrollment/localenroll.pm Tue May 6 20:42:32 2014
@@ -1,6 +1,6 @@
# functions to glue school database system into Lon-CAPA for
# automated enrollment
-# $Id: localenroll.pm,v 1.47 2014/04/30 17:17:25 raeburn Exp $
+# $Id: localenroll.pm,v 1.48 2014/05/06 20:42:32 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -469,6 +469,20 @@
mt => '',
args => [],
}];
+ $outgoing->{'createdactions'} = {
+ environment => {},
+ };
+ # environment can contain key=>value for
+ # items to set in the course environment.
+ # These would be items which are NOT included
+ # in the items set via options in the course
+ # request form. Currently self-enrollment
+ # settings are the only ones allowed, i.e.,
+ # internal.selfenroll_types internal.selfenroll_registered
+ # internal.selfenroll_section internal.selfenroll_start_access
+ # internal.selfenroll_end_access internal.selfenroll_limit
+ # internal.selfenroll_cap internal.selfenroll_approval
+ # internal.selfenroll_notifylist
} elsif ($action eq 'queued') {
$outgoing->{'queuedmsg'} = [{
mt => '',
More information about the LON-CAPA-cvs
mailing list