[LON-CAPA-cvs] cvs: loncom /interface lonmysql.pm lontrackstudent.pm
matthew
lon-capa-cvs@mail.lon-capa.org
Wed, 09 Feb 2005 21:21:08 -0000
matthew Wed Feb 9 16:21:08 2005 EDT
Modified files:
/loncom/interface lonmysql.pm lontrackstudent.pm
Log:
lonmysql.pm: Added &fix_table_name, which takes care of some of
MySQLs stupidity by prepending a '_' to table names which would
be interpreted as numbers.
Modified lontrackstudent.pm to use lonmysql and call fix_table_name
Index: loncom/interface/lonmysql.pm
diff -u loncom/interface/lonmysql.pm:1.25 loncom/interface/lonmysql.pm:1.26
--- loncom/interface/lonmysql.pm:1.25 Mon Dec 20 14:53:36 2004
+++ loncom/interface/lonmysql.pm Wed Feb 9 16:21:08 2005
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# MySQL utility functions
#
-# $Id: lonmysql.pm,v 1.25 2004/12/20 19:53:36 matthew Exp $
+# $Id: lonmysql.pm,v 1.26 2005/02/09 21:21:08 matthew Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1182,7 +1182,22 @@
return 1; # if we got here there was no error, so return a 'true' value
}
+##########################################
+=pod
+
+=item fix_table_name
+
+Fixes a table name so that it will work with MySQL.
+
+=cut
+
+##########################################
+sub fix_table_name {
+ my ($name) = @_;
+ $name =~ s/^(\d+e\d+)/_$1/;
+ return $name;
+}
# ---------------------------- convert 'time' format into a datetime sql format
Index: loncom/interface/lontrackstudent.pm
diff -u loncom/interface/lontrackstudent.pm:1.12 loncom/interface/lontrackstudent.pm:1.13
--- loncom/interface/lontrackstudent.pm:1.12 Thu Dec 30 11:34:05 2004
+++ loncom/interface/lontrackstudent.pm Wed Feb 9 16:21:08 2005
@@ -1,6 +1,6 @@
# The LearningOnline Network with CAPA
#
-# $Id: lontrackstudent.pm,v 1.12 2004/12/30 16:34:05 matthew Exp $
+# $Id: lontrackstudent.pm,v 1.13 2005/02/09 21:21:08 matthew Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -44,6 +44,7 @@
use strict;
use Apache::Constants qw(:common :http);
+use Apache::lonmysql;
use Apache::lonnet();
use Apache::lonlocal;
use Time::HiRes;
@@ -118,10 +119,10 @@
my $prefix = $course.'_'.$domain.'_';
#
my %tables =
- ( student => $prefix.'students',
- res => $prefix.'resource',
- machine => $prefix.'machine_table',
- activity=> $prefix.'activity',
+ ( student =>&Apache::lonmysql::fix_table_name($prefix.'students'),
+ res =>&Apache::lonmysql::fix_table_name($prefix.'resource'),
+ machine =>&Apache::lonmysql::fix_table_name($prefix.'machine_table'),
+ activity=>&Apache::lonmysql::fix_table_name($prefix.'activity'),
);
return %tables;
}
@@ -523,9 +524,6 @@
($r,\%prog_state,&mt('Contacting course home server'));
#
my $result = &request_data_update();
- if (ref($result) eq 'HASH') {
- $result = join(' ',map { $_.'=>'.$result->{$_}; } keys(%$result));
- }
#
if (exists($ENV{'form.selected_student'})) {
# For now, just show all the data, in the future allow selection of