use of org.olat.modules.portfolio.model.SynchedBinder in project openolat by klemens.
the class BinderListController method doOpenBinder.
protected BinderController doOpenBinder(UserRequest ureq, BinderRef row) {
SynchedBinder binder = portfolioService.loadAndSyncBinder(row);
if (binder.isChanged()) {
showInfo("warning.binder.synched");
}
BinderController selectedBinderCtrl = doOpenBinder(ureq, binder.getBinder());
if (row instanceof BinderRow) {
VFSLeaf image = portfolioService.getPosterImageLeaf(binder.getBinder());
((BinderRow) row).setBackgroundImage(image);
}
return selectedBinderCtrl;
}
use of org.olat.modules.portfolio.model.SynchedBinder in project openolat by klemens.
the class BinderListController method doCreateBinderFromTemplate.
private void doCreateBinderFromTemplate(UserRequest ureq, RepositoryEntry entry) {
Binder templateBinder = portfolioService.getBinderByResource(entry.getOlatResource());
Binder newBinder = portfolioService.assignBinder(getIdentity(), templateBinder, null, null, null);
DBFactory.getInstance().commit();
SynchedBinder synchedBinder = portfolioService.loadAndSyncBinder(newBinder);
newBinder = synchedBinder.getBinder();
doOpenBinder(ureq, newBinder).activate(ureq, null, null);
}
use of org.olat.modules.portfolio.model.SynchedBinder in project openolat by klemens.
the class BinderListController method doCreateBinderFromCourseTemplate.
private void doCreateBinderFromCourseTemplate(UserRequest ureq, CourseTemplateRow row) {
RepositoryEntry courseEntry = row.getCourseEntry();
RepositoryEntry templateEntry = row.getTemplateEntry();
PortfolioCourseNode courseNode = row.getCourseNode();
Binder templateBinder = portfolioService.getBinderByResource(templateEntry.getOlatResource());
Binder copyBinder = portfolioService.getBinder(getIdentity(), templateBinder, courseEntry, courseNode.getIdent());
if (copyBinder == null) {
Date deadline = courseNode.getDeadline();
copyBinder = portfolioService.assignBinder(getIdentity(), templateBinder, courseEntry, courseNode.getIdent(), deadline);
DBFactory.getInstance().commit();
SynchedBinder synchedBinder = portfolioService.loadAndSyncBinder(copyBinder);
copyBinder = synchedBinder.getBinder();
if (copyBinder != null) {
showInfo("map.copied", StringHelper.escapeHtml(templateBinder.getTitle()));
ThreadLocalUserActivityLogger.addLoggingResourceInfo(LoggingResourceable.wrap(copyBinder));
ThreadLocalUserActivityLogger.log(PortfolioLoggingAction.PORTFOLIO_TASK_STARTED, getClass());
}
}
doOpenBinder(ureq, copyBinder).activate(ureq, null, null);
}
use of org.olat.modules.portfolio.model.SynchedBinder in project openolat by klemens.
the class PortfolioServiceTest method deleteTemplateBinder.
@Test
public void deleteTemplateBinder() {
Identity owner = JunitTestHelper.createAndPersistIdentityAsRndUser("port-u-20");
RepositoryEntry templateEntry = createTemplate(owner, "Template", "TE");
dbInstance.commitAndCloseSession();
Binder templateBinder = portfolioService.getBinderByResource(templateEntry.getOlatResource());
List<SectionRef> sections = new ArrayList<>();
for (int i = 0; i < 10; i++) {
SectionRef templateSectionRef = portfolioService.appendNewSection(i + ". section ", "Section " + i, null, null, templateBinder);
dbInstance.commit();
sections.add(templateSectionRef);
Section templateSection = portfolioService.getSection(templateSectionRef);
for (int j = 0; j < 10; j++) {
Assignment assignment = portfolioService.addAssignment(i + "_" + j + " Assignment", "", "", AssignmentType.essay, templateSection, false, false, false, null);
Assert.assertNotNull(assignment);
}
dbInstance.commit();
}
// collect the page
List<Page> assignmentPages = new ArrayList<>();
for (int k = 0; k < 10; k++) {
// get a binder from the template
Identity id = JunitTestHelper.createAndPersistIdentityAsRndUser("port-u-13" + k);
Binder binder = portfolioService.assignBinder(id, templateBinder, templateEntry, null, null);
SynchedBinder synchedBinder = portfolioService.loadAndSyncBinder(binder);
binder = synchedBinder.getBinder();
dbInstance.commitAndCloseSession();
List<Assignment> assignments = portfolioService.getAssignments(binder, null);
for (Assignment assignment : assignments) {
Assignment startedAssignment = portfolioService.startAssignment(assignment.getKey(), id);
Assert.assertNotNull(startedAssignment);
Page page = startedAssignment.getPage();
assignmentPages.add(page);
Assert.assertNotNull(page.getBody());
dbInstance.commit();
}
dbInstance.commitAndCloseSession();
}
// delete
boolean deleted = portfolioService.deleteBinderTemplate(templateBinder, templateEntry);
dbInstance.commit();
Assert.assertTrue(deleted);
// check that the pages exists
Assert.assertFalse(assignmentPages.isEmpty());
for (Page page : assignmentPages) {
Page reloadedPage = portfolioService.getPageByKey(page.getKey());
Assert.assertNotNull(reloadedPage);
Section section = reloadedPage.getSection();
Assert.assertNotNull(section);
}
}
use of org.olat.modules.portfolio.model.SynchedBinder in project openolat by klemens.
the class PortfolioServiceTest method deleteSynchedBinder.
@Test
public void deleteSynchedBinder() {
Identity owner = JunitTestHelper.createAndPersistIdentityAsRndUser("port-u-12");
Identity id = JunitTestHelper.createAndPersistIdentityAsRndUser("port-u-13");
RepositoryEntry templateEntry = createTemplate(owner, "Template", "TE");
dbInstance.commitAndCloseSession();
// get section
Binder templateBinder = portfolioService.getBinderByResource(templateEntry.getOlatResource());
SectionRef sectionRef = portfolioService.getSections(templateBinder).get(0);
dbInstance.commit();
// make 2 assignments
Section templateSection = portfolioService.getSection(sectionRef);
Assignment assignment_1 = portfolioService.addAssignment("1 Assignment", "", "", AssignmentType.essay, templateSection, false, false, false, null);
Assignment assignment_2 = portfolioService.addAssignment("2 Assignment", "", "", AssignmentType.essay, templateSection, false, false, false, null);
dbInstance.commit();
List<Assignment> templateAssignments = portfolioService.getAssignments(templateBinder, null);
Assert.assertEquals(2, templateAssignments.size());
// synched and check the sections order
Binder binder = portfolioService.assignBinder(id, templateBinder, templateEntry, null, null);
SynchedBinder synchedBinder = portfolioService.loadAndSyncBinder(binder);
binder = synchedBinder.getBinder();
dbInstance.commitAndCloseSession();
List<Assignment> assignments = portfolioService.getAssignments(binder, null);
Assignment startedAssignment_1 = portfolioService.startAssignment(assignments.get(0).getKey(), id);
Assignment startedAssignment_2 = portfolioService.startAssignment(assignments.get(1).getKey(), id);
Long startedPageKey_1 = startedAssignment_1.getPage().getKey();
Long startedPageKey_2 = startedAssignment_2.getPage().getKey();
dbInstance.commitAndCloseSession();
// add some comments
OLATResourceable startedPageOres_1 = OresHelper.createOLATResourceableInstance(Page.class, startedPageKey_1);
userCommentsDao.createComment(id, startedPageOres_1, null, "Hello");
// delete
boolean deleted = portfolioService.deleteBinder(binder);
dbInstance.commit();
Assert.assertTrue(deleted);
// check that the template is save
Assignment reloadAssignment_1 = assignmentDao.loadAssignmentByKey(assignment_1.getKey());
Assert.assertNotNull(reloadAssignment_1);
Assignment reloadAssignment_2 = assignmentDao.loadAssignmentByKey(assignment_2.getKey());
Assert.assertNotNull(reloadAssignment_2);
// check that the binder is really deleted
Binder reloadedBinder = binderDao.loadByKey(binder.getKey());
Assert.assertNull(reloadedBinder);
Assignment reloadStartedAssignment_1 = assignmentDao.loadAssignmentByKey(startedAssignment_1.getKey());
Assert.assertNull(reloadStartedAssignment_1);
Assignment reloadStartedAssignment_2 = assignmentDao.loadAssignmentByKey(startedAssignment_2.getKey());
Assert.assertNull(reloadStartedAssignment_2);
Page reloadedStartedPage_1 = pageDao.loadByKey(startedPageKey_1);
Assert.assertNull(reloadedStartedPage_1);
Page reloadedStartedPage_2 = pageDao.loadByKey(startedPageKey_2);
Assert.assertNull(reloadedStartedPage_2);
}
Aggregations