[LON-CAPA-cvs] cvs: loncom(GCI_3) /interface lonclonecourse.pm

raeburn raeburn@source.lon-capa.org
Mon, 01 Mar 2010 20:11:04 -0000


raeburn		Mon Mar  1 20:11:04 2010 EDT

  Modified files:              (Branch: GCI_3)
    /loncom/interface	lonclonecourse.pm 
  Log:
  - Customization for GCI_3
    - Some corrections to changes in 1.7.12.1
      - Include package in calls to cput() and assignrole().
      - Eliminate surplus call to get_classlist()
      - Correct $uurl passed to assignrole()
      - items in array ref from $classlist->{$student} different from 
        items to be passed in hash ref to cput for update of classlist db.
  
  
Index: loncom/interface/lonclonecourse.pm
diff -u loncom/interface/lonclonecourse.pm:1.7.12.1 loncom/interface/lonclonecourse.pm:1.7.12.2
--- loncom/interface/lonclonecourse.pm:1.7.12.1	Fri Feb 26 22:45:03 2010
+++ loncom/interface/lonclonecourse.pm	Mon Mar  1 20:11:03 2010
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # routines for clone a course
 #
-# $Id: lonclonecourse.pm,v 1.7.12.1 2010/02/26 22:45:03 raeburn Exp $
+# $Id: lonclonecourse.pm,v 1.7.12.2 2010/03/01 20:11:03 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -245,8 +245,7 @@
 sub copyroster {
     my ($origcrsid,$newcrsid,$accessstart,$accessend) = @_;
     my %origcrsdata=&Apache::lonnet::coursedescription($origcrsid);
-    my $newcrsiddata=&Apache::lonnet::coursedescription($newcrsid);
-
+    my %newcrsdata=&Apache::lonnet::coursedescription($newcrsid);
     my $classlist = 
         &Apache::loncoursedata::get_classlist($origcrsdata{'domain'},$origcrsdata{'num'});
     my %origdate = &Apache::lonnet::get('environment',
@@ -255,14 +254,17 @@
 
     my $enddate = $origdate{'default_enrollment_end_date'};
 
-    my $sec_idx  = &Apache::loncoursedata::CL_SECTION();
-    my $status_idx   = &Apache::loncoursedata::CL_STATUS();
     my $end_idx = &Apache::loncoursedata::CL_END();
     my $start_idx = &Apache::loncoursedata::CL_START();
+    my $id_idx = &Apache::loncoursedata::CL_ID();
+    my $sec_idx  = &Apache::loncoursedata::CL_SECTION();
+    my $name_idx = &Apache::loncoursedata::CL_FULLNAME();
+    my $status_idx   = &Apache::loncoursedata::CL_STATUS();
+    my $type_idx = &Apache::loncoursedata::CL_TYPE();
+    my $locktype_idx = &Apache::loncoursedata::CL_LOCKEDTYPE();
 
     my (%newstudents,%rolesadded,$numadded);
     my $numadded = 0;
-    my $classlist = &Apache::loncoursedata::get_classlist();
     if (ref($classlist) eq 'HASH') {
         foreach my $student (sort(keys(%{$classlist}))) {
             my ($sname,$sdom) = split(/:/,$student);
@@ -271,33 +273,38 @@
             if (($classlist->{$student}->[$status_idx] eq 'Active') ||
                 ($classlist->{$student}->[$end_idx] >= $enddate)) {
                 if (ref($classlist->{$student}) eq 'ARRAY') {
-                    my @info = @{$classlist->{$student}};
-                    $info[$end_idx] = $accessend;
-                    $info[$start_idx] = $accessstart;
-                    $newstudents{$student}{'info'} = join(':',@info);
-                    $newstudents{$student}{'section'} = 
-                        $classlist->{$student}->[$sec_idx];
+                    my $sec = $classlist->{$student}->[$sec_idx];
+                    $newstudents{$student}{'section'} = $sec;
+                    $newstudents{$student}{'info'} =
+                        $accessend.':'.
+                        $accessstart.':'.
+                        $classlist->{$student}->[$id_idx].':'.
+                        $sec.':'.
+                        $classlist->{$student}->[$name_idx].':'.
+                        $classlist->{$student}->[$type_idx].':'.
+                        $classlist->{$student}->[$locktype_idx];
                 }
             }
         }
     }
     if (keys(%newstudents)) {
-        my $uurl='/'.$newcrsid;
+        my $uurl=$newcrsid;
         $uurl=~s/\_/\//g;
         foreach my $student (sort(keys(%newstudents))) {
             my $surl = $uurl;  
             if ($newstudents{$student}{'section'}) {
                 $surl.='/'.$newstudents{$student}{'section'};
             }
-            if (&assignrole($sdom,$sname,$uurl,'st',$accessend,$accessstart,undef,undef,'requestcourses') eq 'ok') {
-                $rolesadded{$student} = $newstudents{$student};
+            my ($sname,$sdom) = split(/:/,$student);
+            if (&Apache::lonnet::assignrole($sdom,$sname,$uurl,'st',$accessend,$accessstart,undef,undef,'requestcourses') eq 'ok') {
+                $rolesadded{$student} = $newstudents{$student}{'info'};
                 $numadded ++ ;
             }
         }
     }
     my $clisterror;
     if (keys(%rolesadded) > 0) {
-        my $reply=cput('classlist',\%rolesadded,$newcrsdata{'domain'},$newcrsdata{'num'});
+        my $reply = &Apache::lonnet::cput('classlist',\%rolesadded,$newcrsdata{'domain'},$newcrsdata{'num'});
         unless (($reply eq 'ok') || ($reply eq 'delayed')) {
             $clisterror = 'error: '.$reply;
         }