Search in sources :

Example 1 with StudentSubjectGrade

use of fi.otavanopisto.pyramus.domainmodel.students.StudentSubjectGrade in project pyramus by otavanopisto.

the class KoskiInternetixLukioStudentHandler method assessmentsToModel.

private void assessmentsToModel(LukionOpiskeluoikeus opiskeluoikeus, Student student, StudentSubjectSelections studentSubjects, boolean calculateMeanGrades, boolean sisällytäVahvistus, String toimipisteOID, boolean defaultStudyProgramme) {
    List<OpiskelijanOPS> opsList = new ArrayList<>();
    opsList.add(OpiskelijanOPS.ops2016);
    opsList.add(OpiskelijanOPS.ops2005);
    KoskiStudyProgrammeHandlerParams handlerParams = getHandlerParams(HANDLER_TYPE);
    // If this is default study programme of the student, we exclude the incompatible education type (ie list all other edutypes)
    // Otherwise, only list credits from one education type
    Predicate<Credit> predicate = defaultStudyProgramme ? credit -> !matchingEducationTypeFilter(credit, handlerParams.getExcludedEducationTypes()) : credit -> matchingEducationTypeFilter(credit, handlerParams.getEducationTypes());
    Map<OpiskelijanOPS, List<CreditStub>> opsCredits = listCredits(student, true, true, opsList, OpiskelijanOPS.ops2016, predicate);
    Map<String, OppiaineenSuoritusWithCurriculum<LukionOppiaineenSuoritus>> map = new HashMap<>();
    Set<OppiaineenSuoritusWithCurriculum<LukionOppiaineenSuoritus>> accomplished = new HashSet<>();
    for (OpiskelijanOPS ops : opsCredits.keySet()) {
        List<CreditStub> credits = opsCredits.get(ops);
        for (CreditStub credit : credits) {
            OppiaineenSuoritusWithCurriculum<LukionOppiaineenSuoritus> oppiaineenSuoritus = getSubject(ops, student, handlerParams.getEducationTypes(), credit.getSubject(), studentSubjects, map);
            collectAccomplishedMarks(credit.getSubject(), oppiaineenSuoritus, studentSubjects, accomplished);
            if (settings.isReportedCredit(credit) && oppiaineenSuoritus != null) {
                LukionKurssinSuoritus kurssiSuoritus = createKurssiSuoritus(student, ops, credit);
                if (kurssiSuoritus != null) {
                    oppiaineenSuoritus.getOppiaineenSuoritus().addOsasuoritus(kurssiSuoritus);
                } else {
                    logger.warning(String.format("Course %s not reported for student %d due to unresolvable credit.", credit.getCourseCode(), student.getId()));
                    koskiPersonLogDAO.create(student.getPerson(), student, KoskiPersonState.UNREPORTED_CREDIT, new Date(), credit.getCourseCode());
                }
            }
        }
    }
    for (OppiaineenSuoritusWithCurriculum<LukionOppiaineenSuoritus> lukionOppiaineenSuoritus : map.values()) {
        if (CollectionUtils.isEmpty(lukionOppiaineenSuoritus.getOppiaineenSuoritus().getOsasuoritukset())) {
            // Skip empty subjects
            continue;
        }
        StudentSubjectGrade studentSubjectGrade = findStudentSubjectGrade(student, lukionOppiaineenSuoritus.getSubject());
        boolean hasStudentSubjectGrade = studentSubjectGrade != null;
        // Valmiille oppiaineelle on rustattava kokonaisarviointi
        if (calculateMeanGrades || hasStudentSubjectGrade) {
            ArviointiasteikkoYleissivistava aineKeskiarvo = accomplished.contains(lukionOppiaineenSuoritus) ? ArviointiasteikkoYleissivistava.GRADE_S : getSubjectMeanGrade(student, lukionOppiaineenSuoritus.getSubject(), lukionOppiaineenSuoritus.getOppiaineenSuoritus());
            if (aineKeskiarvo != null) {
                Date arviointiPvm = (studentSubjectGrade != null && studentSubjectGrade.getGradeDate() != null) ? studentSubjectGrade.getGradeDate() : student.getStudyEndDate();
                LukionOppiaineenArviointi arviointi = new LukionOppiaineenArviointi(aineKeskiarvo, arviointiPvm);
                lukionOppiaineenSuoritus.getOppiaineenSuoritus().addArviointi(arviointi);
            } else {
                logger.warning(String.format("Unresolved mean grade for person %d.", student.getPerson().getId()));
            }
        }
        LukionOppiaineenSuoritus oppiaineenSuoritus = lukionOppiaineenSuoritus.getOppiaineenSuoritus();
        LukionOppiaineenOppimaaranSuoritus oppiaineenOppimaaranSuoritus = LukionOppiaineenOppimaaranSuoritus.from(oppiaineenSuoritus, Kieli.FI, new OrganisaationToimipisteOID(toimipisteOID));
        oppiaineenOppimaaranSuoritus.getKoulutusmoduuli().setPerusteenDiaarinumero(getDiaarinumero(HANDLER_TYPE, lukionOppiaineenSuoritus.getOps()));
        oppiaineenOppimaaranSuoritus.setTodistuksellaNakyvatLisatiedot(getTodistuksellaNakyvatLisatiedot(student));
        if (hasStudentSubjectGrade) {
            oppiaineenOppimaaranSuoritus.setVahvistus(getVahvistus(student, studentSubjectGrade.getGradeApprover(), studentSubjectGrade.getGradeDate(), toimipisteOID));
        } else if (sisällytäVahvistus) {
            oppiaineenOppimaaranSuoritus.setVahvistus(getVahvistus(student, toimipisteOID));
        }
        opiskeluoikeus.addSuoritus(oppiaineenOppimaaranSuoritus);
    }
}
Also used : LukionOppiaineenOppimaaranSuoritus(fi.otavanopisto.pyramus.koski.model.lukio.LukionOppiaineenOppimaaranSuoritus) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) CreditStub(fi.otavanopisto.pyramus.koski.CreditStub) LukionOppiaineenSuoritus(fi.otavanopisto.pyramus.koski.model.lukio.LukionOppiaineenSuoritus) LukionOppiaineenArviointi(fi.otavanopisto.pyramus.koski.model.lukio.LukionOppiaineenArviointi) CreditStubCredit(fi.otavanopisto.pyramus.koski.CreditStubCredit) Credit(fi.otavanopisto.pyramus.domainmodel.grading.Credit) TransferCredit(fi.otavanopisto.pyramus.domainmodel.grading.TransferCredit) LukionKurssinSuoritus(fi.otavanopisto.pyramus.koski.model.lukio.LukionKurssinSuoritus) List(java.util.List) ArrayList(java.util.ArrayList) KoskiStudyProgrammeHandlerParams(fi.otavanopisto.pyramus.koski.settings.KoskiStudyProgrammeHandlerParams) HashSet(java.util.HashSet) OppiaineenSuoritusWithCurriculum(fi.otavanopisto.pyramus.koski.OppiaineenSuoritusWithCurriculum) ArviointiasteikkoYleissivistava(fi.otavanopisto.pyramus.koski.koodisto.ArviointiasteikkoYleissivistava) Date(java.util.Date) StudentSubjectGrade(fi.otavanopisto.pyramus.domainmodel.students.StudentSubjectGrade) OpiskelijanOPS(fi.otavanopisto.pyramus.koski.OpiskelijanOPS) OrganisaationToimipisteOID(fi.otavanopisto.pyramus.koski.model.OrganisaationToimipisteOID)

