[LON-CAPA-cvs] cvs: loncom /interface londropadd.pm
matthew
lon-capa-cvs@mail.lon-capa.org
Wed, 16 Oct 2002 18:45:10 -0000
matthew Wed Oct 16 14:45:10 2002 EDT
Modified files:
/loncom/interface londropadd.pm
Log:
Many changes to deal well with the new status field.
The routine &show_class_list was modified to use javascript to set a few
hidden parameter values and submit the form in order to take you to the next
page when modifying a students information. This is in contrast to the
previous method which passed parameters in a link.
&show_drop_list is now a little brighter about the 'sortby' parameter, for
what it's worth (not much, really).
&drop_student_list acts more intelligent on errors - the errors are still
reported and other information is now suppressed if it is not relevant.
Specifically, if no students were successfully dropped you needn't tell
the user about re-enrollment.
Index: loncom/interface/londropadd.pm
diff -u loncom/interface/londropadd.pm:1.58 loncom/interface/londropadd.pm:1.59
--- loncom/interface/londropadd.pm:1.58 Wed Oct 16 11:02:28 2002
+++ loncom/interface/londropadd.pm Wed Oct 16 14:45:10 2002
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to drop and add students in courses
#
-# $Id: londropadd.pm,v 1.58 2002/10/16 15:02:28 matthew Exp $
+# $Id: londropadd.pm,v 1.59 2002/10/16 18:45:10 matthew Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -755,8 +755,7 @@
if (! exists($ENV{'form.sortby'})) {
$ENV{'form.sortby'} = 'username';
}
- if (! exists($ENV{'form.Status'}) ||
- $ENV{'form.Status'} !~ /^(Any|Expired|Active)$/) {
+ if ($ENV{'form.Status'} !~ /^(Any|Expired|Active)$/) {
$ENV{'form.Status'} = 'Active';
}
my $status_select = &Apache::lonhtmlcommon::StatusOptions
@@ -767,13 +766,16 @@
<p>
<font size="+1">Current Classlist</font>
+END
+ if ($ENV{'form.action'} ne 'modifystudent') {
+ $r->print(<<END);
<font size="+1">
<a href="javascript:document.studentform.state.value='csv';document.studentform.submit();">CSV format</a>
</font>
-$status_select
-</p>
END
+ }
+ $r->print($status_select."</p>\n");
my $cid=$ENV{'request.course.id'};
my ($classlist,$keylist)=&Apache::loncoursedata::get_classlist();
if (! defined($classlist)) {
@@ -821,7 +823,10 @@
$r->print('Select a user name to modify the students information');
}
$r->print(<<END);
+
<input type="hidden" name="sortby" value="$sortby" />
+<input type="hidden" name="sname" value="" />
+<input type="hidden" name="sdom" value="" />
<p>
<table border=2>
<tr><th>
@@ -883,9 +888,12 @@
$username,
$domain));
} elsif ($linkto eq 'modify') {
- $r->print('<a href="/adm/dropadd?action=modifystudent'.
- '&state=selected'.'&sname='.$username.
- '&sdom='.$domain.'&sortby='.$sortby.'">'.
+ $r->print('<a href="'.
+ "javascript:document.studentform.sname.value='".
+ $username.
+ "';document.studentform.sdom.value='".$domain.
+ "';document.studentform.state.value='selected".
+ "';document.studentform.submit();".'">'.
$username."</a>\n");
}
$r->print(<<"END");
@@ -921,7 +929,7 @@
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'};
@@ -949,6 +957,11 @@
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(<<END);
<p>
@@ -961,6 +974,8 @@
<input type="hidden" name="action" value="modifystudent" />
<input type="hidden" name="state" value="done" />
<input type="hidden" name="sortby" value="$sortby" />
+<input type="hidden" name="Status" value="$ENV{'form.Status'}" />
+
<h2>Modify Enrollment for $info{'firstname'} $info{'middlename'}
$info{'lastname'} $info{'generation'}, $sname\@$sdom</h2>
<p>
@@ -998,8 +1013,10 @@
#
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'};
@@ -1010,6 +1027,8 @@
['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 ".
@@ -1071,11 +1090,14 @@
<td> <b>ID</b> </td>
<td> $old{'id'} </td>
<td> $sid </td>
+</tr><tr>
+ <td> <b>Section</b> </td>
+ <td> $old{'section'} </td>
+ <td> $section</td>
</tr>
</table>
<h3>Role Information</h3>
<table>
-<tr><td>Section </td><td> $section </td></tr>
<tr><td>Start Time </td><td> $displayable_starttime </td></tr>
<tr><td>End Time </td><td> $displayable_endtime </td></tr>
</table>
@@ -1106,7 +1128,10 @@
}
$r->print(<<END);
</p><p>
-<a href="/adm/dropadd?action=modifystudent&sortby=$sortby">Modify another students data</a>
+<input type="hidden" name="action" value="modifystudent" />
+<input type="hidden" name="sortby" value="$sortby" />
+<input type="hidden" name="Status" value="$status" />
+<a href="javascript:document.studentform.submit();">Modify another students data</a>
</body></html>
END
return;
@@ -1175,8 +1200,10 @@
sub show_drop_list {
my ($r,$classlist,$keylist,$nosort)=@_;
my $cid=$ENV{'request.course.id'};
- &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
- ['sortby']);
+ if (! exists($ENV{'form.sortby'})) {
+ &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
+ ['sortby']);
+ }
my $sortby = $ENV{'form.sortby'};
if ($sortby !~ /^(username|domain|section|fullname|id)$/) {
$sortby = 'username';
@@ -1502,14 +1529,14 @@
my $result = &modifystudent($udom,$uname,$ENV{'request.course.id'});
if ($result eq 'ok' || $result eq 'ok:') {
$r->print('Dropped '.$uname.' @ '.$udom.'<br>');
+ $count++;
} else {
$r->print('Error dropping '.$uname.' @ '.$udom.': '.$result.
'<br />');
}
- $count++;
}
$r->print('<p><b>Dropped '.$count.' student(s).</b>');
- $r->print('<p>Re-enrollment will re-activate data.');
+ $r->print('<p>Re-enrollment will re-activate data.') if ($count);
}
###################################################################