示例#1
0
  private Map<BranchCourseGroup, Inar> generateInarByBranch(YearViewBean bean, BranchType bType) {
    Map<BranchCourseGroup, Inar> result =
        new TreeMap<BranchCourseGroup, Inar>(BranchCourseGroup.COMPARATOR_BY_NAME);
    Set<BranchCourseGroup> branches = bean.getDegreeCurricularPlan().getBranchesByType(bType);

    for (BranchCourseGroup branch : branches) {
      Inar inar = new Inar();
      result.put(branch, inar);
    }

    for (Enrolment enrol : bean.getEnrolments()) {
      BranchCourseGroup branch =
          enrol.getParentBranchCurriculumGroup() != null
              ? enrol.getParentBranchCurriculumGroup().getDegreeModule()
              : null;
      if (branch != null && branch.getBranchType() == bType) {
        result.get(branch).incEnrolled();
        Grade grade = enrol.getGrade();
        if (grade == null || grade.isEmpty()) {
          result.get(branch).incFrequenting();
        } else if (grade.isApproved()) {
          result.get(branch).incApproved();
        } else if (grade.isNotEvaluated()) {
          result.get(branch).incNotEvaluated();
        } else if (grade.isNotApproved()) {
          result.get(branch).incFlunked();
        }
      }
    }

    return result;
  }
示例#2
0
  private Map<BranchCourseGroup, String> generateAverageByBranch(
      YearViewBean bean, BranchType bType) {
    Map<BranchCourseGroup, String> result =
        new TreeMap<BranchCourseGroup, String>(BranchCourseGroup.COMPARATOR_BY_NAME);

    Set<BranchCourseGroup> branches = bean.getDegreeCurricularPlan().getBranchesByType(bType);

    Map<BranchCourseGroup, BigDecimal> sigma = new HashMap<BranchCourseGroup, BigDecimal>();
    Map<BranchCourseGroup, BigDecimal> cardinality = new HashMap<BranchCourseGroup, BigDecimal>();
    Map<BranchCourseGroup, BigDecimal> average = new HashMap<BranchCourseGroup, BigDecimal>();

    for (BranchCourseGroup branch : branches) {
      sigma.put(branch, new BigDecimal(0));
      cardinality.put(branch, new BigDecimal(0));
      average.put(branch, new BigDecimal(0));
    }

    for (Enrolment enrol : bean.getEnrolments()) {
      BranchCourseGroup branch =
          enrol.getParentBranchCurriculumGroup() != null
              ? enrol.getParentBranchCurriculumGroup().getDegreeModule()
              : null;
      if (branch == null || branch.getBranchType() != bType) {
        continue;
      }

      Grade grade = enrol.getGrade();
      if (grade.isApproved() && grade.getGradeScale() == GradeScale.TYPE20) {
        BigDecimal biggy = sigma.get(branch);
        BigDecimal smalls = biggy.add(grade.getNumericValue());
        sigma.put(branch, smalls);

        BigDecimal notorious = cardinality.get(branch);
        BigDecimal big = notorious.add(BigDecimal.ONE);
        cardinality.put(branch, big);
      }
    }

    for (BranchCourseGroup branch : branches) {
      if (cardinality.get(branch).compareTo(BigDecimal.ZERO) == 0) {
        result.put(branch, "-");
      } else {
        result.put(
            branch,
            (sigma.get(branch))
                .divide(cardinality.get(branch), 2, RoundingMode.HALF_EVEN)
                .toPlainString());
      }
    }

    return result;
  }