[LON-CAPA-cvs] cvs: loncom / lond /enrollment localenroll.pm /lonnet/perl lonnet.pm
raeburn
lon-capa-cvs@mail.lon-capa.org
Mon, 16 Oct 2006 19:18:19 -0000
raeburn Mon Oct 16 15:18:19 2006 EDT
Modified files:
/loncom lond
/loncom/lonnet/perl lonnet.pm
/loncom/enrollment localenroll.pm
Log:
Get regular expression fragments and order of concatenation when creating regular expressions used in course catalog search by institutional code (or parts thereof) - used by coursecatalog.pm
Index: loncom/lond
diff -u loncom/lond:1.344 loncom/lond:1.345
--- loncom/lond:1.344 Fri Oct 13 00:23:02 2006
+++ loncom/lond Mon Oct 16 15:18:11 2006
@@ -2,7 +2,7 @@
# The LearningOnline Network
# lond "LON Daemon" Server (port "LOND" 5663)
#
-# $Id: lond,v 1.344 2006/10/13 04:23:02 raeburn Exp $
+# $Id: lond,v 1.345 2006/10/16 19:18:11 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -59,7 +59,7 @@
my $status='';
my $lastlog='';
-my $VERSION='$Revision: 1.344 $'; #' stupid emacs
+my $VERSION='$Revision: 1.345 $'; #' stupid emacs
my $remoteVERSION;
my $currenthostid="default";
my $currentdomainid;
@@ -4362,6 +4362,38 @@
®ister_handler("autoinstcodeformat",
\&get_institutional_code_format_handler,0,1,0);
+sub get_institutional_defaults_handler {
+ my ($cmd, $tail, $client) = @_;
+ my $userinput = "$cmd:$tail";
+
+ my $dom = $tail;
+ my %defaults_hash;
+ my @code_order;
+ my $outcome;
+ eval {
+ local($SIG{__DIE__})='DEFAULT';
+ $outcome = &localenroll::instcode_defaults($dom,\%defaults_hash,
+ \@code_order);
+ };
+ if (!$@) {
+ if ($outcome eq 'ok') {
+ my $result='';
+ while (my ($key,$value) = each(%defaults_hash)) {
+ $result.=&escape($key).'='.&escape($value).'&';
+ }
+ $result .= 'code_order='.&escape(join('&',@code_order));
+ &Reply($client,$result."\n",$userinput);
+ } else {
+ &Reply($client,"error\n", $userinput);
+ }
+ } else {
+ &Failure($client,"unknown_cmd\n",$userinput);
+ }
+}
+®ister_handler("autoinstcodedefaults",
+ \&get_institutional_defaults_handler,0,1,0);
+
+
# Get domain specific conditions for import of student photographs to a course
#
# Retrieves information from photo_permission subroutine in localenroll.
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.791 loncom/lonnet/perl/lonnet.pm:1.792
--- loncom/lonnet/perl/lonnet.pm:1.791 Fri Oct 13 00:23:15 2006
+++ loncom/lonnet/perl/lonnet.pm Mon Oct 16 15:18:15 2006
@@ -1,7 +1,7 @@
# The LearningOnline Network
# TCP networking package
#
-# $Id: lonnet.pm,v 1.791 2006/10/13 04:23:15 raeburn Exp $
+# $Id: lonnet.pm,v 1.792 2006/10/16 19:18:15 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -4257,6 +4257,40 @@
}
}
+sub auto_instcode_defaults {
+ my ($domain,$returnhash,$code_order) = @_;
+ my @homeservers;
+ foreach my $tryserver (keys %libserv) {
+ if ($hostdom{$tryserver} eq $domain) {
+ if (!grep/^\Q$tryserver\E$/,@homeservers) {
+ push(@homeservers,$tryserver);
+ }
+ }
+ }
+ my $ok_response = 0;
+ my $response;
+ while (@homeservers > 0 && $ok_response == 0) {
+ my $server = shift(@homeservers);
+ $response=&reply('autoinstcodedefaults:'.$domain,$server);
+ if ($response !~ /(con_lost|error|no_such_host|refused)/) {
+ foreach (split(/\&/,$response)) {
+ my ($name,$value)=split(/\=/,$_);
+ if ($name eq 'code_order') {
+ @{$code_order} = split(/\&/,&unescape($value));
+ } else {
+ $$returnhash{&unescape($name)}=&unescape($value);
+ }
+ }
+ }
+ $ok_response = 1;
+ }
+ if ($ok_response) {
+ return 'ok';
+ } else {
+ return $response;
+ }
+}
+
sub auto_validate_class_sec {
my ($cdom,$cnum,$owner,$inst_class) = @_;
my $homeserver = &homeserver($cnum,$cdom);
Index: loncom/enrollment/localenroll.pm
diff -u loncom/enrollment/localenroll.pm:1.16 loncom/enrollment/localenroll.pm:1.17
--- loncom/enrollment/localenroll.pm:1.16 Tue Aug 29 01:58:06 2006
+++ loncom/enrollment/localenroll.pm Mon Oct 16 15:18:19 2006
@@ -1,6 +1,6 @@
# functions to glue school database system into Lon-CAPA for
# automated enrollment
-# $Id: localenroll.pm,v 1.16 2006/08/29 05:58:06 raeburn Exp $
+# $Id: localenroll.pm,v 1.17 2006/10/16 19:18:19 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -438,6 +438,44 @@
}
###############################
+# sub instcode_defaults
+#
+# Incoming data: three arguments
+# (a) $dom - domain
+# (b) $defaults - reference to hash which will contain default regular
+# expression matches for different components of an
+# institutional course code
+# (c) $code_order - reference to array which will contain order of
+# component parts used in institutional code.
+#
+# returns 1 parameter - ('ok' or other value).
+# Used to construct a regular expression to be used when searching for
+# courses based on fragments of an institutional code.
+# $defaults contains defaults to use for each component, and code_order
+# contains keys of hash in order in which they are to be concatenated.
+#
+# e.g., INSTITUTIONALCODE = fs03nop590
+# (MSU's course naming scheme - fs = semester, 03 = year, nop =
+# department name, 590 = course number)
+#
+# %{$defaults} = (
+# 'Year' => '\d{2}',
+# 'Semester' => '^[sfu]s',
+# 'Department' => '\w{2,3}',
+# 'Number' => '\d{3,4}\w?',
+# );
+#
+# @{$code_order} = ('Semester','Year','Department','Number');
+#
+###############################
+
+sub instcode_defaults {
+ my ($dom,$defaults,$code_order) = @_;
+ return 'ok';
+}
+
+
+###############################
# sub AUTOLOAD
#
# Incoming data: none