Search in sources :

Example 1 with AssessmentSectionImpl

use of org.olat.modules.portfolio.model.AssessmentSectionImpl in project OpenOLAT by OpenOLAT.

the class AssessmentSectionDAO method createAssessmentSection.

public AssessmentSection createAssessmentSection(BigDecimal score, Boolean passed, Section section, Identity assessedIdentity) {
    AssessmentSectionImpl assessmentSection = new AssessmentSectionImpl();
    assessmentSection.setCreationDate(new Date());
    assessmentSection.setLastModified(assessmentSection.getCreationDate());
    assessmentSection.setPassed(passed);
    assessmentSection.setScore(score);
    assessmentSection.setSection(section);
    assessmentSection.setIdentity(assessedIdentity);
    dbInstance.getCurrentEntityManager().persist(assessmentSection);
    return assessmentSection;
}
Also used : AssessmentSectionImpl(org.olat.modules.portfolio.model.AssessmentSectionImpl) Date(java.util.Date)

Example 2 with AssessmentSectionImpl

use of org.olat.modules.portfolio.model.AssessmentSectionImpl in project openolat by klemens.

the class PortfolioServiceImpl method updateAssessmentSections.

@Override
public void updateAssessmentSections(BinderRef binderRef, List<AssessmentSectionChange> changes, Identity coachingIdentity) {
    Binder binder = binderDao.loadByKey(binderRef.getKey());
    Map<Identity, List<AssessmentSectionChange>> assessedIdentitiesToChangesMap = new HashMap<>();
    for (AssessmentSectionChange change : changes) {
        List<AssessmentSectionChange> identityChanges;
        if (assessedIdentitiesToChangesMap.containsKey(change.getIdentity())) {
            identityChanges = assessedIdentitiesToChangesMap.get(change.getIdentity());
        } else {
            identityChanges = new ArrayList<>();
            assessedIdentitiesToChangesMap.put(change.getIdentity(), identityChanges);
        }
        identityChanges.add(change);
    }
    for (Map.Entry<Identity, List<AssessmentSectionChange>> changesEntry : assessedIdentitiesToChangesMap.entrySet()) {
        Identity assessedIdentity = changesEntry.getKey();
        List<AssessmentSection> currentAssessmentSections = assessmentSectionDao.loadAssessmentSections(binder, assessedIdentity);
        Set<AssessmentSection> updatedAssessmentSections = new HashSet<>(currentAssessmentSections);
        List<AssessmentSectionChange> identityChanges = changesEntry.getValue();
        for (AssessmentSectionChange change : identityChanges) {
            AssessmentSection assessmentSection = change.getAssessmentSection();
            for (AssessmentSection currentAssessmentSection : currentAssessmentSections) {
                if (assessmentSection != null && assessmentSection.equals(currentAssessmentSection)) {
                    assessmentSection = currentAssessmentSection;
                } else if (change.getSection().equals(currentAssessmentSection.getSection())) {
                    assessmentSection = currentAssessmentSection;
                }
            }
            if (assessmentSection == null) {
                assessmentSection = assessmentSectionDao.createAssessmentSection(change.getScore(), change.getPassed(), change.getSection(), assessedIdentity);
            } else {
                ((AssessmentSectionImpl) assessmentSection).setScore(change.getScore());
                ((AssessmentSectionImpl) assessmentSection).setPassed(change.getPassed());
                assessmentSection = assessmentSectionDao.update(assessmentSection);
            }
            updatedAssessmentSections.add(assessmentSection);
        }
        updateAssessmentEntry(assessedIdentity, binder, updatedAssessmentSections, coachingIdentity);
    }
}
Also used : HashMap(java.util.HashMap) AssessmentSectionChange(org.olat.modules.portfolio.model.AssessmentSectionChange) Binder(org.olat.modules.portfolio.Binder) AssessedBinder(org.olat.modules.portfolio.model.AssessedBinder) SynchedBinder(org.olat.modules.portfolio.model.SynchedBinder) AssessmentSectionImpl(org.olat.modules.portfolio.model.AssessmentSectionImpl) AssessmentSection(org.olat.modules.portfolio.AssessmentSection) ArrayList(java.util.ArrayList) List(java.util.List) Identity(org.olat.core.id.Identity) Map(java.util.Map) HashMap(java.util.HashMap) HashSet(java.util.HashSet)

Example 3 with AssessmentSectionImpl

use of org.olat.modules.portfolio.model.AssessmentSectionImpl in project OpenOLAT by OpenOLAT.

the class PortfolioServiceImpl method updateAssessmentSections.

