[LON-CAPA-cvs] cvs: loncom /interface lonclonecourse.pm loncommon.pm

raeburn raeburn at source.lon-capa.org
Mon Jun 1 16:35:02 EDT 2020


raeburn		Mon Jun  1 20:35:02 2020 EDT

  Modified files:              
    /loncom/interface	lonclonecourse.pm loncommon.pm 
  Log:
  - When cloning a course containing external tool(s) update course label and 
    course title in all instances of tool(s), if values for them in cloned course  
    contained default values: institutional code and course description.
  
  
Index: loncom/interface/lonclonecourse.pm
diff -u loncom/interface/lonclonecourse.pm:1.13 loncom/interface/lonclonecourse.pm:1.14
--- loncom/interface/lonclonecourse.pm:1.13	Sat Jun 29 23:21:05 2019
+++ loncom/interface/lonclonecourse.pm	Mon Jun  1 20:35:02 2020
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # routines for clone a course
 #
-# $Id: lonclonecourse.pm,v 1.13 2019/06/29 23:21:05 raeburn Exp $
+# $Id: lonclonecourse.pm,v 1.14 2020/06/01 20:35:02 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -130,7 +130,7 @@
 # =============================================================== Copy a dbfile
 
 sub copydb {
-    my ($origcrsid,$newcrsid,$which)=@_;
+    my ($origcrsid,$newcrsid,$which,$newinstcode)=@_;
     $which=~s/\.db$//;
     my %origcrsdata=&Apache::lonnet::coursedescription($origcrsid);
     my %newcrsdata= &Apache::lonnet::coursedescription($newcrsid);
@@ -139,6 +139,14 @@
     foreach my $key (keys(%data)) {
 	if ($key=~/^internal./) { delete($data{$key}); }
     }
+    if ($which =~ /^exttool_\d+$/) {
+        if ($origcrsdata{'description'} ne $newcrsdata{'description'}) {
+            $data{'crstitle'} =~s/\Q$origcrsdata{'description'}\E/$newcrsdata{'description'}/;
+        }
+        if ($origcrsdata{'internal.coursecode'} ne $newinstcode) {
+            $data{'crslabel'} =~ s/\Q$origcrsdata{'internal.coursecode'}\E/$newinstcode/;
+        }
+    }
     return &Apache::lonnet::put
 	($which,\%data,$newcrsdata{'domain'},$newcrsdata{'num'});
 }
@@ -255,7 +263,7 @@
 # ========================================================== Copy all userfiles
 
 sub copydbfiles {
-    my ($origcrsid,$newcrsid)=@_;
+    my ($origcrsid,$newcrsid,$newinstcode)=@_;
 
     my ($origcrs_discussion) = ($origcrsid=~m|^/(.*)|);
     $origcrs_discussion=~s|/|_|g;
@@ -264,7 +272,7 @@
         unless ($_=~/^(nohist\_|disclikes|discussiontimes|classlist|versionupdate
                 |resourcedata|\Q$origcrs_discussion\E|slots|slot_reservations
                 |gradingqueue|reviewqueue|CODEs|groupmembership|comm_block)/) {
-            &copydb($origcrsid,$newcrsid,$_);
+            &copydb($origcrsid,$newcrsid,$_,$newinstcode);
         }
 	}
     }
@@ -273,9 +281,9 @@
 # ======================================================= Copy all course files
 
 sub copycoursefiles {
-    my ($origcrsid,$newcrsid,$date_mode,$date_shift)=@_;
+    my ($origcrsid,$newcrsid,$date_mode,$date_shift,$newinstcode)=@_;
     &copyuserfiles($origcrsid,$newcrsid);
-    &copydbfiles($origcrsid,$newcrsid);
+    &copydbfiles($origcrsid,$newcrsid,$newinstcode);
     &copyresourcedb($origcrsid,$newcrsid,$date_mode,$date_shift);
 }
 
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.1341 loncom/interface/loncommon.pm:1.1342
--- loncom/interface/loncommon.pm:1.1341	Fri May 22 15:05:30 2020
+++ loncom/interface/loncommon.pm	Mon Jun  1 20:35:02 2020
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common routines
 #
-# $Id: loncommon.pm,v 1.1341 2020/05/22 15:05:30 raeburn Exp $
+# $Id: loncommon.pm,v 1.1342 2020/06/01 20:35:02 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -16059,7 +16059,8 @@
 	$outcome .= $clonemsg.$linefeed;
 	my %oldcenv=&Apache::lonnet::dump('environment',$$crsudom,$$crsunum);
 # Copy all files
-	&Apache::lonclonecourse::copycoursefiles($cloneid,$$courseid,$args->{'datemode'},$args->{'dateshift'});
+	&Apache::lonclonecourse::copycoursefiles($cloneid,$$courseid,$args->{'datemode'},
+	                                         $args->{'dateshift'},$args->{'crscode'});
 # Restore URL
 	$cenv{'url'}=$oldcenv{'url'};
 # Restore title




More information about the LON-CAPA-cvs mailing list