[LON-CAPA-cvs] cvs: loncom /interface londropadd.pm
matthew
lon-capa-cvs@mail.lon-capa.org
Thu, 26 Sep 2002 13:29:44 -0000
matthew Thu Sep 26 09:29:44 2002 EDT
Modified files:
/loncom/interface londropadd.pm
Log:
Added sorting of classlist on 'drop students' page. This was done by
cut and paste of code from the other view classlist routine, which shames
me to no end. But not enough to find a better way of doing it right now.
Index: loncom/interface/londropadd.pm
diff -u loncom/interface/londropadd.pm:1.53 loncom/interface/londropadd.pm:1.54
--- loncom/interface/londropadd.pm:1.53 Wed Sep 25 12:16:19 2002
+++ loncom/interface/londropadd.pm Thu Sep 26 09:29:44 2002
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to drop and add students in courses
#
-# $Id: londropadd.pm,v 1.53 2002/09/25 16:16:19 matthew Exp $
+# $Id: londropadd.pm,v 1.54 2002/09/26 13:29:44 matthew Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -558,7 +558,7 @@
sub enroll_single_student {
my $r=shift;
$r->print('<h3>Enrolling Student</h3>');
- $r->print('<p>Enrolling '.$ENV{'form.cuname'}." in domain ".
+ $r->print('<p>Enrolling '.$ENV{'form.cuname'}." \@ ".
$ENV{'form.lcdomain'}.'</p>');
if (($ENV{'form.cuname'})&&($ENV{'form.cuname'}!~/\W/)&&
($ENV{'form.lcdomain'})&&($ENV{'form.lcdomain'}!~/\W/)) {
@@ -790,7 +790,8 @@
if (! scalar(@$student_array)) {
$r->print("There are no students currently enrolled.\n");
} else {
- &show_class_list($r,'csv','nolink','any',$student_array,$student_data);
+ &show_class_list($r,'csv','nolink','csv',
+ 'any',$student_array,$student_data);
}
}
@@ -1131,8 +1132,16 @@
sub show_drop_list {
my ($students,$s_data,$r)=@_;
my $cid=$ENV{'request.course.id'};
- $r->print(<<'END');
-<input type="hidden" name="action" value="drop" />
+ &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
+ ['sortby']);
+ my $sortby = $ENV{'form.sortby'};
+ if ($sortby !~ /^(username|domain|section|fullname|id)$/) {
+ $sortby = 'username';
+ }
+ my $action = "drop";
+ $r->print(<<END);
+<input type="hidden" name="sortby" value="$sortby" />
+<input type="hidden" name="action" value="$action" />
<input type="hidden" name="state" value="done" />
<script>
function checkAll(field) {
@@ -1148,10 +1157,28 @@
<p>
<input type="hidden" name="phase" value="four">
<table border=2>
-<tr><th> </th><th>username</th><th>domain</th>
- <th>ID</th><th>student name</th><th>section</th></tr>
+<tr><th> </th>
+ <th>
+ <a href="/adm/dropadd?action=$action&sortby=username">username</a>
+ </th><th>
+ <a href="/adm/dropadd?action=$action&sortby=domain">domain</a>
+ </th><th>
+ <a href="/adm/dropadd?action=$action&sortby=id">ID</a>
+ </th><th>
+ <a href="/adm/dropadd?action=$action&sortby=fullname">student name</a>
+ </th><th>
+ <a href="/adm/dropadd?action=$action&sortby=section">section</a>
+ </th>
+</tr>
END
- foreach my $student (@$students) {
+ my @Sorted_Students = sort {
+ lc($s_data->{$a.':'.$sortby}) cmp lc($s_data->{$b.':'.$sortby})
+ ||
+ lc($s_data->{$a.':username'}) cmp lc($s_data->{$b.':username'})
+ ||
+ lc($s_data->{$a.':domain'}) cmp lc($s_data->{$b.':domain'})
+ } @$students;
+ foreach my $student (@Sorted_Students) {
my $error;
if (exists($s_data->{$student.':error'})) {
$error = $s_data->{$student.':error'};
@@ -1445,9 +1472,9 @@
my ($uname,$udom)=split(/\:/,$_);
my $result = &modifystudent($udom,$uname,$ENV{'request.course.id'});
if ($result eq 'ok' || $result eq 'ok:') {
- $r->print('Dropped '.$uname.' at '.$udom.'<br>');
+ $r->print('Dropped '.$uname.' @ '.$udom.'<br>');
} else {
- $r->print('Error dropping '.$uname.' at '.$udom.': '.$result.
+ $r->print('Error dropping '.$uname.' @ '.$udom.': '.$result.
'<br />');
}
$count++;