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

raeburn lon-capa-cvs@mail.lon-capa.org
Mon, 15 Jan 2007 01:08:54 -0000


raeburn		Sun Jan 14 20:08:54 2007 EDT

  Modified files:              
    /loncom	lond 
    /loncom/interface	lonmodifycourse.pm 
  Log:
  Prevent stripping of trailing null fields in split() by setting limit to -1.
  
  Undesired stripping of trailing null fields had caused extra : separators to be written in values in nohist_courseids.db between type entry and final entry (last access), in some cases where there was no course owner.  Set numcurrent to a maximum to eliminate the extra items the next time put_course_id_handler() runs to update the entry for a particular courseID.
  
  Include type in courseidput when modify_course() results in change in course owner or institutional code.
  
  Typo (sectionums should be sectionnums). 
  
  
Index: loncom/lond
diff -u loncom/lond:1.355 loncom/lond:1.356
--- loncom/lond:1.355	Wed Jan 10 15:22:30 2007
+++ loncom/lond	Sun Jan 14 20:08:28 2007
@@ -2,7 +2,7 @@
 # The LearningOnline Network
 # lond "LON Daemon" Server (port "LOND" 5663)
 #
-# $Id: lond,v 1.355 2007/01/10 20:22:30 albertel Exp $
+# $Id: lond,v 1.356 2007/01/15 01:08:28 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -60,7 +60,7 @@
 my $status='';
 my $lastlog='';
 
-my $VERSION='$Revision: 1.355 $'; #' stupid emacs
+my $VERSION='$Revision: 1.356 $'; #' stupid emacs
 my $remoteVERSION;
 my $currenthostid="default";
 my $currentdomainid;
@@ -3293,13 +3293,14 @@
 	foreach my $pair (@pairs) {
             my ($key,$courseinfo) = split(/=/,$pair,2);
             $courseinfo =~ s/=/:/g;
-
-            my @current_items = split(/:/,$hashref->{$key});
+            my @current_items = split(/:/,$hashref->{$key},-1);
             shift(@current_items); # remove description
             pop(@current_items);   # remove last access
             my $numcurrent = scalar(@current_items);
-
-            my @new_items = split(/:/,$courseinfo);
+            if ($numcurrent > 3) {
+                $numcurrent = 3;
+            }
+            my @new_items = split(/:/,$courseinfo,-1);
             my $numnew = scalar(@new_items);
             if ($numcurrent > 0) {
                 if ($numnew <= $numcurrent) { # flushcourselogs() from pre 2.2 
Index: loncom/interface/lonmodifycourse.pm
diff -u loncom/interface/lonmodifycourse.pm:1.29 loncom/interface/lonmodifycourse.pm:1.30
--- loncom/interface/lonmodifycourse.pm:1.29	Fri Dec 29 12:30:11 2006
+++ loncom/interface/lonmodifycourse.pm	Sun Jan 14 20:08:53 2007
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # handler for DC-only modifiable course settings
 #
-# $Id: lonmodifycourse.pm,v 1.29 2006/12/29 17:30:11 raeburn Exp $
+# $Id: lonmodifycourse.pm,v 1.30 2007/01/15 01:08:53 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -67,7 +67,7 @@
                 } else {
                     $enrollvar{$type} = localtime($settings{$item});
                 }
-            } elsif ($type eq "sectionums") {
+            } elsif ($type eq "sectionnums") {
                 $enrollvar{$type} = $settings{$item};
                 $enrollvar{$type} =~ s/,/, /g;
             } elsif ($type eq "authtype"
@@ -483,7 +483,7 @@
 }
 
 sub modify_course {
-    my ($r,$cdom,$cnum,$cdesc,$domdesc) = @_;
+    my ($r,$cdom,$cnum,$cdesc,$domdesc,$type) = @_;
     my %longtype = &course_settings_descrip();
     my %settings = &Apache::lonnet::get('environment',['internal.courseowner','internal.coursecode','internal.authtype','internal.autharg','internal.sectionnums','internal.crosslistings','description'],$cdom,$cnum);
     my %currattr = ();
@@ -560,7 +560,7 @@
         }
     }
     if ($changeowner == 1 || $changecode == 1) {
-        my $courseid_entry = &escape($cdom.'_'.$cnum).'='.&escape($description).':'.&escape($env{'form.coursecode'}).':'.&escape($env{'form.courseowner'});
+        my $courseid_entry = &escape($cdom.'_'.$cnum).'='.&escape($description).':'.&escape($env{'form.coursecode'}).':'.&escape($env{'form.courseowner'}).':'.&escape($type);
         &Apache::lonnet::courseidput($cdom,$courseid_entry,&Apache::lonnet::homeserver($cnum,$cdom));
     }
 
@@ -922,7 +922,7 @@
                             &Apache::lonhtmlcommon::add_breadcrumb
                             ({href=>"javascript:changePage(document.$phase,'$phase')",
                               text=>"Result"});
-                            &modify_course($r,$cdom,$cnum,$cdesc,$domdesc);
+                            &modify_course($r,$cdom,$cnum,$cdesc,$domdesc,$type);
                         }
                     }
                 } else {