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

albertel lon-capa-cvs@mail.lon-capa.org
Thu, 04 Apr 2002 20:41:17 -0000


albertel		Thu Apr  4 15:41:17 2002 EDT

  Modified files:              
    /loncom/interface	londropadd.pm 
  Log:
  - refactoring
  
  
Index: loncom/interface/londropadd.pm
diff -u loncom/interface/londropadd.pm:1.22 loncom/interface/londropadd.pm:1.23
--- loncom/interface/londropadd.pm:1.22	Thu Apr  4 12:32:45 2002
+++ loncom/interface/londropadd.pm	Thu Apr  4 15:41:17 2002
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to drop and add students in courses 
 #
-# $Id: londropadd.pm,v 1.22 2002/04/04 17:32:45 albertel Exp $
+# $Id: londropadd.pm,v 1.23 2002/04/04 20:41:17 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -227,26 +227,9 @@
 ENDUPFORM
 }
 
-# ======================================================= Menu Phase Two Upload
-
-sub menu_phase_two_upload {
-    my $r=shift;
-
-    my $datatoken=&upfile_store($r);
-
-    my @records=&upfile_record_sep();
-    my $total=$#records;
-    my $distotal=$total+1;
-    
-    $ENV{'SERVER_NAME'}=~/(\w+\.\w+)$/;
-    my $krbdefdom=$1;
-    $krbdefdom=~tr/a-z/A-Z/;
-
-    my $today=time;
-    my $halfyear=$today+15552000;
-
-    my $defdom=$r->dir_config('lonDefDomain');
 
+sub phase_two_header {
+    my ($r,$datatoken,$distotal,$krbdefdom)=@_;
     $r->print(<<ENDPICK);
 <input type=hidden name=phase value=three>
 <input type=hidden name=datatoken value="$datatoken">
@@ -425,48 +408,11 @@
 </script>
 <table border=2><tr><th>Field</th><th>Samples</th></tr>
 ENDPICK
-             my %sone; my %stwo; my %sthree;
-             my $i=0;
+}
 
-             if ($total>=0) {
-                %sone=&record_sep($records[0]);
-                if ($total>=1) {
-                   %stwo=&record_sep($records[1]);
-                   
-	        }
-                if ($total>=2) {
-                   %sthree=&record_sep($records[2]);
-	        }
-                foreach (sort keys %sone) {
-                   $r->print('<tr><td><select name=f'.$i.
-                       ' onChange="flip(this.form,'.$i.');">');
-                   foreach ('none: ','username:Username',
-                      'names:Last Name, First Names',
-                      'fname:First Name','mname:Middle Names/Initials',
-                      'lname:Last Name','gen:Generation',
-                      'id:ID/Student Number','sec:Group/Section',
-                      'ipwd:Initial Password') {
-		      my ($value,$display)=split(/\:/,$_);
-                      $r->print('<option value='.$value.'>'.$display.
-                              '</option>');
-                   }
-                   $r->print('</select></td><td>');
-                   if (defined($sone{$_})) { 
-                      $r->print($sone{$_}."</br>\n"); 
-                   }
-	           if (defined($stwo{$_})) { 
-                      $r->print($stwo{$_}."</br>\n"); 
-                   }
-	           if (defined($sthree{$_})) { 
-                      $r->print($sthree{$_}."</br>\n"); 
-                   }
-                   $r->print('</td></tr>');
-                   $i++;
-	       }
-	       $i--;
-	     }
-             my $keyfields=join(',',sort keys %sone);
-             $r->print(<<ENDPICK);
+sub phase_two_end {
+    my ($r,$i,$keyfields,$defdom,$today,$halfyear)=@_;
+    $r->print(<<ENDPICK);
 </table>
 <input type=hidden name=nfields value=$i>
 <input type=hidden name=keyfields value="$keyfields">
@@ -512,6 +458,71 @@
 <input type=button onClick="verify(this.form)" value="Update Courselist"><br>
 Note: for large courses, this operation might be time consuming.
 ENDPICK
+}
+# ======================================================= Menu Phase Two Upload
+
+sub menu_phase_two_upload {
+    my $r=shift;
+
+    my $datatoken=&upfile_store($r);
+
+    my @records=&upfile_record_sep();
+    my $total=$#records;
+    my $distotal=$total+1;
+
+    $ENV{'SERVER_NAME'}=~/(\w+\.\w+)$/;
+    my $krbdefdom=$1;
+    $krbdefdom=~tr/a-z/A-Z/;
+
+    my $today=time;
+    my $halfyear=$today+15552000;
+
+    my $defdom=$r->dir_config('lonDefDomain');
+
+    &phase_two_header($r,$datatoken,$distotal,$krbdefdom);
+
+    my %sone; my %stwo; my %sthree;
+    my $i=0;
+
+    if ($total>=0) {
+	%sone=&record_sep($records[0]);
+	if ($total>=1) {
+	    %stwo=&record_sep($records[1]);
+	}
+	if ($total>=2) {
+	    %sthree=&record_sep($records[2]);
+	}
+	foreach (sort keys %sone) {
+	    $r->print('<tr><td><select name=f'.$i.
+		      ' onChange="flip(this.form,'.$i.');">');
+	    foreach ('none: ','username:Username',
+		     'names:Last Name, First Names',
+		     'fname:First Name','mname:Middle Names/Initials',
+		     'lname:Last Name','gen:Generation',
+		     'id:ID/Student Number','sec:Group/Section',
+		     'ipwd:Initial Password') {
+		my ($value,$display)=split(/\:/,$_);
+		$r->print('<option value='.$value.'>'.$display.
+			  '</option>');
+	    }
+	    $r->print('</select></td><td>');
+	    if (defined($sone{$_})) { 
+		$r->print($sone{$_}."</br>\n"); 
+	    }
+	    if (defined($stwo{$_})) { 
+		$r->print($stwo{$_}."</br>\n"); 
+	    }
+	    if (defined($sthree{$_})) { 
+		$r->print($sthree{$_}."</br>\n"); 
+	    }
+	    $r->print('</td></tr>');
+	    $i++;
+	}
+	$i--;
+    }
+    my $keyfields=join(',',sort keys %sone);
+
+    &phase_two_end($r,$i,$keyfields,$defdom,$today,$halfyear);
 }
 
 # ======================================================= Enroll single student