use of org.olat.modules.portfolio.Binder in project openolat by klemens.
the class DeletedBinderController method doRestore.
private void doRestore(BinderRow row) {
Binder binder = portfolioService.getBinderByKey(row.getKey());
binder.setBinderStatus(BinderStatus.open);
binder = portfolioService.updateBinder(binder);
showInfo("restore.binder.success");
}
use of org.olat.modules.portfolio.Binder in project openolat by klemens.
the class PortfolioServiceImpl method changePageStatus.
@Override
public Page changePageStatus(Page page, PageStatus status, Identity identity, Role by) {
PageStatus currentStatus = page.getPageStatus();
Page reloadedPage = pageDao.loadByKey(page.getKey());
((PageImpl) reloadedPage).setPageStatus(status);
if (status == PageStatus.published) {
Date now = new Date();
if (reloadedPage.getInitialPublicationDate() == null) {
((PageImpl) reloadedPage).setInitialPublicationDate(now);
}
((PageImpl) reloadedPage).setLastPublicationDate(now);
Section section = reloadedPage.getSection();
// auto update the status of the evaluation form of the authors of the binder
changeAssignmentStatus(page, section, EvaluationFormSessionStatus.done);
if (section != null) {
SectionStatus sectionStatus = section.getSectionStatus();
if (currentStatus == PageStatus.closed) {
if (sectionStatus == SectionStatus.closed) {
((SectionImpl) section).setSectionStatus(SectionStatus.inProgress);
binderDao.updateSection(section);
}
} else if (sectionStatus == null || sectionStatus == SectionStatus.notStarted || sectionStatus == SectionStatus.closed) {
((SectionImpl) section).setSectionStatus(SectionStatus.inProgress);
binderDao.updateSection(section);
}
}
} else if (status == PageStatus.inRevision) {
Section section = reloadedPage.getSection();
changeAssignmentStatus(page, section, EvaluationFormSessionStatus.inProgress);
if (section != null) {
SectionStatus sectionStatus = section.getSectionStatus();
if (sectionStatus == null || sectionStatus == SectionStatus.notStarted || sectionStatus == SectionStatus.closed) {
if (sectionStatus == SectionStatus.closed) {
((SectionImpl) section).setSectionStatus(SectionStatus.inProgress);
binderDao.updateSection(section);
}
}
}
pageUserInfosDao.updateStatus(reloadedPage, PageUserStatus.inProcess, PageUserStatus.done);
} else if (status == PageStatus.closed) {
// set user informations to done
pageUserInfosDao.updateStatus(reloadedPage, PageUserStatus.done);
}
if (reloadedPage.getSection() != null && reloadedPage.getSection().getBinder() != null) {
Binder binder = reloadedPage.getSection().getBinder();
updateAssessmentEntryLastModification(binder, identity, by);
}
return pageDao.updatePage(reloadedPage);
}
use of org.olat.modules.portfolio.Binder in project openolat by klemens.
the class PortfolioServiceImpl method setAssessmentStatus.
@Override
public void setAssessmentStatus(Identity assessedIdentity, BinderRef binderRef, AssessmentEntryStatus status, Identity coachingIdentity) {
Boolean fullyAssessed = Boolean.FALSE;
if (status == AssessmentEntryStatus.done) {
fullyAssessed = Boolean.TRUE;
}
Binder binder = binderDao.loadByKey(binderRef.getKey());
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;
UserCourseEnvironment userCourseEnv = AssessmentHelper.createAndInitUserCourseEnvironment(assessedIdentity, course);
AssessmentEvaluation eval = pfNode.getUserScoreEvaluation(userCourseEnv);
ScoreEvaluation scoreEval = new ScoreEvaluation(eval.getScore(), eval.getPassed(), status, true, fullyAssessed, null, null, binder.getKey());
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.setFullyAssessed(fullyAssessed);
assessmentEntry.setAssessmentStatus(status);
assessmentService.updateAssessmentEntry(assessmentEntry);
}
}
use of org.olat.modules.portfolio.Binder in project openolat by klemens.
the class PortfolioServiceTest method createNewOwnedPorfolio.
@Test
public void createNewOwnedPorfolio() {
Identity id = JunitTestHelper.createAndPersistIdentityAsRndUser("port-u-1");
String title = "My portfolio";
String summary = "My live";
Binder binder = portfolioService.createNewBinder(title, summary, null, id);
dbInstance.commitAndCloseSession();
Assert.assertNotNull(binder);
Assert.assertNotNull(binder.getKey());
Assert.assertNotNull(binder.getCreationDate());
Assert.assertNotNull(binder.getLastModified());
Assert.assertEquals(title, binder.getTitle());
Assert.assertEquals(summary, binder.getSummary());
List<Binder> ownedBinders = portfolioService.getOwnedBinders(id);
Assert.assertNotNull(ownedBinders);
Assert.assertEquals(1, ownedBinders.size());
Binder ownedBinder = ownedBinders.get(0);
Assert.assertNotNull(ownedBinder);
Assert.assertEquals(binder, ownedBinder);
}
use of org.olat.modules.portfolio.Binder in project openolat by klemens.
the class PortfolioServiceTest method deleteBinder.
@Test
public void deleteBinder() {
Identity owner = JunitTestHelper.createAndPersistIdentityAsRndUser("del-binder-");
Binder binder = portfolioService.createNewBinder("Binder to delete", "Deletion", "", owner);
SectionRef sectionRef1 = portfolioService.appendNewSection("1. section ", "Section 1", null, null, binder);
dbInstance.commit();
SectionRef sectionRef2 = portfolioService.appendNewSection("2. section ", "Section 2", null, null, binder);
dbInstance.commit();
portfolioService.updateBinderUserInformations(binder, owner);
dbInstance.commit();
Section reloadedSection1 = portfolioService.getSection(sectionRef1);
Page page1 = portfolioService.appendNewPage(owner, "New page", "A brand new page.", null, null, reloadedSection1);
Section reloadedSection2 = portfolioService.getSection(sectionRef2);
Page page2 = portfolioService.appendNewPage(owner, "New page", "A brand new page.", null, null, reloadedSection2);
Assert.assertNotNull(page1);
Assert.assertNotNull(page2);
dbInstance.commitAndCloseSession();
// delete
boolean deleted = portfolioService.deleteBinder(binder);
dbInstance.commit();
Assert.assertTrue(deleted);
}
Aggregations