# The LearningOnline Network with CAPA # Handler to drop and add students in courses # # (Handler to set parameters for assessments # # (Handler to resolve ambiguous file locations # # (TeX Content Handler # # 05/29/00,05/30,10/11 Gerd Kortemeyer) # # 10/11,10/12,10/16 Gerd Kortemeyer) # # 11/20,11/21,11/22,11/23,11/24,11/25,11/27,11/28, # 12/08,12/12 Gerd Kortemeyer) # # 12/26, 12/27 Gerd Kortemeyer package Apache::londropadd; use strict; use Apache::lonnet; use Apache::Constants qw(:common :http REDIRECT); # ================================================================ 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

Drop/Add Students

Course: $ENV{'course.'.$ENV{'request.course.id'}.'.description'}

ENDHEAD # --------------------------------------------------- Phase one, initial screen unless ($ENV{'form.phase'}) { $r->print(<

Upload a courselist


Type:


Enroll a single student


Drop a student

ENDUPFORM } # ------------------------------------------------------------------- Phase two if ($ENV{'form.phase'} eq 'two') { if ($ENV{'form.fileupload'}) { my $datatoken=Apache::lonnet::reply( 'tmpput:'.Apache::lonnet::escape($ENV{'form.upfile'}), $r->dir_config('lonHostID')); my $separator=''; my $remove=''; if ($ENV{'form.upfiletype'} eq 'csv') { $separator='\"\,\s*\"'; $remove='"'; } elsif ($ENV{'form.upfiletype'} eq 'space') { $separator='\s+'; } elsif ($ENV{'form.upfiletype'} eq 'tab') { $separator='\t+'; } elsif ($ENV{'form.upfiletype'} eq 'xml') { } my @lines=split(/\n/,$ENV{'form.upfile'}); my $total=$#lines+1; $ENV{'SERVER_NAME'}=~/(\w+\.\w+)$/; my $krbdefdom=$1; $krbdefdom=~tr/a-z/A-Z/; $r->print(<


Identify fields

Total number of students: $total ENDPICK my @sone; my @stwo; my @sthree; my $nfields=0; if ($#lines>=0) { $lines[0]=~s/^$remove//; $lines[0]=~s/$remove$//; @sone=split(/$separator/,$lines[0]); $nfields=$#sone; if ($#lines>=1) { $lines[1]=~s/^$remove//; $lines[1]=~s/$remove$//; @stwo=split(/$separator/,$lines[1]); $nfields=$#stwo; } if ($#lines>=2) { $lines[2]=~s/^$remove//; $lines[2]=~s/$remove$//; @sthree=split(/$separator/,$lines[2]); $nfields=$#sthree; } my $i; for ($i=0;$i<=$nfields;$i++) { $r->print(''); } } $r->print(<

Login Type

Kerberos authenticated with domain

Internally authenticated (with initial password )

ENDPICK } elsif ($ENV{'form.enroll'}) { } elsif ($ENV{'form.drop'}) { } } # ----------------------------------------------------------------- Phase three if ($ENV{'form.phase'} eq 'three') { if ($ENV{'form.datatoken'}) { my $separator=''; my $remove=''; if ($ENV{'form.upfiletype'} eq 'csv') { $separator='\"\,\s*\"'; $remove='"'; } elsif ($ENV{'form.upfiletype'} eq 'space') { $separator='\s+'; } elsif ($ENV{'form.upfiletype'} eq 'tab') { $separator='\t+'; } elsif ($ENV{'form.upfiletype'} eq 'xml') { } map { my $line=$_; $line=~s/^$remove//; $line=~s/$remove$//; my @entries=split(/$separator/,$line); $r->print($entries[8].'
'); } split(/\n/, &Apache::lonnet::unescape(Apache::lonnet::reply( 'tmpget:'.$ENV{'form.datatoken'},$r->dir_config('lonHostID'))) ); } } # ------------------------------------------------------------------------- End $r->print(''); } else { # ----------------------------- Not in a course, or not allowed to modify parms $ENV{'user.error.msg'}= "/adm/dropadd:cst:0:0:Cannot drop or add students"; return HTTP_NOT_ACCEPTABLE; } return OK; } 1; __END__

FieldSamples
'); 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('