[LON-CAPA-cvs] cvs: loncom /interface loncoursequeueadmin.pm

raeburn raeburn@source.lon-capa.org
Sun, 16 Aug 2009 23:04:42 -0000


raeburn		Sun Aug 16 23:04:42 2009 EDT

  Modified files:              
    /loncom/interface	loncoursequeueadmin.pm 
  Log:
  - Status change when course request is rejected by DC stored in a separate key => value record in courserequests.db file belonging to requestor. 
    - key is status:$cdom:$cnum
  - Minor changes to formatting of LON-CAPA messages sent following DC review of request. 
  
  
Index: loncom/interface/loncoursequeueadmin.pm
diff -u loncom/interface/loncoursequeueadmin.pm:1.2 loncom/interface/loncoursequeueadmin.pm:1.3
--- loncom/interface/loncoursequeueadmin.pm:1.2	Sun Aug 16 19:16:16 2009
+++ loncom/interface/loncoursequeueadmin.pm	Sun Aug 16 23:04:42 2009
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Utilities to administer domain course requests and course self-enroll requests 
 #
-# $Id: loncoursequeueadmin.pm,v 1.2 2009/08/16 19:16:16 raeburn Exp $
+# $Id: loncoursequeueadmin.pm,v 1.3 2009/08/16 23:04:42 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -77,13 +77,13 @@
         $rawsubj = 'Self-enrollment requests processed';
         push(@rawmsg,{
                       mt => 'Enrollment requests in the following course: [_1]have been processed.',
-                      args => ["\n  $contextdesc\n"],
+                      args => ["\n  $contextdesc"],
                      });
     } elsif ($context eq 'domainmanagers') {
         $rawsubj = 'Course requests reviewed';
         push(@rawmsg,{
                       mt  => 'Course creation requests in the following domain: [_1]have been reviewed.',
-                      args => ["\n  $contextdesc\n"],
+                      args => ["\n  $contextdesc"],
                      });
         if (ref($textstr) eq 'ARRAY') {
             push(@rawmsg,@{$textstr});
@@ -345,7 +345,7 @@
         $domdesc,$now,$sender,$approvedmsg,$rejectedmsg,$beneficiary,
         @existing,@missingreq,@invalidusers,@limitexceeded,@completed,
         @processing_errors,@warn_approves,@warn_rejects,@approvals,
-        @rejections,%courseroles,%communityroles,%domdefs);
+        @rejections,@rejectionerrors,%courseroles,%communityroles,%domdefs);
     @approvals = &Apache::loncommon::get_env_multiple('form.approvereq');
     @rejections = &Apache::loncommon::get_env_multiple('form.rejectreq');
     $now = time;
@@ -546,8 +546,9 @@
         @changes = map {$_.'_approval'} (@changes);
     }
     if (@rejections) {
-        foreach my $user (@rejections) {
+        foreach my $item (@rejections) {
             if ($context eq 'course') {
+                my $user = $item;
                 &send_selfserve_notification($user,$rejectedmsg,$cid,$coursedesc,
                                              $now,$beneficiary,$sender);
                 my ($uname,$udom) = split(/:/,$user);
@@ -564,8 +565,10 @@
                     push(@warn_rejects,$user);
                 }
             } else {
-                if (ref($requesthash{$user.'_approval'}) eq 'HASH') {
-                    if (&Apache::lonnet::homeserver($user,$cdom) eq 'no_host') {
+                my $cnum = $item;
+                if (ref($requesthash{$cnum.'_approval'}) eq 'HASH') {
+                    if (&Apache::lonnet::homeserver($cnum,$cdom) eq 'no_host') {
+                        my $requestkey = $cdom.'_'.$cnum;
                         my $ownername = $requesthash{$cnum.'_approval'}{'ownername'};
                         my $ownerdom = $requesthash{$cnum.'_approval'}{'ownerdom'};
                         my $coursedesc = $requesthash{$cnum.'_approval'}{'description'};
@@ -573,7 +576,7 @@
                                                      $cid,$coursedesc,$now,$beneficiary,
                                                      $sender);
                         my %history =
-                            &Apache::lonnet::restore($cdom.'_'.$cnum,'courserequests',
+                            &Apache::lonnet::restore($requestkey,'courserequests',
                                                      $ownerdom,$ownername);
                         if ((ref($history{'details'}) eq 'HASH') &&
                             ($history{'disposition'} eq 'approval')) {
@@ -586,12 +589,29 @@
                                             adjudicator => $env{'user.name'}.':'.$env{'user.domain'},
                                               );
                             my $userresult =
-                                 &Apache::lonnet::store_userdata($namespace,\%reqhash,$ownerdom,$ownername);
-                            if ($userresult ne 'ok') {
-                                push(@warn_rejects,$user);
+                                &Apache::lonnet::store_userdata(\%reqhash,$requestkey,
+                                                'courserequests',$ownerdom,$ownername);
+                            if ($userresult eq 'ok') {
+                                my %status = (
+                                               'status:'.$cdom.':'.$cnum => 'rejected'
+                                             );
+                                my $statusresult =
+                                    &Apache::lonnet::put('courserequests',\%status,
+                                                         $ownerdom,$ownername);
+                                if ($statusresult ne 'ok') {
+                                    push(@warn_rejects,$cnum);
+                                }
+                            } else {
+                                push(@warn_rejects,$cnum);
                             }
+                        } else {
+                            push(@warn_rejects,$cnum);
                         }
+                    } else {
+                        push(@existing,$cnum);
                     }
+                } else {
+                    push(@rejectionerrors,$cnum);
                 }
             }
         }
@@ -750,6 +770,19 @@
             $output .= '</ul></p>';
         }
     }
+    if (@rejectionerrors) {
+        $output .= '<p>'.&mt('The following course creation request rejections could not be fully processed because an error occurred:').'<ul>';
+        foreach my $cnum (@rejectionerrors) {
+            my $showcourse;
+            if (ref($requesthash{$cnum.'_approval'})) {
+                $showcourse = $requesthash{$cnum.'_approval'}{'description'};
+            } else {
+                $showcourse = $cnum;
+            }
+            $output .= '<li>'.$showcourse.'</li>';
+        }
+        $output .= '</ul></p>';
+    }
     if (@warn_approves || @warn_rejects) {
         if ($context eq 'course') {
             $output .= '<p>'.&mt("For the following users, an error occurred when updating the user's own self-enroll requests record:").'<ul>';