use of org.olat.modules.portfolio.model.BinderImpl in project openolat by klemens.
the class PortfolioServiceImpl method createAndPersistBinderTemplate.
@Override
public void createAndPersistBinderTemplate(Identity owner, RepositoryEntry entry, Locale locale) {
BinderImpl binder = binderDao.createAndPersist(entry.getDisplayname(), entry.getDescription(), null, entry);
if (owner != null) {
groupDao.addMembershipTwoWay(binder.getBaseGroup(), owner, PortfolioRoles.owner.name());
}
// add section
Translator pt = Util.createPackageTranslator(PortfolioHomeController.class, locale);
String sectionTitle = pt.translate("new.section.title");
String sectionDescription = pt.translate("new.section.desc");
binderDao.createSection(sectionTitle, sectionDescription, null, null, binder);
}
use of org.olat.modules.portfolio.model.BinderImpl in project openolat by klemens.
the class PortfolioServiceImpl method getAssessmentStatus.
@Override
public AssessmentEntryStatus getAssessmentStatus(Identity assessedIdentity, BinderRef binderRef) {
Binder binder = binderDao.loadByKey(binderRef.getKey());
RepositoryEntry entry = binder.getEntry();
AssessmentEntryStatus status = null;
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;
UserCourseEnvironment userCourseEnv = AssessmentHelper.createAndInitUserCourseEnvironment(assessedIdentity, course);
AssessmentEvaluation eval = pfNode.getUserScoreEvaluation(userCourseEnv);
status = eval.getAssessmentStatus();
}
} else {
OLATResource resource = ((BinderImpl) binder.getTemplate()).getOlatResource();
RepositoryEntry referenceEntry = repositoryService.loadByResourceKey(resource.getKey());
AssessmentEntry assessmentEntry = assessmentService.getOrCreateAssessmentEntry(assessedIdentity, null, binder.getEntry(), binder.getSubIdent(), referenceEntry);
status = assessmentEntry.getAssessmentStatus();
}
return status;
}
use of org.olat.modules.portfolio.model.BinderImpl in project openolat by klemens.
the class BinderDAO method createCopy.
public BinderImpl createCopy(BinderImpl template, RepositoryEntry entry, String subIdent) {
BinderImpl binder = new BinderImpl();
binder.setCreationDate(new Date());
binder.setLastModified(binder.getCreationDate());
binder.setTitle(template.getTitle());
binder.setSummary(template.getSummary());
binder.setImagePath(template.getImagePath());
binder.setStatus(BinderStatus.open.name());
binder.setBaseGroup(groupDao.createGroup());
binder.setTemplate(template);
binder.setCopyDate(binder.getCreationDate());
if (entry != null) {
binder.setEntry(entry);
}
if (StringHelper.containsNonWhitespace(subIdent)) {
binder.setSubIdent(subIdent);
}
dbInstance.getCurrentEntityManager().persist(binder);
binder.getSections().size();
for (Section templateSection : template.getSections()) {
Section section = createInternalSection(binder, templateSection);
binder.getSections().add(section);
dbInstance.getCurrentEntityManager().persist(section);
}
binder = dbInstance.getCurrentEntityManager().merge(binder);
return binder;
}
use of org.olat.modules.portfolio.model.BinderImpl in project openolat by klemens.
the class PortfolioServiceImpl method updateAssessmentEntryLastModification.
private void updateAssessmentEntryLastModification(Binder binder, Identity doer, Role by) {
if (binder.getEntry() == null)
return;
RepositoryEntry entry = binder.getEntry();
List<Identity> assessedIdentities = getMembers(binder, PortfolioRoles.owner.name());
// order status from the entry / section
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;
for (Identity assessedIdentity : assessedIdentities) {
UserCourseEnvironment userCourseEnv = AssessmentHelper.createAndInitUserCourseEnvironment(assessedIdentity, course);
pfNode.updateLastModifications(userCourseEnv, doer, by);
}
}
} else {
OLATResource resource = ((BinderImpl) binder.getTemplate()).getOlatResource();
RepositoryEntry referenceEntry = repositoryService.loadByResourceKey(resource.getKey());
for (Identity assessedIdentity : assessedIdentities) {
AssessmentEntry assessmentEntry = assessmentService.getOrCreateAssessmentEntry(assessedIdentity, null, binder.getEntry(), binder.getSubIdent(), referenceEntry);
if (by == Role.coach) {
assessmentEntry.setLastCoachModified(new Date());
} else if (by == Role.user) {
assessmentEntry.setLastUserModified(new Date());
}
assessmentService.updateAssessmentEntry(assessmentEntry);
}
}
}
Aggregations