From: Gavin L. v. a. <we...@ma...> - 2005-12-21 23:27:55
|
Log Message: ----------- Gateway update: deal with missing problem groups in gateway tests slightly more gracefully. Modified Files: -------------- webwork2/lib/WeBWorK/ContentGenerator: Instructor.pm Revision Data ------------- Index: Instructor.pm =================================================================== RCS file: /webwork/cvs/system/webwork2/lib/WeBWorK/ContentGenerator/Instructor.pm,v retrieving revision 1.52 retrieving revision 1.53 diff -Llib/WeBWorK/ContentGenerator/Instructor.pm -Llib/WeBWorK/ContentGenerator/Instructor.pm -u -r1.52 -r1.53 --- lib/WeBWorK/ContentGenerator/Instructor.pm +++ lib/WeBWorK/ContentGenerator/Instructor.pm @@ -199,6 +199,23 @@ # get list of problems in group my @problemList = $db->listGlobalProblems($problemGroupName); + # sanity check: if the group set hasn't been defined or doesn't + # actually contain problems (oops), then we can't very well assign + # this problem to the user. we could go on and assign all other + # problems, but that results in a partial set. so we die here if + # this happens. philosophically we're requiring that the instructor + # set up the sets correctly or have to deal with the carnage after- + # wards. I'm not sure that this is the best long-term solution. + # FIXME: this means that we may have created a set version that + # doesn't have any problems. this is bad. but it's hard to see + # where else to deal with it---fixing the problem requires checking + # at the set version-creation level that all the problems in the + # set are well defined. FIXME + die("Error in set version creation: no problems are available " . + "in problem group $problemGroupName. Set " . + $userSet->set_id . " has been created for $userID, but " . + "does not contain the right problems.\n") if (! @problemList); + my $nProb = @problemList; my $whichProblem = int(rand($nProb)); |