| … | |
… | |
| 69 | use CGI qw(); |
69 | use CGI qw(); |
| 70 | use WeBWorK::File::Classlist; |
70 | use WeBWorK::File::Classlist; |
| 71 | use WeBWorK::Utils qw(readFile readDirectory cryptPassword); |
71 | use WeBWorK::Utils qw(readFile readDirectory cryptPassword); |
| 72 | use WeBWorK::Authen qw(checkKey); |
72 | use WeBWorK::Authen qw(checkKey); |
| 73 | use Apache::Constants qw(:common REDIRECT DONE); #FIXME -- this should be called higher up in the object tree. |
73 | use Apache::Constants qw(:common REDIRECT DONE); #FIXME -- this should be called higher up in the object tree. |
| 74 | use constant HIDE_USERS_THRESHHOLD => 50; |
74 | use constant HIDE_USERS_THRESHHOLD => 200; |
| 75 | use constant EDIT_FORMS => [qw(cancelEdit saveEdit)]; |
75 | use constant EDIT_FORMS => [qw(cancelEdit saveEdit)]; |
| 76 | use constant PASSWORD_FORMS => [qw(cancelPassword savePassword)]; |
76 | use constant PASSWORD_FORMS => [qw(cancelPassword savePassword)]; |
| 77 | use constant VIEW_FORMS => [qw(filter sort edit password import export add delete)]; |
77 | use constant VIEW_FORMS => [qw(filter sort edit password import export add delete)]; |
| 78 | |
78 | |
| 79 | # permissions needed to perform a given action |
79 | # permissions needed to perform a given action |
| … | |
… | |
| 92 | use constant FIELD_PERMS => { |
92 | use constant FIELD_PERMS => { |
| 93 | act_as => "become_student", |
93 | act_as => "become_student", |
| 94 | sets => "assign_problem_sets", |
94 | sets => "assign_problem_sets", |
| 95 | }; |
95 | }; |
| 96 | |
96 | |
| 97 | 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)]; |
97 | # Use param v_u in place of visible_users to shorten URL's in GET methods around line 1600 below. |
|
|
98 | # This is a hack to get around: Maximum URL Length Is 2,083 Characters in Internet Explorer. |
|
|
99 | # v_u appears 6 times in the code. Maybe we should replace the GET method by POST --- AKP |
|
|
100 | 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)]; |
| 98 | |
101 | |
| 99 | use constant SORT_SUBS => { |
102 | use constant SORT_SUBS => { |
| 100 | user_id => \&byUserID, |
103 | user_id => \&byUserID, |
| 101 | first_name => \&byFirstName, |
104 | first_name => \&byFirstName, |
| 102 | last_name => \&byLastName, |
105 | last_name => \&byLastName, |
| … | |
… | |
| 309 | |
312 | |
| 310 | my @allUserIDs = $db->listUsers; |
313 | my @allUserIDs = $db->listUsers; |
| 311 | $self->{totalSets} = $db->listGlobalSets; # save for use in "assigned sets" links |
314 | $self->{totalSets} = $db->listGlobalSets; # save for use in "assigned sets" links |
| 312 | $self->{allUserIDs} = \@allUserIDs; |
315 | $self->{allUserIDs} = \@allUserIDs; |
| 313 | |
316 | |
| 314 | if (defined $r->param("visible_users")) { |
317 | if (defined $r->param("v_u")) { |
| 315 | $self->{visibleUserIDs} = [ $r->param("visible_users") ]; |
318 | $self->{visibleUserIDs} = [ $r->param("v_u") ]; |
| 316 | } elsif (defined $r->param("no_visible_users")) { |
319 | } elsif (defined $r->param("no_visible_users")) { |
| 317 | $self->{visibleUserIDs} = []; |
320 | $self->{visibleUserIDs} = []; |
| 318 | } else { |
321 | } else { |
| 319 | if (@allUserIDs > HIDE_USERS_THRESHHOLD) { |
322 | if ((@allUserIDs > HIDE_USERS_THRESHHOLD) and (not defined $r->param("show_all_users") )) { |
| 320 | $self->{visibleUserIDs} = []; |
323 | $self->{visibleUserIDs} = []; |
| 321 | } else { |
324 | } else { |
| 322 | $self->{visibleUserIDs} = [ @allUserIDs ]; |
325 | $self->{visibleUserIDs} = [ @allUserIDs ]; |
| 323 | } |
326 | } |
| 324 | } |
327 | } |
| … | |
… | |
| 481 | ########## print state data |
484 | ########## print state data |
| 482 | |
485 | |
| 483 | print "\n<!-- state data here -->\n"; |
486 | print "\n<!-- state data here -->\n"; |
| 484 | |
487 | |
| 485 | if (@visibleUserIDs) { |
488 | if (@visibleUserIDs) { |
| 486 | print CGI::hidden(-name=>"visible_users", -value=>\@visibleUserIDs); |
489 | print CGI::hidden(-name=>"v_u", -value=>\@visibleUserIDs); |
| 487 | } else { |
490 | } else { |
| 488 | print CGI::hidden(-name=>"no_visible_users", -value=>"1"); |
491 | print CGI::hidden(-name=>"no_visible_users", -value=>"1"); |
| 489 | } |
492 | } |
| 490 | |
493 | |
| 491 | if (@prevVisibleUserIDs) { |
494 | if (@prevVisibleUserIDs) { |
| … | |
… | |
| 1448 | userID => $User->user_id |
1451 | userID => $User->user_id |
| 1449 | }), |
1452 | }), |
| 1450 | params => {effectiveUser => $User->user_id} |
1453 | params => {effectiveUser => $User->user_id} |
| 1451 | ); |
1454 | ); |
| 1452 | |
1455 | |
| 1453 | my $userListURL = $self->systemLink($urlpath->new(type=>'instructor_user_list', args=>{courseID => $courseName} )) . "&editMode=1&visible_users=" . $User->user_id; |
1456 | my $userListURL = $self->systemLink($urlpath->new(type=>'instructor_user_list', args=>{courseID => $courseName} )) . "&editMode=1&v_u=" . $User->user_id; |
| 1454 | |
1457 | |
| 1455 | my $imageURL = $ce->{webworkURLs}->{htdocs}."/images/edit.gif"; |
1458 | my $imageURL = $ce->{webworkURLs}->{htdocs}."/images/edit.gif"; |
| 1456 | my $imageLink = CGI::a({href => $userListURL}, CGI::img({src=>$imageURL, border=>0})); |
1459 | my $imageLink = CGI::a({href => $userListURL}, CGI::img({src=>$imageURL, border=>0})); |
| 1457 | |
1460 | |
| 1458 | my @tableCells; |
1461 | my @tableCells; |
| … | |
… | |
| 1576 | # prepend selection checkbox? only if we're NOT editing! |
1579 | # prepend selection checkbox? only if we're NOT editing! |
| 1577 | unless($editMode or $passwordMode) { |
1580 | unless($editMode or $passwordMode) { |
| 1578 | |
1581 | |
| 1579 | #warn "line 1573 visibleUserIDs=@visableUserIDs \n"; |
1582 | #warn "line 1573 visibleUserIDs=@visableUserIDs \n"; |
| 1580 | my %current_state =(); |
1583 | my %current_state =(); |
| 1581 | if (@visableUserIDs) { |
1584 | if (@visableUserIDs) { |
|
|
1585 | # This is a hack to get around: Maximum URL Length Is 2,083 Characters in Internet Explorer. |
|
|
1586 | # Without passing visable users the URL is about 270 characters. If the total URL is under the limit |
|
|
1587 | # we will pass visable users. If it is over, we will not pass any and all users will be displayed. |
|
|
1588 | # Maybe we should replace the GET method by POST --- AKP |
|
|
1589 | |
|
|
1590 | # calculate number of visableUserIDs and total length |
|
|
1591 | my $number_of_visableUserIDs = scalar(@visableUserIDs); |
|
|
1592 | my $total_length = 0; |
|
|
1593 | foreach (@visableUserIDs) {$total_length += length} |
|
|
1594 | # warn ("Number of visable users is $number_of_visableUserIDs. Total length of ids is $total_length\n"); |
|
|
1595 | if ($total_length + 9*$number_of_visableUserIDs < 1800) { |
| 1582 | %current_state = ( |
1596 | %current_state = ( |
|
|
1597 | primarySortField => "$primarySortField", |
|
|
1598 | secondarySortField => "$secondarySortField", |
|
|
1599 | v_u => \@visableUserIDs |
|
|
1600 | ); |
|
|
1601 | } else { |
|
|
1602 | %current_state = ( |
| 1583 | primarySortField => "$primarySortField", |
1603 | primarySortField => "$primarySortField", |
| 1584 | secondarySortField => "$secondarySortField", |
1604 | secondarySortField => "$secondarySortField", |
| 1585 | visible_users => \@visableUserIDs |
1605 | show_all_users => "1" |
| 1586 | ); |
1606 | ); |
|
|
1607 | } |
| 1587 | } else { |
1608 | } else { |
| 1588 | %current_state = ( |
1609 | %current_state = ( |
| 1589 | primarySortField => "$primarySortField", |
1610 | primarySortField => "$primarySortField", |
| 1590 | secondarySortField => "$secondarySortField", |
1611 | secondarySortField => "$secondarySortField", |
| 1591 | no_visible_users => "1" |
1612 | no_visible_users => "1" |
| 1592 | ); |
1613 | ); |
| 1593 | } |
1614 | } |
| 1594 | @tableHeadings = ( |
1615 | @tableHeadings = ( |
| 1595 | "Select", |
1616 | "Select", |
| 1596 | CGI::a({href => $self->systemLink($urlpath->new(type=>'instructor_user_list', args=>{courseID => $courseName,} ), params=>{labelSortMethod=>'user_id', %current_state})}, 'Login Name'), |
1617 | CGI::a({href => $self->systemLink($urlpath->new(type=>'instructor_user_list', args=>{courseID => $courseName,} ), params=>{labelSortMethod=>'user_id', %current_state})}, 'Login Name'), |
| 1597 | "Login Status", |
1618 | "Login Status", |
| 1598 | "Assigned Sets", |
1619 | "Assigned Sets", |