[LON-CAPA-cvs] cvs: modules /msu localenroll.pm

raeburn lon-capa-cvs@mail.lon-capa.org
Sat, 03 Jul 2004 18:29:22 -0000


raeburn		Sat Jul  3 14:29:22 2004 EDT

  Modified files:              
    /modules/msu	localenroll.pm 
  Log:
  Retrieval of format of institutional codes, split by attribute (semester, department etc.). Used by lonsupportreq.pm to build code selection option in help support form. 
  
  
Index: modules/msu/localenroll.pm
diff -u modules/msu/localenroll.pm:1.8 modules/msu/localenroll.pm:1.9
--- modules/msu/localenroll.pm:1.8	Tue Apr 20 15:59:02 2004
+++ modules/msu/localenroll.pm	Sat Jul  3 14:29:21 2004
@@ -1,10 +1,39 @@
+# functions to glue school database system into Lon-CAPA for
+# automated enrollment
+# $Id: localenroll.pm,v 1.9 2004/07/03 18:29:21 raeburn Exp $
+#
+# Copyright Michigan State University Board of Trustees
+#
+# This file is part of the LearningOnline Network with CAPA (LON-CAPA).
+#
+# LON-CAPA is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# LON-CAPA is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with LON-CAPA; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+#
+# /home/httpd/html/adm/gpl.txt
+#
+# http://www.lon-capa.org/
+#
 package localenroll;
 
 use strict;
 use DBI;
 use LONCAPA::Configuration;
 
-sub run { return 1; }
+sub run () {
+    my $dom = shift;
+    return 1;
+}
 
 sub fetch_enrollment {
   my ($dom,$affiliatesref,$replyref) = @_;
@@ -128,7 +157,7 @@
 }
 
 sub get_sections {
-    my $coursecode = shift;
+    my ($coursecode,$dom) = @_;
     my @secs = ();
     if ($coursecode =~ m/^([suf]s\d{2})(\w{2,3})(\d{3,4}\w?)/) {
         my $term = $1;
@@ -161,7 +190,7 @@
 }
 
 sub new_course  {
-    my ($course_id,$owner) = @_;
+    my ($course_id,$owner,$dom) = @_;
     my $outcome = '';
     if ($owner eq '') {
         $outcome = "Inclusion of enrollment could not be established for the course section $course_id because no owner was provided for this LON-CAPA course.";
@@ -202,7 +231,7 @@
 }
 
 sub validate_courseID {
-    my $course_id = shift;
+    my ($course_id,$dom) = @_;
     my $outcome = '';
     if ($course_id =~ m/^([suf]s\d{2})(\w{2,3})(\d{3,4}\w?)(\d{3})/) {
         my $term = $1;
@@ -242,10 +271,34 @@
 }
 
 sub create_password {
-    my $authparam = shift;
+    my ($authparam,$dom) = @_;
     my $authchk = 'ok';
     my $create_passwd = 0;
     return ($authparam,$create_passwd,$authchk);
 }
 
+sub instcode_format {
+    my ($dom,$instcodes,$codes,$codetitles,$cat_titles,$cat_order) = @_;
+    my $outcome;
+    @{$codetitles} = ("Year","Semester","Department","Number");
+    %{$$cat_titles{'Semester'}} = (
+                   fs => 'Fall',
+                   ss => 'Spring',
+                   us => 'Summer'
+                    );
+    @{$$cat_order{'Semester'}} = ('ss','us','fs');
+    foreach my $cid (keys %{$instcodes) {
+        if ($$instcodes{$cid} =~ m/^([suf]s)(\d{2})\w{2,3}\d{3,4}\w?\d{3}$/) {
+            my $year = $2;
+            $year =~ s/^0//;
+            $$codes{$cid}{'Year'} = 2000 + $year;
+            $$codes{$cid}{'Semester'} = $1;
+            $$codes{$cid}{'Department'} = $3;
+            $$codes{$cid}{'Number'} = $4;
+        }
+    }
+    my $outcome = 'ok';
+    return $outcome;
+}
+
 1;