From: Arnie P. v. a. <we...@ma...> - 2005-06-21 19:46:37
|
Log Message: ----------- Put in hacks to get around: Maximum URL Length Is 2,083 Characters in Internet Explorer. When sorting by clicking labels we use the GET method and send the user_id's of the visable users so that we only sort visable users but for over about 110 students this is above MSIE's limit. If the total URL is under the limit we will pass visable users. If it is over, we will not pass any and all users will be displayed. The is almost enought to amke me use FireFox. Maybe we should replace the GET method by POST but that requires a greater change. Arnie Modified Files: -------------- webwork-modperl/lib/WeBWorK/ContentGenerator/Instructor: UserList.pm Revision Data ------------- Index: UserList.pm =================================================================== RCS file: /webwork/cvs/system/webwork-modperl/lib/WeBWorK/ContentGenerator/Instructor/UserList.pm,v retrieving revision 1.66 retrieving revision 1.67 diff -Llib/WeBWorK/ContentGenerator/Instructor/UserList.pm -Llib/WeBWorK/ContentGenerator/Instructor/UserList.pm -u -r1.66 -r1.67 --- lib/WeBWorK/ContentGenerator/Instructor/UserList.pm +++ lib/WeBWorK/ContentGenerator/Instructor/UserList.pm @@ -71,7 +71,7 @@ use WeBWorK::Utils qw(readFile readDirectory cryptPassword); use WeBWorK::Authen qw(checkKey); use Apache::Constants qw(:common REDIRECT DONE); #FIXME -- this should be called higher up in the object tree. -use constant HIDE_USERS_THRESHHOLD => 50; +use constant HIDE_USERS_THRESHHOLD => 200; use constant EDIT_FORMS => [qw(cancelEdit saveEdit)]; use constant PASSWORD_FORMS => [qw(cancelPassword savePassword)]; use constant VIEW_FORMS => [qw(filter sort edit password import export add delete)]; @@ -94,7 +94,10 @@ sets => "assign_problem_sets", }; -use constant STATE_PARAMS => [qw(user effectiveUser key visible_users no_visible_users prev_visible_users no_prev_visible_users editMode passwordMode primarySortField secondarySortField ternarySortField labelSortMethod)]; +# Use param v_u in place of visible_users to shorten URL's in GET methods around line 1600 below. +# This is a hack to get around: Maximum URL Length Is 2,083 Characters in Internet Explorer. +# v_u appears 6 times in the code. Maybe we should replace the GET method by POST --- AKP +use constant STATE_PARAMS => [qw(user effectiveUser key v_u no_visible_users prev_visible_users no_prev_visible_users editMode passwordMode primarySortField secondarySortField ternarySortField labelSortMethod)]; use constant SORT_SUBS => { user_id => \&byUserID, @@ -311,12 +314,12 @@ $self->{totalSets} = $db->listGlobalSets; # save for use in "assigned sets" links $self->{allUserIDs} = \@allUserIDs; - if (defined $r->param("visible_users")) { - $self->{visibleUserIDs} = [ $r->param("visible_users") ]; + if (defined $r->param("v_u")) { + $self->{visibleUserIDs} = [ $r->param("v_u") ]; } elsif (defined $r->param("no_visible_users")) { $self->{visibleUserIDs} = []; } else { - if (@allUserIDs > HIDE_USERS_THRESHHOLD) { + if ((@allUserIDs > HIDE_USERS_THRESHHOLD) and (not defined $r->param("show_all_users") )) { $self->{visibleUserIDs} = []; } else { $self->{visibleUserIDs} = [ @allUserIDs ]; @@ -483,7 +486,7 @@ print "\n<!-- state data here -->\n"; if (@visibleUserIDs) { - print CGI::hidden(-name=>"visible_users", -value=>\@visibleUserIDs); + print CGI::hidden(-name=>"v_u", -value=>\@visibleUserIDs); } else { print CGI::hidden(-name=>"no_visible_users", -value=>"1"); } @@ -1450,7 +1453,7 @@ params => {effectiveUser => $User->user_id} ); - my $userListURL = $self->systemLink($urlpath->new(type=>'instructor_user_list', args=>{courseID => $courseName} )) . "&editMode=1&visible_users=" . $User->user_id; + my $userListURL = $self->systemLink($urlpath->new(type=>'instructor_user_list', args=>{courseID => $courseName} )) . "&editMode=1&v_u=" . $User->user_id; my $imageURL = $ce->{webworkURLs}->{htdocs}."/images/edit.gif"; my $imageLink = CGI::a({href => $userListURL}, CGI::img({src=>$imageURL, border=>0})); @@ -1578,19 +1581,37 @@ #warn "line 1573 visibleUserIDs=@visableUserIDs \n"; my %current_state =(); - if (@visableUserIDs) { - %current_state = ( - primarySortField => "$primarySortField", - secondarySortField => "$secondarySortField", - visible_users => \@visableUserIDs - ); - } else { + if (@visableUserIDs) { + # This is a hack to get around: Maximum URL Length Is 2,083 Characters in Internet Explorer. + # Without passing visable users the URL is about 270 characters. If the total URL is under the limit + # we will pass visable users. If it is over, we will not pass any and all users will be displayed. + # Maybe we should replace the GET method by POST --- AKP + + # calculate number of visableUserIDs and total length + my $number_of_visableUserIDs = scalar(@visableUserIDs); + my $total_length = 0; + foreach (@visableUserIDs) {$total_length += length} + # warn ("Number of visable users is $number_of_visableUserIDs. Total length of ids is $total_length\n"); + if ($total_length + 9*$number_of_visableUserIDs < 1800) { + %current_state = ( + primarySortField => "$primarySortField", + secondarySortField => "$secondarySortField", + v_u => \@visableUserIDs + ); + } else { + %current_state = ( + primarySortField => "$primarySortField", + secondarySortField => "$secondarySortField", + show_all_users => "1" + ); + } + } else { %current_state = ( primarySortField => "$primarySortField", secondarySortField => "$secondarySortField", no_visible_users => "1" - ); - } + ); + } @tableHeadings = ( "Select", CGI::a({href => $self->systemLink($urlpath->new(type=>'instructor_user_list', args=>{courseID => $courseName,} ), params=>{labelSortMethod=>'user_id', %current_state})}, 'Login Name'), |