| 1 | ################################################################################ |
1 | ################################################################################ |
| 2 | # WeBWorK Online Homework Delivery System |
2 | # WeBWorK Online Homework Delivery System |
| 3 | # Copyright © 2000-2003 The WeBWorK Project, http://openwebwork.sf.net/ |
3 | # Copyright © 2000-2003 The WeBWorK Project, http://openwebwork.sf.net/ |
| 4 | # $CVSHeader: webwork-modperl/lib/WeBWorK/ContentGenerator.pm,v 1.93 2004/04/29 22:20:36 sh002i Exp $ |
4 | # $CVSHeader: webwork-modperl/lib/WeBWorK/ContentGenerator.pm,v 1.94 2004/05/04 16:03:09 jj Exp $ |
| 5 | # |
5 | # |
| 6 | # This program is free software; you can redistribute it and/or modify it under |
6 | # This program is free software; you can redistribute it and/or modify it under |
| 7 | # the terms of either: (a) the GNU General Public License as published by the |
7 | # the terms of either: (a) the GNU General Public License as published by the |
| 8 | # Free Software Foundation; either version 2, or (at your option) any later |
8 | # Free Software Foundation; either version 2, or (at your option) any later |
| 9 | # version, or (b) the "Artistic License" which comes with this package. |
9 | # version, or (b) the "Artistic License" which comes with this package. |
| … | |
… | |
| 502 | if ($permLevel > 0) { |
502 | if ($permLevel > 0) { |
| 503 | my $ipfx = "${pfx}Instructor::"; |
503 | my $ipfx = "${pfx}Instructor::"; |
| 504 | |
504 | |
| 505 | my $userID = $r->param("effectiveUser"); |
505 | my $userID = $r->param("effectiveUser"); |
| 506 | my $setID = $urlpath->arg("setID"); |
506 | my $setID = $urlpath->arg("setID"); |
|
|
507 | $setID = "" unless grep /$setID/, $db->listUserSets($userID); |
| 507 | my $problemID = $urlpath->arg("problemID"); |
508 | my $problemID = $urlpath->arg("problemID"); |
|
|
509 | $problemID = "" unless grep /$problemID/, $db->listUserProblems($userID, $setID); |
| 508 | |
510 | |
| 509 | my $instr = $urlpath->newFromModule("${ipfx}Index", %args); |
511 | my $instr = $urlpath->newFromModule("${ipfx}Index", %args); |
| 510 | my $addUsers = $urlpath->newFromModule("${ipfx}AddUsers", %args); |
512 | my $addUsers = $urlpath->newFromModule("${ipfx}AddUsers", %args); |
| 511 | my $userList = $urlpath->newFromModule("${ipfx}UserList", %args); |
513 | my $userList = $urlpath->newFromModule("${ipfx}UserList", %args); |
| 512 | |
514 | |
| … | |
… | |
| 724 | |
726 | |
| 725 | Defined in this package. |
727 | Defined in this package. |
| 726 | |
728 | |
| 727 | Print any error messages resulting from the last form submission. |
729 | Print any error messages resulting from the last form submission. |
| 728 | |
730 | |
|
|
731 | This method is deprecated -- use message() instead |
|
|
732 | |
| 729 | The implementation in this package prints the value of the field |
733 | The implementation in this package prints the value of the field |
| 730 | $self->{submitError}, if it is present. |
734 | $self->{submitError}, if it is present. |
| 731 | |
735 | |
| 732 | =cut |
736 | =cut |
| 733 | |
737 | |
| … | |
… | |
| 738 | print $self->{submitError} if exists $self->{submitError}; |
742 | print $self->{submitError} if exists $self->{submitError}; |
| 739 | print "<!-- END " . __PACKAGE__ . "::submiterror -->\n"; |
743 | print "<!-- END " . __PACKAGE__ . "::submiterror -->\n"; |
| 740 | |
744 | |
| 741 | return ""; |
745 | return ""; |
| 742 | } |
746 | } |
|
|
747 | |
|
|
748 | =item message() |
|
|
749 | |
|
|
750 | Defined in this package. |
|
|
751 | |
|
|
752 | Print any messages (error or non-error) resulting from the last form submission. |
|
|
753 | This could be used to give Sucess and Failure messages after an action is performed by a module. |
|
|
754 | |
|
|
755 | The implementation in this package prints the value of the field |
|
|
756 | $self->{message}, if it is present. |
|
|
757 | |
|
|
758 | =cut |
|
|
759 | |
|
|
760 | sub message { |
|
|
761 | my ($self) = @_; |
|
|
762 | |
|
|
763 | print "\n<!-- BEGIN " . __PACKAGE__ . "::message -->\n"; |
|
|
764 | print $self->{message} if exists $self->{message}; |
|
|
765 | print "<!-- END " . __PACKAGE__ . "::message -->\n"; |
|
|
766 | |
|
|
767 | return ""; |
|
|
768 | } |
|
|
769 | |
|
|
770 | =item addmessage($message) |
|
|
771 | |
|
|
772 | Defined in this package. |
|
|
773 | |
|
|
774 | Concatenates a new message to any previous ones. |
|
|
775 | This is preferred over any direct access to $self->{message} to avoid overwriting any |
|
|
776 | previously submitted messages |
|
|
777 | |
|
|
778 | The implementation in this package concatenates the given message to the end of the |
|
|
779 | current value of the field $self->{message} or sets $self->{message} if it is empty |
|
|
780 | |
|
|
781 | =cut |
|
|
782 | |
|
|
783 | sub addmessage { |
|
|
784 | my ($self, $message) = @_; |
|
|
785 | |
|
|
786 | $self->{message} .= $message; |
|
|
787 | |
|
|
788 | return ""; |
|
|
789 | } |
|
|
790 | |
| 743 | |
791 | |
| 744 | =item title() |
792 | =item title() |
| 745 | |
793 | |
| 746 | Defined in this package. |
794 | Defined in this package. |
| 747 | |
795 | |
| … | |
… | |
| 877 | |
925 | |
| 878 | sub if_submiterror { |
926 | sub if_submiterror { |
| 879 | my ($self, $arg) = @_; |
927 | my ($self, $arg) = @_; |
| 880 | |
928 | |
| 881 | if (exists $self->{submitError}) { |
929 | if (exists $self->{submitError}) { |
|
|
930 | return $arg; |
|
|
931 | } else { |
|
|
932 | return !$arg; |
|
|
933 | } |
|
|
934 | } |
|
|
935 | |
|
|
936 | =item if_message($arg) |
|
|
937 | |
|
|
938 | If the last form submission generated a message, $arg is returned. Otherwise, the |
|
|
939 | inverse of $arg is returned. |
|
|
940 | |
|
|
941 | The implementation in this package checks for the field $self->{message} to |
|
|
942 | determine if a message is present. |
|
|
943 | |
|
|
944 | If a subclass uses some other method to classify submission results, this method could be |
|
|
945 | redefined to handle that variance: |
|
|
946 | |
|
|
947 | sub if_message { |
|
|
948 | my ($self, $arg) = @_; |
|
|
949 | |
|
|
950 | my $status = $self->{processReturnValue}; |
|
|
951 | if ($status != 0) { |
|
|
952 | return $arg; |
|
|
953 | } else { |
|
|
954 | return !$arg; |
|
|
955 | } |
|
|
956 | } |
|
|
957 | |
|
|
958 | =cut |
|
|
959 | |
|
|
960 | sub if_message { |
|
|
961 | my ($self, $arg) = @_; |
|
|
962 | |
|
|
963 | if (exists $self->{message}) { |
| 882 | return $arg; |
964 | return $arg; |
| 883 | } else { |
965 | } else { |
| 884 | return !$arg; |
966 | return !$arg; |
| 885 | } |
967 | } |
| 886 | } |
968 | } |