--- loncom/interface/Attic/londropadd.pm 2001/02/13 21:24:18 1.10
+++ loncom/interface/Attic/londropadd.pm 2003/11/06 20:04:06 1.88
@@ -1,322 +1,403 @@
# The LearningOnline Network with CAPA
# Handler to drop and add students in courses
#
-# (Handler to set parameters for assessments
+# $Id: londropadd.pm,v 1.88 2003/11/06 20:04:06 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
#
-# 12/26,12/27,12/28,
-# 01/01/01,01/15,02/10,02/13 Gerd Kortemeyer
+# (TeX Content Handler
+#
+###############################################################
+##############################################################
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;
+use Apache::lonlocal;
-# ================================================================ Print header
-
+###############################################################
+###############################################################
sub header {
- my $r=shift;
- $r->print(<
-
Drop/Add Students
-
+ + $Text{'enrollone'} + +
+ + $Text{'modify'} + +
+ + $Text{'view'} + +
+ + $Text{'drop'} + +
+END +} -sub upfile_record_sep { - if ($ENV{'form.upfiletype'} eq 'xml') { +############################################################### +############################################################### +sub print_upload_manager_header { + my ($r,$datatoken,$distotal,$krbdefdom)=@_; + my $javascript; + if (! exists($ENV{'form.upfile_associate'})) { + $ENV{'form.upfile_associate'} = 'forward'; + } + if ($ENV{'form.associate'} eq 'Reverse Association') { + if ( $ENV{'form.upfile_associate'} ne 'reverse' ) { + $ENV{'form.upfile_associate'} = 'reverse'; + } else { + $ENV{'form.upfile_associate'} = 'forward'; + } + } + if ($ENV{'form.upfile_associate'} eq 'reverse') { + $javascript=&upload_manager_javascript_reverse_associate(); } else { - return split(/\n/,$ENV{'form.upfile'}); - } -} - -# =============================================== Separate a record into fields - -sub record_sep { - my $record=shift; - my %components=(); - if ($ENV{'form.upfiletype'} eq 'xml') { - } elsif ($ENV{'form.upfiletype'} eq 'space') { - my $i=0; - map { - my $field=$_; - $field=~s/^(\"|\')//; - $field=~s/(\"|\')$//; - $components{$i}=$field; - $i++; - } split(/\s+/,$record); - } elsif ($ENV{'form.upfiletype'} eq 'tab') { - my $i=0; - map { - my $field=$_; - $field=~s/^(\"|\')//; - $field=~s/(\"|\')$//; - $components{$i}=$field; - $i++; - } split(/\t+/,$record); - } else { - my @allfields=split(/\,/,$record); - my $i=0; - my $j; - for ($j=0;$j<=$#allfields;$j++) { - my $field=$allfields[$j]; - if ($field=~/^\s*(\"|\')/) { - my $delimiter=$1; - while (($field!~/$delimiter$/) && ($j<$#allfields)) { - $j++; - $field.=','.$allfields[$j]; - } - $field=~s/^\s*$delimiter//; - $field=~s/$delimiter\s*$//; - } - $components{$i}=$field; - $i++; - } - } - return %components; -} - -# =========== Drop student from all sections of a course, except optional $csec - -sub dropstudent { - my ($udom,$unam,$courseid,$csec)=@_; - $courseid=~s/\_/\//g; - $courseid=~s/^(\w)/\/$1/; - map { - my ($key,$value)=split(/\=/,$_); - $key=&Apache::lonnet::unescape($key); - if ($key=~/^$courseid(?:\/)*(\w+)*\_st$/) { - my $section=$1; - if ($key eq $courseid.'_st') { $section=''; } - if ($section ne $csec) { - my ($dummy,$end,$start)=split(/\_/, - &Apache::lonnet::unescape($value)); - my $now=time; - my $notactive=0; - if ($start) { - if ($now<$start) { $notactive=1; } - } - if ($end) { - if ($now>$end) { $notactive=1; } - } - unless ($notactive) { - my $reply=&Apache::lonnet::modifystudent( - $udom,$unam,'','','', - '','','','',$section,time); - } - } - } - } split(/\&/,&Apache::lonnet::reply('dump:'.$udom.':'.$unam.':roles', - &Apache::lonnet::homeserver($unam,$udom))); -} - -# ============================================================== Menu Phase One - -sub menu_phase_one { - my $r=shift; - $r->print(<-
-
-ENDUPFORM + $javascript=&upload_manager_javascript_forward_associate(); + } + my $javascript_validations=&javascript_validations($krbdefdom); + my $checked=(($ENV{'form.noFirstLine'})?' checked="1"':''); + $r->print('
\n". + &mt('Total number of records found in file: [_1].',$distotal). + "\n". + "
Field | Samples | |||
---|---|---|---|---|
'); - if (defined($sone{$i})) { - $r->print($sone{$i}."\n"); - } - if (defined($stwo{$i})) { - $r->print($stwo{$i}."\n"); - } - if (defined($sthree{$i})) { - $r->print($sthree{$i}."\n"); - } - $r->print(' |
Starting Date | '. + ''.$startform.' | '. + ''.$dateDefault.' | '."
Ending Date | '. + ''.$endform.' | '. + ''.$perpetual.' | '."
Username: | +|
---|---|
Domain: | +$domform |
+ | + + |
First Name: | +|
---|---|
Middle Name: | +|
Last Name: | +|
Generation: | +|
Home Server: | +$homeserver_form |
First Name: | ++ + |
---|---|
Middle Name: | ++ + |
Last Name: | ++ + |
Generation: | ++ + |
Group/Section: +
+$date_table +
++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("
+Current Class List
+
+END
+ if ($ENV{'form.action'} ne 'modifystudent') {
+ $r->print(<
+
+ username + | + domain + | + ID + | + student name + | + section + | +
---|---|---|---|---|
\n "); + if ($linkto eq 'nothing') { + $r->print($username); + } elsif ($linkto eq 'aboutme') { + $r->print(&Apache::loncommon::aboutmewrapper($username, + $username, + $domain)); + } elsif ($linkto eq 'modify') { + $r->print(''. + $username."\n"); + } + $r->print(<<"END"); + | +$domain | +$id | +$name | +$section | +
'. + 'Your Excel spreadsheet is ready for download.
'."\n"); + } +} + + +# +# print out form for modification of a single students data +# +sub print_modify_student_form { + my $r = shift(); + &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, + ['sdom','sname']); + my $sname = $ENV{'form.sname'}; + my $sdom = $ENV{'form.sdom'}; + my $sortby = $ENV{'form.sortby'}; + # determine the students name information + my %info=&Apache::lonnet::get('environment', + ['firstname','middlename', + 'lastname','generation','id'], + $sdom, $sname); + my ($tmp) = keys(%info); + if ($tmp =~ /^(con_lost|error|no_such_host)/i) { + $r->print('Error'. + ''. + 'Unable to retrieve environment data for '.$sname. + 'in domain '.$sdom.'
'. + 'Please contact your LON-CAPA administrator '. + 'regarding this situation.