Example 2 with StudentSubjectGrade

use of fi.otavanopisto.pyramus.domainmodel.students.StudentSubjectGrade in project pyramus by otavanopisto.

the class StudentTORController method addTORCredit.

private static void addTORCredit(StudentTOR tor, Student student, Subject subject, Credit credit, Integer courseNumber, Set<Curriculum> creditCurriculums, Double courseLength, TORCourseLengthUnit courseLengthUnit, TORProblems problems) {
    if (credit.getGrade() == null) {
        return;
    }
    if (student.getCurriculum() != null) {
        Long studentCurriculumId = student.getCurriculum().getId();
        if (!creditCurriculums.isEmpty()) {
            boolean matchingCurriculum = creditCurriculums.stream().map(Curriculum::getId).anyMatch(studentCurriculumId::equals);
            // Both student and credit have curriculums set, but they didn't match -> skip the credit
            if (!matchingCurriculum) {
                return;
            }
        }
    }
    Long educationTypeId = subject.getEducationType() != null ? subject.getEducationType().getId() : null;
    fi.otavanopisto.pyramus.tor.Subject subjectModel = new fi.otavanopisto.pyramus.tor.Subject(subject.getId(), subject.getCode(), subject.getName(), educationTypeId, subject.getArchived());
    TORSubject torSubject = tor.findSubject(subject.getId());
    if (torSubject == null) {
        torSubject = TORSubject.from(subjectModel);
        tor.addSubject(torSubject);
        StudentSubjectGradeDAO studentSubjectGradeDAO = DAOFactory.getInstance().getStudentSubjectGradeDAO();
        StudentSubjectGrade studentSubjectGrade = studentSubjectGradeDAO.findBy(student, subject);
        if (studentSubjectGrade != null && studentSubjectGrade.getGrade() != null) {
            fi.otavanopisto.pyramus.domainmodel.grading.Grade grade = studentSubjectGrade.getGrade();
            Grade gradeModel = new Grade(grade.getId(), grade.getName(), grade.getDescription(), grade.getGradingScale().getId(), grade.getPassingGrade(), grade.getQualification(), grade.getGPA(), grade.getArchived());
            torSubject.setMeanGrade(gradeModel);
        }
    }
    TORCourse torCourse = torSubject.findCourse(courseNumber);
    if (torCourse == null) {
        torCourse = new TORCourse(subjectModel, courseNumber, courseLength, courseLengthUnit);
        torSubject.addCourse(torCourse);
    } else {
        if (torCourse.getLengthUnit() != courseLengthUnit) {
            problems.add(new TORProblem(TORProblemType.INCOMPATIBLE_LENGTHUNITS, String.format("%s%d", subjectModel.getCode(), courseNumber)));
        }
    }
    String gradeName = credit.getGrade().getName();
    Double gpa = credit.getGrade().getGPA();
    torCourse.addCredit(new TORCredit(credit.getGrade().getId(), gradeName, gpa, credit.getDate(), TORCreditType.COURSEASSESSMENT, credit.getGrade().getPassingGrade()));
}
Also used : StudentSubjectGrade(fi.otavanopisto.pyramus.domainmodel.students.StudentSubjectGrade) Subject(fi.otavanopisto.pyramus.domainmodel.base.Subject) StudentSubjectGradeDAO(fi.otavanopisto.pyramus.dao.students.StudentSubjectGradeDAO) StudentSubjectGrade(fi.otavanopisto.pyramus.domainmodel.students.StudentSubjectGrade)

