From: <we...@ma...> - 2005-05-26 18:20:14
|
Log Message: ----------- Allow sorting by first name, last name, or email address. Also default sorting is by last name, then by first name, then by user_id where as before it was by last name only. Modified Files: -------------- webwork-modperl/lib/WeBWorK/ContentGenerator/Instructor: StudentProgress.pm Revision Data ------------- Index: StudentProgress.pm =================================================================== RCS file: /webwork/cvs/system/webwork-modperl/lib/WeBWorK/ContentGenerator/Instructor/StudentProgress.pm,v retrieving revision 1.11 retrieving revision 1.12 diff -Llib/WeBWorK/ContentGenerator/Instructor/StudentProgress.pm -Llib/WeBWorK/ContentGenerator/Instructor/StudentProgress.pm -u -r1.11 -r1.12 --- lib/WeBWorK/ContentGenerator/Instructor/StudentProgress.pm +++ lib/WeBWorK/ContentGenerator/Instructor/StudentProgress.pm @@ -283,6 +283,9 @@ my $sort_method = sub { my ($a,$b) = @_; return 0 unless defined($sort_method_name); + return lc($a->{last_name}) cmp lc($b->{last_name}) if $sort_method_name eq 'last_name'; + return lc($a->{first_name}) cmp lc($b->{first_name}) if $sort_method_name eq 'first_name'; + return lc($a->{email_address}) cmp lc($b->{email_address}) if $sort_method_name eq 'email_address'; return $b->{score} <=> $a->{score} if $sort_method_name eq 'score'; return $b->{index} <=> $a->{index} if $sort_method_name eq 'index'; return $a->{section} cmp $b->{section} if $sort_method_name eq 'section'; @@ -473,9 +476,16 @@ } $WeBWorK::timer->continue("end mainloop") if defined($WeBWorK::timer); - @augmentedUserRecords = sort { &$sort_method($a,$b) - || - lc($a->{last_name}) cmp lc($b->{last_name} ) } @augmentedUserRecords; + @augmentedUserRecords = sort { + &$sort_method($a,$b) + || + lc($a->{last_name}) cmp lc($b->{last_name}) + || + lc($a->{first_name}) cmp lc($b->{first_name}) + || + $a->{user_id} cmp $b->{user_id} + } + @augmentedUserRecords; # construct header @@ -497,22 +507,24 @@ 'or 0 if there are no attempts.' ), CGI::br(), - "Click on student's name to see the student's version of the problem set; + "Click on student's name to see the student's version of the problem set. Click heading to sort table. ", CGI::br(), CGI::br(), - defined($sort_method_name) ?" sort method is $sort_method_name":"", + defined($sort_method_name) ?" Entries are sorted by $sort_method_name":"", CGI::start_table({-border=>5,style=>'font-size:smaller'}), CGI::Tr(CGI::td( {-align=>'left'}, - [CGI::a({"href"=>$self->systemLink($setStatsPage,params=>{sort=>'name' })},'Name'), - CGI::a({"href"=>$self->systemLink($setStatsPage,params=>{sort=>'score'})},'Score'), - 'Out'.CGI::br().'Of', - CGI::a({"href"=>$self->systemLink($setStatsPage,params=>{sort=>'index'})},'Ind'), - 'Problems'.CGI::br().$problem_header, - CGI::a({"href"=>$self->systemLink($setStatsPage,params=>{sort=>'section'})},'Section'), - CGI::a({"href"=>$self->systemLink($setStatsPage,params=>{sort=>'recitation'})},'Recitation'), - CGI::a({"href"=>$self->systemLink($setStatsPage,params=>{sort=>'user_id'})},'Login Name'), - ]) + ['Name'.CGI::br().CGI::a({"href"=>$self->systemLink($setStatsPage,params=>{sort=>'first_name' })},'First'). + ' '.CGI::a({"href"=>$self->systemLink($setStatsPage,params=>{sort=>'last_name' })},'Last').CGI::br(). + CGI::a({"href"=>$self->systemLink($setStatsPage,params=>{sort=>'email_address' })},'Email'), + CGI::a({"href"=>$self->systemLink($setStatsPage,params=>{sort=>'score'})},'Score'), + 'Out'.CGI::br().'Of', + CGI::a({"href"=>$self->systemLink($setStatsPage,params=>{sort=>'index'})},'Ind'), + 'Problems'.CGI::br().$problem_header, + CGI::a({"href"=>$self->systemLink($setStatsPage,params=>{sort=>'section'})},'Section'), + CGI::a({"href"=>$self->systemLink($setStatsPage,params=>{sort=>'recitation'})},'Recitation'), + CGI::a({"href"=>$self->systemLink($setStatsPage,params=>{sort=>'user_id'})},'Login Name'), + ]) ); |