More robust, less intensive duplicate checking

If a user is in more than one group, and team mode is enabled,
previously an error was only thrown when they or someone in one of
their groups submitted work. Now the error is thrown whenever one views
the workshop, and the check is completed in a single database call.