@@ -88,12 +88,12 @@ sub getProblemPool ($self, %args) {
88
88
89
89
my $pool = $self -> find($search_info , { join => [qw/ courses/ ] });
90
90
91
- unless ($pool ) {
92
- my $course_name = $course -> course_name;
91
+ DB::Exception::PoolNotInCourse-> throw(message => ' The pool with '
92
+ . ($args {info }{pool_name } ? ' name ' . $args {info }{pool_name } : ' id ' . $args {info }{problem_pool_id })
93
+ . ' is not in the course '
94
+ . $course -> course_name)
95
+ unless $pool ;
93
96
94
- DB::Exception::PoolNotInCourse-> throw(
95
- message => " The pool with name \{ $args {info}->{pool_name}} is not in the course $course_name " );
96
- }
97
97
return $pool if $args {as_result_set };
98
98
return { $pool -> get_columns };
99
99
}
@@ -193,7 +193,7 @@ sub updateProblemPool ($self, %args) {
193
193
194
194
my $pool = $self -> getProblemPool(info => $args {info }, as_result_set => 1);
195
195
196
- DB::Excpetion ::PoolNotInCourse-> throw(
196
+ DB::Exception ::PoolNotInCourse-> throw(
197
197
message => ' The problem pool '
198
198
. (
199
199
$args {info }-> {pool_name }
@@ -312,7 +312,6 @@ This gets a single problem out of a ProblemPool.
312
312
=cut
313
313
314
314
sub getPoolProblem ($self , %args ) {
315
-
316
315
my $problem_pool = $self -> getProblemPool(info => $args {info }, as_result_set => 1);
317
316
318
317
my $pool_problem_info = {};
@@ -328,6 +327,12 @@ sub getPoolProblem ($self, %args) {
328
327
329
328
if (scalar (@pool_problems ) == 1) {
330
329
return $args {as_result_set } ? $pool_problems [0] : { $pool_problems [0]-> get_inflated_columns };
330
+ } elsif (scalar (@pool_problems ) == 0) {
331
+ DB::Exception::PoolProblemNotInPool-> throw(message => ' The problem with id '
332
+ . $pool_problem_info -> {pool_problem_id }
333
+ . ' is not in the pool named \' '
334
+ . $problem_pool -> pool_name
335
+ . " '" );
331
336
} else {
332
337
# Pick a random problem.
333
338
my $prob = $pool_problems [ rand @pool_problems ];
0 commit comments