--- loncom/interface/Attic/londropadd.pm 2002/09/26 13:29:44 1.54 +++ loncom/interface/Attic/londropadd.pm 2002/10/16 18:45:10 1.59 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Handler to drop and add students in courses # -# $Id: londropadd.pm,v 1.54 2002/09/26 13:29:44 matthew Exp $ +# $Id: londropadd.pm,v 1.59 2002/10/16 18:45:10 matthew Exp $ # # Copyright Michigan State University Board of Trustees # @@ -594,17 +594,25 @@ sub enroll_single_student { my $home = &Apache::lonnet::homeserver($ENV{'form.cuname'}, $ENV{'form.lcdomain'}); if ((($amode) && ($genpwd)) || ($home ne 'no_host')) { + # Clean out any old roles the student has in this class. &modifystudent($ENV{'form.lcdomain'},$ENV{'form.cuname'}, $ENV{'request.course.id'},$ENV{'form.csec'}, $desiredhost); - $r->print(&Apache::lonnet::modifystudent( - $ENV{'form.lcdomain'},$ENV{'form.cuname'}, - $ENV{'form.cstid'},$amode,$genpwd, - $ENV{'form.cfirst'},$ENV{'form.cmiddle'}, - $ENV{'form.clast'},$ENV{'form.cgen'}, - $ENV{'form.csec'},$ENV{'form.enddate'}, - $ENV{'form.startdate'},$ENV{'form.forceid'}, - $desiredhost)); + my $login_result = &Apache::lonnet::modifystudent + ($ENV{'form.lcdomain'},$ENV{'form.cuname'}, + $ENV{'form.cstid'},$amode,$genpwd, + $ENV{'form.cfirst'},$ENV{'form.cmiddle'}, + $ENV{'form.clast'},$ENV{'form.cgen'}, + $ENV{'form.csec'},$ENV{'form.enddate'}, + $ENV{'form.startdate'},$ENV{'form.forceid'}, + $desiredhost); + if ($login_result =~ /^ok/) { + $r->print($login_result); + $r->print("
If active, the new role will be available ". + "when the student next logs in to LON-CAPA.
"); + } else { + $r->print("unable to enroll: ".$login_result); + } } else { $r->print('ERROR '. 'Invalid login mode or password. '. @@ -726,58 +734,60 @@ END return; } -# =================================================== get the current classlist -sub get_current_classlist { - my $r = shift; - # Call DownloadClasslist - my $cid = $ENV{'request.course.id'}; - my $c = $r->connection; - my $classlisthash = &Apache::loncoursedata::DownloadClasslist - ($cid,'Not downloaded',$c); - # Call ProcessClasslist - my %cache; - my @students = &Apache::loncoursedata::ProcessClasslist(\%cache, - $classlisthash, - $cid,$c); - return (\@students,\%cache); -} - # ========================================================= Menu Phase Two Drop sub print_drop_menu { my $r=shift; $r->print("
-Current Classlist -CSV format -
+Current Classlist + +END + if ($ENV{'form.action'} ne 'modifystudent') { + $r->print(<
- username + username | - domain + domain | - ID + ID | - student name + student name | - section + section | |
---|---|---|---|---|---|
'. - 'Error'. - 'Error retrieving data for '. - join('@',split(/:/,$student)). - ', '.$error.' | |||||
\n ");
if ($linkto eq 'nothing') {
@@ -869,9 +888,12 @@ END
$username,
$domain));
} elsif ($linkto eq 'modify') {
- $r->print(''.
+ $r->print(''.
$username."\n");
}
$r->print(<<"END");
@@ -888,6 +910,9 @@ END
foreach ($username,$domain,$id,$name,$section) {
push @line,&Apache::loncommon::csv_translate($_);
}
+ if ($statusmode eq 'Any') {
+ push @line,&Apache::loncommon::csv_translate($status);
+ }
my $tmp = $";
$" = '","';
$r->print("\"@line\"\n");
@@ -904,7 +929,7 @@ END
sub print_modify_student_form {
my $r = shift();
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
- ['sdom','sname','sortby']);
+ ['sdom','sname']);
my $sname = $ENV{'form.sname'};
my $sdom = $ENV{'form.sdom'};
my $sortby = $ENV{'form.sortby'};
@@ -932,6 +957,11 @@ sub print_modify_student_form {
my $enddateform = &Apache::lonhtmlcommon::date_setter('studentform',
'enddate',
$endtime);
+ #
+ if (! exists($ENV{'form.Status'}) ||
+ $ENV{'form.Status'} !~ /^(Any|Expired|Active)$/) {
+ $ENV{'form.Status'} = 'crap';
+ }
# Make sure student is enrolled in course
$r->print(<Modify Enrollment for $info{'firstname'} $info{'middlename'} $info{'lastname'} $info{'generation'}, $sname\@$sdom@@ -981,8 +1013,10 @@ END # sub modify_single_student { my $r = shift; - # Get the 'sortby' variable so the user does not need to re-sort + # Get the 'sortby' and 'Status' variables so the user goes back to their + # previous screen my $sortby = $ENV{'form.sortby'}; + my $status = $ENV{'form.Status'}; # # We always need this information my $slogin = $ENV{'form.slogin'}; @@ -993,6 +1027,8 @@ sub modify_single_student { ['firstname','middlename', 'lastname','generation','id'], $sdom, $slogin); + $old{'section'} = &Apache::lonnet::getsection($sdom,$slogin, + $ENV{'request.course.id'}); my ($tmp) = keys(%old); if ($tmp =~ /^(con_lost|error|no_such_host)/i) { $r->print("There was an error determining the environment values ". @@ -1054,11 +1090,14 @@ sub modify_single_student { ID |
$old{'id'} |
$sid |
+ | ||
Section | +$old{'section'} | +$section |
Section | $section |
Start Time | $displayable_starttime |
End Time | $displayable_endtime |
-Modify another students data + + + +Modify another students data