[LON-CAPA-cvs] cvs: loncom /interface loncoursequeueadmin.pm lonrequestcourse.pm
raeburn
raeburn@source.lon-capa.org
Sun, 21 Feb 2010 23:38:51 -0000
This is a MIME encoded message
--raeburn1266795531
Content-Type: text/plain
raeburn Sun Feb 21 23:38:51 2010 EDT
Modified files:
/loncom/interface lonrequestcourse.pm loncoursequeueadmin.pm
Log:
- Code to update user's courserequests.db moved to &update_coursereq_status() in loncoursequeueadmin.pm
to be more widely available.
--raeburn1266795531
Content-Type: text/plain
Content-Disposition: attachment; filename="raeburn-20100221233851.txt"
Index: loncom/interface/lonrequestcourse.pm
diff -u loncom/interface/lonrequestcourse.pm:1.43 loncom/interface/lonrequestcourse.pm:1.44
--- loncom/interface/lonrequestcourse.pm:1.43 Thu Jan 14 20:08:13 2010
+++ loncom/interface/lonrequestcourse.pm Sun Feb 21 23:38:51 2010
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Request a course
#
-# $Id: lonrequestcourse.pm,v 1.43 2010/01/14 20:08:13 raeburn Exp $
+# $Id: lonrequestcourse.pm,v 1.44 2010/02/21 23:38:51 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -176,7 +176,6 @@
&get_breadcrumbs($dom,$action,\$state,\%states,\%trail);
if ($action eq 'display') {
if (($dom eq $env{'request.role.domain'}) && (&Apache::lonnet::allowed('ccc',$dom))) {
- my $namespace = 'courserequestqueue';
if ($env{'form.cnum'} ne '') {
my $cnum = $env{'form.cnum'};
my $reqkey = $cnum.'_approval';
@@ -2934,26 +2933,9 @@
}
}
}
- my ($statusresult);
- if ($requestkey =~ /^($match_domain)_($match_courseid)$/) {
- $storeresult = &Apache::lonnet::store_userdata(\%reqhash,$requestkey,
- 'courserequests');
- if ($storeresult eq 'ok') {
- my %status = (
- 'status:'.$dom.':'.$cnum => $reqstatus,
- );
- $statusresult = &Apache::lonnet::put('courserequests',\%status);
- }
- } else {
- $storeresult = 'error: invalid requestkey format';
- }
- if ($storeresult ne 'ok') {
- $output .= '<span class="LC_warning">'.&mt('An error occurred saving a record of the details of your request: [_1].',$storeresult).'</span><br />';
- &Apache::lonnet::logthis("Error saving course request - $requestkey for $env{'user.name'}:$env{'user.domain'} - $storeresult");
- } elsif ($statusresult ne 'ok') {
- $output .= '<span class="LC_warning">'.&mt('An error occurred saving a record of the status of your request: [_1].',$statusresult).'</span><br />';
- &Apache::lonnet::logthis("Error saving course request status for $requestkey (for $env{'user.name'}:$env{'user.domain'}) - $statusresult");
- }
+ ($storeresult,my $updateresult) =
+ &Apache::loncoursequeueadmin::update_coursereq_status(\%reqhash,$dom,
+ $cnum,$reqstatus,'request');
if ($modified && $queued && $storeresult eq 'ok') {
if ($crstype eq 'community') {
$output .= '<p>'.&mt('Your community request has been updated').'</p>';
@@ -2963,7 +2945,10 @@
$output .= ¬ification_information($disposition,$req_notifylist,$cnum,$now);
}
if ($validationerror ne '') {
- $output .= '<span class="LC_warning">'.&mt('An error occurred validating your request with institutional data sources: [_1].',$validationerror).'</p>';
+ $output .= '<p class="LC_warning">'.&mt('An error occurred validating your request with institutional data sources: [_1].',$validationerror).'</p>';
+ }
+ if ($updateresult) {
+ $output .= $updateresult;
}
}
if ($creationresult ne '') {
@@ -3139,8 +3124,8 @@
'</div>';
} else {
$output .= '<div class="LC_warning">'.
- &mt('Your request status is: [_1].',$disposition).
- '</div>'
+ &mt('Your request status is: [_1].',$disposition).
+ '</div>';
}
return $output;
}
Index: loncom/interface/loncoursequeueadmin.pm
diff -u loncom/interface/loncoursequeueadmin.pm:1.18 loncom/interface/loncoursequeueadmin.pm:1.19
--- loncom/interface/loncoursequeueadmin.pm:1.18 Sun Feb 21 02:38:23 2010
+++ loncom/interface/loncoursequeueadmin.pm Sun Feb 21 23:38:51 2010
@@ -1,7 +1,7 @@
# The LearningOnline Network
-# Utilities to administer domain course requests and course self-enroll requests
+# Utilities to administer domain course requests and course self-enroll requests
#
-# $Id: loncoursequeueadmin.pm,v 1.18 2010/02/21 02:38:23 raeburn Exp $
+# $Id: loncoursequeueadmin.pm,v 1.19 2010/02/21 23:38:51 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -74,7 +74,7 @@
use Apache::lonmsg;
use Apache::lonlocal;
use Apache::lonuserutils;
-use LONCAPA;
+use LONCAPA qw(:DEFAULT :match);
sub send_selfserve_notification {
my ($notifylist,$textstr,$cid,$contextdesc,$timestamp,$context,$sender,
@@ -375,7 +375,7 @@
$stucounts,$idx,$classlist,%requesthash,$cid,$hostname,$protocol,
$domdesc,$now,$sender,$approvedmsg,$rejectedmsg,$beneficiary,
@existing,@missingreq,@invalidusers,@limitexceeded,@completed,
- @processing_errors,@warn_approves,@warn_rejects,@approvals,
+ @processing_errors,@warn_approves,@warn_rejects,@approvals,@warn_dels,
@rejections,@rejectionerrors,@nopermissions,%courseroles,
%communityroles,%domdefs,%approvalmsg,%rejectionmsg,$crstype);
@approvals = &Apache::loncommon::get_env_multiple('form.approvereq');
@@ -466,7 +466,6 @@
my $uhome = &Apache::lonnet::homeserver($uname,$udom);
if ($uhome ne 'no_host') {
if (exists($requesthash{$uname.':'.$udom})) {
-
if (exists($classlist->{$uname.':'.$udom})) {
if (ref($classlist->{$uname.':'.$udom}) eq 'ARRAY') {
if (($classlist->{$uname.':'.$udom}->[$idx->{'status'}] eq 'Active') ||
@@ -565,6 +564,10 @@
$approvedmsg = $approvalmsg{'course'};
}
push(@completed,$cnum);
+
+ unless (&Apache::lonnet::del_dom($namespace,[$cnum.'_approval'],$cdom) eq 'ok') {
+ push(@warn_dels,$cnum);
+ }
&send_selfserve_notification($ownername.':'.$ownerdom,$approvedmsg,
$cid,$coursedesc,$now,$beneficiary,$sender,undef,undef,$crstype);
my %reqhash = (
@@ -679,6 +682,9 @@
} else {
push(@warn_rejects,$cnum);
}
+ unless (&Apache::lonnet::del_dom($namespace,[$cnum.'_approval'],$cdom) eq 'ok') {
+ push(@warn_dels,$cnum);
+ }
} else {
push(@warn_rejects,$cnum);
}
@@ -896,6 +902,19 @@
$output .= '</ul></p>';
}
}
+ if (@warn_dels) {
+ $output .= '<p>'.&mt("For the following course/community requests an error occurred when removing requests for the following from the pending queue:").'<ul>';
+ foreach my $cnum (@warn_dels) {
+ my $showcourse;
+ if (ref($requesthash{$cnum.'_approval'})) {
+ $showcourse = $requesthash{$cnum.'_approval'}{'description'};
+ } else {
+ $showcourse = $cnum;
+ }
+ $output .= '<li>'.$showcourse.'</li>';
+ }
+ $output .= '</ul></p>';
+ }
return $output;
}
@@ -1185,4 +1204,40 @@
return $output;
}
+sub update_coursereq_status {
+ my ($reqhash,$dom,$cnum,$reqstatus,$context) = @_;
+ my ($storeresult,$statusresult,$output);
+ my $requestkey = $dom.'_'.$cnum;
+ if ($requestkey =~ /^($match_domain)_($match_courseid)$/) {
+ $storeresult = &Apache::lonnet::store_userdata($reqhash,$requestkey,
+ 'courserequests');
+ if ($storeresult eq 'ok') {
+ my %status = (
+ 'status:'.$dom.':'.$cnum => $reqstatus,
+ );
+ $statusresult = &Apache::lonnet::put('courserequests',\%status);
+ }
+ } else {
+ $storeresult = 'error: invalid requestkey format';
+ }
+ if ($storeresult ne 'ok') {
+ $output = &mt('An error occurred saving a record of the details of your request: [_1].',$storeresult);
+ if ($context eq 'domain') {
+ $output .= "\n";
+ } else {
+ $output = '<span class="LC_warning">'.$output.'</span><br />';
+ }
+ &Apache::lonnet::logthis("Error saving course request - $requestkey for $env{'user.name'}:$env{'user.domain'} - $storeresult");
+ } elsif ($statusresult ne 'ok') {
+ $output = &mt('An error occurred saving a record of the status of your request: [_1].',$statusresult);
+ if ($context eq 'domain') {
+ $output .= "\n";
+ } else {
+ $output = '<span class="LC_warning">'.$output.'</span><br />';
+ }
+ &Apache::lonnet::logthis("Error saving course request status for $requestkey (for $env{'user.name'}:$env{'user.domain'}) - $statusresult");
+ }
+ return ($storeresult,$output);
+}
+
1;
--raeburn1266795531--