use of fi.otavanopisto.pyramus.domainmodel.grading.Credit 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.grading.Credit in project pyramus by otavanopisto.
the class GradingService method getCreditVariable.
public String getCreditVariable(@WebParam(name = "creditId") Long creditId, @WebParam(name = "key") String key) {
CreditDAO creditDAO = DAOFactory.getInstance().getCreditDAO();
CreditVariableDAO creditVariableDAO = DAOFactory.getInstance().getCreditVariableDAO();
Credit credit = creditDAO.findById(creditId);
return creditVariableDAO.findByCreditAndKey(credit, key);
}
use of fi.otavanopisto.pyramus.domainmodel.grading.Credit in project pyramus by otavanopisto.
the class EditVerbalAssessmentViewController method process.
/**
* Processes the page request by including the corresponding JSP page to the response.
*
* @param pageRequestContext Page request context
*/
public void process(PageRequestContext pageRequestContext) {
CreditDAO creditDAO = DAOFactory.getInstance().getCreditDAO();
Long creditId = pageRequestContext.getLong("creditId");
Credit credit = creditId != null ? creditDAO.findById(creditId) : null;
if (credit != null)
pageRequestContext.getRequest().setAttribute("verbalAssessment", credit.getVerbalAssessment());
pageRequestContext.setIncludeJSP("/templates/courses/editverbalassessment.jsp");
}
use of fi.otavanopisto.pyramus.domainmodel.grading.Credit in project pyramus by otavanopisto.
the class CreditEntityFactory method buildFromDomainObject.
public CreditEntity buildFromDomainObject(Object domainObject) {
if (domainObject == null)
return null;
Credit credit = (Credit) domainObject;
TransferCreditDAO transferCreditDAO = DAOFactory.getInstance().getTransferCreditDAO();
CourseAssessmentDAO courseAssessmentDAO = DAOFactory.getInstance().getCourseAssessmentDAO();
switch(credit.getCreditType()) {
case CourseAssessment:
return EntityFactoryVault.buildFromDomainObject(courseAssessmentDAO.findById(credit.getId()));
case TransferCredit:
return EntityFactoryVault.buildFromDomainObject(transferCreditDAO.findById(credit.getId()));
}
return null;
}
use of fi.otavanopisto.pyramus.domainmodel.grading.Credit in project pyramus by otavanopisto.
the class MuikkuRESTService method getStudentStudyActivity.
@Path("/students/{ID:[0-9]*}/studyActivity")
@GET
@RESTPermit(handling = Handling.INLINE)
public Response getStudentStudyActivity(@PathParam("ID") Long id) {
// Access check
Student student = studentController.findStudentById(id);
if (student == null || student.getArchived()) {
return Response.status(Status.NOT_FOUND).build();
}
if (!restSecurity.hasPermission(new String[] { MuikkuPermissions.GET_STUDENT_COURSE_ACTIVITY, UserPermissions.USER_OWNER }, student, Style.OR)) {
return Response.status(Status.FORBIDDEN).build();
}
if (!sessionController.hasEnvironmentPermission(OrganizationPermissions.ACCESS_ALL_ORGANIZATIONS)) {
if (!UserUtils.isMemberOf(sessionController.getUser(), student.getOrganization())) {
return Response.status(Status.FORBIDDEN).build();
}
}
Map<String, StudyActivityItemRestModel> items = new HashMap<>();
// Transfer credits
List<TransferCredit> transferCredits = transferCreditDAO.listByStudent(student);
transferCredits.sort(Comparator.comparing(TransferCredit::getDate).reversed());
for (TransferCredit transferCredit : transferCredits) {
String key = getActivityItemKey(transferCredit.getSubject(), transferCredit.getCourseNumber());
StudyActivityItemRestModel item = getTransferCreditActivityItem(transferCredit);
if (!items.containsKey(key) || items.get(key).getDate().getTime() < item.getDate().getTime()) {
items.put(key, item);
}
}
// Course assessments
List<CourseAssessment> courseAssessments = courseAssessmentDAO.listByStudent(student);
courseAssessments.sort(Comparator.comparing(CourseAssessment::getDate).reversed());
for (CourseAssessment courseAssessment : courseAssessments) {
Course course = courseAssessment.getCourseStudent().getCourse();
String key = getActivityItemKey(course.getSubject(), course.getCourseNumber());
StudyActivityItemRestModel item = getCourseAssessmentActivityItem(courseAssessment);
if (!items.containsKey(key) || items.get(key).getDate().getTime() < item.getDate().getTime()) {
items.put(key, item);
}
}
// Linked credits
List<CreditLink> creditLinks = creditLinkDAO.listByStudent(student);
for (CreditLink creditLink : creditLinks) {
Credit credit = creditLink.getCredit();
if (credit.getCreditType() == CreditType.CourseAssessment) {
CourseAssessment courseAssessment = (CourseAssessment) credit;
Course course = courseAssessment.getCourseStudent().getCourse();
String key = getActivityItemKey(course.getSubject(), course.getCourseNumber());
StudyActivityItemRestModel item = getCourseAssessmentActivityItem(courseAssessment);
if (!items.containsKey(key) || items.get(key).getDate().getTime() < item.getDate().getTime()) {
items.put(key, item);
}
} else if (credit.getCreditType() == CreditType.TransferCredit) {
TransferCredit transferCredit = (TransferCredit) credit;
String key = getActivityItemKey(transferCredit.getSubject(), transferCredit.getCourseNumber());
StudyActivityItemRestModel item = getTransferCreditActivityItem(transferCredit);
if (!items.containsKey(key) || items.get(key).getDate().getTime() < item.getDate().getTime()) {
items.put(key, item);
}
}
}
// Courses
List<CourseStudent> courseStudents = courseStudentDAO.listByStudent(student);
for (CourseStudent courseStudent : courseStudents) {
Course course = courseStudent.getCourse();
String key = getActivityItemKey(course.getSubject(), course.getCourseNumber());
if (!items.containsKey(key)) {
StudyActivityItemRestModel item = new StudyActivityItemRestModel();
item.setCourseId(course.getId());
item.setCourseName(course.getName());
if (course.getCourseNumber() != null && course.getCourseNumber() > 0) {
item.setCourseNumber(course.getCourseNumber());
}
item.setDate(courseStudent.getEnrolmentTime());
item.setStatus(StudyActivityItemStatus.ONGOING);
item.setSubject(course.getSubject().getCode());
items.put(key, item);
}
}
return Response.ok(items.values()).build();
}
Aggregations