From: Sam H. v. a. <we...@ma...> - 2005-11-03 04:19:47
|
Log Message: ----------- fixed code to filter out undefined sets, improved error reporting when that happens. Modified Files: -------------- webwork2/lib/WeBWorK/ContentGenerator: Hardcopy.pm Revision Data ------------- Index: Hardcopy.pm =================================================================== RCS file: /webwork/cvs/system/webwork2/lib/WeBWorK/ContentGenerator/Hardcopy.pm,v retrieving revision 1.69 retrieving revision 1.70 diff -Llib/WeBWorK/ContentGenerator/Hardcopy.pm -Llib/WeBWorK/ContentGenerator/Hardcopy.pm -u -r1.69 -r1.70 --- lib/WeBWorK/ContentGenerator/Hardcopy.pm +++ lib/WeBWorK/ContentGenerator/Hardcopy.pm @@ -261,27 +261,34 @@ } # get sets for selection + my @globalSetIDs; my @GlobalSets; if ($perm_multiuser) { # if we're allowed to select sets for multiple users, get all sets. - @GlobalSets = $db->getGlobalSets($db->listGlobalSets); + @globalSetIDs = $db->listGlobalSets; + @GlobalSets = $db->getGlobalSets(@globalSetIDs); } else { # otherwise, only get the sets assigned to the effective user. # note that we are getting GlobalSets, but using the list of UserSets assigned to the # effective user. this is because if we pass UserSets to ScrollingRecordList it will # give us composite IDs back, which is a pain in the ass to deal with. - @GlobalSets = $db->getGlobalSets($db->listUserSets($eUserID)); + @globalSetIDs = $db->listUserSets($eUserID); + @GlobalSets = $db->getGlobalSets(@globalSetIDs); } + $GlobalSets[1] = undef; + # filter out unwanted sets + my @WantedGlobalSets; foreach my $i (0 .. $#GlobalSets) { my $Set = $GlobalSets[$i]; unless (defined $Set) { - warn "\$GlobalSets[\$i] not defined -- skipping"; + warn "\$GlobalSets[\$i] (ID $globalSetIDs[$i]) not defined -- skipping"; next; } - splice @GlobalSets, $i, 1 unless $Set->open_date <= time or $perm_unopened; - splice @GlobalSets, $i, 1 unless $Set->published or $perm_unpublished; + next unless $Set->open_date <= time or $perm_unopened; + next unless $Set->published or $perm_unpublished; + push @WantedGlobalSets, $Set; } my $scrolling_user_list = scrollingRecordList({ @@ -302,7 +309,7 @@ default_filters => ["all"], size => 20, multiple => $perm_multiset, - }, @GlobalSets); + }, @WantedGlobalSets); # we change the text a little bit depending on whether the user has multiuser privileges my $ss = $perm_multiuser ? "s" : ""; |