@Override
  public Set<User> getMembers() {
    Set<User> users = new HashSet<User>();

    Set<Degree> degrees = new HashSet<>();
    for (CompetenceCourse competenceCourse : executionCourse.getCompetenceCourses()) {
      for (CurricularCourse curricularCourse :
          competenceCourse.getAssociatedCurricularCoursesSet()) {
        degrees.add(curricularCourse.getDegree());
      }
    }
    // students of any degree sharing the same competence of the given execution course
    for (Degree degree : degrees) {
      for (Registration registration : degree.getActiveRegistrations()) {
        User user = registration.getPerson().getUser();
        if (user != null) {
          users.add(user);
        }
      }
    }
    // students attending the given execution course (most will be in the previous case but some may
    // not)
    for (Attends attends : executionCourse.getAttendsSet()) {
      User user = attends.getRegistration().getPerson().getUser();
      if (user != null) {
        users.add(user);
      }
    }
    return users;
  }
Ejemplo n.º 2
0
  /**
   * Checks if person belongs to curricular course. The unit path format should be:
   * IST{.<SubUnitAcronym>}.<DegreeAcronym>.<CurricularCourseAcronym>
   *
   * <p>Accepted roles: STUDENT
   *
   * @param person
   * @param groupCheckQuery
   * @return
   * @throws NonExistingServiceException
   * @throws ExcepcaoPersistencia
   */
  private static Boolean checkCurricularCourseGroup(Person person, GroupCheckQuery groupCheckQuery)
      throws NonExistingServiceException {
    final String[] unitAcronyms = groupCheckQuery.unitFullPath.split("\\.");

    if (!groupCheckQuery.roleType.equals("STUDENT")) {
      throw new NonExistingServiceException();
    }

    for (final DegreeCurricularPlan degreeCurricularPlan :
        getDegree(unitAcronyms).getActiveDegreeCurricularPlans()) {

      final CurricularCourse curricularCourse =
          degreeCurricularPlan.getCurricularCourseByAcronym(unitAcronyms[4]);

      if (curricularCourse != null) {
        List<Enrolment> enrolments =
            curricularCourse.getEnrolmentsByExecutionPeriod(
                getExecutionPeriod(groupCheckQuery.year, groupCheckQuery.semester));
        for (Enrolment enrolment : enrolments) {
          if (enrolment.getStudentCurricularPlan().getRegistration().getPerson().equals(person)) {
            return true;
          }
        }
      }
    }

    return false;
  }
  public List<DegreeCourseStatisticsDTO> run(
      CompetenceCourse competenceCourse, ExecutionSemester executionSemester)
      throws FenixServiceException {
    Map<Degree, List<CurricularCourse>> groupedCourses =
        competenceCourse.getAssociatedCurricularCoursesGroupedByDegree();

    List<DegreeCourseStatisticsDTO> results = new ArrayList<DegreeCourseStatisticsDTO>();

    for (Degree degree : groupedCourses.keySet()) {
      List<Enrolment> enrollments = new ArrayList<Enrolment>();
      List<CurricularCourse> curricularCourses = groupedCourses.get(degree);

      for (CurricularCourse curricularCourse : curricularCourses) {
        enrollments.addAll(curricularCourse.getActiveEnrollments(executionSemester));
      }

      DegreeCourseStatisticsDTO degreeCourseStatistics = new DegreeCourseStatisticsDTO();
      degreeCourseStatistics.setExternalId(degree.getExternalId());
      degreeCourseStatistics.setName(degree.getSigla());
      createCourseStatistics(degreeCourseStatistics, enrollments);

      results.add(degreeCourseStatistics);
    }

    return results;
  }
 public ExecutionCourseManagementBean(
     final ExecutionSemester semester, final CurricularCourse curricularCourse) {
   setSemester(semester);
   setCurricularCourseList(new ArrayList<CurricularCourse>());
   getCurricularCourseList().add(curricularCourse);
   setName(curricularCourse.getNameI18N().getContent(MultiLanguageString.pt));
 }
 private void load(final DegreeModule degreeModule) {
   degreeModule.getName();
   if (degreeModule.isCourseGroup()) {
     final CourseGroup courseGroup = (CourseGroup) degreeModule;
     for (final org.fenixedu.academic.domain.degreeStructure.Context context :
         courseGroup.getChildContextsSet()) {
       final DegreeModule child = context.getChildDegreeModule();
       load(child);
     }
   } else {
     final CurricularCourse curricularCourse = (CurricularCourse) degreeModule;
     final CompetenceCourse competenceCourse = curricularCourse.getCompetenceCourse();
     if (competenceCourse != null) {
       competenceCourse.getName();
     }
   }
 }
Ejemplo n.º 6
0
  /**
   * Checks if person belongs to curricular course. The unit path format should be:
   * IST{.<SubUnitAcronym>}.<DegreeAcronym>.<CurricularCourseAcronym>
   *
   * <p>Accepted roles: STUDENT and TEACHER
   *
   * @param person
   * @param groupCheckQuery
   * @return
   * @throws NonExistingServiceException
   * @throws ExcepcaoPersistencia
   */
  private static Boolean checkExecutionCourseGroup(Person person, GroupCheckQuery groupCheckQuery)
      throws NonExistingServiceException {
    String[] unitAcronyms = groupCheckQuery.unitFullPath.split("\\.");

    if (!groupCheckQuery.roleType.equals("TEACHER")
        && !groupCheckQuery.roleType.equals("STUDENT")) {
      throw new NonExistingServiceException();
    }

    Degree degree = getDegree(unitAcronyms);
    for (DegreeCurricularPlan degreeCurricularPlan : degree.getActiveDegreeCurricularPlans()) {

      ExecutionSemester executionSemester =
          getExecutionPeriod(groupCheckQuery.year, groupCheckQuery.semester);

      CurricularCourse curricularCourse =
          degreeCurricularPlan.getCurricularCourseByAcronym(unitAcronyms[4]);

      if (curricularCourse != null) {
        List<ExecutionCourse> executionCourses =
            curricularCourse.getExecutionCoursesByExecutionPeriod(executionSemester);

        for (ExecutionCourse executionCourse : executionCourses) {
          Group group;

          if (groupCheckQuery.roleType.equals("TEACHER")) {
            group = TeacherGroup.get(executionCourse);
          } else {
            group = StudentGroup.get(executionCourse);
          }

          if (group.isMember(person.getUser())) {
            return true;
          }
        }
      }
    }

    return false;
  }