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

matthew lon-capa-cvs@mail.lon-capa.org
Fri, 03 May 2002 20:38:13 -0000


matthew		Fri May  3 16:38:13 2002 EDT

  Modified files:              
    /loncom/interface	londropadd.pm 
  Log:
  Added course list viewing capability.  BUG 205. 
  Rewrote web page header information.
  
  
Index: loncom/interface/londropadd.pm
diff -u loncom/interface/londropadd.pm:1.39 loncom/interface/londropadd.pm:1.40
--- loncom/interface/londropadd.pm:1.39	Fri May  3 13:45:07 2002
+++ loncom/interface/londropadd.pm	Fri May  3 16:38:13 2002
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to drop and add students in courses 
 #
-# $Id: londropadd.pm,v 1.39 2002/05/03 17:45:07 matthew Exp $
+# $Id: londropadd.pm,v 1.40 2002/05/03 20:38:13 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -62,14 +62,14 @@
     return(<<ENDHEAD);
 <html>
 <head>
-<title>LON-CAPA Student Drop/Add</title>
+<title>LON-CAPA Enrollment Manager</title>
 </head>
 <body bgcolor="#FFFFFF">
 <img align=right src=/adm/lonIcons/lonlogos.gif>
-<h1>Drop/Add Students</h1>
-<form method="post" enctype="multipart/form-data"
-action="/adm/dropadd" name="studentform">
-<h2>Course: $ENV{'course.'.$ENV{'request.course.id'}.'.description'}</h2>
+<h1>$ENV{'course.'.$ENV{'request.course.id'}.'.description'}</h1>
+<h2>Enrollment Manager</h2>
+<form method="post" enctype="multipart/form-data"  
+      action="/adm/dropadd" name="studentform">
 ENDHEAD
 }
 
@@ -150,13 +150,16 @@
 <hr>
 <h3>Upload a courselist</h3>
 $upfile_select
-<p><input type=submit name=fileupload value="Upload Courselist">
-<hr>
+<p><input type=submit name="fileupload" value="Upload Courselist">
+<hr />
 <h3>Enroll a single student</h3>
-<p><input type=submit name=enroll value="Enroll Student">
-<hr>
+<p><input type=submit name="enroll" value="Enroll Student"></p>
+<hr />
+<h3>Classlist</h3>
+<p><input type=submit name="view" value="View Class List"></p>
+<hr />
 <h3>Drop students</h3>
-<p><input type=submit name=drop value="Selection List">
+<p><input type=submit name="drop" value="Selection List"></p>
 ENDUPFORM
 }
 
@@ -170,6 +173,7 @@
     }
     my $javascript_validations=&javascript_validations($krbdefdom);
     $r->print(<<ENDPICK);
+<h3>Uploading Class List</h3>
 <hr>
 <h3>Identify fields</h3>
 Total number of records found in file: $distotal <hr />
@@ -570,6 +574,7 @@
 # ======================================================= Menu Phase Two Enroll
 sub menu_phase_two_enroll {
     my $r=shift;
+    $r->print("<h3>Enroll One Student</h3>");
     my ($krbdefdom) = $ENV{'SERVER_NAME'}=~/(\w+\.\w+)$/;
     $krbdefdom=~tr/a-z/A-Z/;
     my $today    = time;
@@ -695,6 +700,7 @@
 # ========================================================= Menu Phase Two Drop
 sub menu_phase_two_drop {
     my $r=shift;
+    $r->print("<h3>Drop Students</h3>");
     my $cid=$ENV{'request.course.id'};
     my ($error,%currentlist)=&get_current_classlist
         ($ENV{'course.'.$cid.'.domain'},$ENV{'course.'.$cid.'.num'});
@@ -712,6 +718,66 @@
     }
 }
 
+# ============================================== view classlist
+sub menu_phase_two_view {
+    my $r=shift;
+    $r->print("<h3>Current Classlist</h3>");
+    my $cid=$ENV{'request.course.id'};
+    my ($error,%currentlist)=&get_current_classlist
+        ($ENV{'course.'.$cid.'.domain'},$ENV{'course.'.$cid.'.num'});
+    if (defined($error)) {
+        if ($error =~ /^No such file or directory/) {
+            $r->print("There are no students currently enrolled.\n");
+        } else {
+            $r->print("<pre>ERROR:$error</pre>");
+        }
+    } elsif (!defined(%currentlist)) { 
+        $r->print("There are no students currently enrolled.\n");
+    } else {
+        # Print out the available choices
+        &show_class_list($r,%currentlist);
+    }
+}
+
+# =================================================== Show student list to drop
+sub show_class_list {
+    my ($r,%currentlist)=@_;
+    my $cid=$ENV{'request.course.id'};
+    $r->print(<<END);
+<p>
+<table border=2>
+<tr><th>username</th><th>domain</th><th>ID</th>
+    <th>student name</th><th>generation</th><th>section</th></tr>
+END
+    foreach (sort keys %currentlist) {
+        my ($sname,$sdom)=split(/\:/,$_);
+        my %reply=&Apache::lonnet::idrget($sdom,$sname);
+        my $ssec=&Apache::lonnet::usection($sdom,$sname,$cid);
+        my %info=&Apache::lonnet::get('environment',
+                                      ['firstname','middlename',
+                                       'lastname','generation'],
+                                      $sdom, $sname);
+        my ($tmp) = keys(%info);
+        if ($tmp =~ /^(con_lost|error|no_such_host)/i) {
+            $r->print('<tr><td colspan="6"><font color="red">'.
+                      'Internal error: unable to get environment '.
+                      'for '.$sname.' in domain '.$sdom.'</font></td></tr>');
+        } else {
+            $r->print(<<"END");
+<tr>
+    <td>$sname</td>
+    <td>$sdom</td>
+    <td>$reply{$sname}</td>
+    <td>$info{'lastname'}, $info{'firstname'} $info{'middlename'}</td>
+    <td>$info{'generation'}</td>
+    <td>$ssec</td>
+</tr>
+END
+        }
+    }
+    $r->print('</table><br>');
+}
+
 # =================================================== Show student list to drop
 sub show_drop_list {
     my ($r,%currentlist)=@_;
@@ -1007,6 +1073,8 @@
                 &menu_phase_two_enroll($r);
             } elsif ($ENV{'form.drop'}) {
                 &menu_phase_two_drop($r);
+            } elsif ($ENV{'form.view'}) {
+                &menu_phase_two_view($r);
             }
         }
         # Phase three