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

harris41 lon-capa-cvs@mail.lon-capa.org
Wed, 06 Mar 2002 22:34:06 -0000


harris41		Wed Mar  6 17:34:06 2002 EDT

  Modified files:              
    /loncom/interface	londropadd.pm 
  Log:
  map to foreach
  
  
Index: loncom/interface/londropadd.pm
diff -u loncom/interface/londropadd.pm:1.19 loncom/interface/londropadd.pm:1.20
--- loncom/interface/londropadd.pm:1.19	Fri Jan  4 13:13:58 2002
+++ loncom/interface/londropadd.pm	Wed Mar  6 17:34:06 2002
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to drop and add students in courses 
 #
-# $Id: londropadd.pm,v 1.19 2002/01/04 18:13:58 www Exp $
+# $Id: londropadd.pm,v 1.20 2002/03/06 22:34:06 harris41 Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -129,22 +129,22 @@
     if ($ENV{'form.upfiletype'} eq 'xml') {
     } elsif ($ENV{'form.upfiletype'} eq 'space') {
         my $i=0;
-        map {
+        foreach (split(/\s+/,$record) {
             my $field=$_;
             $field=~s/^(\"|\')//;
             $field=~s/(\"|\')$//;
             $components{$i}=$field;
             $i++;
-        } split(/\s+/,$record);
+        }
     } elsif ($ENV{'form.upfiletype'} eq 'tab') {
         my $i=0;
-        map {
+        foreach (split(/\t+/,$record)) {
             my $field=$_;
             $field=~s/^(\"|\')//;
             $field=~s/(\"|\')$//;
             $components{$i}=$field;
             $i++;
-        } split(/\t+/,$record);        
+        }
     } else {
         my @allfields=split(/\,/,$record);
         my $i=0;
@@ -173,7 +173,9 @@
      my ($udom,$unam,$courseid,$csec)=@_;
      $courseid=~s/\_/\//g;
      $courseid=~s/^(\w)/\/$1/;
-     map {
+     foreach (split(/\&/,
+		    &Apache::lonnet::reply('dump:'.$udom.':'.$unam.':roles',
+			     &Apache::lonnet::homeserver($unam,$udom)))) {
         my ($key,$value)=split(/\=/,$_);
         $key=&Apache::lonnet::unescape($key);
         if ($key=~/^$courseid(?:\/)*(\w+)*\_st$/) {
@@ -197,8 +199,7 @@
             }
 	  }
         }
-    } split(/\&/,&Apache::lonnet::reply('dump:'.$udom.':'.$unam.':roles',
-                                 &Apache::lonnet::homeserver($unam,$udom)));
+    }
 }
 
 # ============================================================== Menu Phase One
@@ -434,19 +435,19 @@
                 if ($total>=2) {
                    %sthree=&record_sep($records[2]);
 	        }
-                map {
+                foreach (sort keys %sone) {
                    $r->print('<tr><td><select name=f'.$i.
                        ' onChange="flip(this.form,'.$i.');">');
-                   map {
-                      my ($value,$display)=split(/\:/,$_);
-                      $r->print('<option value='.$value.'>'.$display.
-                              '</option>');
-                   } ('none: ','username:Username',
+                   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');
+                      '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"); 
@@ -459,7 +460,7 @@
                    }
                    $r->print('</td></tr>');
                    $i++;
-	       } sort keys %sone;
+	       }
 	       $i--;
 	     }
              my $keyfields=join(',',sort keys %sone);
@@ -770,7 +771,7 @@
                  my %currentlist=();
                  my $now=time;
                  unless ($classlst=~/^error\:/) {
-                     map {
+                     foreach (split(/\&/,$classlst)) {
                         my ($name,$value)=split(/\=/,$_);
                         my ($end,$start)=split(/\:/,
                                             &Apache::lonnet::unescape($value));
@@ -779,7 +780,7 @@
                         if ($active) {
 		           $currentlist{&Apache::lonnet::unescape($name)}=1;
                         }
-                     } split(/\&/,$classlst);
+                     }
 # ----------------------------------------------------------- Print out choices
                      &show_drop_list($r,%currentlist);
 	         } else {
@@ -797,7 +798,7 @@
 
     $r->print('<input type=hidden name=phase value=four>');
                      $r->print('<table border=2>');
-                     map {
+                     foreach (sort keys %currentlist) {
                          my ($sname,$sdom)=split(/\:/,$_);
                          my %reply=&Apache::lonnet::idrget($sdom,$sname);
                          my $ssec=&Apache::lonnet::usection($sdom,$sname,$cid);
@@ -815,7 +816,7 @@
                                    &Apache::lonnet::unescape($reply[1]).
                                    '</td><td>'.
                                    $ssec."</td></tr>\n");
-                     } sort keys %currentlist;
+                     }
                      $r->print('</table><br>');
                      $r->print('<input type=submit value="Drop Students">');
 }
@@ -863,7 +864,7 @@
               my %student=();
 # ----------------------------------------------------------- Get new classlist
 # --------------------------------------------------------- Enroll new students
-	      map {
+	      foreach (@studentdata) {
 		  my %entries=&record_sep($_);
 
                 unless (($entries{$fields{'username'}} eq '') ||
@@ -939,7 +940,7 @@
                      }
                   }
                  }                 
-              } @studentdata;
+              }
               $r->print('<p>Processed Students: '.$count);
 # --------------------------------------------------------------- Drop students
               if ($ENV{'form.fullup'} eq 'yes') {
@@ -952,7 +953,7 @@
                  my %currentlist=();
                  my $now=time;
                  unless ($classlst=~/^error\:/) {
-                     map {
+                     foreach (split(/\&/,$classlst)) {
                         my ($name,$value)=split(/\=/,$_);
                         my ($end,$start)=split(/\:/,
                                             &Apache::lonnet::unescape($value));
@@ -961,9 +962,9 @@
                         if ($active) {
 		           $currentlist{&Apache::lonnet::unescape($name)}=1;
                         }
-                     } split(/\&/,$classlst);
+                     }
 # ------------------------------------------------ Now got up-to-date classlist
-                     map {
+                     foreach (@studentdata) {
  	                my %entries=&record_sep($_);
                         unless (($entries{$fields{'username'}} eq '') ||
                           (!defined($entries{$fields{'username'}}))) {
@@ -971,7 +972,7 @@
                             $entries{$fields{'username'}}.':'.
                             $domain});
 		        }
-                     } @studentdata;
+                     }
 # ----------------------------------------------------------- Print out choices
                      &show_drop_list($r,%currentlist);
 	         } else {
@@ -990,14 +991,14 @@
 sub drop_student_list {
     my $r=shift;
     my $count=0;
-    map {
+    foreach (keys %ENV) {
 	if ($_=~/^form\.drop\:/) {
 	    my ($dummy,$uname,$udom)=split(/\:/,$_);
             &dropstudent($udom,$uname,$ENV{'request.course.id'});
             $r->print('Dropped '.$uname.' at '.$udom.'<br>');
             $count++;
         }
-    } keys %ENV;
+    }
     $r->print('<p><b>Dropped '.$count.' student(s).</b>');
     $r->print('<p>Re-enrollment will re-activate data.');
 }