Log Message:
-----------
cleaned up error reporting for status methods. if arguments are not
defined and non-empty, a warning is given (using "carp") and an
undefined value is returned.
Modified Files:
--------------
webwork2/lib/WeBWorK:
CourseEnvironment.pm
webwork2/lib/WeBWorK/ContentGenerator:
Login.pm
Revision Data
-------------
Index: CourseEnvironment.pm
===================================================================
RCS file: /webwork/cvs/system/webwork2/lib/WeBWorK/CourseEnvironment.pm,v
retrieving revision 1.32
retrieving revision 1.33
diff -Llib/WeBWorK/CourseEnvironment.pm -Llib/WeBWorK/CourseEnvironment.pm -u -r1.32 -r1.33
--- lib/WeBWorK/CourseEnvironment.pm
+++ lib/WeBWorK/CourseEnvironment.pm
@@ -253,8 +253,10 @@
sub status_abbrev_to_name {
my ($ce, $status_abbrev) = @_;
- carp "status_abbrev_to_name: status_abbrev (first argument) must be defined and non-empty"
- if not defined $status_abbrev or $status_abbrev eq "";
+ if (not defined $status_abbrev or $status_abbrev eq "") {
+ carp "status_abbrev_to_name: status_abbrev (first argument) must be defined and non-empty";
+ return;
+ }
return $ce->{_status_abbrev_to_name}{$status_abbrev};
}
@@ -268,8 +270,10 @@
sub status_name_to_abbrevs {
my ($ce, $status_name) = @_;
- carp "status_name_to_abbrevs: status_name (first argument) must be defined and non-empty"
- if not defined $status_name or $status_name eq "";
+ if (not defined $status_name or $status_name eq "") {
+ carp "status_name_to_abbrevs: status_name (first argument) must be defined and non-empty";
+ return;
+ }
return unless exists $ce->{statuses}{$status_name};
return @{$ce->{statuses}{$status_name}{abbrevs}};
@@ -283,10 +287,14 @@
sub status_has_behavior {
my ($ce, $status_name, $behavior) = @_;
- carp "status_has_behavior: status_name (first argument) must be defined and non-empty"
- if not defined $status_name or $status_name eq "";
- carp "status_has_behavior: behavior (second argument) must be defined and non-empty"
- if not defined $behavior or $behavior eq "";
+ if (not defined $status_name or $status_name eq "") {
+ carp "status_has_behavior: status_name (first argument) must be defined and non-empty";
+ return;
+ }
+ if (not defined $behavior or $behavior eq "") {
+ carp "status_has_behavior: behavior (second argument) must be defined and non-empty";
+ return;
+ }
if (exists $ce->{statuses}{$status_name}) {
if (exists $ce->{statuses}{$status_name}{behaviors}) {
@@ -309,16 +317,20 @@
sub status_abbrev_has_behavior {
my ($ce, $status_abbrev, $behavior) = @_;
- carp "status_abbrev_has_behavior: status_abbrev (first argument) must be defined and non-empty"
- if not defined $status_abbrev or $status_abbrev eq "";
- carp "status_abbrev_has_behavior: behavior (second argument) must be defined and non-empty"
- if not defined $behavior or $behavior eq "";
+ if (not defined $status_abbrev or $status_abbrev eq "") {
+ carp "status_abbrev_has_behavior: status_abbrev (first argument) must be defined and non-empty";
+ return;
+ }
+ if (not defined $behavior or $behavior eq "") {
+ carp "status_abbrev_has_behavior: behavior (second argument) must be defined and non-empty";
+ return;
+ }
my $status_name = $ce->status_abbrev_to_name($status_abbrev);
if (defined $status_name) {
return $ce->status_has_behavior($status_name, $behavior);
} else {
- carp "status abbreviation '$status_abbrev' not found in \%statuses -- assuming no behaviors.\n";
+ warn "status abbreviation '$status_abbrev' not found in \%statuses -- assuming no behaviors.\n";
}
}
Index: Login.pm
===================================================================
RCS file: /webwork/cvs/system/webwork2/lib/WeBWorK/ContentGenerator/Login.pm,v
retrieving revision 1.34
retrieving revision 1.35
diff -Llib/WeBWorK/ContentGenerator/Login.pm -Llib/WeBWorK/ContentGenerator/Login.pm -u -r1.34 -r1.35
--- lib/WeBWorK/ContentGenerator/Login.pm
+++ lib/WeBWorK/ContentGenerator/Login.pm
@@ -177,7 +177,6 @@
my @GuestUsers = $db->getUsers(@guestUserIDs);
my @allowedGuestUsers;
foreach my $GuestUser (@GuestUsers) {
- warn "GuestUser=".$GuestUser->toString."\n";
next unless defined $GuestUser->status;
next unless $GuestUser->status ne "";
push @allowedGuestUsers, $GuestUser
|