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