Beispiel #1
0
  /**
   * Ver onde sao guardados os StudentInquiries (QUC): ir por CurricularCourses
   *
   * <p>1. Extrair o ED 2. A partir do ED extrair duas collections: CourseResults e TeacherResults
   * 3. Magia para tirar um score desses results (ainda nao sei o q possa ser esse score. vou
   * extrair o 'average_NDE' e 'average_P6_1' apenas a titulo de exemplo. nao tem qq valor real. os
   * values sao em double, passar a BigDecimals e trabalhar sempre neste format). 4. Aplicar 50% à
   * media do score de todos os CourseResults e 50% à media do score de todos os TeacherResults 5.
   * Mostrar esse score.
   */
  private String generateQUCResults(YearViewBean bean) {
    ExecutionDegree executionDegree =
        ExecutionDegree.getByDegreeCurricularPlanAndExecutionYear(
            bean.getDegreeCurricularPlan(), bean.getExecutionYear());

    Set<StudentInquiriesCourseResult> courseResults =
        executionDegree.getStudentInquiriesCourseResultsSet();
    Set<StudentInquiriesTeachingResult> teachingResults =
        executionDegree.getStudentInquiriesTeachingResultsSet();

    BigDecimal sigmaCR = new BigDecimal(0);
    BigDecimal cardinalityCR = new BigDecimal(0);
    BigDecimal averageCR = new BigDecimal(0);

    BigDecimal sigmaTR = new BigDecimal(0);
    BigDecimal cardinalityTR = new BigDecimal(0);
    BigDecimal averageTR = new BigDecimal(0);

    BigDecimal partialCourse = new BigDecimal(0);
    BigDecimal partialTeaching = new BigDecimal(0);

    String result;

    for (StudentInquiriesCourseResult courseResult : courseResults) {
      BigDecimal converted =
          new BigDecimal(courseResult.getAverage_NDE() != null ? courseResult.getAverage_NDE() : 0);
      sigmaCR = sigmaCR.add(converted);
      cardinalityCR = cardinalityCR.add(BigDecimal.ONE);
    }
    if (cardinalityCR.compareTo(BigDecimal.ZERO) != 0) {
      averageCR = sigmaCR.divide(cardinalityCR, 4, RoundingMode.HALF_EVEN);
    } else {
      averageCR = BigDecimal.ZERO;
    }

    for (StudentInquiriesTeachingResult teachingResult : teachingResults) {
      BigDecimal converted =
          new BigDecimal(
              teachingResult.getAverage_P6_1() != null ? teachingResult.getAverage_P6_1() : 0);
      sigmaTR = sigmaTR.add(converted);
      cardinalityTR = cardinalityTR.add(BigDecimal.ONE);
    }
    if (cardinalityCR.compareTo(BigDecimal.ZERO) != 0) {
      averageTR = sigmaTR.divide(cardinalityTR, 4, RoundingMode.HALF_EVEN);
    } else {
      averageTR = BigDecimal.ZERO;
    }

    partialCourse = averageCR.divide(new BigDecimal(2), 2, RoundingMode.HALF_EVEN);
    partialTeaching = averageTR.divide(new BigDecimal(2), 2, RoundingMode.HALF_EVEN);

    result = partialCourse.add(partialTeaching).toPlainString();

    return result;
  }
  @Atomic
  public void setAnsweredInquiry() {
    if (getInquiryRegistry().getState() == InquiriesRegistryState.ANSWERED) {
      return;
    }
    InquiryCourseAnswer inquiryCourseAnswer = new InquiryCourseAnswer();
    DateTime endTime = new DateTime();
    inquiryCourseAnswer.setAnswerDuration(endTime.getMillis() - getStartedWhen().getMillis());
    inquiryCourseAnswer.setAttendenceClassesPercentage(
        getInquiryRegistry().getAttendenceClassesPercentage());

    inquiryCourseAnswer.setEntryGrade(
        InquiryGradesInterval.getInterval(getInquiryRegistry().getRegistration().getEntryGrade()));
    inquiryCourseAnswer.setExecutionCourse(getInquiryRegistry().getExecutionCourse());
    inquiryCourseAnswer.setExecutionDegreeStudent(
        getInquiryRegistry()
            .getRegistration()
            .getLastStudentCurricularPlan()
            .getDegreeCurricularPlan()
            .getMostRecentExecutionDegree());
    ExecutionDegree executionDegreeCourse =
        ExecutionDegree.getByDegreeCurricularPlanAndExecutionYear(
            getInquiryRegistry().getCurricularCourse().getDegreeCurricularPlan(),
            getInquiryRegistry().getExecutionPeriod().getExecutionYear());
    inquiryCourseAnswer.setExecutionDegreeCourse(executionDegreeCourse);
    inquiryCourseAnswer.setExecutionPeriod(getInquiryRegistry().getExecutionPeriod());

    inquiryCourseAnswer.setNumberOfEnrolments(
        InquiryCourseAnswer.getNumberOfEnrolments(getInquiryRegistry()));
    inquiryCourseAnswer.setResponseDateTime(endTime);
    inquiryCourseAnswer.setRegistrationProtocol(
        getInquiryRegistry().getRegistration().getRegistrationProtocol());
    inquiryCourseAnswer.setStudyDaysSpentInExamsSeason(
        getInquiryRegistry().getStudyDaysSpentInExamsSeason());
    for (Shift enrolledShift :
        getInquiryRegistry()
            .getRegistration()
            .getShiftsFor(getInquiryRegistry().getExecutionCourse())) {
      inquiryCourseAnswer.addEnrolledShifts(enrolledShift);
    }
    final StudentInquiryExecutionPeriod studentInquiryExecutionPeriod =
        getInquiryRegistry()
            .getRegistration()
            .getStudent()
            .getStudentInquiryExecutionPeriod(getInquiryRegistry().getExecutionPeriod());
    inquiryCourseAnswer.setWeeklyHoursSpentInAutonomousWork(
        studentInquiryExecutionPeriod.getWeeklyHoursSpentInClassesSeason());
    inquiryCourseAnswer.setWeeklyHoursSpentPercentage(
        getInquiryRegistry().getWeeklyHoursSpentPercentage());

    inquiryCourseAnswer.setCommittedFraud(
        Boolean.FALSE); // TODO actualmente não existe registo desta info no fenix
    inquiryCourseAnswer.setGrade(getInquiryRegistry().getLastGradeInterval());
    for (InquiryBlockDTO inquiryBlockDTO : getCurricularCourseBlocks()) {
      for (InquiryGroupQuestionBean groupQuestionBean : inquiryBlockDTO.getInquiryGroups()) {
        for (InquiryQuestionDTO questionDTO : groupQuestionBean.getInquiryQuestions()) {
          if (!StringUtils.isEmpty(questionDTO.getResponseValue())) {
            QuestionAnswer questionAnswer =
                new QuestionAnswer(
                    inquiryCourseAnswer,
                    questionDTO.getInquiryQuestion(),
                    questionDTO.getFinalValue());
          }
        }
      }
    }

    for (AffiliatedTeacherDTO teacherDTO : getTeachersInquiries().keySet()) {
      for (StudentTeacherInquiryBean teacherInquiryBean : getTeachersInquiries().get(teacherDTO)) {
        if (teacherInquiryBean.isFilled() && teacherInquiryBean.isInquiryFilledIn()) {
          InquiryStudentTeacherAnswer inquiryTeacherAnswer = new InquiryStudentTeacherAnswer();

          inquiryTeacherAnswer.setProfessorship(
              teacherInquiryBean.getExecutionCourse().getProfessorship(teacherDTO.getTeacher()));

          inquiryTeacherAnswer.setShiftType(teacherInquiryBean.getShiftType());
          inquiryTeacherAnswer.setInquiryCourseAnswer(inquiryCourseAnswer);
          for (InquiryBlockDTO inquiryBlockDTO : teacherInquiryBean.getTeacherInquiryBlocks()) {
            for (InquiryGroupQuestionBean groupQuestionBean : inquiryBlockDTO.getInquiryGroups()) {
              for (InquiryQuestionDTO questionDTO : groupQuestionBean.getInquiryQuestions()) {
                QuestionAnswer questionAnswer =
                    new QuestionAnswer(
                        inquiryTeacherAnswer,
                        questionDTO.getInquiryQuestion(),
                        questionDTO.getFinalValue());
              }
            }
          }
        }
      }
    }
    getInquiryRegistry().setState(InquiriesRegistryState.ANSWERED);
  }