--- loncom/interface/Attic/londropadd.pm 2000/12/27 21:57:10 1.4 +++ loncom/interface/Attic/londropadd.pm 2001/01/01 15:43:46 1.7 @@ -14,7 +14,8 @@ # 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 +# 12/26,12/27,12/28, +# 01/01/01 Gerd Kortemeyer package Apache::londropadd; @@ -330,9 +331,10 @@ Kerberos authenticated with domain

Internally authenticated (with initial password -)

+) +

LON-CAPA Domain for Students

LON-CAPA domain:

- +

Starting and Ending Dates

@@ -345,8 +347,11 @@ LON-CAPA domain: Set Ending Date

- - +

Full Update

+ Full update +(also dropping students)

+
+Note: for large courses, this operation might be time consuming. ENDPICK } elsif ($ENV{'form.enroll'}) { } elsif ($ENV{'form.drop'}) { @@ -374,8 +379,25 @@ ENDPICK my $enddate=$ENV{'form.enddate'}; if ($startdate=~/\D/) { $startdate=''; } if ($enddate=~/\D/) { $enddate=''; } - my $count=1; - my @studentdata=(); + my $domain=$ENV{'form.lcdomain'}; + my $amode=''; + my $genpwd=''; + if ($ENV{'form.login'} eq 'krb') { + $amode='krb4'; + $genpwd=$ENV{'form.krbdom'}; + } elsif ($ENV{'form.login'} eq 'int') { + $amode='internal'; + if ((defined($ENV{'form.intpwd'})) && ($ENV{'form.intpwd'})) { + $genpwd=$ENV{'form.intpwd'}; + } + } + unless (($domain=~/\W/) || ($amode eq '')) { + $r->print('

Enrolling Students

'); + my $count=0; + my $flushc=0; + my %student=(); +# ----------------------------------------------------------- Get new classlist + my @studentdata=(); { my $fh; if ($fh=Apache::File->new($r->dir_config('lonDaemons'). @@ -383,6 +405,7 @@ ENDPICK @studentdata=<$fh>; } } +# --------------------------------------------------------- Enroll new students map { my $line=$_; chomp($line); @@ -413,12 +436,87 @@ ENDPICK $r->print('

Unacceptable username: '. $entries[$fields{'username'}].' for user '. $fname.' '.$mname.' '.$lname.' '.$gen.'

'); - } else { -$r->print($count.': '.$fname.' - '.$mname.' - '.$lname.' - '.$gen.'
'); $count++; + } else { + my $sec=''; + my $username=$entries[$fields{'username'}]; + if (defined($fields{'sec'})) { + if (defined($entries[$fields{'sec'}])) { + $sec=$entries[$fields{'sec'}]; + } + } + my $id=''; + if (defined($fields{'id'})) { + if (defined($entries[$fields{'id'}])) { + $id=$entries[$fields{'id'}]; + } + $id=~tr/A-Z/a-z/; + } + my $password=''; + if ($genpwd) { + $password=$genpwd; + } else { + if (defined($fields{'ipwd'})) { + if ($entries[$fields{'ipwd'}]) { + $password=$entries[$fields{'ipwd'}]; + } + } + } + if ($password) { + my $reply=&Apache::lonnet::modifystudent( + $domain,$username,$id,$amode,$password, + $fname,$mname,$lname,$gen,$sec,$enddate,$startdate); + unless ($reply eq 'ok') { + $r->print( + "

Error enrolling $username: $reply

"); + } else { + $count++; $flushc++; + $student{$username}=1; + $r->print('. '); + if ($flushc>15) { + $r->rflush; + $flushc=0; + } + } + } else { + $r->print( + "

No password for $username

"); + } } } } @studentdata; + $r->print('

Processed Students: '.$count); +# --------------------------------------------------------------- Drop students + if ($ENV{'form.fullup'} eq 'yes') { + $r->print('

Dropping Students

'); +# ------------------------------------------------------- Get current classlist + my $cid=$ENV{'request.course.id'}; + my $classlst=&Apache::lonnet::reply + ('dump:'.$ENV{'course.'.$cid.'.domain'}.':'. + $ENV{'course.'.$cid.'.num'}.':classlist', + $ENV{'course.'.$cid.'.home'}); + my %currentlist=(); + my $now=time; + unless ($classlst=~/^error\:/) { + map { + my ($name,$value)=split(/\=/,$_); + my ($end,$start)=split(/\_/, + &Apache::lonnet::unescape($value)); + my $active=1; + if (($end) && ($now>$end)) { $active=0; } + if ($active) { + $currentlist{&Apache::lonnet::unescape($name)}=1; + } + } split(/\&/,$classlst); + + } else { + $r->print( + '

Could not access classlist: '.$classlst. + '

'); + } + } +# ------------------------------------------------------------------------ Done } + } } # ------------------------------------------------------------------------- End $r->print('');