/* (non-Javadoc)
   * @see org.cloudcoder.app.client.rpc.GetCoursesAndProblemsService#findCurrentQuiz(org.cloudcoder.app.shared.model.Problem)
   */
  @Override
  public Quiz findCurrentQuiz(Problem problem) throws CloudCoderAuthenticationException {
    // Make sure user is authenticated
    User user =
        ServletUtil.checkClientIsAuthenticated(
            getThreadLocalRequest(), GetCoursesAndProblemsServiceImpl.class);

    // Find current quiz (if any)
    Quiz quiz = Database.getInstance().findCurrentQuiz(user, problem);

    if (quiz != null) {
      // Set the end time to the current time: this allows the client
      // to compute how long the quiz has been active
      quiz.setEndTime(System.currentTimeMillis());
    }

    return quiz;
  }