[LON-CAPA-cvs] cvs: loncom /interface loncoursedata.pm

albertel lon-capa-cvs-allow@mail.lon-capa.org
Tue, 03 Apr 2007 20:04:55 -0000


albertel		Tue Apr  3 16:04:55 2007 EDT

  Modified files:              
    /loncom/interface	loncoursedata.pm 
  Log:
  - with - and . allowed in courseids (and much longer domain/lonids allowed)
    need to do something to keep under the 64 character limit on table names,
    reverting to md5ing them
  
  
  
Index: loncom/interface/loncoursedata.pm
diff -u loncom/interface/loncoursedata.pm:1.180 loncom/interface/loncoursedata.pm:1.181
--- loncom/interface/loncoursedata.pm:1.180	Tue Jan 16 17:50:12 2007
+++ loncom/interface/loncoursedata.pm	Tue Apr  3 16:04:54 2007
@@ -1,6 +1,6 @@
 # The LearningOnline Network with CAPA
 #
-# $Id: loncoursedata.pm,v 1.180 2007/01/16 22:50:12 albertel Exp $
+# $Id: loncoursedata.pm,v 1.181 2007/04/03 20:04:54 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -38,26 +38,24 @@
 
 =head1 PACKAGES USED
 
- Apache::Constants qw(:common :http)
- Apache::lonnet()
- Apache::lonhtmlcommon
- HTML::TokeParser
- GDBM_File
-
+  Apache::lonnet
+  Apache::longroup
+  Time::HiRes
+  Apache::lonmysql
+  LONCAPA
+  Digest::MD5
+ 
 =cut
 
 package Apache::loncoursedata;
 
 use strict;
 use Apache::lonnet;
-use Apache::lonhtmlcommon;
-use Apache::longroup;
-use Time::HiRes;
-use Apache::lonmysql;
-use HTML::TokeParser;
-use GDBM_File;
-use lib '/home/httpd/lib/perl/';
+use Apache::longroup();
+use Time::HiRes();
+use Apache::lonmysql();
 use LONCAPA;
+use Digest::MD5();
 
 =pod
 
@@ -2007,7 +2005,7 @@
     &setup_table_names($courseid);
     my $symb_id = &get_symb_id($symb);
     my $part_id = &get_part_id($part);
-    my $stats_table = $courseid.'_problem_stats';
+    my $stats_table = &temp_table_name($courseid,'problem_stats');
     #
     my $dbh = &Apache::lonmysql::get_dbh();
     return undef if (! defined($dbh));
@@ -2520,7 +2518,7 @@
     my $time_limits = &limit_by_start_end_time($starttime,$endtime,'a');
     my @Symbids = map { &get_symb_id($_); } @{$symbs};
     #
-    my $stats_table = $courseid.'_problem_stats';
+    my $stats_table = &temp_table_name($courseid,'problem_stats');
     my $symb_restriction = join(' OR ',map {'a.symb_id='.$_;} @Symbids);
     my $request = 'DROP TABLE '.$stats_table;
     $dbh->do($request);
@@ -2599,7 +2597,7 @@
     my $time_limits = &limit_by_start_end_time($starttime,$endtime,'a');
     my @Symbids = map { &get_symb_id($_); } @{$symbs};
     #
-    my $stats_table = $courseid.'_problem_stats';
+    my $stats_table = &temp_table_name($courseid,'problem_stats');
     my $symb_restriction = join(' OR ',map {'a.symb_id='.$_;} @Symbids);
     my $request = 'DROP TABLE '.$stats_table;
     $dbh->do($request);
@@ -2897,7 +2895,7 @@
     &setup_table_names($courseid);
     my $dbh = &Apache::lonmysql::get_dbh();
     return (undef) if (! defined($dbh));
-    my $tmptable = $courseid.'_temp_'.time;
+    my $tmptable = &temp_table_name($courseid,'temp_'.time);
     my $request = 'DROP TABLE IF EXISTS '.$tmptable;
 #    &Apache::lonnet::logthis('request = '.$/.$request);
     $dbh->do($request);
@@ -3009,7 +3007,7 @@
     }
     #
     # Set up database names
-    my $base_id = $courseid;
+    my $base_id = 'md5_'.&Digest::MD5::md5_hex($courseid);
     $symb_table               = $base_id.'_'.'symb';
     $part_table               = $base_id.'_'.'part';
     $student_table            = $base_id.'_'.'student';
@@ -3038,6 +3036,12 @@
     return;
 }
 
+sub temp_table_name {
+    my ($courseid,$affix) = @_;
+    my $base_id = 'md5_'.&Digest::MD5::md5_hex($courseid);
+    return $base_id.'_'.$affix;
+}
+
 ################################################
 ################################################