@@ -88,12 +88,12 @@ sub getProblemPool ($self, %args) {
8888
8989 my $pool = $self -> find($search_info , { join => [qw/ courses/ ] });
9090
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 ;
9396
94- DB::Exception::PoolNotInCourse-> throw(
95- message => " The pool with name \{ $args {info}->{pool_name}} is not in the course $course_name " );
96- }
9797 return $pool if $args {as_result_set };
9898 return { $pool -> get_columns };
9999}
@@ -193,7 +193,7 @@ sub updateProblemPool ($self, %args) {
193193
194194 my $pool = $self -> getProblemPool(info => $args {info }, as_result_set => 1);
195195
196- DB::Excpetion ::PoolNotInCourse-> throw(
196+ DB::Exception ::PoolNotInCourse-> throw(
197197 message => ' The problem pool '
198198 . (
199199 $args {info }-> {pool_name }
@@ -312,7 +312,6 @@ This gets a single problem out of a ProblemPool.
312312=cut
313313
314314sub getPoolProblem ($self , %args ) {
315-
316315 my $problem_pool = $self -> getProblemPool(info => $args {info }, as_result_set => 1);
317316
318317 my $pool_problem_info = {};
@@ -328,6 +327,12 @@ sub getPoolProblem ($self, %args) {
328327
329328 if (scalar (@pool_problems ) == 1) {
330329 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+ . " '" );
331336 } else {
332337 # Pick a random problem.
333338 my $prob = $pool_problems [ rand @pool_problems ];
0 commit comments