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

raeburn raeburn@source.lon-capa.org
Thu, 11 Jun 2009 20:09:26 -0000


raeburn		Thu Jun 11 20:09:26 2009 EDT

  Modified files:              
    /modules/msu	localenroll.pm 
    /loncom/enrollment	localenroll.pm 
  Log:
  - Request creation of official courses.
      - retrieve possible values for institutional categories.
      - used by lond::get_possible_instcodes_handler().
  
  
Index: modules/msu/localenroll.pm
diff -u modules/msu/localenroll.pm:1.39 modules/msu/localenroll.pm:1.40
--- modules/msu/localenroll.pm:1.39	Tue Aug 26 07:04:35 2008
+++ modules/msu/localenroll.pm	Thu Jun 11 20:09:25 2009
@@ -1,6 +1,6 @@
 # functions to glue school database system into Lon-CAPA for
 # automated enrollment
-# $Id: localenroll.pm,v 1.39 2008/08/26 07:04:35 raeburn Exp $
+# $Id: localenroll.pm,v 1.40 2009/06/11 20:09:25 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -330,6 +330,54 @@
     return $outcome;
 }
 
+sub possible_instcodes {
+    my ($dom,$codetitles,$cat_titles,$cat_order) = @_;
+    @{$codetitles} = ("Year","Semester","Department","Number");
+    %{$$cat_titles{'Semester'}} = (
+                   fs => 'Fall',
+                   ss => 'Spring',
+                   us => 'Summer'
+                    );
+    @{$$cat_order{'Semester'}} = ('ss','us','fs');
+    ($$cat_titles{'Department'},$$cat_order{'Department'}) = &get_all_depts($dom);
+    ($$cat_titles{'Year'},$$cat_order{'Year'}) = &get_possible_years($dom);
+    return 'ok';
+}
+
+sub get_all_depts {
+    my ($dom) = @_;
+    my ($dbh,$dbflag) = &connect_DB('SIS');
+    my (@depts,%deptnames); 
+    if ($dbflag) {
+        eval {
+            my $sth = $dbh->prepare("SELECT DISTINCT(Subj_Code) FROM SISCRSS");
+            $sth->execute();
+            while ( my ($dept) = $sth->fetchrow_array()) {
+                push(@depts,$dept);
+                $deptnames{$dept} = $dept;
+            }
+            $sth->finish;
+        };
+        &disconnect_DB($dbh);
+    }
+    @depts = sort(@depts);
+    return (\%deptnames,\@depts);
+}
+
+sub get_possible_years {
+    my ($dom) = @_;
+    my (%longyears,@years);
+    (undef,undef,undef,undef,undef,my $year) = localtime(time);
+    $year += 1900;
+    for (my $i=-1; $i<3; $i++) {
+        my $yr = $year + $i;
+        my $shortyr = substr($yr,2);
+        $longyears{$shortyr} = $yr;
+        push(@years,$shortyr);
+    }
+    return(\%longyears,\@years);
+}
+
 sub get_owner {
     my ($dom,$crs) = @_;
     my $owner;
Index: loncom/enrollment/localenroll.pm
diff -u loncom/enrollment/localenroll.pm:1.34 loncom/enrollment/localenroll.pm:1.35
--- loncom/enrollment/localenroll.pm:1.34	Mon Mar  9 01:58:52 2009
+++ loncom/enrollment/localenroll.pm	Thu Jun 11 20:09:25 2009
@@ -1,6 +1,6 @@
 # functions to glue school database system into Lon-CAPA for 
 # automated enrollment
-# $Id: localenroll.pm,v 1.34 2009/03/09 01:58:52 weissno Exp $
+# $Id: localenroll.pm,v 1.35 2009/06/11 20:09:25 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -41,8 +41,6 @@
 
 =over
 
-=back
-
 =cut
 
 package localenroll;
@@ -381,6 +379,43 @@
     return $outcome;
 }
 
+=pod
+
+=item possible_instcodes()
+
+Gather acceptable values for institutional categories to use in course creation request form for official courses.
+
+ requires four arguments:
+ domain ($dom)
+ reference to array of titles ($codetitles)
+ reference to hash of abbreviations used in categories ($cat_titles).
+ reference to hash of arrays specifying sort order used in category titles ($cat_order).
+
+ e.g., 
+ @{$codetitles} = ("Year","Semester","Department","Number");
+
+ %{$$cat_titles{'Semester'}} = (
+                   fs => 'Fall',
+                   ss => 'Spring',
+                   us => 'Summer');
+
+ @{$$cat_order{'Semester'}} = ('ss','us','fs');
+
+ returns 1 parameter: 'ok' if no processing errors.
+
+=cut
+
+sub possible_instcodes {
+    my ($dom,$codetitles,$cat_titles,$cat_order) = @_;
+    @{$codetitles} = ();
+    %{$$cat_titles{'Semester'}} = ();
+    @{$$cat_order{'Semester'}} = ('ss','us','fs');
+    ($$cat_titles{'Department'},$$cat_order{'Department'}) = &get_all_depts($dom);
+    ($$cat_titles{'Year'},$$cat_order{'Year'}) = &get_possible_years($dom);
+    return 'ok';
+}
+
+
 
 =pod