--- loncom/interface/Attic/londropadd.pm 2000/12/27 21:57:10 1.4
+++ loncom/interface/Attic/londropadd.pm 2003/06/20 18:34:52 1.67
@@ -1,157 +1,256 @@
# The LearningOnline Network with CAPA
# Handler to drop and add students in courses
#
-# (Handler to set parameters for assessments
+# $Id: londropadd.pm,v 1.67 2003/06/20 18:34:52 matthew Exp $
#
-# (Handler to resolve ambiguous file locations
+# Copyright Michigan State University Board of Trustees
#
-# (TeX Content Handler
+# This file is part of the LearningOnline Network with CAPA (LON-CAPA).
+#
+# LON-CAPA is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# LON-CAPA is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with LON-CAPA; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
-# 05/29/00,05/30,10/11 Gerd Kortemeyer)
+# /home/httpd/html/adm/gpl.txt
#
-# 10/11,10/12,10/16 Gerd Kortemeyer)
+# http://www.lon-capa.org/
#
-# 11/20,11/21,11/22,11/23,11/24,11/25,11/27,11/28,
-# 12/08,12/12 Gerd Kortemeyer)
+# (Handler to set parameters for assessments
+#
+# (Handler to resolve ambiguous file locations
+#
+# (TeX Content Handler
#
-# 12/26, 12/27 Gerd Kortemeyer
+###############################################################
+###############################################################
package Apache::londropadd;
use strict;
-use Apache::lonnet;
+use Apache::lonnet();
+use Apache::loncommon();
+use Apache::lonhtmlcommon();
use Apache::Constants qw(:common :http REDIRECT);
+use Spreadsheet::WriteExcel;
-
-# ================================================================ Main Handler
-
-sub handler {
- my $r=shift;
-
- if ($r->header_only) {
- $r->content_type('text/html');
- $r->send_http_header;
- return OK;
- }
-
-# ----------------------------------------------------- Needs to be in a course
-
- if (($ENV{'request.course.fn'}) &&
- (&Apache::lonnet::allowed('cst',$ENV{'request.course.id'}))) {
-
-# ------------------------------------------------------------------ Start page
- $r->content_type('text/html');
- $r->send_http_header;
- $r->print(<
-LON-CAPA Student Drop/Add
+LON-CAPA Enrollment Manager
-
-
-
Drop/Add Students
-
+
ID/Student Number
+
+ID/Student Number:
+
+
+Disable ID/Student Number Safeguard and Force Change of Conflicting IDs
+(only do if you know what you are doing)
+
+
+
+END
+ return;
+}
+
+# ========================================================= Menu Phase Two Drop
+sub print_drop_menu {
+ my $r=shift;
+ $r->print("
Drop Students
");
+ my $cid=$ENV{'request.course.id'};
+ my ($classlist,$keylist) = &Apache::loncoursedata::get_classlist();
+ if (! defined($classlist)) {
+ $r->print("There are no students currently enrolled.\n");
+ return;
+ }
+ # Print out the available choices
+ &show_drop_list($r,$classlist,$keylist);
+ return;
+}
+
+# ============================================== view classlist
+sub print_html_classlist {
+ my $r=shift;
+ if (! exists($ENV{'form.sortby'})) {
+ $ENV{'form.sortby'} = 'username';
+ }
+ if ($ENV{'form.Status'} !~ /^(Any|Expired|Active)$/) {
+ $ENV{'form.Status'} = 'Active';
+ }
+ my $status_select = &Apache::lonhtmlcommon::StatusOptions
+ ($ENV{'form.Status'},'studentform');
+ $r->print(<
+
+
+Current Classlist
+
+END
+ if ($ENV{'form.action'} ne 'modifystudent') {
+ $r->print(<
+CSV format
+
+Excel format
+
+
+Student Status:
+END
+ }
+ $r->print($status_select."
\n");
+ my $cid=$ENV{'request.course.id'};
+ my ($classlist,$keylist)=&Apache::loncoursedata::get_classlist();
+ if (! defined($classlist)) {
+ $r->print("There are no students currently enrolled.\n");
+ } else {
+ # Print out the available choices
+ if ($ENV{'form.action'} eq 'modifystudent') {
+ &show_class_list($r,'view','modify','modifystudent',
+ $ENV{'form.Status'},$classlist,$keylist);
+ } else {
+ &show_class_list($r,'view','aboutme','classlist',
+ $ENV{'form.Status'},$classlist,$keylist);
}
- if (document.studentform.pres_marker.value=='start') {
- document.studentform.startdate.value=
- document.studentform.pres_value.value;
+ }
+}
+
+# ============================================== view classlist
+sub print_formatted_classlist {
+ my $r=shift;
+ my $mode = shift;
+ my $cid=$ENV{'request.course.id'};
+ my ($classlist,$keylist)=&Apache::loncoursedata::get_classlist();
+ if (! defined($classlist)) {
+ $r->print("There are no students currently enrolled.\n");
+ } else {
+ &show_class_list($r,$mode,'nolink','csv',
+ $ENV{'form.Status'},$classlist,$keylist);
+ }
+}
+
+# =================================================== Show student list to drop
+sub show_class_list {
+ my ($r,$mode,$linkto,$action,$statusmode,$classlist,$keylist)=@_;
+ my $cid=$ENV{'request.course.id'};
+ #
+ # Variables for excel output
+ my ($excel_workbook, $excel_sheet, $excel_filename,$row);
+ #
+ my $sortby = $ENV{'form.sortby'};
+ if ($sortby !~ /^(username|domain|section|fullname|id)$/) {
+ $sortby = 'username';
+ }
+ # Print out header
+ if ($mode eq 'view') {
+ if ($linkto eq 'aboutme') {
+ $r->print('Select a user name to view the users personal page.');
+ } elsif ($linkto eq 'modify') {
+ $r->print('Select a user name to modify the students information');
}
- pclose();
+ $r->print(<
+
+
+