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);
}
}
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()));
}
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");
}
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();
}
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));
}
Aggregations