Search in sources :

Example 1 with Credit

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);
    }
}
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 Credit

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);
}
Also used : CreditVariableDAO(fi.otavanopisto.pyramus.dao.grading.CreditVariableDAO) Credit(fi.otavanopisto.pyramus.domainmodel.grading.Credit) TransferCredit(fi.otavanopisto.pyramus.domainmodel.grading.TransferCredit) TransferCreditDAO(fi.otavanopisto.pyramus.dao.grading.TransferCreditDAO) CreditDAO(fi.otavanopisto.pyramus.dao.grading.CreditDAO)

Example 3 with Credit

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");
}
Also used : Credit(fi.otavanopisto.pyramus.domainmodel.grading.Credit) CreditDAO(fi.otavanopisto.pyramus.dao.grading.CreditDAO)

Example 4 with Credit

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;
}
Also used : Credit(fi.otavanopisto.pyramus.domainmodel.grading.Credit) TransferCreditDAO(fi.otavanopisto.pyramus.dao.grading.TransferCreditDAO) CourseAssessmentDAO(fi.otavanopisto.pyramus.dao.grading.CourseAssessmentDAO)

Example 5 with Credit

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();
}
Also used : StudyActivityItemRestModel(fi.otavanopisto.pyramus.rest.model.hops.StudyActivityItemRestModel) HashMap(java.util.HashMap) CourseStudent(fi.otavanopisto.pyramus.domainmodel.courses.CourseStudent) StudentGroupStudent(fi.otavanopisto.pyramus.domainmodel.students.StudentGroupStudent) Student(fi.otavanopisto.pyramus.domainmodel.students.Student) CourseAssessment(fi.otavanopisto.pyramus.domainmodel.grading.CourseAssessment) Credit(fi.otavanopisto.pyramus.domainmodel.grading.Credit) TransferCredit(fi.otavanopisto.pyramus.domainmodel.grading.TransferCredit) CourseStudent(fi.otavanopisto.pyramus.domainmodel.courses.CourseStudent) CreditLink(fi.otavanopisto.pyramus.domainmodel.grading.CreditLink) TransferCredit(fi.otavanopisto.pyramus.domainmodel.grading.TransferCredit) Course(fi.otavanopisto.pyramus.domainmodel.courses.Course) Path(javax.ws.rs.Path) RESTPermit(fi.otavanopisto.pyramus.rest.annotation.RESTPermit) GET(javax.ws.rs.GET)

Aggregations

Credit (fi.otavanopisto.pyramus.domainmodel.grading.Credit)10 TransferCredit (fi.otavanopisto.pyramus.domainmodel.grading.TransferCredit)7 HashMap (java.util.HashMap)5 TransferCreditDAO (fi.otavanopisto.pyramus.dao.grading.TransferCreditDAO)4 StudentSubjectGrade (fi.otavanopisto.pyramus.domainmodel.students.StudentSubjectGrade)4 ArviointiasteikkoYleissivistava (fi.otavanopisto.pyramus.koski.koodisto.ArviointiasteikkoYleissivistava)4 KoskiStudyProgrammeHandlerParams (fi.otavanopisto.pyramus.koski.settings.KoskiStudyProgrammeHandlerParams)4 ArrayList (java.util.ArrayList)4 Date (java.util.Date)4 HashSet (java.util.HashSet)4 List (java.util.List)4 Course (fi.otavanopisto.pyramus.domainmodel.courses.Course)3 CourseAssessment (fi.otavanopisto.pyramus.domainmodel.grading.CourseAssessment)3 CreditLink (fi.otavanopisto.pyramus.domainmodel.grading.CreditLink)3 Student (fi.otavanopisto.pyramus.domainmodel.students.Student)3 CreditStub (fi.otavanopisto.pyramus.koski.CreditStub)3 OpiskelijanOPS (fi.otavanopisto.pyramus.koski.OpiskelijanOPS)3 OppiaineenSuoritusWithCurriculum (fi.otavanopisto.pyramus.koski.OppiaineenSuoritusWithCurriculum)3 KurssinArviointi (fi.otavanopisto.pyramus.koski.model.KurssinArviointi)3 OrganisaationToimipisteOID (fi.otavanopisto.pyramus.koski.model.OrganisaationToimipisteOID)3