/**
   * 初回得点分布Mapを取得する
   *
   * @param analysisInfo テスト結果分析画面の情報
   * @param paramMap パラメータMAP
   * @param planId 教育プランID
   * @return 初回得点分布Map
   * @throws EducationManagementException
   */
  private HashMap<Integer, Integer> getFirstScoreForPersonCountsList(
      TestResultAnalysisInfo analysisInfo, HashMap<String, Integer> paramMap, String planId)
      throws EducationManagementException {

    HashMap<Integer, Integer> firstScoreForPersons = new HashMap<Integer, Integer>();

    try {
      BusObjectIterator<GetFirstScoreForPersonCounts> firstScoreForPersonCounts =
          GetFirstScoreForPersonCounts.execute(planId);

      // 初回得点合計
      int totalScore = 0;
      // 回答者数
      int totalCount = 0;
      // 最小の初回点数
      int minFirstScore = 0;

      while (firstScoreForPersonCounts.hasMoreElements()) {
        GetFirstScoreForPersonCounts record = firstScoreForPersonCounts.nextElement();
        // 初回点数
        int firstScore = Integer.parseInt(getValue(record, "FIRST_SCORE"));
        // 人数
        int persons = Integer.parseInt(getValue(record, "PERSON_COUNTS"));

        // 初回得点合計
        totalScore = totalScore + firstScore * persons;

        // 回答者数を合計する
        totalCount += persons;

        // 最小の初回点数
        if (!firstScoreForPersonCounts.hasMoreElements()) {
          minFirstScore = firstScore;
        }

        // 初回点数と人数をMapにプットする
        firstScoreForPersons.put(firstScore, persons);
      }
      // 回答者数
      paramMap.put("totalCount", totalCount);
      // 最小の初回点数
      paramMap.put("minFirstScore", minFirstScore);

      // 初回得点平均の取得
      String firstAverageScore = getAverageScore(paramMap, totalScore);
      // 初回得点平均を設定する
      analysisInfo.setAverageScore(firstAverageScore);

    } catch (Exception e) {
      // システムエラーが発生する場合、
      EducationManagementException educationManagementException =
          new EducationManagementException(
              e,
              ErrorMessages.E10004,
              new Object[] {EducationManagementConst.TBL_NAME_EDU_TRAINEE});
      LOGGER.error(
          educationManagementException,
          ErrorMessages.E10004,
          new Object[] {EducationManagementConst.TBL_NAME_EDU_TRAINEE});
      throw educationManagementException;
    }

    return firstScoreForPersons;
  }
  /**
   * テスト結果分析情報取得メソッド
   *
   * @param planId 教育プラン
   * @return  TestResultAnalysisInfo
   * @throws EducationManagementException
   */
  public TestResultAnalysisInfo getTestResultAnalysisInfo(String planId)
      throws EducationManagementException {

    // パラメータMAP
    HashMap<String, Integer> paramMap = new HashMap<String, Integer>();
    // 回答者数
    int totalCount = 0;
    paramMap.put("totalCount", totalCount);
    // 問題数
    int questionCounts = 0;
    paramMap.put("questionCounts", questionCounts);
    // 最小の初回点数
    int minFirstScore = 0;
    paramMap.put("minFirstScore", minFirstScore);
    // 最大の回数
    int maxGradingNum = 0;
    paramMap.put("maxGradingNum", maxGradingNum);

    // テスト結果分析画面の情報
    TestResultAnalysisInfo analysisInfo = new TestResultAnalysisInfo();

    // 解説・正解Table、問題別初回不正解者数TableとChart用
    QuestionsAndFirstPassCountsList qestionList = new QuestionsAndFirstPassCountsList();

    // 初回得点分布Mapの取得
    HashMap<Integer, Integer> firstScoreForPersons =
        getFirstScoreForPersonCountsList(analysisInfo, paramMap, planId);

    // 合格試験回数分布Mapの取得
    HashMap<Integer, Integer> gradingNumForPersons =
        getGradingNumForPersonCountsList(paramMap, planId);

    // 問題情報と初回不正解者数
    editQuestionsAndFirstPassCountsList(paramMap, planId, qestionList);
    analysisInfo.setQuestionsAndFirstPassCountsListObject(qestionList);

    // 初回得点分布Table
    FirstScoreForTableList firstScoreTableList = new FirstScoreForTableList();
    // 初回得点分布Chart
    FirstScoreForChartList firstScoreChartList = new FirstScoreForChartList();
    // 初回得点分布TableとChartのデータ編集
    editFirstScore(paramMap, firstScoreForPersons, firstScoreTableList, firstScoreChartList);

    analysisInfo.setFirstScoreForTableListObject(firstScoreTableList);
    analysisInfo.setFirstScoreForChartListObject(firstScoreChartList);

    // 合格試験回数分布Table
    GradingNumForTableList gradingNumTableList = new GradingNumForTableList();
    // 合格試験回数分布Chart
    GradingNumForChartList gradingNumChartList = new GradingNumForChartList();
    // 合格試験回数分布TableとChartのデータ編集
    editGradingNum(paramMap, gradingNumForPersons, gradingNumTableList, gradingNumChartList);

    analysisInfo.setGradingNumForTableListObject(gradingNumTableList);
    analysisInfo.setGradingNumForChartListObject(gradingNumChartList);

    // 基本情報の編集
    editBaseInfo(paramMap, planId, analysisInfo);

    return analysisInfo;
  }
  /**
   * 基本情報を編集する
   *
   * @param paramMap パラメータMAP
   * @param planId プランID
   * @param analysisInfo テスト結果分析画面の情報
   * @throws EducationManagementException
   */
  private void editBaseInfo(
      HashMap<String, Integer> paramMap, String planId, TestResultAnalysisInfo analysisInfo)
      throws EducationManagementException {
    // 教育セットコード
    String eduSetCd = null;

    try {
      EDU_PLAN eduPlan = EDU_PLAN.getEduPlanObject(planId);

      // 教育セットコード
      eduSetCd = eduPlan.getEDU_SET_CD();

      // 教育名称
      analysisInfo.setEducationName(eduPlan.getEDUCATION_NM());

      DateFormat format = new SimpleDateFormat("yyyy年MM月dd日");

      // 開催日
      analysisInfo.setHoldingStartDate(format.format(eduPlan.getHOLDING_START_DATE()));
      // 終了日
      analysisInfo.setHoldingEndDate(format.format(eduPlan.getHOLDING_END_DATE()));

      // 回答者数
      analysisInfo.setAnswerPersonCounts(paramMap.get("totalCount"));

    } catch (Exception e) {
      // システムエラーが発生する場合、
      EducationManagementException educationManagementException =
          new EducationManagementException(
              e, ErrorMessages.E10004, new Object[] {EducationManagementConst.TBL_NAME_EDU_PLAN});
      LOGGER.error(
          educationManagementException,
          ErrorMessages.E10004,
          new Object[] {EducationManagementConst.TBL_NAME_EDU_PLAN});
      throw educationManagementException;
    }

    try {

      EDU_EDUCATION_SET eduEducationSet = EDU_EDUCATION_SET.getEduEducationSetObject(eduSetCd);
      // 回答方式が1:選択の場合
      if (EducationManagementConst.ANSWER_TYPE_FLG_CHOOSE.equals(
          eduEducationSet.getANSWER_TYPE_FLG())) {

        // 回答方式
        analysisInfo.setAnswerTypeFlg(EducationManagementConst.ANSWER_TYPE_DISPLAY_CHOOSE);
      } else if (EducationManagementConst.ANSWER_TYPE_FLG_TEXT.equals(
          eduEducationSet.getANSWER_TYPE_FLG())) {
        // 回答方式が 2:記述回答の場合

        analysisInfo.setAnswerTypeFlg(EducationManagementConst.ANSWER_TYPE_DISPLAY_TEXT);
      }

    } catch (Exception e) {
      // システムエラーが発生する場合、
      EducationManagementException educationManagementException =
          new EducationManagementException(
              e,
              ErrorMessages.E10004,
              new Object[] {EducationManagementConst.TBL_NAME_EDU_EDUCATION_SET});
      LOGGER.error(
          educationManagementException,
          ErrorMessages.E10004,
          new Object[] {EducationManagementConst.TBL_NAME_EDU_EDUCATION_SET});
      throw educationManagementException;
    }
  }