[LON-CAPA-cvs] cvs: loncom /interface loncommon.pm /misc refresh_courseids_db.pl

raeburn raeburn@source.lon-capa.org
Fri, 24 Dec 2010 07:58:10 -0000


raeburn		Fri Dec 24 07:58:10 2010 EDT

  Modified files:              
    /loncom/interface	loncommon.pm 
    /loncom/misc	refresh_courseids_db.pl 
  Log:
  - &build_release_hashes() moved from misc/refresh_courseids_db.pl to 
    interface/loncommn.pm to facilitate re-use.
  
  
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.989 loncom/interface/loncommon.pm:1.990
--- loncom/interface/loncommon.pm:1.989	Sat Dec 18 23:53:57 2010
+++ loncom/interface/loncommon.pm	Fri Dec 24 07:58:04 2010
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common routines
 #
-# $Id: loncommon.pm,v 1.989 2010/12/18 23:53:57 raeburn Exp $
+# $Id: loncommon.pm,v 1.990 2010/12/24 07:58:04 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -11271,6 +11271,36 @@
     return ($symb,$enc);
 }
 
+sub build_release_hashes {
+    my ($checkparms,$checkresponsetypes,$checkcrstypes,$anonsurvey,$randomizetry) = @_;
+    return unless((ref($checkparms) eq 'HASH') && (ref($checkresponsetypes) eq 'HASH') &&
+                  (ref($checkcrstypes) eq 'HASH') && (ref($anonsurvey) eq 'HASH') &&
+                  (ref($randomizetry) eq 'HASH'));
+    foreach my $key (keys(%Apache::lonnet::needsrelease)) {
+        my ($item,$name,$value) = split(/:/,$key);
+        if ($item eq 'parameter') {
+            if (ref($checkparms->{$name}) eq 'ARRAY') {
+                unless(grep(/^\Q$name\E$/,@{$checkparms->{$name}})) {
+                    push(@{$checkparms->{$name}},$value);
+                }
+            } else {
+                push(@{$checkparms->{$name}},$value);
+            }
+        } elsif ($item eq 'resourcetag') {
+            if ($name eq 'responsetype') {
+                $checkresponsetypes->{$value} = $Apache::lonnet::needsrelease{$key}
+            }
+        } elsif ($item eq 'course') {
+            if ($name eq 'crstype') {
+                $checkcrstypes->{$value} = $Apache::lonnet::needsrelease{$key};
+            }
+        }
+    }
+    ($anonsurvey->{major},$anonsurvey->{minor}) = split(/\./,$Apache::lonnet::needsrelease{'parameter:type:anonsurvey'});
+    ($randomizetry->{major},$randomizetry->{minor}) = split(/\./,$Apache::lonnet::needsrelease{'parameter:type:randomizetry'});
+    return;
+}
+
 =pod
 
 =back
Index: loncom/misc/refresh_courseids_db.pl
diff -u loncom/misc/refresh_courseids_db.pl:1.9 loncom/misc/refresh_courseids_db.pl:1.10
--- loncom/misc/refresh_courseids_db.pl:1.9	Thu Dec 16 17:03:48 2010
+++ loncom/misc/refresh_courseids_db.pl	Fri Dec 24 07:58:09 2010
@@ -1,7 +1,7 @@
 #!/usr/bin/perl
 # The LearningOnline Network
 #
-# $Id: refresh_courseids_db.pl,v 1.9 2010/12/16 17:03:48 raeburn Exp $
+# $Id: refresh_courseids_db.pl,v 1.10 2010/12/24 07:58:09 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -80,7 +80,8 @@
 my @domains = sort(&Apache::lonnet::current_machine_domains());
 my @ids=&Apache::lonnet::current_machine_ids();
 
-&build_release_hashes();
+&Apache::loncommon::build_release_hashes(\%checkparms,\%checkresponsetypes,
+                                         \%checkcrstypes,\%anonsurvey,\%randomizetry);
 $env{'allowed.bre'} = 'F';
 
 foreach my $dom (@domains) {
@@ -454,29 +455,3 @@
     return $resourcedata;
 }
 
-sub build_release_hashes {
-    foreach my $key (keys(%Apache::lonnet::needsrelease)) {
-        my ($item,$name,$value) = split(/:/,$key);
-        if ($item eq 'parameter') {
-            if (ref($checkparms{$name}) eq 'ARRAY') {
-                unless(grep(/^\Q$name\E$/,@{$checkparms{$name}})) {
-                    push(@{$checkparms{$name}},$value);
-                }
-            } else {
-                push(@{$checkparms{$name}},$value);
-            }
-        } elsif ($item eq 'resourcetag') {
-            if ($name eq 'responsetype') {
-                $checkresponsetypes{$value} = $Apache::lonnet::needsrelease{$key}
-            }
-        } elsif ($item eq 'course') {
-            if ($name eq 'crstype') {
-                $checkcrstypes{$value} = $Apache::lonnet::needsrelease{$key};
-            }
-        }
-    }
-    ($anonsurvey{major},$anonsurvey{minor}) = split(/\./,$Apache::lonnet::needsrelease{'parameter:type:anonsurvey'});
-    ($randomizetry{major},$randomizetry{minor}) = split(/\./,$Apache::lonnet::needsrelease{'parameter:type:randomizetry'});
-    return;
-}
-