use of org.olat.modules.portfolio.model.BinderImpl in project OpenOLAT by OpenOLAT.
the class PortfolioServiceImpl method loadAndSyncBinder.
@Override
public SynchedBinder loadAndSyncBinder(BinderRef binder) {
Binder reloadedBinder = binderDao.loadByKey(binder.getKey());
AtomicBoolean changes = new AtomicBoolean(false);
if (reloadedBinder.getTemplate() != null) {
reloadedBinder = binderDao.syncWithTemplate((BinderImpl) reloadedBinder.getTemplate(), (BinderImpl) reloadedBinder, changes);
}
return new SynchedBinder(reloadedBinder, changes.get());
}
use of org.olat.modules.portfolio.model.BinderImpl in project OpenOLAT by OpenOLAT.
the class PortfolioServiceImpl method assignBinder.
@Override
public Binder assignBinder(Identity owner, BinderRef templateBinder, RepositoryEntry entry, String subIdent, Date deadline) {
BinderImpl reloadedTemplate = (BinderImpl) binderDao.loadByKey(templateBinder.getKey());
BinderImpl binder = binderDao.createCopy(reloadedTemplate, entry, subIdent);
groupDao.addMembershipTwoWay(binder.getBaseGroup(), owner, PortfolioRoles.owner.name());
return binder;
}
use of org.olat.modules.portfolio.model.BinderImpl in project OpenOLAT by OpenOLAT.
the class PortfolioServiceImpl method updateAssessmentEntry.
private void updateAssessmentEntry(Identity assessedIdentity, Binder binder, Set<AssessmentSection> assessmentSections, Identity coachingIdentity) {
boolean allPassed = true;
int totalSectionPassed = 0;
int totalSectionClosed = 0;
BigDecimal totalScore = new BigDecimal("0.0");
AssessmentEntryStatus binderStatus = null;
for (AssessmentSection assessmentSection : assessmentSections) {
if (assessmentSection.getScore() != null) {
totalScore = totalScore.add(assessmentSection.getScore());
}
if (assessmentSection.getPassed() != null && assessmentSection.getPassed().booleanValue()) {
allPassed &= true;
totalSectionPassed++;
}
Section section = assessmentSection.getSection();
if (section.getSectionStatus() == SectionStatus.closed) {
totalSectionClosed++;
}
}
Boolean totalPassed = null;
if (totalSectionClosed == assessmentSections.size()) {
totalPassed = new Boolean(allPassed);
} else {
if (assessmentSections.size() == totalSectionPassed) {
totalPassed = Boolean.TRUE;
}
binderStatus = AssessmentEntryStatus.inProgress;
}
// order status from the entry / section
RepositoryEntry entry = binder.getEntry();
if ("CourseModule".equals(entry.getOlatResource().getResourceableTypeName())) {
ICourse course = CourseFactory.loadCourse(entry);
CourseNode courseNode = course.getRunStructure().getNode(binder.getSubIdent());
if (courseNode instanceof PortfolioCourseNode) {
PortfolioCourseNode pfNode = (PortfolioCourseNode) courseNode;
ScoreEvaluation scoreEval = new ScoreEvaluation(totalScore.floatValue(), totalPassed, binderStatus, true, true, null, null, binder.getKey());
UserCourseEnvironment userCourseEnv = AssessmentHelper.createAndInitUserCourseEnvironment(assessedIdentity, course);
pfNode.updateUserScoreEvaluation(scoreEval, userCourseEnv, coachingIdentity, false, Role.coach);
}
} else {
OLATResource resource = ((BinderImpl) binder.getTemplate()).getOlatResource();
RepositoryEntry referenceEntry = repositoryService.loadByResourceKey(resource.getKey());
AssessmentEntry assessmentEntry = assessmentService.getOrCreateAssessmentEntry(assessedIdentity, null, binder.getEntry(), binder.getSubIdent(), referenceEntry);
assessmentEntry.setScore(totalScore);
assessmentEntry.setPassed(totalPassed);
assessmentEntry.setAssessmentStatus(binderStatus);
assessmentService.updateAssessmentEntry(assessmentEntry);
}
}
use of org.olat.modules.portfolio.model.BinderImpl in project OpenOLAT by OpenOLAT.
the class PortfolioServiceImpl method getRepositoryEntry.
@Override
public RepositoryEntry getRepositoryEntry(Binder binder) {
OLATResource resource = ((BinderImpl) binder).getOlatResource();
Long resourceKey = resource.getKey();
return repositoryService.loadByResourceKey(resourceKey);
}
use of org.olat.modules.portfolio.model.BinderImpl in project OpenOLAT by OpenOLAT.
the class PortfolioServiceImpl method internalCopyTransientBinder.
private Binder internalCopyTransientBinder(Binder transientBinder, RepositoryEntry entry, String imagePath, boolean copy) {
Binder binder = binderDao.createAndPersist(transientBinder.getTitle(), transientBinder.getSummary(), imagePath, entry);
// copy sections
for (Section transientSection : ((BinderImpl) transientBinder).getSections()) {
SectionImpl section = binderDao.createSection(transientSection.getTitle(), transientSection.getDescription(), transientSection.getBeginDate(), transientSection.getEndDate(), binder);
List<Assignment> transientAssignments = ((SectionImpl) transientSection).getAssignments();
for (Assignment transientAssignment : transientAssignments) {
if (transientAssignment != null) {
File newStorage = portfolioFileStorage.generateAssignmentSubDirectory();
String storage = portfolioFileStorage.getRelativePath(newStorage);
assignmentDao.createAssignment(transientAssignment.getTitle(), transientAssignment.getSummary(), transientAssignment.getContent(), storage, transientAssignment.getAssignmentType(), transientAssignment.getAssignmentStatus(), section, transientAssignment.isOnlyAutoEvaluation(), transientAssignment.isReviewerSeeAutoEvaluation(), transientAssignment.isAnonymousExternalEvaluation(), transientAssignment.getFormEntry());
// copy attachments
File templateDirectory = portfolioFileStorage.getAssignmentDirectory(transientAssignment);
if (copy && templateDirectory != null) {
FileUtils.copyDirContentsToDir(templateDirectory, newStorage, false, "Assignment attachments");
}
}
}
}
return binder;
}
Aggregations