Search in sources :

Example 1 with AssessmentSectionChange

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

the class BinderAssessmentController method commitChanges.

private void commitChanges() {
    List<AssessmentSectionWrapper> rows = model.getObjects();
    List<Identity> assessedIdentities = portfolioService.getMembers(binder, PortfolioRoles.owner.name());
    List<AssessmentSectionChange> changes = new ArrayList<>();
    for (AssessmentSectionWrapper row : rows) {
        Section section = row.getSection();
        if (secCallback.canAssess(section) && !SectionStatus.isClosed(section)) {
            BigDecimal score = null;
            if (withScore) {
                String value = row.getScoreEl().getValue();
                if (StringHelper.containsNonWhitespace(value)) {
                    score = new BigDecimal(value);
                }
            }
            Boolean passed = null;
            if (withPassed) {
                passed = row.getPassedEl().isSelected(0);
            }
            for (Identity assessedIdentity : assessedIdentities) {
                changes.add(new AssessmentSectionChange(assessedIdentity, row.getSection(), row.getAssessmentSection(), score, passed));
            }
        }
    }
    portfolioService.updateAssessmentSections(binder, changes, getIdentity());
}
Also used : AssessmentSectionChange(org.olat.modules.portfolio.model.AssessmentSectionChange) ArrayList(java.util.ArrayList) Identity(org.olat.core.id.Identity) AssessmentSection(org.olat.modules.portfolio.AssessmentSection) Section(org.olat.modules.portfolio.Section) BigDecimal(java.math.BigDecimal)

Example 2 with AssessmentSectionChange

use of org.olat.modules.portfolio.model.AssessmentSectionChange 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 AssessmentSectionChange

use of org.olat.modules.portfolio.model.AssessmentSectionChange 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 AssessmentSectionChange

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

the class BinderAssessmentController method commitChanges.

private void commitChanges() {
    List<AssessmentSectionWrapper> rows = model.getObjects();
    List<Identity> assessedIdentities = portfolioService.getMembers(binder, PortfolioRoles.owner.name());
    List<AssessmentSectionChange> changes = new ArrayList<>();
    for (AssessmentSectionWrapper row : rows) {
        Section section = row.getSection();
        if (secCallback.canAssess(section) && !SectionStatus.isClosed(section)) {
            BigDecimal score = null;
            if (withScore) {
                String value = row.getScoreEl().getValue();
                if (StringHelper.containsNonWhitespace(value)) {
                    score = new BigDecimal(value);
                }
            }
            Boolean passed = null;
            if (withPassed) {
                passed = row.getPassedEl().isSelected(0);
            }
            for (Identity assessedIdentity : assessedIdentities) {
                changes.add(new AssessmentSectionChange(assessedIdentity, row.getSection(), row.getAssessmentSection(), score, passed));
            }
        }
    }
    portfolioService.updateAssessmentSections(binder, changes, getIdentity());
}
Also used : AssessmentSectionChange(org.olat.modules.portfolio.model.AssessmentSectionChange) ArrayList(java.util.ArrayList) Identity(org.olat.core.id.Identity) AssessmentSection(org.olat.modules.portfolio.AssessmentSection) Section(org.olat.modules.portfolio.Section) BigDecimal(java.math.BigDecimal)

Aggregations

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