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

raeburn raeburn at source.lon-capa.org
Sun Aug 14 12:13:22 EDT 2016


raeburn		Sun Aug 14 16:13:22 2016 EDT

  Modified files:              
    /loncom/interface	loncoursedata.pm lonmysql.pm lonstatistics.pm 
  Log:
  - Ensure course's "temporary" MySQL tables for student information are
    current when Chart or Statistics web GUI is used.
  
  
Index: loncom/interface/loncoursedata.pm
diff -u loncom/interface/loncoursedata.pm:1.199 loncom/interface/loncoursedata.pm:1.200
--- loncom/interface/loncoursedata.pm:1.199	Sun Jul 24 14:34:59 2016
+++ loncom/interface/loncoursedata.pm	Sun Aug 14 16:13:21 2016
@@ -1,6 +1,6 @@
 # The LearningOnline Network with CAPA
 #
-# $Id: loncoursedata.pm,v 1.199 2016/07/24 14:34:59 raeburn Exp $
+# $Id: loncoursedata.pm,v 1.200 2016/08/14 16:13:21 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1396,6 +1396,44 @@
     return;
 }
 
+sub ensure_current_sections {
+    my ($courseid) = @_;
+    my ($cdom,$cnum);
+    if (defined($courseid)) {
+        my %coursehash = &Apache::lonnet::coursedescription($courseid);
+        $cdom = $coursehash{'domain'};
+        $cnum = $coursehash{'num'};
+    } elsif ($env{'request.course.id'}) {
+        $courseid = $env{'request.course.id'};
+        $cdom = $env{'course.'.$courseid.'.domain'};
+        $cnum = $env{'course.'.$courseid.'.num'};
+    }
+    &setup_table_names($courseid);
+    my @CurrentTables = &Apache::lonmysql::tables_in_db();
+    unless (grep(/^\Q$student_table\E$/, at CurrentTables)) {
+        return;
+    }
+    # Get the update time for the student table
+    my $getuserdir = 1;
+    my $modifiedtime = &Apache::lonnet::GetFileTimestamp
+        ($cdom,$cnum,'classlist.db',$getuserdir);
+    my %tableinfo = &Apache::lonmysql::table_information($student_table);
+    my $updatetime;
+    if ($tableinfo{'Update_time'}) {
+        $updatetime = $tableinfo{'Update_time'};
+    }
+    if ((!defined($updatetime)) || ($modifiedtime > $updatetime)) {
+        if (&Apache::lonmysql::drop_table($student_table)) {
+            if (&init_dbs($courseid)) {
+                return "error creating $student_table\n";
+            } else {
+                &populate_student_table($courseid);
+            }
+        }
+    }
+    return;
+}
+
 sub get_student_data_from_performance_cache {
     my ($sname,$sdom,$symb,$courseid)=@_;
     my $student = $sname.':'.$sdom if (defined($sname) && defined($sdom));
Index: loncom/interface/lonmysql.pm
diff -u loncom/interface/lonmysql.pm:1.39 loncom/interface/lonmysql.pm:1.40
--- loncom/interface/lonmysql.pm:1.39	Tue May 31 02:40:02 2011
+++ loncom/interface/lonmysql.pm	Sun Aug 14 16:13:22 2016
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # MySQL utility functions
 #
-# $Id: lonmysql.pm,v 1.39 2011/05/31 02:40:02 raeburn Exp $
+# $Id: lonmysql.pm,v 1.40 2016/08/14 16:13:22 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1287,7 +1287,7 @@
     my $timestamp=shift;
     if ($timestamp=~/^(\d+)\-(\d+)\-(\d+)\s+(\d+)\:(\d+)\:(\d+)$/) {
         $timestamp=&maketime('year'=>$1,'month'=>$2,'day'=>$3,
-                             'hours'=>$4,'minutes'=>$5,'seconds'=>$6);
+                             'hours'=>$4,'minutes'=>$5,'seconds'=>$6,'dlsav'=>-1);
     }
     return $timestamp;
 }
Index: loncom/interface/lonstatistics.pm
diff -u loncom/interface/lonstatistics.pm:1.162 loncom/interface/lonstatistics.pm:1.163
--- loncom/interface/lonstatistics.pm:1.162	Mon Apr 25 23:00:58 2016
+++ loncom/interface/lonstatistics.pm	Sun Aug 14 16:13:22 2016
@@ -1,6 +1,6 @@
 # The LearningOnline Network with CAPA
 #
-# $Id: lonstatistics.pm,v 1.162 2016/04/25 23:00:58 raeburn Exp $
+# $Id: lonstatistics.pm,v 1.163 2016/08/14 16:13:22 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -547,6 +547,11 @@
         &PrepareClasslist()
     }
     #
+    # Make sure course's student table is up to date
+    if (@Sections) {
+        &Apache::loncoursedata::ensure_current_sections();
+    }
+    #
     # Build the form element
     my $Str = "\n";
     $Str .= '<select name="'.$elementname.'" ';




More information about the LON-CAPA-cvs mailing list