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());
}
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);
}
}
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);
}
}
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());
}
Aggregations