--- loncom/interface/loncoursedata.pm 2016/04/25 23:00:58 1.197 +++ 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.197 2016/04/25 23:00:58 raeburn Exp $ +# $Id: loncoursedata.pm,v 1.200 2016/08/14 16:13:21 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -1306,7 +1306,11 @@ sub ensure_current_groups { if ($cdom eq '' || $cnum eq '') { return 'error: invalid course'; } - &ensure_tables_are_set_up($courseid); + &setup_table_names($courseid); + my @CurrentTables = &Apache::lonmysql::tables_in_db(); + unless (grep(/^\Q$groupnames_table\E$/,@CurrentTables)) { + return; + } # Get the update time for the groupnames table my $getuserdir = 1; my $modifiedtime = &Apache::lonnet::GetFileTimestamp @@ -1316,7 +1320,6 @@ sub ensure_current_groups { if ($tableinfo{'Update_time'}) { $updatetime = $tableinfo{'Update_time'}; } - print STDERR "1. updatetime is ||$updatetime|| and modifidtime is ||$modifiedtime||\n"; if (! defined($updatetime) || $modifiedtime > $updatetime) { my (%groups_in_sql,%removegroups,$addgroup); my %curr_groups = &Apache::longroup::coursegroups($cdom,$cnum); @@ -1367,7 +1370,11 @@ sub ensure_current_students_groups { $cdom = $env{'course.'.$courseid.'.domain'}; $cnum = $env{'course.'.$courseid.'.num'}; } - &ensure_tables_are_set_up($courseid); + &setup_table_names($courseid); + my @CurrentTables = &Apache::lonmysql::tables_in_db(); + unless (grep(/^\Q$students_groups_table\E$/,@CurrentTables)) { + return; + } # Get the update time for the groupnames table my $getuserdir = 1; my $modifiedtime = &Apache::lonnet::GetFileTimestamp @@ -1377,7 +1384,6 @@ sub ensure_current_students_groups { if ($tableinfo{'Update_time'}) { $updatetime = $tableinfo{'Update_time'}; } - print STDERR "2. updatetime is ||$updatetime|| and modifidtime is ||$modifiedtime||\n"; if ((!defined($updatetime)) || ($modifiedtime > $updatetime)) { if (&Apache::lonmysql::drop_table($students_groups_table)) { if (&init_dbs($courseid)) { @@ -1390,6 +1396,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; +} + sub get_student_data_from_performance_cache { my ($sname,$sdom,$symb,$courseid)=@_; my $student = $sname.':'.$sdom if (defined($sname) && defined($sdom)); @@ -2392,14 +2436,15 @@ sub CL_STATUS { return 7; } sub CL_TYPE { return 8; } sub CL_LOCKEDTYPE { return 9; } sub CL_CREDITS { return 10; } -sub CL_GROUP { return 11; } -sub CL_PERMANENTEMAIL { return 12; } -sub CL_ROLE { return 13; } -sub CL_EXTENT { return 14; } -sub CL_PHOTO { return 15; } -sub CL_THUMBNAIL { return 16; } -sub CL_AUTHORQUOTA { return 17; } -sub CL_AUTHORUSAGE { return 18; } +sub CL_INSTSEC { return 11; } +sub CL_GROUP { return 12; } +sub CL_PERMANENTEMAIL { return 13; } +sub CL_ROLE { return 14; } +sub CL_EXTENT { return 15; } +sub CL_PHOTO { return 16; } +sub CL_THUMBNAIL { return 17; } +sub CL_AUTHORQUOTA { return 18; } +sub CL_AUTHORUSAGE { return 19; } sub get_classlist { my ($cdom,$cnum) = @_; @@ -2419,9 +2464,9 @@ sub get_classlist { } my ($sname,$sdom) = split(/:/,$student); my @Values = split(/:/,$info); - my ($end,$start,$id,$section,$fullname,$type,$lockedtype,$credits); + my ($end,$start,$id,$section,$fullname,$type,$lockedtype,$credits,$instsec); if (@Values > 2) { - ($end,$start,$id,$section,$fullname,$type,$lockedtype,$credits) = @Values; + ($end,$start,$id,$section,$fullname,$type,$lockedtype,$credits,$instsec) = @Values; } else { # We have to get the data ourselves ($end,$start) = @Values; $section = &Apache::lonnet::getsection($sdom,$sname,$cid); @@ -2461,12 +2506,12 @@ sub get_classlist { } $classlist{$student} = [$sdom,$sname,$end,$start,$id,$section,$fullname,$status,$type, - $lockedtype,$credits]; + $lockedtype,$credits,$instsec]; } if (wantarray()) { return (\%classlist,['domain','username','end','start','id', 'section','fullname','status','type', - 'lockedtype','credits']); + 'lockedtype','credits','instsec']); } else { return \%classlist; } @@ -3197,7 +3242,7 @@ $env{'course.'.$cid.'.domain'}, and $env Returns a reference to a hash which contains: keys '$sname:$sdom' values [$sdom,$sname,$end,$start,$id,$section,$fullname,$status,$type, - $lockedtype,$credits] + $lockedtype,$credits,$instsec] The constant values CL_SDOM, CL_SNAME, CL_END, etc. can be used as indices into the returned list to future-proof clients against