--- loncom/interface/Attic/londropadd.pm 2001/02/13 21:24:18 1.10
+++ loncom/interface/Attic/londropadd.pm 2008/09/11 14:47:21 1.174
@@ -1,322 +1,555 @@
# The LearningOnline Network with CAPA
# Handler to drop and add students in courses
#
-# (Handler to set parameters for assessments
+# $Id: londropadd.pm,v 1.174 2008/09/11 14:47:21 bisitz 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,02/10,02/13 Gerd Kortemeyer
+# /home/httpd/html/adm/gpl.txt
+#
+# http://www.lon-capa.org/
+#
+#
+###############################################################
+##############################################################
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();
-# ================================================================ Print header
-
+###############################################################
+###############################################################
sub header {
- my $r=shift;
- $r->print(<
-
-LON-CAPA Student Drop/Add
-
-
-
-Drop/Add Students
-
\n\n".&mt('Processed [_1] student(s).',$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
+}
- }
+# ================================================================== 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).
+ '
');
+ }
+ }
+ $r->print(''.&mt('Dropped [_1] student(s).',$count).'
');
+ $r->print(''.&mt('Re-enrollment will re-activate data.')) if ($count);
}
-# ================================================================ Main Handler
+sub section_check_js {
+ my $groupslist;
+ my %curr_groups = &Apache::longroup::coursegroups();
+ if (%curr_groups) {
+ $groupslist = join('","',sort(keys(%curr_groups)));
+ }
+ return <<"END";
+function validate(caller) {
+ var groups = new Array("$groupslist");
+ var secname = caller.value;
+ if ((secname == 'all') || (secname == 'none')) {
+ alert("'"+secname+"' may not be used as the name for a section, as it is a reserved word.\\nPlease choose a different section name.");
+ return 'error';
+ }
+ if (secname != '') {
+ for (var k=0; kheader_only) {
- $r->content_type('text/html');
- $r->send_http_header;
- return OK;
- }
+ $permission{'enrl'} =
+ &Apache::lonnet::allowed('cst',$env{'request.course.id'});
-# ----------------------------------------------------- Needs to be in a course
+ $permission{'grp_view'} =
+ &Apache::lonnet::allowed('vcg',$env{'request.course.id'});
+ $permission{'grp_manage'} =
+ &Apache::lonnet::allowed('mdg',$env{'request.course.id'});
+ my $allowed = 0;
+ foreach my $perm (values(%permission)) {
+ if ($perm) { $allowed=1; last; }
+ }
+ return (\%permission,$allowed);
+}
- if (($ENV{'request.course.fn'}) &&
- (&Apache::lonnet::allowed('cst',$ENV{'request.course.id'}))) {
+###################################################################
+###################################################################
-# ------------------------------------------------------------------ Start page
- $r->content_type('text/html');
- $r->send_http_header;
- &header($r);
-
-# --------------------------------------------------- Phase one, initial screen
- unless ($ENV{'form.phase'}) {
- &menu_phase_one($r);
- }
-# ------------------------------------------------------------------- Phase two
- if ($ENV{'form.phase'} eq 'two') {
- if ($ENV{'form.fileupload'}) {
- &menu_phase_two_upload($r);
- } elsif ($ENV{'form.enroll'}) {
- &menu_phase_two_enroll($r);
- } elsif ($ENV{'form.drop'}) {
- &menu_phase_two_drop($r);
- }
- }
+=pod
+=item &handler
+The typical handler you see in all these modules. Takes $r, the
+http request, as an argument.
+
+The response to the request is governed by two form variables
+
+ form.action form.state response
+ ---------------------------------------------------
+ undefined undefined print main menu
+ upload undefined print courselist upload menu
+ upload got_file deal with uploaded file,
+ print the upload managing menu
+ upload enrolling enroll students based on upload
+ drop undefined print the classlist ready to drop
+ drop done drop the selected students
+ enrollstudent undefined print student username domain form
+ enrollstudent gotusername print single student enroll menu
+ enrollstudent enrolling enroll student
+ classlist undefined print html classlist
+ classlist csv print csv classlist
+ modifystudent undefined print classlist to select student to modify
+ modifystudent selected print modify student menu
+ modifystudent done make modifications to student record
+=cut
-# ----------------------------------------------------------------- Phase three
- if ($ENV{'form.phase'} eq 'three') {
- if ($ENV{'form.datatoken'}) {
- &upfile_drop_add($r);
- }
- }
-# ------------------------------------------------------------------------- End
- $r->print('