@Override
public void updateAssessmentSections(BinderRef binderRef, List<AssessmentSectionChange> changes, Identity coachingIdentity) {
    Binder binder = binderDao.loadByKey(binderRef.getKey());
    Map<Identity, List<AssessmentSectionChange>> assessedIdentitiesToChangesMap = new HashMap<>();
    for (AssessmentSectionChange change : changes) {
        List<AssessmentSectionChange> identityChanges;
        if (assessedIdentitiesToChangesMap.containsKey(change.getIdentity())) {
            identityChanges = assessedIdentitiesToChangesMap.get(change.getIdentity());
        } else {
            identityChanges = new ArrayList<>();
            assessedIdentitiesToChangesMap.put(change.getIdentity(), identityChanges);
        }
        identityChanges.add(change);
    }
    for (Map.Entry<Identity, List<AssessmentSectionChange>> changesEntry : assessedIdentitiesToChangesMap.entrySet()) {
        Identity assessedIdentity = changesEntry.getKey();
        List<AssessmentSection> currentAssessmentSections = assessmentSectionDao.loadAssessmentSections(binder, assessedIdentity);
        Set<AssessmentSection> updatedAssessmentSections = new HashSet<>(currentAssessmentSections);
        List<AssessmentSectionChange> identityChanges = changesEntry.getValue();
        for (AssessmentSectionChange change : identityChanges) {
            AssessmentSection assessmentSection = change.getAssessmentSection();
            for (AssessmentSection currentAssessmentSection : currentAssessmentSections) {
                if (assessmentSection != null && assessmentSection.equals(currentAssessmentSection)) {
                    assessmentSection = currentAssessmentSection;
                } else if (change.getSection().equals(currentAssessmentSection.getSection())) {
                    assessmentSection = currentAssessmentSection;
                }
            }
            if (assessmentSection == null) {
                assessmentSection = assessmentSectionDao.createAssessmentSection(change.getScore(), change.getPassed(), change.getSection(), assessedIdentity);
            } else {
                ((AssessmentSectionImpl) assessmentSection).setScore(change.getScore());
                ((AssessmentSectionImpl) assessmentSection).setPassed(change.getPassed());
                assessmentSection = assessmentSectionDao.update(assessmentSection);
            }
            updatedAssessmentSections.add(assessmentSection);
        }
        updateAssessmentEntry(assessedIdentity, binder, updatedAssessmentSections, coachingIdentity);
    }
}
Also used : HashMap(java.util.HashMap) AssessmentSectionChange(org.olat.modules.portfolio.model.AssessmentSectionChange) Binder(org.olat.modules.portfolio.Binder) AssessedBinder(org.olat.modules.portfolio.model.AssessedBinder) SynchedBinder(org.olat.modules.portfolio.model.SynchedBinder) AssessmentSectionImpl(org.olat.modules.portfolio.model.AssessmentSectionImpl) AssessmentSection(org.olat.modules.portfolio.AssessmentSection) ArrayList(java.util.ArrayList) List(java.util.List) Identity(org.olat.core.id.Identity) Map(java.util.Map) HashMap(java.util.HashMap) HashSet(java.util.HashSet)

Example 4 with AssessmentSectionImpl

use of org.olat.modules.portfolio.model.AssessmentSectionImpl in project openolat by klemens.

the class AssessmentSectionDAO method createAssessmentSection.

public AssessmentSection createAssessmentSection(BigDecimal score, Boolean passed, Section section, Identity assessedIdentity) {
    AssessmentSectionImpl assessmentSection = new AssessmentSectionImpl();
    assessmentSection.setCreationDate(new Date());
    assessmentSection.setLastModified(assessmentSection.getCreationDate());
    assessmentSection.setPassed(passed);
    assessmentSection.setScore(score);
    assessmentSection.setSection(section);
    assessmentSection.setIdentity(assessedIdentity);
    dbInstance.getCurrentEntityManager().persist(assessmentSection);
    return assessmentSection;
}
Also used : AssessmentSectionImpl(org.olat.modules.portfolio.model.AssessmentSectionImpl) Date(java.util.Date)

Aggregations

AssessmentSectionImpl (org.olat.modules.portfolio.model.AssessmentSectionImpl)4 ArrayList (java.util.ArrayList)2 Date (java.util.Date)2 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 List (java.util.List)2 Map (java.util.Map)2 Identity (org.olat.core.id.Identity)2 AssessmentSection (org.olat.modules.portfolio.AssessmentSection)2 Binder (org.olat.modules.portfolio.Binder)2 AssessedBinder (org.olat.modules.portfolio.model.AssessedBinder)2 AssessmentSectionChange (org.olat.modules.portfolio.model.AssessmentSectionChange)2 SynchedBinder (org.olat.modules.portfolio.model.SynchedBinder)2