Example 3 with StudentSubjectGrade

use of fi.otavanopisto.pyramus.domainmodel.students.StudentSubjectGrade in project pyramus by otavanopisto.

the class EditStudentSubjectGradeDialogViewController method process.

public void process(PageRequestContext requestContext) {
    StudentDAO studentDAO = DAOFactory.getInstance().getStudentDAO();
    StaffMemberDAO staffMemberDAO = DAOFactory.getInstance().getStaffMemberDAO();
    SubjectDAO subjectDAO = DAOFactory.getInstance().getSubjectDAO();
    StudentSubjectGradeDAO studentSubjectGradeDAO = DAOFactory.getInstance().getStudentSubjectGradeDAO();
    GradingScaleDAO gradingScaleDAO = DAOFactory.getInstance().getGradingScaleDAO();
    Long studentId = requestContext.getLong("studentId");
    Long subjectId = requestContext.getLong("subjectId");
    if (studentId == null || subjectId == null) {
        logger.log(Level.WARNING, String.format("Unable to load view due to missing studentId (%d) or subjectId (%d).", studentId, subjectId));
        try {
            requestContext.getResponse().sendError(HttpServletResponse.SC_BAD_REQUEST);
        } catch (Exception e) {
            logger.log(Level.SEVERE, "Couldn't send response", e);
        }
        return;
    }
    Student student = studentDAO.findById(studentId);
    Subject subject = subjectDAO.findById(subjectId);
    StudentSubjectGrade studentSubjectGrade = studentSubjectGradeDAO.findBy(student, subject);
    List<GradingScale> gradingScales = gradingScaleDAO.listUnarchived();
    List<StaffMember> studyApprovers = staffMemberDAO.listByProperty(StaffMemberProperties.STUDY_APPROVER.getKey(), "1");
    StaffMember selectedStudyApprover = studentSubjectGrade != null && studentSubjectGrade.getGradeApprover() != null ? studentSubjectGrade.getGradeApprover() : null;
    if (selectedStudyApprover != null) {
        Long selectedStudyApproverId = selectedStudyApprover.getId();
        boolean isSelectedInList = studyApprovers.stream().map(StaffMember::getId).anyMatch(selectedStudyApproverId::equals);
        if (!isSelectedInList) {
            studyApprovers.add(selectedStudyApprover);
        }
    }
    studyApprovers.sort(Comparator.comparing(StaffMember::getLastName).thenComparing(StaffMember::getFirstName));
    requestContext.getRequest().setAttribute("student", student);
    requestContext.getRequest().setAttribute("subject", subject);
    requestContext.getRequest().setAttribute("studentSubjectGrade", studentSubjectGrade);
    requestContext.getRequest().setAttribute("gradingScales", gradingScales);
    requestContext.getRequest().setAttribute("studyApprovers", studyApprovers);
    requestContext.setIncludeJSP("/templates/students/editstudentsubjectgradedialog.jsp");
}
Also used : GradingScale(fi.otavanopisto.pyramus.domainmodel.grading.GradingScale) GradingScaleDAO(fi.otavanopisto.pyramus.dao.grading.GradingScaleDAO) SubjectDAO(fi.otavanopisto.pyramus.dao.base.SubjectDAO) Student(fi.otavanopisto.pyramus.domainmodel.students.Student) StaffMember(fi.otavanopisto.pyramus.domainmodel.users.StaffMember) Subject(fi.otavanopisto.pyramus.domainmodel.base.Subject) StudentDAO(fi.otavanopisto.pyramus.dao.students.StudentDAO) StaffMemberDAO(fi.otavanopisto.pyramus.dao.users.StaffMemberDAO) StudentSubjectGradeDAO(fi.otavanopisto.pyramus.dao.students.StudentSubjectGradeDAO) StudentSubjectGrade(fi.otavanopisto.pyramus.domainmodel.students.StudentSubjectGrade)

