| … | |
… | |
| 257 | |
257 | |
| 258 | # templates for getting field names |
258 | # templates for getting field names |
| 259 | my $userTemplate = $self->{userTemplate} = $db->newUser; |
259 | my $userTemplate = $self->{userTemplate} = $db->newUser; |
| 260 | my $permissionLevelTemplate = $self->{permissionLevelTemplate} = $db->newPermissionLevel; |
260 | my $permissionLevelTemplate = $self->{permissionLevelTemplate} = $db->newPermissionLevel; |
| 261 | |
261 | |
| 262 | return CGI::div({class=>"ResultsWithError"}, CGI::p("You are not authorized to access the instructor tools.")) |
262 | return CGI::div({class=>"ResultsWithError"}, CGI::p($r->maketext("You are not authorized to access the instructor tools."))) |
| 263 | unless $authz->hasPermissions($user, "access_instructor_tools"); |
263 | unless $authz->hasPermissions($user, "access_instructor_tools"); |
| 264 | |
264 | |
| 265 | # This table can be consulted when display-ready forms of field names are needed. |
265 | # This table can be consulted when display-ready forms of field names are needed. |
| 266 | my %prettyFieldNames = map { $_ => $_ } |
266 | my %prettyFieldNames = map { $_ => $_ } |
| 267 | $userTemplate->FIELDS(), |
267 | $userTemplate->FIELDS(), |
| … | |
… | |
| 277 | section |
277 | section |
| 278 | recitation |
278 | recitation |
| 279 | comment |
279 | comment |
| 280 | permission |
280 | permission |
| 281 | )} = ( |
281 | )} = ( |
| 282 | "Login Name", |
282 | $r->maketext("Login Name"), |
| 283 | "First Name", |
283 | $r->maketext("First Name"), |
| 284 | "Last Name", |
284 | $r->maketext("Last Name"), |
| 285 | "Email Address", |
285 | $r->maketext("Email Address"), |
| 286 | "Student ID", |
286 | $r->maketext("Student ID"), |
| 287 | "Status", |
287 | $r->maketext("Status"), |
| 288 | "Section", |
288 | $r->maketext("Section"), |
| 289 | "Recitation", |
289 | $r->maketext("Recitation"), |
| 290 | "Comment", |
290 | $r->maketext("Comment"), |
| 291 | "Permission Level" |
291 | $r->maketext("Permission Level") |
| 292 | ); |
292 | ); |
| 293 | |
293 | |
| 294 | $self->{prettyFieldNames} = \%prettyFieldNames; |
294 | $self->{prettyFieldNames} = \%prettyFieldNames; |
| 295 | ########## set initial values for state fields |
295 | ########## set initial values for state fields |
| 296 | |
296 | |
| … | |
… | |
| 324 | $self->{selectedUserIDs} = []; |
324 | $self->{selectedUserIDs} = []; |
| 325 | } |
325 | } |
| 326 | |
326 | |
| 327 | $self->{editMode} = $r->param("editMode") || 0; |
327 | $self->{editMode} = $r->param("editMode") || 0; |
| 328 | |
328 | |
| 329 | return CGI::div({class=>"ResultsWithError"}, CGI::p("You are not authorized to modify student data")) |
329 | return CGI::div({class=>"ResultsWithError"}, CGI::p($r->maketext("You are not authorized to modify student data"))) |
| 330 | if $self->{editMode} and not $authz->hasPermissions($user, "modify_student_data"); |
330 | if $self->{editMode} and not $authz->hasPermissions($user, "modify_student_data"); |
| 331 | |
331 | |
| 332 | |
332 | |
| 333 | $self->{passwordMode} = $r->param("passwordMode") || 0; |
333 | $self->{passwordMode} = $r->param("passwordMode") || 0; |
| 334 | |
334 | |
| 335 | return CGI::div({class=>"ResultsWithError"}, CGI::p("You are not authorized to modify student data")) |
335 | return CGI::div({class=>"ResultsWithError"}, CGI::p($r->maketext("You are not authorized to modify student data"))) |
| 336 | if $self->{passwordMode} and not $authz->hasPermissions($user, "modify_student_data"); |
336 | if $self->{passwordMode} and not $authz->hasPermissions($user, "modify_student_data"); |
| 337 | |
337 | |
| 338 | if (defined $r->param("labelSortMethod")) { |
338 | if (defined $r->param("labelSortMethod")) { |
| 339 | $self->{primarySortField} = $r->param("labelSortMethod"); |
339 | $self->{primarySortField} = $r->param("labelSortMethod"); |
| 340 | $self->{secondarySortField} = $r->param("primarySortField"); |
340 | $self->{secondarySortField} = $r->param("primarySortField"); |
| … | |
… | |
| 378 | CGI::i($self->$actionHandler(\%genericParams, \%actionParams, \%tableParams)), |
378 | CGI::i($self->$actionHandler(\%genericParams, \%actionParams, \%tableParams)), |
| 379 | '</div>', |
379 | '</div>', |
| 380 | CGI::hr() |
380 | CGI::hr() |
| 381 | ); |
381 | ); |
| 382 | } else { |
382 | } else { |
| 383 | return CGI::div({class=>"ResultsWithError"}, CGI::p("You are not authorized to perform this action.")); |
383 | return CGI::div({class=>"ResultsWithError"}, CGI::p($r->maketext("You are not authorized to perform this action."))); |
| 384 | } |
384 | } |
| 385 | } |
385 | } |
| 386 | |
386 | |
| 387 | ########## retrieve possibly changed values for member fields |
387 | ########## retrieve possibly changed values for member fields |
| 388 | |
388 | |
| … | |
… | |
| 473 | $PermissionLevels[$i] = $PermissionLevel; |
473 | $PermissionLevels[$i] = $PermissionLevel; |
| 474 | } |
474 | } |
| 475 | |
475 | |
| 476 | ########## print site identifying information |
476 | ########## print site identifying information |
| 477 | |
477 | |
| 478 | print WeBWorK::CGI_labeled_input(-type=>"button", -id=>"show_hide", -input_attr=>{-value=>"Show/Hide Site Description", -class=>"button_input"}); |
478 | print WeBWorK::CGI_labeled_input(-type=>"button", -id=>"show_hide", -input_attr=>{-value=>$r->maketext("Show/Hide Site Description"), -class=>"button_input"}); |
| 479 | print CGI::p({-id=>"site_description", -style=>"display:none"}, CGI::em("This is the classlist editor page, where you can view and edit the records of all the students currently enrolled in this course. The top of the page contains forms which allow you to filter which students to view, sort your students in a chosen order, edit student records, give new passwords to students, import/export student records from/to external files, or add/delete students. To use, please select the action you would like to perform, enter in the relevant information in the fields below, and hit the \"Take Action!\" button at the bottom of the form. The bottom of the page contains a table containing the student usernames and their information.")); |
479 | print CGI::p({-id=>"site_description", -style=>"display:none"}, CGI::em($r->maketext("_CLASSLIST_EDITOR_DESCRIPTION"))); |
| 480 | |
480 | |
| 481 | ########## print beginning of form |
481 | ########## print beginning of form |
| 482 | |
482 | |
| 483 | print CGI::start_form({method=>"post", action=>$self->systemLink($urlpath,authen=>0), name=>"userlist", class=>"edit_form"}); |
483 | print CGI::start_form({method=>"post", action=>$self->systemLink($urlpath,authen=>0), name=>"userlist", class=>"edit_form"}); |
| 484 | print $self->hidden_authen_fields(); |
484 | print $self->hidden_authen_fields(); |
| … | |
… | |
| 510 | print "\n<!-- state data here -->\n"; |
510 | print "\n<!-- state data here -->\n"; |
| 511 | |
511 | |
| 512 | ########## print action forms |
512 | ########## print action forms |
| 513 | |
513 | |
| 514 | # print CGI::start_table({}); |
514 | # print CGI::start_table({}); |
| 515 | print CGI::p("Select an action to perform:"); |
515 | print CGI::p($r->maketext("Select an action to perform").":"); |
| 516 | |
516 | |
| 517 | my @formsToShow; |
517 | my @formsToShow; |
| 518 | if ($editMode) { |
518 | if ($editMode) { |
| 519 | @formsToShow = @{ EDIT_FORMS() }; |
519 | @formsToShow = @{ EDIT_FORMS() }; |
| 520 | }elsif ($passwordMode) { |
520 | }elsif ($passwordMode) { |
| … | |
… | |
| 529 | next if FORM_PERMS()->{$actionID} and not $authz->hasPermissions($user, FORM_PERMS()->{$actionID}); |
529 | next if FORM_PERMS()->{$actionID} and not $authz->hasPermissions($user, FORM_PERMS()->{$actionID}); |
| 530 | my $actionForm = "${actionID}_form"; |
530 | my $actionForm = "${actionID}_form"; |
| 531 | my $onChange = "document.userlist.action[$i].checked=true"; |
531 | my $onChange = "document.userlist.action[$i].checked=true"; |
| 532 | my %actionParams = $self->getActionParams($actionID); |
532 | my %actionParams = $self->getActionParams($actionID); |
| 533 | |
533 | |
| 534 | print CGI::div({-class=>"column"},WeBWorK::CGI_labeled_input(-type=>"radio", -id=>$actionID."_id", -label_text=>ucfirst(WeBWorK::split_cap($actionID)), -input_attr=>{-name=>"action", -value=>$actionID}, -label_attr=>{-class=>"radio_label"}),CGI::br(),$self->$actionForm($onChange, %actionParams),CGI::br()); |
534 | print CGI::div({-class=>"column"},WeBWorK::CGI_labeled_input(-type=>"radio", -id=>$actionID."_id", -label_text=>$r->maketext(ucfirst(WeBWorK::split_cap($actionID))), -input_attr=>{-name=>"action", -value=>$actionID}, -label_attr=>{-class=>"radio_label"}),CGI::br(),$self->$actionForm($onChange, %actionParams),CGI::br()); |
| 535 | |
535 | |
| 536 | $i++; |
536 | $i++; |
| 537 | } |
537 | } |
| 538 | my $selectAll =WeBWorK::CGI_labeled_input(-type=>'button', -id=>"select_all", -input_attr=>{-name=>'check_all', -class=>"button_input", -value=>'Select all users', |
538 | my $selectAll =WeBWorK::CGI_labeled_input(-type=>'button', -id=>"select_all", -input_attr=>{-name=>'check_all', -class=>"button_input", -value=>$r->maketext('Select all users'), |
| 539 | onClick => "for (i in document.userlist.elements) { |
539 | onClick => "for (i in document.userlist.elements) { |
| 540 | if (document.userlist.elements[i].name =='selected_users') { |
540 | if (document.userlist.elements[i].name =='selected_users') { |
| 541 | document.userlist.elements[i].checked = true |
541 | document.userlist.elements[i].checked = true |
| 542 | } |
542 | } |
| 543 | }" }); |
543 | }" }); |
| 544 | my $selectNone =WeBWorK::CGI_labeled_input(-type=>'button', -id=>"select_none", -input_attr=>{-name=>'check_none', -class=>"button_input", -value=>'Unselect all users', |
544 | my $selectNone =WeBWorK::CGI_labeled_input(-type=>'button', -id=>"select_none", -input_attr=>{-name=>'check_none', -class=>"button_input", -value=>$r->maketext('Unselect all users'), |
| 545 | onClick => "for (i in document.userlist.elements) { |
545 | onClick => "for (i in document.userlist.elements) { |
| 546 | if (document.userlist.elements[i].name =='selected_users') { |
546 | if (document.userlist.elements[i].name =='selected_users') { |
| 547 | document.userlist.elements[i].checked = false |
547 | document.userlist.elements[i].checked = false |
| 548 | } |
548 | } |
| 549 | }" }); |
549 | }" }); |
| 550 | unless ($editMode or $passwordMode) { |
550 | unless ($editMode or $passwordMode) { |
| 551 | print $selectAll." ". $selectNone; |
551 | print $selectAll." ". $selectNone; |
| 552 | } |
552 | } |
| 553 | print WeBWorK::CGI_labeled_input(-type=>"reset", -id=>"clear_entries", -input_attr=>{-value=>"Clear", -class=>"button_input"}); |
553 | print WeBWorK::CGI_labeled_input(-type=>"reset", -id=>"clear_entries", -input_attr=>{-value=>$r->maketext("Clear"), -class=>"button_input"}); |
| 554 | print WeBWorK::CGI_labeled_input(-type=>"submit", -id=>"take_action", -input_attr=>{-value=>"Take Action!", -class=>"button_input"}).CGI::br().CGI::br(); |
554 | print WeBWorK::CGI_labeled_input(-type=>"submit", -id=>"take_action", -input_attr=>{-value=>$r->maketext("Take Action!"), -class=>"button_input"}).CGI::br().CGI::br(); |
| 555 | # print CGI::end_table(); |
555 | # print CGI::end_table(); |
| 556 | |
556 | |
| 557 | ########## print table |
557 | ########## print table |
| 558 | |
558 | |
| 559 | print CGI::p({},"Showing ", scalar @Users, " out of ", scalar @allUserIDs, " users."); |
559 | print CGI::p({},$r->maketext("Showing [_1] out of [_2] users", scalar @Users, scalar @allUserIDs)); |
| 560 | |
560 | |
| 561 | print CGI::p("If a password field is left blank, the student's current password will be maintained.") if $passwordMode; |
561 | print CGI::p($r->maketext("If a password field is left blank, the student's current password will be maintained.")) if $passwordMode; |
| 562 | if ($editMode) { |
562 | if ($editMode) { |
| 563 | |
563 | |
| 564 | |
564 | |
| 565 | print CGI::p('<b>Click</b> on the login name to <b>edit individual problem set data</b>, (e.g. due dates) for these students.'); |
565 | print CGI::p($r->maketext('Click on the login name to edit individual problem set data, (e.g. due dates) for these students.')); |
| 566 | } |
566 | } |
| 567 | $self->printTableHTML(\@Users, \@PermissionLevels, \%prettyFieldNames, |
567 | $self->printTableHTML(\@Users, \@PermissionLevels, \%prettyFieldNames, |
| 568 | editMode => $editMode, |
568 | editMode => $editMode, |
| 569 | passwordMode => $passwordMode, |
569 | passwordMode => $passwordMode, |
| 570 | selectedUserIDs => \@selectedUserIDs, |
570 | selectedUserIDs => \@selectedUserIDs, |
| … | |
… | |
| 619 | |
619 | |
| 620 | sub filter_form { |
620 | sub filter_form { |
| 621 | my ($self, $onChange, %actionParams) = @_; |
621 | my ($self, $onChange, %actionParams) = @_; |
| 622 | #return CGI::table({}, CGI::Tr({-valign=>"top"}, |
622 | #return CGI::table({}, CGI::Tr({-valign=>"top"}, |
| 623 | # CGI::td({}, |
623 | # CGI::td({}, |
|
|
624 | my $r = $self->r; |
| 624 | |
625 | |
| 625 | my %prettyFieldNames = %{ $self->{prettyFieldNames} }; |
626 | my %prettyFieldNames = %{ $self->{prettyFieldNames} }; |
| 626 | |
627 | |
| 627 | return join("", |
628 | return join("", |
| 628 | # "Show ", |
629 | # "Show ", |
| … | |
… | |
| 642 | # -onchange => $onChange, |
643 | # -onchange => $onChange, |
| 643 | # ), |
644 | # ), |
| 644 | WeBWorK::CGI_labeled_input( |
645 | WeBWorK::CGI_labeled_input( |
| 645 | -type=>"select", |
646 | -type=>"select", |
| 646 | -id=>"filter_select", |
647 | -id=>"filter_select", |
| 647 | -label_text=>"Show Which Users?: ", |
648 | -label_text=>$r->maketext("Show Which Users?").": ", |
| 648 | -input_attr=>{ |
649 | -input_attr=>{ |
| 649 | -name => "action.filter.scope", |
650 | -name => "action.filter.scope", |
| 650 | -values => [qw(all none selected match_regex)], |
651 | -values => [qw(all none selected match_regex)], |
| 651 | -default => $actionParams{"action.filter.scope"}->[0] || "match_regex", |
652 | -default => $actionParams{"action.filter.scope"}->[0] || "match_regex", |
| 652 | -labels => { |
653 | -labels => { |
| 653 | all => "all users", |
654 | all => $r->maketext("all users"), |
| 654 | none => "no users", |
655 | none => $r->maketext("no users"), |
| 655 | selected => "selected users", |
656 | selected => $r->maketext("selected users"), |
| 656 | match_regex => "users who match on selected field", |
657 | match_regex => $r->maketext("users who match on selected field"), |
| 657 | }, |
658 | }, |
| 658 | -onchange => $onChange, |
659 | -onchange => $onChange, |
| 659 | } |
660 | } |
| 660 | ), |
661 | ), |
| 661 | CGI::br(), |
662 | CGI::br(), |
| 662 | " ", |
663 | " ", |
| 663 | CGI::div({-id=>"filter_elements"}, |
664 | CGI::div({-id=>"filter_elements"}, |
| 664 | WeBWorK::CGI_labeled_input( |
665 | WeBWorK::CGI_labeled_input( |
| 665 | -type=>"select", |
666 | -type=>"select", |
| 666 | -id=>"filter_type_select", |
667 | -id=>"filter_type_select", |
| 667 | -label_text=>"What field should filtered users match on?: ", |
668 | -label_text=>$r->maketext("What field should filtered users match on?").": ", |
| 668 | -input_attr=>{ |
669 | -input_attr=>{ |
| 669 | -name => "action.filter.field", |
670 | -name => "action.filter.field", |
| 670 | -value => [ keys %{ FIELD_PROPERTIES() } ], |
671 | -value => [ keys %{ FIELD_PROPERTIES() } ], |
| 671 | -default => $actionParams{"action.filter.field"}->[0] || "user_id", |
672 | -default => $actionParams{"action.filter.field"}->[0] || "user_id", |
| 672 | -labels => \%prettyFieldNames, |
673 | -labels => \%prettyFieldNames, |
| … | |
… | |
| 675 | ), |
676 | ), |
| 676 | CGI::br(), |
677 | CGI::br(), |
| 677 | WeBWorK::CGI_labeled_input( |
678 | WeBWorK::CGI_labeled_input( |
| 678 | -type=>"text", |
679 | -type=>"text", |
| 679 | -id=>"filter_text", |
680 | -id=>"filter_text", |
| 680 | -label_text=>"Filter by what text?: ", |
681 | -label_text=>$r->maketext("Filter by what text?").": ", |
| 681 | -input_attr=>{ |
682 | -input_attr=>{ |
| 682 | -name => "action.filter.user_ids", |
683 | -name => "action.filter.user_ids", |
| 683 | -value => $actionParams{"action.filter.user_ids"}->[0] || "",, |
684 | -value => $actionParams{"action.filter.user_ids"}->[0] || "",, |
| 684 | -width => "50", |
685 | -width => "50", |
| 685 | -onchange => $onChange, |
686 | -onchange => $onChange, |
| … | |
… | |
| 776 | return $result; |
777 | return $result; |
| 777 | } |
778 | } |
| 778 | |
779 | |
| 779 | sub sort_form { |
780 | sub sort_form { |
| 780 | my ($self, $onChange, %actionParams) = @_; |
781 | my ($self, $onChange, %actionParams) = @_; |
|
|
782 | my $r = $self->r; |
|
|
783 | |
| 781 | return join ("", |
784 | return join ("", |
| 782 | # "Sort by ", |
785 | # "Sort by ", |
| 783 | # CGI::popup_menu( |
786 | # CGI::popup_menu( |
| 784 | # -name => "action.sort.primary", |
787 | # -name => "action.sort.primary", |
| 785 | # -values => [qw(user_id first_name last_name email_address student_id status section recitation comment permission)], |
788 | # -values => [qw(user_id first_name last_name email_address student_id status section recitation comment permission)], |
| … | |
… | |
| 799 | # -onchange => $onChange, |
802 | # -onchange => $onChange, |
| 800 | # ), |
803 | # ), |
| 801 | WeBWorK::CGI_labeled_input( |
804 | WeBWorK::CGI_labeled_input( |
| 802 | -type=>"select", |
805 | -type=>"select", |
| 803 | -id=>"sort_select_1", |
806 | -id=>"sort_select_1", |
| 804 | -label_text=>"Sort by: ", |
807 | -label_text=>$r->maketext("Sort by").": ", |
| 805 | -input_attr=>{ |
808 | -input_attr=>{ |
| 806 | -name => "action.sort.primary", |
809 | -name => "action.sort.primary", |
| 807 | -values => [qw(user_id first_name last_name email_address student_id status section recitation comment permission)], |
810 | -values => [qw(user_id first_name last_name email_address student_id status section recitation comment permission)], |
| 808 | -default => $actionParams{"action.sort.primary"}->[0] || "last_name", |
811 | -default => $actionParams{"action.sort.primary"}->[0] || "last_name", |
| 809 | -labels => { |
812 | -labels => { |
| 810 | user_id => "Login Name", |
813 | user_id => $r->maketext("Login Name"), |
| 811 | first_name => "First Name", |
814 | first_name => $r->maketext("First Name"), |
| 812 | last_name => "Last Name", |
815 | last_name => $r->maketext("Last Name"), |
| 813 | email_address => "Email Address", |
816 | email_address => $r->maketext("Email Address"), |
| 814 | student_id => "Student ID", |
817 | student_id => $r->maketext("Student ID"), |
| 815 | status => "Enrollment Status", |
818 | status => $r->maketext("Enrollment Status"), |
| 816 | section => "Section", |
819 | section => $r->maketext("Section"), |
| 817 | recitation => "Recitation", |
820 | recitation => $r->maketext("Recitation"), |
| 818 | comment => "Comment", |
821 | comment => $r->maketext("Comment"), |
| 819 | permission => "Permission Level" |
822 | permission => $r->maketext("Permission Level") |
| 820 | }, |
823 | }, |
| 821 | -onchange => $onChange, |
824 | -onchange => $onChange, |
| 822 | }, |
825 | }, |
| 823 | ), |
826 | ), |
| 824 | CGI::br(), |
827 | CGI::br(), |
| … | |
… | |
| 842 | # -onchange => $onChange, |
845 | # -onchange => $onChange, |
| 843 | # ), |
846 | # ), |
| 844 | WeBWorK::CGI_labeled_input( |
847 | WeBWorK::CGI_labeled_input( |
| 845 | -type=>"select", |
848 | -type=>"select", |
| 846 | -id=>"sort_select_2", |
849 | -id=>"sort_select_2", |
| 847 | -label_text=>"Then by: ", |
850 | -label_text=>$r->maketext("Then by").": ", |
| 848 | -input_attr=>{ |
851 | -input_attr=>{ |
| 849 | -name => "action.sort.secondary", |
852 | -name => "action.sort.secondary", |
| 850 | -values => [qw(user_id first_name last_name email_address student_id status section recitation comment permission)], |
853 | -values => [qw(user_id first_name last_name email_address student_id status section recitation comment permission)], |
| 851 | -default => $actionParams{"action.sort.secondary"}->[0] || "first_name", |
854 | -default => $actionParams{"action.sort.secondary"}->[0] || "first_name", |
| 852 | -labels => { |
855 | -labels => { |
| 853 | user_id => "Login Name", |
856 | user_id => $r->maketext("Login Name"), |
| 854 | first_name => "First Name", |
857 | first_name => $r->maketext("First Name"), |
| 855 | last_name => "Last Name", |
858 | last_name => $r->maketext("Last Name"), |
| 856 | email_address => "Email Address", |
859 | email_address => $r->maketext("Email Address"), |
| 857 | student_id => "Student ID", |
860 | student_id => $r->maketext("Student ID"), |
| 858 | status => "Enrollment Status", |
861 | status => $r->maketext("Enrollment Status"), |
| 859 | section => "Section", |
862 | section => $r->maketext("Section"), |
| 860 | recitation => "Recitation", |
863 | recitation => $r->maketext("Recitation"), |
| 861 | comment => "Comment", |
864 | comment => $r->maketext("Comment"), |
| 862 | permission => "Permission Level" |
865 | permission => $r->maketext("Permission Level") |
| 863 | }, |
866 | }, |
| 864 | -onchange => $onChange, |
867 | -onchange => $onChange, |
| 865 | }, |
868 | }, |
| 866 | ), |
869 | ), |
| 867 | CGI::br(), |
870 | CGI::br(), |
| … | |
… | |
| 885 | # -onchange => $onChange, |
888 | # -onchange => $onChange, |
| 886 | # ), |
889 | # ), |
| 887 | WeBWorK::CGI_labeled_input( |
890 | WeBWorK::CGI_labeled_input( |
| 888 | -type=>"select", |
891 | -type=>"select", |
| 889 | -id=>"sort_select_3", |
892 | -id=>"sort_select_3", |
| 890 | -label_text=>"Then by: ", |
893 | -label_text=>$r->maketext("Then by").": ", |
| 891 | -input_attr=>{ |
894 | -input_attr=>{ |
| 892 | -name => "action.sort.ternary", |
895 | -name => "action.sort.ternary", |
| 893 | -values => [qw(user_id first_name last_name email_address student_id status section recitation comment permission)], |
896 | -values => [qw(user_id first_name last_name email_address student_id status section recitation comment permission)], |
| 894 | -default => $actionParams{"action.sort.ternary"}->[0] || "user_id", |
897 | -default => $actionParams{"action.sort.ternary"}->[0] || "user_id", |
| 895 | -labels => { |
898 | -labels => { |
| 896 | user_id => "Login Name", |
899 | user_id => $r->maketext("Login Name"), |
| 897 | first_name => "First Name", |
900 | first_name => $r->maketext("First Name"), |
| 898 | last_name => "Last Name", |
901 | last_name => $r->maketext("Last Name"), |
| 899 | email_address => "Email Address", |
902 | email_address => $r->maketext("Email Address"), |
| 900 | student_id => "Student ID", |
903 | student_id => $r->maketext("Student ID"), |
| 901 | status => "Enrollment Status", |
904 | status => $r->maketext("Enrollment Status"), |
| 902 | section => "Section", |
905 | section => $r->maketext("Section"), |
| 903 | recitation => "Recitation", |
906 | recitation => $r->maketext("Recitation"), |
| 904 | comment => "Comment", |
907 | comment => $r->maketext("Comment"), |
| 905 | permission => "Permission Level" |
908 | permission => $r->maketext("Permission Level") |
| 906 | }, |
909 | }, |
| 907 | -onchange => $onChange, |
910 | -onchange => $onChange, |
| 908 | }, |
911 | }, |
| 909 | ), |
912 | ), |
| 910 | ); |
913 | ); |
| … | |
… | |
| 937 | return "Users sorted by $names{$primary}, then by $names{$secondary}, then by $names{$ternary}."; |
940 | return "Users sorted by $names{$primary}, then by $names{$secondary}, then by $names{$ternary}."; |
| 938 | } |
941 | } |
| 939 | |
942 | |
| 940 | sub edit_form { |
943 | sub edit_form { |
| 941 | my ($self, $onChange, %actionParams) = @_; |
944 | my ($self, $onChange, %actionParams) = @_; |
|
|
945 | my $r = $self->r; |
| 942 | |
946 | |
| 943 | return join("", |
947 | return join("", |
| 944 | # "Edit ", |
948 | # "Edit ", |
| 945 | # CGI::popup_menu( |
949 | # CGI::popup_menu( |
| 946 | # -name => "action.edit.scope", |
950 | # -name => "action.edit.scope", |
| … | |
… | |
| 954 | # -onchange => $onChange, |
958 | # -onchange => $onChange, |
| 955 | # ), |
959 | # ), |
| 956 | WeBWorK::CGI_labeled_input( |
960 | WeBWorK::CGI_labeled_input( |
| 957 | -type=>"select", |
961 | -type=>"select", |
| 958 | -id=>"edit_select", |
962 | -id=>"edit_select", |
| 959 | -label_text=>"Edit Which Users?: ", |
963 | -label_text=>$r->maketext("Edit Which Users?").": ", |
| 960 | -input_attr=>{ |
964 | -input_attr=>{ |
| 961 | -name => "action.edit.scope", |
965 | -name => "action.edit.scope", |
| 962 | -values => [qw(all visible selected)], |
966 | -values => [qw(all visible selected)], |
| 963 | -default => $actionParams{"action.edit.scope"}->[0] || "selected", |
967 | -default => $actionParams{"action.edit.scope"}->[0] || "selected", |
| 964 | -labels => { |
968 | -labels => { |
| 965 | all => "all users", |
969 | all => $r->maketext("all users"), |
| 966 | visible => "visible users", |
970 | visible => $r->maketext("visible users"), |
| 967 | selected => "selected users" |
971 | selected => $r->maketext("selected users") |
| 968 | }, |
972 | }, |
| 969 | -onchange => $onChange, |
973 | -onchange => $onChange, |
| 970 | } |
974 | } |
| 971 | ), |
975 | ), |
| 972 | ); |
976 | ); |
| … | |
… | |
| 994 | } |
998 | } |
| 995 | |
999 | |
| 996 | |
1000 | |
| 997 | sub password_form { |
1001 | sub password_form { |
| 998 | my ($self, $onChange, %actionParams) = @_; |
1002 | my ($self, $onChange, %actionParams) = @_; |
|
|
1003 | my $r = $self->r; |
| 999 | |
1004 | |
| 1000 | return join("", |
1005 | return join("", |
| 1001 | # "Give new password to ", |
1006 | # "Give new password to ", |
| 1002 | # CGI::popup_menu( |
1007 | # CGI::popup_menu( |
| 1003 | # -name => "action.password.scope", |
1008 | # -name => "action.password.scope", |
| … | |
… | |
| 1011 | # -onchange => $onChange, |
1016 | # -onchange => $onChange, |
| 1012 | # ), |
1017 | # ), |
| 1013 | WeBWorK::CGI_labeled_input( |
1018 | WeBWorK::CGI_labeled_input( |
| 1014 | -type=>"select", |
1019 | -type=>"select", |
| 1015 | -id=>"password_select", |
1020 | -id=>"password_select", |
| 1016 | -label_text=>"Give new password to which users?: ", |
1021 | -label_text=>$r->maketext("Give new password to which users?").": ", |
| 1017 | -input_attr=>{ |
1022 | -input_attr=>{ |
| 1018 | -name => "action.password.scope", |
1023 | -name => "action.password.scope", |
| 1019 | -values => [qw(all visible selected)], |
1024 | -values => [qw(all visible selected)], |
| 1020 | -default => $actionParams{"action.password.scope"}->[0] || "selected", |
1025 | -default => $actionParams{"action.password.scope"}->[0] || "selected", |
| 1021 | -labels => { |
1026 | -labels => { |
| 1022 | all => "all users", |
1027 | all => $r->maketext("all users"), |
| 1023 | visible => "visible users", |
1028 | visible => $r->maketext("visible users"), |
| 1024 | selected => "selected users" |
1029 | selected => $r->maketext("selected users") |
| 1025 | }, |
1030 | }, |
| 1026 | -onchange => $onChange, |
1031 | -onchange => $onChange, |
| 1027 | }, |
1032 | }, |
| 1028 | ), |
1033 | ), |
| 1029 | ); |
1034 | ); |
| … | |
… | |
| 1050 | return $result; |
1055 | return $result; |
| 1051 | } |
1056 | } |
| 1052 | |
1057 | |
| 1053 | sub delete_form { |
1058 | sub delete_form { |
| 1054 | my ($self, $onChange, %actionParams) = @_; |
1059 | my ($self, $onChange, %actionParams) = @_; |
|
|
1060 | my $r = $self->r; |
| 1055 | |
1061 | |
| 1056 | return join("", |
1062 | return join("", |
| 1057 | # CGI::div({class=>"ResultsWithError"}, |
1063 | # CGI::div({class=>"ResultsWithError"}, |
| 1058 | # "Delete ", |
1064 | # "Delete ", |
| 1059 | # CGI::popup_menu( |
1065 | # CGI::popup_menu( |
| … | |
… | |
| 1067 | # }, |
1073 | # }, |
| 1068 | # -onchange => $onChange, |
1074 | # -onchange => $onChange, |
| 1069 | # ), |
1075 | # ), |
| 1070 | # CGI::em(" Deletion destroys all user-related data and is not undoable!"), |
1076 | # CGI::em(" Deletion destroys all user-related data and is not undoable!"), |
| 1071 | # ), |
1077 | # ), |
| 1072 | CGI::span({-class=>"ResultsWithError"}, CGI::em("Warning: Deletion destroys all user-related data and is not undoable!")),CGI::br(), |
1078 | CGI::span({-class=>"ResultsWithError"}, CGI::em($r->maketext("Warning: Deletion destroys all user-related data and is not undoable!"))),CGI::br(), |
| 1073 | WeBWorK::CGI_labeled_input( |
1079 | WeBWorK::CGI_labeled_input( |
| 1074 | -type=>"select", |
1080 | -type=>"select", |
| 1075 | -id=>"delete_select", |
1081 | -id=>"delete_select", |
| 1076 | -label_text=>"Delete how many?: ", |
1082 | -label_text=>$r->maketext("Delete how many?").": ", |
| 1077 | -input_attr=>{ |
1083 | -input_attr=>{ |
| 1078 | -name => "action.delete.scope", |
1084 | -name => "action.delete.scope", |
| 1079 | -values => [qw(none selected)], |
1085 | -values => [qw(none selected)], |
| 1080 | -default => $actionParams{"action.delete.scope"}->[0] || "none", |
1086 | -default => $actionParams{"action.delete.scope"}->[0] || "none", |
| 1081 | -labels => { |
1087 | -labels => { |
| 1082 | none => "no users.", |
1088 | none => $r->maketext("no users"), |
| 1083 | # visible => "visible users.", |
1089 | # visible => "visible users", |
| 1084 | selected => "selected users." |
1090 | selected => $r->maketext("selected users") |
| 1085 | }, |
1091 | }, |
| 1086 | -onchange => $onChange, |
1092 | -onchange => $onChange, |
| 1087 | }, |
1093 | }, |
| 1088 | ), |
1094 | ), |
| 1089 | ); |
1095 | ); |
| … | |
… | |
| 1128 | |
1134 | |
| 1129 | return "deleted $num user" . ($num == 1 ? "" : "s. ") . $error; |
1135 | return "deleted $num user" . ($num == 1 ? "" : "s. ") . $error; |
| 1130 | } |
1136 | } |
| 1131 | sub add_form { |
1137 | sub add_form { |
| 1132 | my ($self, $onChange, %actionParams) = @_; |
1138 | my ($self, $onChange, %actionParams) = @_; |
|
|
1139 | my $r = $self->r; |
| 1133 | |
1140 | |
| 1134 | #return "Add ", CGI::input({name=>'number_of_students', value=>1,size => 3}), " student(s). "; |
1141 | #return "Add ", CGI::input({name=>'number_of_students', value=>1,size => 3}), " student(s). "; |
| 1135 | return WeBWorK::CGI_labeled_input(-type=>"text", -id=>"add_entry", -label_text=>"Add how many student(s)?: ", -input_attr=>{name=>'number_of_students', value=>1,size => 3}); |
1142 | return WeBWorK::CGI_labeled_input(-type=>"text", -id=>"add_entry", -label_text=>$r->maketext("Add how many students?").": ", -input_attr=>{name=>'number_of_students', value=>1,size => 3}); |
| 1136 | } |
1143 | } |
| 1137 | |
1144 | |
| 1138 | sub add_handler { |
1145 | sub add_handler { |
| 1139 | my ($self, $genericParams, $actionParams, $tableParams) = @_; |
1146 | my ($self, $genericParams, $actionParams, $tableParams) = @_; |
| 1140 | # This action is redirected to the addUser.pm module using ../instructor/add_user/... |
1147 | # This action is redirected to the addUser.pm module using ../instructor/add_user/... |
| 1141 | return "Nothing done by add student handler"; |
1148 | return "Nothing done by add student handler"; |
| 1142 | } |
1149 | } |
| 1143 | sub import_form { |
1150 | sub import_form { |
| 1144 | my ($self, $onChange, %actionParams) = @_; |
1151 | my ($self, $onChange, %actionParams) = @_; |
|
|
1152 | my $r = $self->r; |
|
|
1153 | |
| 1145 | return join(" ", |
1154 | return join(" ", |
| 1146 | # "Import users from file", |
1155 | # "Import users from file", |
| 1147 | # CGI::popup_menu( |
1156 | # CGI::popup_menu( |
| 1148 | # -name => "action.import.source", |
1157 | # -name => "action.import.source", |
| 1149 | # -values => [ $self->getCSVList() ], |
1158 | # -values => [ $self->getCSVList() ], |
| … | |
… | |
| 1151 | # -onchange => $onChange, |
1160 | # -onchange => $onChange, |
| 1152 | # ), |
1161 | # ), |
| 1153 | WeBWorK::CGI_labeled_input( |
1162 | WeBWorK::CGI_labeled_input( |
| 1154 | -type=>"select", |
1163 | -type=>"select", |
| 1155 | -id=>"import_select_source", |
1164 | -id=>"import_select_source", |
| 1156 | -label_text=>"Import users from what file?: ", |
1165 | -label_text=>$r->maketext("Import users from what file?").": ", |
| 1157 | -input_attr=>{ |
1166 | -input_attr=>{ |
| 1158 | -name => "action.import.source", |
1167 | -name => "action.import.source", |
| 1159 | -values => [ $self->getCSVList() ], |
1168 | -values => [ $self->getCSVList() ], |
| 1160 | -default => $actionParams{"action.import.source"}->[0] || "", |
1169 | -default => $actionParams{"action.import.source"}->[0] || "", |
| 1161 | -onchange => $onChange, |
1170 | -onchange => $onChange, |
| … | |
… | |
| 1176 | # -onchange => $onChange, |
1185 | # -onchange => $onChange, |
| 1177 | # ), |
1186 | # ), |
| 1178 | WeBWorK::CGI_labeled_input( |
1187 | WeBWorK::CGI_labeled_input( |
| 1179 | -type=>"select", |
1188 | -type=>"select", |
| 1180 | -id=>"import_select_replace", |
1189 | -id=>"import_select_replace", |
| 1181 | -label_text=>"Replace which users?: ", |
1190 | -label_text=>$r->maketext("Replace which users?").": ", |
| 1182 | -input_attr=>{ |
1191 | -input_attr=>{ |
| 1183 | -name => "action.import.replace", |
1192 | -name => "action.import.replace", |
| 1184 | -values => [("any users", "visible users", "selected users", "no users")], |
1193 | -values => [qw(any visible selected none)], |
| 1185 | -default => $actionParams{"action.import.replace"}->[0] || "none", |
1194 | -default => $actionParams{"action.import.replace"}->[0] || "none", |
| 1186 | -labels => { |
1195 | -labels => { |
| 1187 | any => "any", |
1196 | any => $r->maketext("any users"), |
| 1188 | visible => "visible", |
1197 | visible => $r->maketext("visible users"), |
| 1189 | selected => "selected", |
1198 | selected => $r->maketext("selected users"), |
| 1190 | none => "no", |
1199 | none => $r->maketext("no users"), |
| 1191 | }, |
1200 | }, |
| 1192 | -onchange => $onChange, |
1201 | -onchange => $onChange, |
| 1193 | } |
1202 | } |
| 1194 | ), |
1203 | ), |
| 1195 | CGI::br(), |
1204 | CGI::br(), |
| … | |
… | |
| 1206 | # ), |
1215 | # ), |
| 1207 | # "new users", |
1216 | # "new users", |
| 1208 | WeBWorK::CGI_labeled_input( |
1217 | WeBWorK::CGI_labeled_input( |
| 1209 | -type=>"select", |
1218 | -type=>"select", |
| 1210 | -id=>"import_select_add", |
1219 | -id=>"import_select_add", |
| 1211 | -label_text=>"Add which new users?: ", |
1220 | -label_text=>$r->maketext("Add which new users?").": ", |
| 1212 | -input_attr=>{ |
1221 | -input_attr=>{ |
| 1213 | -name => "action.import.add", |
1222 | -name => "action.import.add", |
| 1214 | -values => [("any users", "no users")], |
1223 | -values => [qw(any none)], |
| 1215 | -default => $actionParams{"action.import.add"}->[0] || "any", |
1224 | -default => $actionParams{"action.import.add"}->[0] || "any", |
| 1216 | -labels => { |
1225 | -labels => { |
| 1217 | any => "any", |
1226 | any => $r->maketext("any users"), |
| 1218 | none => "no", |
1227 | none => $r->maketext("no users"), |
| 1219 | }, |
1228 | }, |
| 1220 | -onchange => $onChange, |
1229 | -onchange => $onChange, |
| 1221 | } |
1230 | } |
| 1222 | ), |
1231 | ), |
| 1223 | ); |
1232 | ); |
| … | |
… | |
| 1262 | . " (" . join (", ", @$skipped) . ") "; |
1271 | . " (" . join (", ", @$skipped) . ") "; |
| 1263 | } |
1272 | } |
| 1264 | |
1273 | |
| 1265 | sub export_form { |
1274 | sub export_form { |
| 1266 | my ($self, $onChange, %actionParams) = @_; |
1275 | my ($self, $onChange, %actionParams) = @_; |
|
|
1276 | my $r = $self->r; |
|
|
1277 | |
| 1267 | return join("", |
1278 | return join("", |
| 1268 | # "Export ", |
1279 | # "Export ", |
| 1269 | # CGI::popup_menu( |
1280 | # CGI::popup_menu( |
| 1270 | # -name => "action.export.scope", |
1281 | # -name => "action.export.scope", |
| 1271 | # -values => [qw(all visible selected)], |
1282 | # -values => [qw(all visible selected)], |
| … | |
… | |
| 1278 | # -onchange => $onChange, |
1289 | # -onchange => $onChange, |
| 1279 | # ), |
1290 | # ), |
| 1280 | WeBWorK::CGI_labeled_input( |
1291 | WeBWorK::CGI_labeled_input( |
| 1281 | -type=>"select", |
1292 | -type=>"select", |
| 1282 | -id=>"export_select_scope", |
1293 | -id=>"export_select_scope", |
| 1283 | -label_text=>"Export which users?: ", |
1294 | -label_text=>$r->maketext("Export which users?").": ", |
| 1284 | -input_attr=>{ |
1295 | -input_attr=>{ |
| 1285 | -name => "action.export.scope", |
1296 | -name => "action.export.scope", |
| 1286 | -values => [("all users", "visible users", "selected users")], |
1297 | -values => [qw(all visible selected)], |
| 1287 | -default => $actionParams{"action.export.scope"}->[0] || "visible", |
1298 | -default => $actionParams{"action.export.scope"}->[0] || "visible", |
| 1288 | -labels => { |
1299 | -labels => { |
| 1289 | all => "all users", |
1300 | all => $r->maketext("all users"), |
| 1290 | visible => "visible users", |
1301 | visible => $r->maketext("visible users"), |
| 1291 | selected => "selected users" |
1302 | selected => $r->maketext("selected users") |
| 1292 | }, |
1303 | }, |
| 1293 | -onchange => $onChange, |
1304 | -onchange => $onChange, |
| 1294 | } |
1305 | } |
| 1295 | ), |
1306 | ), |
| 1296 | CGI::br(), |
1307 | CGI::br(), |
| … | |
… | |
| 1303 | # -onchange => $onChange, |
1314 | # -onchange => $onChange, |
| 1304 | # ), |
1315 | # ), |
| 1305 | WeBWorK::CGI_labeled_input( |
1316 | WeBWorK::CGI_labeled_input( |
| 1306 | -type=>"select", |
1317 | -type=>"select", |
| 1307 | -id=>"export_select_target", |
1318 | -id=>"export_select_target", |
| 1308 | -label_text=>"Export to what kind of file?: ", |
1319 | -label_text=>$r->maketext("Export to what kind of file?").": ", |
| 1309 | -input_attr=>{ |
1320 | -input_attr=>{ |
| 1310 | -name=>"action.export.target", |
1321 | -name=>"action.export.target", |
| 1311 | -values => [ "new", $self->getCSVList() ], |
1322 | -values => [ "new", $self->getCSVList() ], |
| 1312 | -labels => { new => "Enter filename below" }, |
1323 | -labels => { new => $r->maketext("Enter filename below") }, |
| 1313 | -default => $actionParams{"action.export.target"}->[0] || "", |
1324 | -default => $actionParams{"action.export.target"}->[0] || "", |
| 1314 | -onchange => $onChange, |
1325 | -onchange => $onChange, |
| 1315 | } |
1326 | } |
| 1316 | ), |
1327 | ), |
| 1317 | CGI::br(), |
1328 | CGI::br(), |
| … | |
… | |
| 1325 | # ), |
1336 | # ), |
| 1326 | CGI::div({-id=>"export_elements"}, |
1337 | CGI::div({-id=>"export_elements"}, |
| 1327 | WeBWorK::CGI_labeled_input( |
1338 | WeBWorK::CGI_labeled_input( |
| 1328 | -type=>"text", |
1339 | -type=>"text", |
| 1329 | -id=>"export_filename", |
1340 | -id=>"export_filename", |
| 1330 | -label_text=>"Filename: ", |
1341 | -label_text=>$r->maketext("Filename").": ", |
| 1331 | -input_attr=>{ |
1342 | -input_attr=>{ |
| 1332 | -name => "action.export.new", |
1343 | -name => "action.export.new", |
| 1333 | -value => $actionParams{"action.export.new"}->[0] || "",, |
1344 | -value => $actionParams{"action.export.new"}->[0] || "",, |
| 1334 | -width => "50", |
1345 | -width => "50", |
| 1335 | -onchange => $onChange, |
1346 | -onchange => $onChange, |
| … | |
… | |
| 1376 | return scalar @userIDsToExport . " users exported to file $dir/$fileName"; |
1387 | return scalar @userIDsToExport . " users exported to file $dir/$fileName"; |
| 1377 | } |
1388 | } |
| 1378 | |
1389 | |
| 1379 | sub cancelEdit_form { |
1390 | sub cancelEdit_form { |
| 1380 | my ($self, $onChange, %actionParams) = @_; |
1391 | my ($self, $onChange, %actionParams) = @_; |
|
|
1392 | my $r = $self->r; |
| 1381 | return CGI::span("-Abandon changes"); |
1393 | return CGI::span("-".$r->maketext("Abandon changes")); |
| 1382 | } |
1394 | } |
| 1383 | |
1395 | |
| 1384 | sub cancelEdit_handler { |
1396 | sub cancelEdit_handler { |
| 1385 | my ($self, $genericParams, $actionParams, $tableParams) = @_; |
1397 | my ($self, $genericParams, $actionParams, $tableParams) = @_; |
| 1386 | my $r = $self->r; |
1398 | my $r = $self->r; |
| … | |
… | |
| 1399 | return "changes abandoned"; |
1411 | return "changes abandoned"; |
| 1400 | } |
1412 | } |
| 1401 | |
1413 | |
| 1402 | sub saveEdit_form { |
1414 | sub saveEdit_form { |
| 1403 | my ($self, $onChange, %actionParams) = @_; |
1415 | my ($self, $onChange, %actionParams) = @_; |
|
|
1416 | my $r = $self->r; |
| 1404 | return CGI::span("-Save changes"); |
1417 | return CGI::span("-".$r->maketext("Save changes")); |
| 1405 | } |
1418 | } |
| 1406 | |
1419 | |
| 1407 | sub saveEdit_handler { |
1420 | sub saveEdit_handler { |
| 1408 | my ($self, $genericParams, $actionParams, $tableParams) = @_; |
1421 | my ($self, $genericParams, $actionParams, $tableParams) = @_; |
| 1409 | my $r = $self->r; |
1422 | my $r = $self->r; |
| … | |
… | |
| 1446 | return "changes saved"; |
1459 | return "changes saved"; |
| 1447 | } |
1460 | } |
| 1448 | |
1461 | |
| 1449 | sub cancelPassword_form { |
1462 | sub cancelPassword_form { |
| 1450 | my ($self, $onChange, %actionParams) = @_; |
1463 | my ($self, $onChange, %actionParams) = @_; |
|
|
1464 | my $r = $self->r; |
| 1451 | return CGI::span("-Abandon changes"); |
1465 | return CGI::span("-".$r->maketext("Abandon changes")); |
| 1452 | } |
1466 | } |
| 1453 | |
1467 | |
| 1454 | sub cancelPassword_handler { |
1468 | sub cancelPassword_handler { |
| 1455 | my ($self, $genericParams, $actionParams, $tableParams) = @_; |
1469 | my ($self, $genericParams, $actionParams, $tableParams) = @_; |
| 1456 | my $r = $self->r; |
1470 | my $r = $self->r; |
| … | |
… | |
| 1469 | return "changes abandoned"; |
1483 | return "changes abandoned"; |
| 1470 | } |
1484 | } |
| 1471 | |
1485 | |
| 1472 | sub savePassword_form { |
1486 | sub savePassword_form { |
| 1473 | my ($self, $onChange, %actionParams) = @_; |
1487 | my ($self, $onChange, %actionParams) = @_; |
|
|
1488 | my $r = $self->r; |
| 1474 | return CGI::span("-Save changes"); |
1489 | return CGI::span("-".$r->maketext("Save changes")); |
| 1475 | } |
1490 | } |
| 1476 | |
1491 | |
| 1477 | sub savePassword_handler { |
1492 | sub savePassword_handler { |
| 1478 | my ($self, $genericParams, $actionParams, $tableParams) = @_; |
1493 | my ($self, $genericParams, $actionParams, $tableParams) = @_; |
| 1479 | my $r = $self->r; |
1494 | my $r = $self->r; |
| … | |
… | |
| 1674 | # "display" methods |
1689 | # "display" methods |
| 1675 | ################################################################################ |
1690 | ################################################################################ |
| 1676 | |
1691 | |
| 1677 | sub fieldEditHTML { |
1692 | sub fieldEditHTML { |
| 1678 | my ($self, $fieldName, $value, $properties) = @_; |
1693 | my ($self, $fieldName, $value, $properties) = @_; |
|
|
1694 | my $r = $self->r; |
| 1679 | my $ce = $self->r->ce; |
1695 | my $ce = $self->r->ce; |
| 1680 | my $size = $properties->{size}; |
1696 | my $size = $properties->{size}; |
| 1681 | my $type = $properties->{type}; |
1697 | my $type = $properties->{type}; |
| 1682 | my $access = $properties->{access}; |
1698 | my $access = $properties->{access}; |
| 1683 | my $items = $properties->{items}; |
1699 | my $items = $properties->{items}; |
| … | |
… | |
| 1701 | } |
1717 | } |
| 1702 | return $value; |
1718 | return $value; |
| 1703 | } |
1719 | } |
| 1704 | |
1720 | |
| 1705 | if ($type eq "number" or $type eq "text") { |
1721 | if ($type eq "number" or $type eq "text") { |
| 1706 | return WeBWorK::CGI_labeled_input(-type=>"text", -id=>$fieldName."_id", -label_text=>"Edit:", -input_attr=>{name=>$fieldName, value=>$value, size=>$size}); |
1722 | return WeBWorK::CGI_labeled_input(-type=>"text", -id=>$fieldName."_id", -label_text=>$r->maketext("Edit").":", -input_attr=>{name=>$fieldName, value=>$value, size=>$size}); |
| 1707 | } |
1723 | } |
| 1708 | |
1724 | |
| 1709 | if ($type eq "enumerable") { |
1725 | if ($type eq "enumerable") { |
| 1710 | my $matched = undef; # Whether a synonym match has occurred |
1726 | my $matched = undef; # Whether a synonym match has occurred |
| 1711 | |
1727 | |
| … | |
… | |
| 1729 | # }); |
1745 | # }); |
| 1730 | |
1746 | |
| 1731 | return WeBWorK::CGI_labeled_input( |
1747 | return WeBWorK::CGI_labeled_input( |
| 1732 | -type=>"select", |
1748 | -type=>"select", |
| 1733 | -id=>$fieldName."_id", |
1749 | -id=>$fieldName."_id", |
| 1734 | -label_text=>ucfirst($fieldName), |
1750 | -label_text=>$r->maketext(ucfirst($fieldName)), |
| 1735 | -input_attr=>{ |
1751 | -input_attr=>{ |
| 1736 | name => $fieldName, |
1752 | name => $fieldName, |
| 1737 | values => [keys %$items], |
1753 | values => [keys %$items], |
| 1738 | default => $value, |
1754 | default => $value, |
| 1739 | labels => $items, |
1755 | labels => $items, |
| … | |
… | |
| 1752 | my (@values, %labels); |
1768 | my (@values, %labels); |
| 1753 | while (my ($k, $v) = each %{$ce->{statuses}}) { |
1769 | while (my ($k, $v) = each %{$ce->{statuses}}) { |
| 1754 | my @abbrevs = @{$v->{abbrevs}}; |
1770 | my @abbrevs = @{$v->{abbrevs}}; |
| 1755 | push @values, $abbrevs[0]; |
1771 | push @values, $abbrevs[0]; |
| 1756 | foreach my $abbrev (@abbrevs) { |
1772 | foreach my $abbrev (@abbrevs) { |
| 1757 | $labels{$abbrev} = $k; |
1773 | $labels{$abbrev} = $r->maketext($k); |
| 1758 | } |
1774 | } |
| 1759 | } |
1775 | } |
| 1760 | |
1776 | |
| 1761 | # return CGI::popup_menu({ |
1777 | # return CGI::popup_menu({ |
| 1762 | # name => $fieldName, |
1778 | # name => $fieldName, |
| … | |
… | |
| 1766 | # }); |
1782 | # }); |
| 1767 | |
1783 | |
| 1768 | return WeBWorK::CGI_labeled_input( |
1784 | return WeBWorK::CGI_labeled_input( |
| 1769 | -type=>"select", |
1785 | -type=>"select", |
| 1770 | -id=>$fieldName."_id", |
1786 | -id=>$fieldName."_id", |
| 1771 | -label_text=>"Edit:", |
1787 | -label_text=>$r->maketext("Edit").":", |
| 1772 | -input_attr=>{ |
1788 | -input_attr=>{ |
| 1773 | name => $fieldName, |
1789 | name => $fieldName, |
| 1774 | values => \@values, |
1790 | values => \@values, |
| 1775 | default => $value, |
1791 | default => $value, |
| 1776 | labels => \%labels, |
1792 | labels => \%labels, |
| … | |
… | |
| 1799 | # }); |
1815 | # }); |
| 1800 | |
1816 | |
| 1801 | return WeBWorK::CGI_labeled_input( |
1817 | return WeBWorK::CGI_labeled_input( |
| 1802 | -type=>"select", |
1818 | -type=>"select", |
| 1803 | -id=>$fieldName."_id", |
1819 | -id=>$fieldName."_id", |
| 1804 | -label_text=>"Edit:", |
1820 | -label_text=>$r->maketext("Edit").":", |
| 1805 | -input_attr=>{ |
1821 | -input_attr=>{ |
| 1806 | -name => $fieldName, |
1822 | -name => $fieldName, |
| 1807 | -values => \@values, |
1823 | -values => \@values, |
| 1808 | -default => [$default], # force default of 0 to be a selector value (instead of |
1824 | -default => [$default], # force default of 0 to be a selector value (instead of |
| 1809 | # being considered as a null -- now works with CGI 3.42 |
1825 | # being considered as a null -- now works with CGI 3.42 |
| … | |
… | |
| 1908 | } else { |
1924 | } else { |
| 1909 | # check to see if a user is currently logged in |
1925 | # check to see if a user is currently logged in |
| 1910 | # DBFIXME use a WHERE clause |
1926 | # DBFIXME use a WHERE clause |
| 1911 | my $Key = $db->getKey($User->user_id); |
1927 | my $Key = $db->getKey($User->user_id); |
| 1912 | my $is_active = ($Key and time <= $Key->timestamp()+$ce->{sessionKeyTimeout}); # cribbed from check_session |
1928 | my $is_active = ($Key and time <= $Key->timestamp()+$ce->{sessionKeyTimeout}); # cribbed from check_session |
| 1913 | push @tableCells, $is_active ? CGI::b("active") : CGI::em("inactive"); |
1929 | push @tableCells, $is_active ? CGI::b($r->maketext("Active")) : CGI::em($r->maketext("Inactive")); |
| 1914 | } |
1930 | } |
| 1915 | |
1931 | |
| 1916 | # change password (only in password mode) |
1932 | # change password (only in password mode) |
| 1917 | if ($passwordMode) { |
1933 | if ($passwordMode) { |
| 1918 | if ($User->user_id eq $user) { |
1934 | if ($User->user_id eq $user) { |
| 1919 | push @tableCells, CGI::div({-class=>"ResultsWithError"},"You may not change your own password here!") # don't allow a professor to change their own password from this form |
1935 | push @tableCells, CGI::div({-class=>"ResultsWithError"},$r->maketext("You may not change your own password here!")) # don't allow a professor to change their own password from this form |
| 1920 | } |
1936 | } |
| 1921 | else { |
1937 | else { |
| 1922 | my $fieldName = 'user.' . $User->user_id . '.' . 'new_password'; |
1938 | my $fieldName = 'user.' . $User->user_id . '.' . 'new_password'; |
| 1923 | push @tableCells, WeBWorK::CGI_labeled_input(-type=>"text", -id=>"password_edit", -label_text=>"New Password: ", -input_attr=>{name=>$fieldName, size=>14}); |
1939 | push @tableCells, WeBWorK::CGI_labeled_input(-type=>"text", -id=>"password_edit", -label_text=>$r->maketext("New Password").": ", -input_attr=>{name=>$fieldName, size=>14}); |
| 1924 | } |
1940 | } |
| 1925 | } |
1941 | } |
| 1926 | # User ID (edit mode) or Assigned Sets (otherwise) |
1942 | # User ID (edit mode) or Assigned Sets (otherwise) |
| 1927 | if ( $passwordMode) { |
1943 | if ( $passwordMode) { |
| 1928 | # straight user ID |
1944 | # straight user ID |
| … | |
… | |
| 2043 | no_visible_users => "1" |
2059 | no_visible_users => "1" |
| 2044 | ); |
2060 | ); |
| 2045 | } |
2061 | } |
| 2046 | @tableHeadings = ( |
2062 | @tableHeadings = ( |
| 2047 | #"Select", |
2063 | #"Select", |
| 2048 | CGI::a({href => $self->systemLink($urlpath->new(type=>'instructor_user_list', args=>{courseID => $courseName,} ), params=>{labelSortMethod=>'user_id', %current_state})}, 'Login Name'), |
2064 | CGI::a({href => $self->systemLink($urlpath->new(type=>'instructor_user_list', args=>{courseID => $courseName,} ), params=>{labelSortMethod=>'user_id', %current_state})}, $r->maketext('Login Name')), |
| 2049 | "Login Status", |
2065 | $r->maketext("Login Status"), |
| 2050 | "Assigned Sets", |
2066 | $r->maketext("Assigned Sets"), |
| 2051 | CGI::a({href => $self->systemLink($urlpath->new(type=>'instructor_user_list', args=>{courseID => $courseName,} ), params=>{labelSortMethod=>'first_name', %current_state})}, 'First Name'), |
2067 | CGI::a({href => $self->systemLink($urlpath->new(type=>'instructor_user_list', args=>{courseID => $courseName,} ), params=>{labelSortMethod=>'first_name', %current_state})}, $r->maketext('First Name')), |
| 2052 | CGI::a({href => $self->systemLink($urlpath->new(type=>'instructor_user_list', args=>{courseID => $courseName,} ), params=>{labelSortMethod=>'last_name', %current_state})}, 'Last Name'), |
2068 | CGI::a({href => $self->systemLink($urlpath->new(type=>'instructor_user_list', args=>{courseID => $courseName,} ), params=>{labelSortMethod=>'last_name', %current_state})}, $r->maketext('Last Name')), |
| 2053 | CGI::a({href => $self->systemLink($urlpath->new(type=>'instructor_user_list', args=>{courseID => $courseName,} ), params=>{labelSortMethod=>'email_address', %current_state})}, 'Email Address'), |
2069 | CGI::a({href => $self->systemLink($urlpath->new(type=>'instructor_user_list', args=>{courseID => $courseName,} ), params=>{labelSortMethod=>'email_address', %current_state})}, $r->maketext('Email Address')), |
| 2054 | CGI::a({href => $self->systemLink($urlpath->new(type=>'instructor_user_list', args=>{courseID => $courseName,} ), params=>{labelSortMethod=>'student_id', %current_state})}, 'Student ID'), |
2070 | CGI::a({href => $self->systemLink($urlpath->new(type=>'instructor_user_list', args=>{courseID => $courseName,} ), params=>{labelSortMethod=>'student_id', %current_state})}, $r->maketext('Student ID')), |
| 2055 | CGI::a({href => $self->systemLink($urlpath->new(type=>'instructor_user_list', args=>{courseID => $courseName,} ), params=>{labelSortMethod=>'status', %current_state})}, 'Status'), |
2071 | CGI::a({href => $self->systemLink($urlpath->new(type=>'instructor_user_list', args=>{courseID => $courseName,} ), params=>{labelSortMethod=>'status', %current_state})}, $r->maketext('Status')), |
| 2056 | CGI::a({href => $self->systemLink($urlpath->new(type=>'instructor_user_list', args=>{courseID => $courseName,} ), params=>{labelSortMethod=>'section', %current_state})}, 'Section'), |
2072 | CGI::a({href => $self->systemLink($urlpath->new(type=>'instructor_user_list', args=>{courseID => $courseName,} ), params=>{labelSortMethod=>'section', %current_state})}, $r->maketext('Section')), |
| 2057 | CGI::a({href => $self->systemLink($urlpath->new(type=>'instructor_user_list', args=>{courseID => $courseName,} ), params=>{labelSortMethod=>'recitation', %current_state})}, 'Recitation'), |
2073 | CGI::a({href => $self->systemLink($urlpath->new(type=>'instructor_user_list', args=>{courseID => $courseName,} ), params=>{labelSortMethod=>'recitation', %current_state})}, $r->maketext('Recitation')), |
| 2058 | CGI::a({href => $self->systemLink($urlpath->new(type=>'instructor_user_list', args=>{courseID => $courseName,} ), params=>{labelSortMethod=>'comment', %current_state})}, 'Comment'), |
2074 | CGI::a({href => $self->systemLink($urlpath->new(type=>'instructor_user_list', args=>{courseID => $courseName,} ), params=>{labelSortMethod=>'comment', %current_state})}, $r->maketext('Comment')), |
| 2059 | CGI::a({href => $self->systemLink($urlpath->new(type=>'instructor_user_list', args=>{courseID => $courseName,} ), params=>{labelSortMethod=>'permission', %current_state})}, 'Permission Level'), |
2075 | CGI::a({href => $self->systemLink($urlpath->new(type=>'instructor_user_list', args=>{courseID => $courseName,} ), params=>{labelSortMethod=>'permission', %current_state})}, $r->maketext('Permission Level')), |
| 2060 | ) |
2076 | ) |
| 2061 | } |
2077 | } |
| 2062 | if($passwordMode) { |
2078 | if($passwordMode) { |
| 2063 | unshift @tableHeadings, "New Password"; |
2079 | unshift @tableHeadings, "New Password"; |
| 2064 | } |
2080 | } |
| … | |
… | |
| 2068 | print CGI::start_table({-nowrap=>0, -class=>"set_table", -summary=>"A table showing all the current users along with several fields of user information. The fields from left to right are: Login Name, Login Status, Assigned Sets, First Name, Last Name, Email Address, Student ID, Enrollment Status, Section, Recitation, Comments, and Permission Level. The table headers for Login Name and fields from First Name to Permission Level have links to the form at the top of the page. The Login Name fields contain checkboxes for selecting the user and links that allow you to act as and edit the information of the user. Clicking the emails will allow you to email the corresponding user."}); |
2084 | print CGI::start_table({-nowrap=>0, -class=>"set_table", -summary=>"A table showing all the current users along with several fields of user information. The fields from left to right are: Login Name, Login Status, Assigned Sets, First Name, Last Name, Email Address, Student ID, Enrollment Status, Section, Recitation, Comments, and Permission Level. The table headers for Login Name and fields from First Name to Permission Level have links to the form at the top of the page. The Login Name fields contain checkboxes for selecting the user and links that allow you to act as and edit the information of the user. Clicking the emails will allow you to email the corresponding user."}); |
| 2069 | } else { |
2085 | } else { |
| 2070 | print CGI::start_table({-border=>1, -nowrap=>1, -class=>"set_table", -summary=>"A table showing all the current users along with several fields of user information. The fields from left to right are: Login Name, Login Status, Assigned Sets, First Name, Last Name, Email Address, Student ID, Enrollment Status, Section, Recitation, Comments, and Permission Level. The table headers for Login Name and fields from First Name to Permission Level have links to the form at the top of the page. The Login Name fields contain checkboxes for selecting the user and links that allow you to act as and edit the information of the user. Clicking the emails will allow you to email the corresponding user."}); |
2086 | print CGI::start_table({-border=>1, -nowrap=>1, -class=>"set_table", -summary=>"A table showing all the current users along with several fields of user information. The fields from left to right are: Login Name, Login Status, Assigned Sets, First Name, Last Name, Email Address, Student ID, Enrollment Status, Section, Recitation, Comments, and Permission Level. The table headers for Login Name and fields from First Name to Permission Level have links to the form at the top of the page. The Login Name fields contain checkboxes for selecting the user and links that allow you to act as and edit the information of the user. Clicking the emails will allow you to email the corresponding user."}); |
| 2071 | } |
2087 | } |
| 2072 | |
2088 | |
| 2073 | print CGI::caption("Users List"); |
2089 | print CGI::caption($r->maketext("Users List")); |
| 2074 | |
2090 | |
| 2075 | print CGI::Tr({}, CGI::th({}, \@tableHeadings)); |
2091 | print CGI::Tr({}, CGI::th({}, \@tableHeadings)); |
| 2076 | |
2092 | |
| 2077 | |
2093 | |
| 2078 | for (my $i = 0; $i < @Users; $i++) { |
2094 | for (my $i = 0; $i < @Users; $i++) { |