--- loncom/interface/Attic/londropadd.pm 2001/01/15 14:51:18 1.9
+++ loncom/interface/Attic/londropadd.pm 2012/04/24 21:05:15 1.179
@@ -1,217 +1,538 @@
# The LearningOnline Network with CAPA
# Handler to drop and add students in courses
#
-# (Handler to set parameters for assessments
+# $Id: londropadd.pm,v 1.179 2012/04/24 21:05:15 droeschl 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).
#
-# 05/29/00,05/30,10/11 Gerd Kortemeyer)
+# 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.
#
-# 10/11,10/12,10/16 Gerd Kortemeyer)
+# 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.
#
-# 11/20,11/21,11/22,11/23,11/24,11/25,11/27,11/28,
-# 12/08,12/12 Gerd Kortemeyer)
+# 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
#
-# 12/26,12/27,12/28,
-# 01/01/01,01/15 Gerd Kortemeyer
+# /home/httpd/html/adm/gpl.txt
+#
+# http://www.lon-capa.org/
+#
+#
+
+=head1 NAME
+
+Apache::londropadd.pm
+
+=head1 SYNOPSIS
+
+drop & add students
+
+This is part of the LearningOnline Network with CAPA project
+described at http://www.lon-capa.org.
+
+=head1 SUBROUTINES
+
+=over
+
+=cut
package Apache::londropadd;
use strict;
use Apache::lonnet;
+use Apache::loncommon();
+use Apache::lonhtmlcommon();
use Apache::Constants qw(:common :http REDIRECT);
+use Spreadsheet::WriteExcel;
+use Apache::lonstathelpers();
+use Apache::lonlocal;
+use Apache::longroup;
+use LONCAPA();
+
+sub header {
+ my ($jscript,$loaditems) = @_;
+ my $start_page;
+ if (ref($loaditems) eq 'HASH') {
+ $start_page=&Apache::loncommon::start_page('Enrollment Manager',$jscript,{'add_entries' => $loaditems,});
+ } else {
+ $start_page=&Apache::loncommon::start_page('Enrollment Manager',$jscript);
+ }
+ return(<
+ENDHEAD
+}
+=pod
-# ================================================================ Main Handler
+=item domain_form()
+
+ build a domain and server selection form
+
+=cut
+
+sub domain_form {
+ my ($defdom) = @_;
+ # Set up domain and server selection forms
+ #
+ # Get the domains
+ my @domains = &Apache::lonnet::all_domains();
+ # build up the menu information to be passed to
+ # &Apache::loncommon::linked_select_forms
+ my %select_menus;
+ foreach my $dom (@domains) {
+ # set up the text for this domain
+ $select_menus{$dom}->{'text'}= $dom;
+ # we want a choice of 'default' as the default in the second menu
+ $select_menus{$dom}->{'default'}= 'default';
+ $select_menus{$dom}->{'select2'}->{'default'} = 'default';
+ # Now build up the other items in the second menu
+ my %servers = &Apache::lonnet::get_servers($dom,'library');
+ foreach my $server (keys(%servers)) {
+ $select_menus{$dom}->{'select2'}->{$server}
+ = "$server $servers{$server}";
+ }
+ }
+ my $result = &Apache::loncommon::linked_select_forms
+ ('studentform',' with home server ',$defdom,
+ 'lcdomain','lcserver',\%select_menus);
+ return $result;
+}
-sub handler {
- my $r=shift;
+=pod
- if ($r->header_only) {
- $r->content_type('text/html');
- $r->send_http_header;
- return OK;
- }
+=item print_main_menu()
-# ----------------------------------------------------- Needs to be in a course
+ Menu Phase One
- if (($ENV{'request.course.fn'}) &&
- (&Apache::lonnet::allowed('cst',$ENV{'request.course.id'}))) {
+=cut
-# ------------------------------------------------------------------ Start page
- $r->content_type('text/html');
- $r->send_http_header;
- $r->print(<
-
-LON-CAPA Student Drop/Add
-
-
-
-Drop/Add Students
-
\n\n".&mt('Processed [quant,_1,student].',$count).
+ "
\n");
+ $r->print("\n".
+ &mt('If active, the new role will be available when the '.
+ 'students next log in to LON-CAPA.')."
\n");
+ #####################################
+ # Drop students #
+ #####################################
+ if ($env{'form.fullup'} eq 'yes') {
+ $r->print(''.&mt('Dropping Students')."
\n");
+ # Get current classlist
+ my ($classlist,$keylist)=&Apache::loncoursedata::get_classlist();
+ if (! defined($classlist)) {
+ $r->print(&mt('There are no students currently enrolled.').
+ "\n");
+ } else {
+ # Remove the students we just added from the list of students.
+ foreach (@studentdata) {
+ my %entries=&Apache::loncommon::record_sep($_);
+ unless (($entries{$fields{'username'}} eq '') ||
+ (!defined($entries{$fields{'username'}}))) {
+ delete($classlist->{$entries{$fields{'username'}}.
+ ':'.$domain});
+ }
+ }
+ # Print out list of dropped students.
+ &show_drop_list($r,$classlist,$keylist,'nosort');
+ }
+ }
+ } # end of unless
+}
- } else {
- $r->print(
- 'Could not access classlist: '.$classlst.
- '
');
- }
- }
-# ------------------------------------------------------------------------ Done
- }
+# ================================================================== Phase four
+sub drop_student_list {
+ my $r=shift;
+ my $count=0;
+ my @droplist = &Apache::loncommon::get_env_multiple('form.droplist');
+ foreach (@droplist) {
+ my ($uname,$udom)=split(/\:/,$_);
+ # drop student
+ my $result = &Apache::lonuserutils::modifystudent($udom,$uname,
+ $env{'request.course.id'});
+ if ($result eq 'ok' || $result eq 'ok:') {
+ $r->print(&mt('Dropped [_1]',$uname.'@'.$udom).'
');
+ $count++;
+ } else {
+ $r->print(
+ &mt('Error dropping [_1]:[_2]',$uname.'@'.$udom,$result).
+ '
');
}
- }
-# ------------------------------------------------------------------------- End
- $r->print('