Example 4 with StudentSubjectGrade

use of fi.otavanopisto.pyramus.domainmodel.students.StudentSubjectGrade in project pyramus by otavanopisto.

the class StudentSubjectGradeDAO method listByStudent.

public List<StudentSubjectGrade> listByStudent(Student student) {
    EntityManager entityManager = getEntityManager();
    CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
    CriteriaQuery<StudentSubjectGrade> criteria = criteriaBuilder.createQuery(StudentSubjectGrade.class);
    Root<StudentSubjectGrade> root = criteria.from(StudentSubjectGrade.class);
    criteria.select(root);
    criteria.where(criteriaBuilder.equal(root.get(StudentSubjectGrade_.student), student));
    return entityManager.createQuery(criteria).getResultList();
}
Also used : CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) EntityManager(javax.persistence.EntityManager) StudentSubjectGrade(fi.otavanopisto.pyramus.domainmodel.students.StudentSubjectGrade)

Example 5 with StudentSubjectGrade

use of fi.otavanopisto.pyramus.domainmodel.students.StudentSubjectGrade in project pyramus by otavanopisto.

the class StudentSubjectGradeDAO method findBy.

public StudentSubjectGrade findBy(Student student, Subject subject) {
    EntityManager entityManager = getEntityManager();
    CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
    CriteriaQuery<StudentSubjectGrade> criteria = criteriaBuilder.createQuery(StudentSubjectGrade.class);
    Root<StudentSubjectGrade> root = criteria.from(StudentSubjectGrade.class);
    criteria.select(root);
    criteria.where(criteriaBuilder.equal(root.get(StudentSubjectGrade_.student), student), criteriaBuilder.equal(root.get(StudentSubjectGrade_.subject), subject));
    return getSingleResult(entityManager.createQuery(criteria));
}
Also used : CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) EntityManager(javax.persistence.EntityManager) StudentSubjectGrade(fi.otavanopisto.pyramus.domainmodel.students.StudentSubjectGrade)

Aggregations

StudentSubjectGrade (fi.otavanopisto.pyramus.domainmodel.students.StudentSubjectGrade)8 StudentSubjectGradeDAO (fi.otavanopisto.pyramus.dao.students.StudentSubjectGradeDAO)3 Subject (fi.otavanopisto.pyramus.domainmodel.base.Subject)3 Date (java.util.Date)3 HashMap (java.util.HashMap)3 SubjectDAO (fi.otavanopisto.pyramus.dao.base.SubjectDAO)2 StudentDAO (fi.otavanopisto.pyramus.dao.students.StudentDAO)2 StaffMemberDAO (fi.otavanopisto.pyramus.dao.users.StaffMemberDAO)2 Credit (fi.otavanopisto.pyramus.domainmodel.grading.Credit)2 Student (fi.otavanopisto.pyramus.domainmodel.students.Student)2 StaffMember (fi.otavanopisto.pyramus.domainmodel.users.StaffMember)2 CreditStub (fi.otavanopisto.pyramus.koski.CreditStub)2 OpiskelijanOPS (fi.otavanopisto.pyramus.koski.OpiskelijanOPS)2 OppiaineenSuoritusWithCurriculum (fi.otavanopisto.pyramus.koski.OppiaineenSuoritusWithCurriculum)2 ArviointiasteikkoYleissivistava (fi.otavanopisto.pyramus.koski.koodisto.ArviointiasteikkoYleissivistava)2 OrganisaationToimipisteOID (fi.otavanopisto.pyramus.koski.model.OrganisaationToimipisteOID)2 KoskiStudyProgrammeHandlerParams (fi.otavanopisto.pyramus.koski.settings.KoskiStudyProgrammeHandlerParams)2 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 List (java.util.List)2