use of org.olat.modules.portfolio.Page in project openolat by klemens.
the class SharedPagesController method doSelectedPage.
private Activateable2 doSelectedPage(UserRequest ureq, SharedPageRow row) {
removeAsListenerAndDispose(pageCtrl);
Page reloadedPage = portfolioService.getPageByKey(row.getPageKey());
Binder binder = reloadedPage.getSection().getBinder();
OLATResourceable pageOres = OresHelper.createOLATResourceableInstance("Entry", reloadedPage.getKey());
WindowControl swControl = addToHistory(ureq, pageOres, null);
List<AccessRights> rights = portfolioService.getAccessRights(binder, getIdentity());
BinderSecurityCallback secCallback = BinderSecurityCallbackFactory.getCallbackForCoach(binder, rights);
pageCtrl = new PageRunController(ureq, swControl, stackPanel, secCallback, reloadedPage, false);
listenTo(pageCtrl);
stackPanel.pushController(reloadedPage.getTitle(), pageCtrl);
return pageCtrl;
}
use of org.olat.modules.portfolio.Page in project openolat by klemens.
the class SharedPagesController method toggleBookmark.
private void toggleBookmark(SharedPageRow row) {
Page page = portfolioService.getPageByKey(row.getPageKey());
PageUserInformations infos = portfolioService.getPageUserInfos(page, getIdentity(), PageUserStatus.incoming);
infos.setMark(!infos.isMark());
infos = portfolioService.updatePageUserInfos(infos);
if (searchParams.isBookmarkOnly() && !infos.isMark()) {
List<SharedPageRow> rows = model.getObjects();
rows.remove(row);
model.setObjects(rows);
tableEl.reset(false, false, true);
} else {
row.getBookmarkLink().setIconLeftCSS(infos.isMark() ? Mark.MARK_CSS_LARGE : Mark.MARK_ADD_CSS_LARGE);
}
}
use of org.olat.modules.portfolio.Page in project OpenOLAT by OpenOLAT.
the class EvaluationFormSessionDAOTest method createSessionForPortfolio.
@Test
public void createSessionForPortfolio() {
Identity id = JunitTestHelper.createAndPersistIdentityAsRndUser("eva-1");
BinderImpl binder = binderDao.createAndPersist("Binder evaluation 1", "A binder with an evaluation", null, null);
Section section = binderDao.createSection("Section", "First section", null, null, binder);
dbInstance.commit();
Section reloadedSection = binderDao.loadSectionByKey(section.getKey());
Page page = pageDao.createAndPersist("Page 1", "A page with an evalutation.", null, null, true, reloadedSection, null);
dbInstance.commit();
RepositoryEntry formEntry = createFormEntry("Eva. form for session");
PageBody reloadedBody = pageDao.loadPageBodyByKey(page.getBody().getKey());
EvaluationFormSession session = evaluationFormSessionDao.createSessionForPortfolio(id, reloadedBody, formEntry);
dbInstance.commit();
Assert.assertNotNull(session);
Assert.assertNotNull(session.getKey());
Assert.assertNotNull(session.getCreationDate());
Assert.assertNotNull(session.getLastModified());
Assert.assertEquals(reloadedBody, session.getPageBody());
Assert.assertEquals(id, session.getIdentity());
}
use of org.olat.modules.portfolio.Page in project OpenOLAT by OpenOLAT.
the class PortfolioServiceTest method syncBinder_moveAssignmentsInSection_multiple.
@Test
public void syncBinder_moveAssignmentsInSection_multiple() {
Identity owner = JunitTestHelper.createAndPersistIdentityAsRndUser("port-u-10");
Identity id = JunitTestHelper.createAndPersistIdentityAsRndUser("port-u-11");
RepositoryEntry templateEntry = createTemplate(owner, "Template", "TE");
dbInstance.commitAndCloseSession();
// make 2 sections
Binder templateBinder = portfolioService.getBinderByResource(templateEntry.getOlatResource());
SectionRef sectionRef1 = portfolioService.getSections(templateBinder).get(0);
dbInstance.commit();
// make 4 assignments
Section templateSection1 = portfolioService.getSection(sectionRef1);
Assignment assignment_1_1 = portfolioService.addAssignment("1.1 Assignment", "", "", AssignmentType.essay, templateSection1, false, false, false, null);
Assignment assignment_1_2 = portfolioService.addAssignment("1.2 Assignment", "", "", AssignmentType.essay, templateSection1, false, false, false, null);
Assignment assignment_1_3 = portfolioService.addAssignment("1.3 Assignment", "", "", AssignmentType.essay, templateSection1, false, false, false, null);
Assignment assignment_1_4 = portfolioService.addAssignment("1.4 Assignment", "", "", AssignmentType.essay, templateSection1, false, false, false, null);
Assignment assignment_1_5 = portfolioService.addAssignment("1.5 Assignment", "", "", AssignmentType.essay, templateSection1, false, false, false, null);
Assignment assignment_1_6 = portfolioService.addAssignment("1.6 Assignment", "", "", AssignmentType.essay, templateSection1, false, false, false, null);
dbInstance.commit();
List<Assignment> templateAssignments = portfolioService.getAssignments(templateBinder, null);
Assert.assertEquals(6, templateAssignments.size());
// a user take the binder and synched it a first time
Binder binder = portfolioService.assignBinder(id, templateBinder, templateEntry, "74", null);
dbInstance.commit();
SynchedBinder synchedBinder = portfolioService.loadAndSyncBinder(binder);
dbInstance.commitAndCloseSession();
Assert.assertNotNull(synchedBinder);
Assert.assertEquals(binder, synchedBinder.getBinder());
// start all assignments
List<Assignment> assignments = portfolioService.getAssignments(binder, null);
Assert.assertEquals(6, assignments.size());
for (Assignment assignment : assignments) {
portfolioService.startAssignment(assignment.getKey(), id);
dbInstance.commit();
}
dbInstance.commit();
// check that the student has it's 8 pages
List<Page> pages = portfolioService.getPages(binder, null);
Assert.assertEquals(6, pages.size());
dbInstance.commit();
// synched and check the sections order
SynchedBinder synchedBinder2 = portfolioService.loadAndSyncBinder(binder);
Binder freshBinder = synchedBinder2.getBinder();
dbInstance.commitAndCloseSession();
// ooops, someone deleted the assignment (simulate jump in the numbering of the list)
List<Section> sections = portfolioService.getSections(freshBinder);
List<Assignment> firstSectionAssignments = portfolioService.getAssignments(sections.get(0), null);
dbInstance.getCurrentEntityManager().remove(firstSectionAssignments.get(1));
dbInstance.getCurrentEntityManager().remove(firstSectionAssignments.get(2));
dbInstance.getCurrentEntityManager().remove(firstSectionAssignments.get(3));
dbInstance.getCurrentEntityManager().remove(firstSectionAssignments.get(5));
dbInstance.commit();
List<Assignment> firstSectionDeletedAssignments = portfolioService.getAssignments(sections.get(0), null);
Assert.assertEquals(2, firstSectionDeletedAssignments.size());
// synched and check the sections order
SynchedBinder synchedBinder3 = portfolioService.loadAndSyncBinder(binder);
Binder freshBinder3 = synchedBinder3.getBinder();
dbInstance.commitAndCloseSession();
Assert.assertNotNull(freshBinder3);
List<Assignment> firstSectionAssignmentResynched = portfolioService.getAssignments(sections.get(0), null);
List<Assignment> templateAssignmentsSynched = new ArrayList<>();
Assert.assertEquals(6, firstSectionAssignmentResynched.size());
for (Assignment firstSectionAssignment : firstSectionAssignmentResynched) {
Assert.assertEquals(firstSectionAssignment.getTitle(), firstSectionAssignment.getTemplateReference().getTitle());
templateAssignmentsSynched.add(firstSectionAssignment.getTemplateReference());
}
Assert.assertTrue(templateAssignmentsSynched.contains(assignment_1_1));
Assert.assertTrue(templateAssignmentsSynched.contains(assignment_1_2));
Assert.assertTrue(templateAssignmentsSynched.contains(assignment_1_3));
Assert.assertTrue(templateAssignmentsSynched.contains(assignment_1_4));
Assert.assertTrue(templateAssignmentsSynched.contains(assignment_1_5));
Assert.assertTrue(templateAssignmentsSynched.contains(assignment_1_6));
}
use of org.olat.modules.portfolio.Page in project OpenOLAT by OpenOLAT.
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