use of fi.otavanopisto.pyramus.koski.CreditStub in project pyramus by otavanopisto.
the class KoskiInternetixLukioStudentHandler method findCourseType.
private LukionKurssinTyyppi findCourseType(Student student, CreditStub courseCredit, boolean national, LukionKurssinTyyppi... allowedValues) {
Set<LukionKurssinTyyppi> resolvedTypes = new HashSet<>();
for (CreditStubCredit credit : courseCredit.getCredits()) {
if (credit.getCredit() instanceof CourseAssessment) {
CourseAssessment courseAssessment = (CourseAssessment) credit.getCredit();
if (courseAssessment.getCourseStudent() != null && courseAssessment.getCourseStudent().getCourse() != null) {
Course course = courseAssessment.getCourseStudent().getCourse();
Set<Long> educationSubTypeIds = course.getCourseEducationTypes().stream().flatMap(educationType -> educationType.getCourseEducationSubtypes().stream().map(subType -> subType.getEducationSubtype().getId())).collect(Collectors.toSet());
for (Long educationSubTypeId : educationSubTypeIds) {
String mappedValue = settings.getCourseTypeMapping(educationSubTypeId);
if (mappedValue != null && EnumUtils.isValidEnum(LukionKurssinTyyppi.class, mappedValue)) {
resolvedTypes.add(LukionKurssinTyyppi.valueOf(mappedValue));
}
}
} else
logger.warning(String.format("CourseAssessment %d has no courseStudent or Course", courseAssessment.getId()));
} else if (credit.getCredit() instanceof TransferCredit) {
TransferCredit transferCredit = (TransferCredit) credit.getCredit();
if (national && transferCredit.getOptionality() == CourseOptionality.MANDATORY) {
resolvedTypes.add(LukionKurssinTyyppi.pakollinen);
} else {
resolvedTypes.add(LukionKurssinTyyppi.syventava);
}
} else {
logger.warning(String.format("Unknown credit type %s", credit.getClass().getSimpleName()));
}
}
Set<LukionKurssinTyyppi> allowedSet = new HashSet<>(Arrays.asList(allowedValues));
allowedSet.removeIf(element -> !resolvedTypes.contains(element));
if (allowedSet.size() == 0) {
logger.warning(String.format("Course %s has no feasible subtypes.", courseCredit.getCourseCode()));
koskiPersonLogDAO.create(student.getPerson(), student, KoskiPersonState.UNRESOLVABLE_SUBTYPES, new Date(), courseCredit.getCourseCode());
return allowedValues[0];
} else if (allowedSet.size() == 1) {
return allowedSet.iterator().next();
} else {
for (LukionKurssinTyyppi type : allowedValues) {
if (allowedSet.contains(type)) {
logger.warning(String.format("Course %s has several matching subtypes.", courseCredit.getCourseCode()));
koskiPersonLogDAO.create(student.getPerson(), student, KoskiPersonState.UNRESOLVABLE_SUBTYPES, new Date(), courseCredit.getCourseCode());
return type;
}
}
}
return allowedValues[0];
}
use of fi.otavanopisto.pyramus.koski.CreditStub in project pyramus by otavanopisto.
the class AbstractKoskiLukioStudentHandler2019 method findCourseType.
private LukionKurssinTyyppi findCourseType(Student student, CreditStub courseCredit, boolean national, LukionKurssinTyyppi... allowedValues) {
Set<LukionKurssinTyyppi> resolvedTypes = new HashSet<>();
for (CreditStubCredit credit : courseCredit.getCredits()) {
if (credit.getCredit() instanceof CourseAssessment) {
CourseAssessment courseAssessment = (CourseAssessment) credit.getCredit();
if (courseAssessment.getCourseStudent() != null && courseAssessment.getCourseStudent().getCourse() != null) {
Course course = courseAssessment.getCourseStudent().getCourse();
Set<Long> educationSubTypeIds = course.getCourseEducationTypes().stream().flatMap(educationType -> educationType.getCourseEducationSubtypes().stream().map(subType -> subType.getEducationSubtype().getId())).collect(Collectors.toSet());
for (Long educationSubTypeId : educationSubTypeIds) {
String mappedValue = settings.getCourseTypeMapping2019(educationSubTypeId);
if (mappedValue != null && EnumUtils.isValidEnum(LukionKurssinTyyppi.class, mappedValue)) {
resolvedTypes.add(LukionKurssinTyyppi.valueOf(mappedValue));
}
}
} else {
logger.warning(String.format("CourseAssessment %d has no courseStudent or Course", courseAssessment.getId()));
}
} else if (credit.getCredit() instanceof TransferCredit) {
TransferCredit transferCredit = (TransferCredit) credit.getCredit();
if (national && transferCredit.getOptionality() == CourseOptionality.MANDATORY) {
resolvedTypes.add(LukionKurssinTyyppi.pakollinen);
} else {
// TODO Is this correct?
resolvedTypes.add(LukionKurssinTyyppi.syventava);
}
} else {
logger.warning(String.format("Unknown credit type %s", credit.getClass().getSimpleName()));
}
}
Set<LukionKurssinTyyppi> allowedSet = new HashSet<>(Arrays.asList(allowedValues));
allowedSet.removeIf(element -> !resolvedTypes.contains(element));
if (allowedSet.size() == 0) {
logger.warning(String.format("Course %s has no feasible subtypes.", courseCredit.getCourseCode()));
koskiPersonLogDAO.create(student.getPerson(), student, KoskiPersonState.UNRESOLVABLE_SUBTYPES, new Date(), courseCredit.getCourseCode());
return allowedValues[0];
} else if (allowedSet.size() == 1) {
return allowedSet.iterator().next();
} else {
for (LukionKurssinTyyppi type : allowedValues) {
if (allowedSet.contains(type)) {
logger.warning(String.format("Course %s has several matching subtypes.", courseCredit.getCourseCode()));
koskiPersonLogDAO.create(student.getPerson(), student, KoskiPersonState.UNRESOLVABLE_SUBTYPES, new Date(), courseCredit.getCourseCode());
return type;
}
}
}
return allowedValues[0];
}
use of fi.otavanopisto.pyramus.koski.CreditStub in project pyramus by otavanopisto.
the class AbstractKoskiLukioStudentHandler2019 method assessmentsToModel.
protected Set<LukionOsasuoritus2019> assessmentsToModel(OpiskelijanOPS ops, Student student, EducationType studentEducationType, StudentSubjectSelections studentSubjects, boolean calculateMeanGrades) {
Collection<CreditStub> credits = listCredits(student, true, true, ops, credit -> matchingCurriculumFilter(student, credit));
Set<LukionOsasuoritus2019> results = new HashSet<>();
Map<String, OppiaineenSuoritusWithSubject<LukionOsasuoritus2019>> map = new HashMap<>();
Set<OppiaineenSuoritusWithSubject<LukionOsasuoritus2019>> accomplished = new HashSet<>();
for (CreditStub credit : credits) {
OppiaineenSuoritusWithSubject<LukionOsasuoritus2019> oppiaineenSuoritusWSubject = getSubject(student, ops, studentEducationType, credit.getSubject(), studentSubjects, map);
collectAccomplishedMarks(credit.getSubject(), oppiaineenSuoritusWSubject, studentSubjects, accomplished);
if (settings.isReportedCredit(credit) && oppiaineenSuoritusWSubject != null) {
LukionOpintojaksonSuoritus2019 kurssiSuoritus = createKurssiSuoritus(student, studentSubjects, oppiaineenSuoritusWSubject.isPaikallinenOppiaine(), ops, credit);
if (kurssiSuoritus != null) {
oppiaineenSuoritusWSubject.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 (OppiaineenSuoritusWithSubject<LukionOsasuoritus2019> lukionOppiaineenSuoritusWSubject : map.values()) {
LukionOsasuoritus2019 lukionOsaSuoritus = lukionOppiaineenSuoritusWSubject.getOppiaineenSuoritus();
if (CollectionUtils.isEmpty(lukionOsaSuoritus.getOsasuoritukset())) {
// Skip empty subjects
continue;
}
if (calculateMeanGrades && (lukionOsaSuoritus instanceof LukionOppiaineenSuoritus2019)) {
LukionOppiaineenSuoritus2019 lukionOppiaineenSuoritus = (LukionOppiaineenSuoritus2019) lukionOsaSuoritus;
ArviointiasteikkoYleissivistava aineKeskiarvo = accomplished.contains(lukionOppiaineenSuoritusWSubject) ? ArviointiasteikkoYleissivistava.GRADE_S : getSubjectMeanGrade(student, lukionOppiaineenSuoritusWSubject.getSubject(), lukionOsaSuoritus);
if (aineKeskiarvo != null) {
LukionOppiaineenArviointi arviointi = new LukionOppiaineenArviointi(aineKeskiarvo, student.getStudyEndDate());
lukionOppiaineenSuoritus.addArviointi(arviointi);
} else {
logger.warning(String.format("Unresolved mean grade for person %d.", student.getPerson().getId()));
}
}
results.add(lukionOsaSuoritus);
}
return results;
}
use of fi.otavanopisto.pyramus.koski.CreditStub in project pyramus by otavanopisto.
the class KoskiLukioStudentHandler method findCourseType.
private LukionKurssinTyyppi findCourseType(Student student, CreditStub courseCredit, boolean national, LukionKurssinTyyppi... allowedValues) {
Set<LukionKurssinTyyppi> resolvedTypes = new HashSet<>();
for (CreditStubCredit credit : courseCredit.getCredits()) {
if (credit.getCredit() instanceof CourseAssessment) {
CourseAssessment courseAssessment = (CourseAssessment) credit.getCredit();
if (courseAssessment.getCourseStudent() != null && courseAssessment.getCourseStudent().getCourse() != null) {
Course course = courseAssessment.getCourseStudent().getCourse();
Set<Long> educationSubTypeIds = course.getCourseEducationTypes().stream().flatMap(educationType -> educationType.getCourseEducationSubtypes().stream().map(subType -> subType.getEducationSubtype().getId())).collect(Collectors.toSet());
for (Long educationSubTypeId : educationSubTypeIds) {
String mappedValue = settings.getCourseTypeMapping(educationSubTypeId);
if (mappedValue != null && EnumUtils.isValidEnum(LukionKurssinTyyppi.class, mappedValue)) {
resolvedTypes.add(LukionKurssinTyyppi.valueOf(mappedValue));
}
}
} else
logger.warning(String.format("CourseAssessment %d has no courseStudent or Course", courseAssessment.getId()));
} else if (credit.getCredit() instanceof TransferCredit) {
TransferCredit transferCredit = (TransferCredit) credit.getCredit();
if (national && transferCredit.getOptionality() == CourseOptionality.MANDATORY) {
resolvedTypes.add(LukionKurssinTyyppi.pakollinen);
} else {
resolvedTypes.add(LukionKurssinTyyppi.syventava);
}
} else {
logger.warning(String.format("Unknown credit type %s", credit.getClass().getSimpleName()));
}
}
Set<LukionKurssinTyyppi> allowedSet = new HashSet<>(Arrays.asList(allowedValues));
allowedSet.removeIf(element -> !resolvedTypes.contains(element));
if (allowedSet.size() == 0) {
logger.warning(String.format("Course %s has no feasible subtypes.", courseCredit.getCourseCode()));
koskiPersonLogDAO.create(student.getPerson(), student, KoskiPersonState.UNRESOLVABLE_SUBTYPES, new Date(), courseCredit.getCourseCode());
return allowedValues[0];
} else if (allowedSet.size() == 1) {
return allowedSet.iterator().next();
} else {
for (LukionKurssinTyyppi type : allowedValues) {
if (allowedSet.contains(type)) {
logger.warning(String.format("Course %s has several matching subtypes.", courseCredit.getCourseCode()));
koskiPersonLogDAO.create(student.getPerson(), student, KoskiPersonState.UNRESOLVABLE_SUBTYPES, new Date(), courseCredit.getCourseCode());
return type;
}
}
}
return allowedValues[0];
}
Aggregations