--- loncom/interface/loncoursedata.pm 2016/07/24 14:34:59 1.199 +++ loncom/interface/loncoursedata.pm 2016/08/14 16:13:21 1.200 @@ -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 # @@ -1393,6 +1393,44 @@ sub ensure_current_students_groups { } } } + 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$/,@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; }