[LON-CAPA-cvs] cvs: loncom / lond

raeburn raeburn@source.lon-capa.org
Sat, 22 Aug 2009 19:10:01 -0000


raeburn		Sat Aug 22 19:10:01 2009 EDT

  Modified files:              
    /loncom	lond 
  Log:
  - &crsreq_checks_handler() added to interface to localenroll::crsreq_checks() to determine if "validate" should be an option which can be set for course requests on the DC's configuration menu.
  - &validate_crsreq_handler() added to interface to localenroll::validate_crsreq() to determine if course request (with process type 'validate') should be processed immediately, put in a 'pending' queue, rejected, or marked for approval by a DC.  
  
  
Index: loncom/lond
diff -u loncom/lond:1.422 loncom/lond:1.423
--- loncom/lond:1.422	Tue Aug 18 20:08:13 2009
+++ loncom/lond	Sat Aug 22 19:10:01 2009
@@ -2,7 +2,7 @@
 # The LearningOnline Network
 # lond "LON Daemon" Server (port "LOND" 5663)
 #
-# $Id: lond,v 1.422 2009/08/18 20:08:13 raeburn Exp $
+# $Id: lond,v 1.423 2009/08/22 19:10:01 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -59,7 +59,7 @@
 my $status='';
 my $lastlog='';
 
-my $VERSION='$Revision: 1.422 $'; #' stupid emacs
+my $VERSION='$Revision: 1.423 $'; #' stupid emacs
 my $remoteVERSION;
 my $currenthostid="default";
 my $currentdomainid;
@@ -4870,7 +4870,7 @@
 &register_handler("autorun", \&enrollment_enabled_handler, 0, 1, 0);
 
 #
-#   Validate an institutional code use for a LON-CAPA course.          
+#   Validate an institutional code used for a LON-CAPA course.          
 #
 # Formal Parameters:
 #   $cmd          - The command request that got us dispatched.
@@ -4888,13 +4888,10 @@
 sub validate_instcode_handler {
     my ($cmd, $tail, $client) = @_;
     my $userinput = "$cmd:$tail";
-    my ($dom,$instcode,$owner,$inststatus,$instseclist) = split(/:/, $tail);
+    my ($dom,$instcode,$owner) = split(/:/, $tail);
     $instcode = &unescape($instcode);
     $owner = &unescape($owner);
-    $inststatus = &unescape($inststatus);
-    $instseclist = &unescape($instseclist);
-    my $outcome=&localenroll::validate_instcode($dom,$instcode,$owner,
-                                                $inststatus,$instseclist);
+    my $outcome=&localenroll::validate_instcode($dom,$instcode,$owner);
     &Reply($client, \$outcome, $userinput);
 
     return 1;
@@ -5104,6 +5101,59 @@
 }
 &register_handler("autoretrieve", \&retrieve_auto_file_handler, 0,1,0);
 
+sub crsreq_checks_handler {
+    my ($cmd, $tail, $client) = @_;
+    my $userinput = "$cmd:$tail";
+    my $dom = $tail;
+    my $result;
+    eval {
+        local($SIG{__DIE__})='DEFAULT';
+        my %validations;
+        my $response = &localenroll::crsreq_checks($dom,\%validations);
+        if ($response eq 'ok') { 
+            foreach my $key (keys(%validations)) {
+                $result .= &escape($key).'='.&Apache::lonnet::freeze_escape($validations{$key}).'&';
+            }
+            $result =~ s/\&$//;
+        } else {
+            $result = 'error';
+        }
+    };
+    if (!$@) {
+        &Reply($client, \$result, $userinput);
+    } else {
+        &Failure($client,"unknown_cmd\n",$userinput);
+    }
+    return 1;
+}
+&register_handler("autocrsreqchecks", \&crsreq_checks_handler, 0, 1, 0);
+
+sub validate_crsreq_handler {
+    my ($cmd, $tail, $client) = @_;
+    my $userinput = "$cmd:$tail";
+    my ($dom,$owner,$crstype,$inststatuslist,$instcode,$instseclist) = split(/:/, $tail);
+    $instcode = &unescape($instcode);
+    $owner = &unescape($owner);
+    $crstype = &unescape($crstype);
+    $inststatuslist = &unescape($inststatuslist);
+    $instcode = &unescape($instcode);
+    $instseclist = &unescape($instseclist);
+    my $outcome;
+    eval {
+        local($SIG{__DIE__})='DEFAULT';
+        $outcome = &localenroll::validate_crsreq($dom,$owner,$crstype,
+                                                 $inststatuslist,$instcode,
+                                                 $instseclist);
+    };
+    if (!$@) {
+        &Reply($client, \$outcome, $userinput);
+    } else {
+        &Failure($client,"unknown_cmd\n",$userinput);
+    }
+    return 1;
+}
+&register_handler("autocrsreqvalidation", \&validate_crsreq_handler, 0, 1, 0);
+
 #
 #   Read and retrieve institutional code format (for support form).
 # Formal Parameters: