Search in sources :

Example 81 with Binder

use of org.olat.modules.portfolio.Binder in project OpenOLAT by OpenOLAT.

the class PortfolioServiceTest method deleteSectionWithPages.

@Test
public void deleteSectionWithPages() {
    // prepare a binder with 2 sections and some pages
    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);
    List<Page> pagesSection1 = new ArrayList<>();
    for (int i = 0; i < 10; i++) {
        Page page = portfolioService.appendNewPage(owner, "New page", "A brand new page.", null, null, reloadedSection1);
        pagesSection1.add(page);
    }
    Section reloadedSection2 = portfolioService.getSection(sectionRef2);
    Page page2 = portfolioService.appendNewPage(owner, "New page", "A brand new page.", null, null, reloadedSection2);
    Assert.assertNotNull(page2);
    dbInstance.commitAndCloseSession();
    // delete the section
    portfolioService.deleteSection(binder, reloadedSection1);
    dbInstance.commit();
    // check if section 2 is still around
    Section section2 = binderDao.loadSectionByKey(sectionRef2.getKey());
    Assert.assertEquals(reloadedSection2, section2);
    Page reloadedPage2 = pageDao.loadByKey(page2.getKey());
    Assert.assertNotNull(reloadedPage2);
    Assert.assertEquals(page2, reloadedPage2);
    // check if section 1 is deleted
    Section deletedSection1 = binderDao.loadSectionByKey(sectionRef1.getKey());
    Assert.assertNull(deletedSection1);
    for (Page pageSection1 : pagesSection1) {
        Page deletedPage = pageDao.loadByKey(pageSection1.getKey());
        Assert.assertNull(deletedPage);
    }
}
Also used : SynchedBinder(org.olat.modules.portfolio.model.SynchedBinder) Binder(org.olat.modules.portfolio.Binder) ArrayList(java.util.ArrayList) Page(org.olat.modules.portfolio.Page) Identity(org.olat.core.id.Identity) SectionRef(org.olat.modules.portfolio.SectionRef) Section(org.olat.modules.portfolio.Section) Test(org.junit.Test)

Example 82 with Binder

use of org.olat.modules.portfolio.Binder in project OpenOLAT by OpenOLAT.

the class PortfolioServiceTest method binderAndSectionAndPageAccessRights_byIdentity.

@Test
public void binderAndSectionAndPageAccessRights_byIdentity() {
    Identity owner = JunitTestHelper.createAndPersistIdentityAsRndUser("port-u-5");
    Identity identity = JunitTestHelper.createAndPersistIdentityAsRndUser("port-u-6");
    String title = "My published binder";
    String summary = "My live";
    Binder binder = portfolioService.createNewBinder(title, summary, null, owner);
    dbInstance.commit();
    portfolioService.appendNewSection("Section", "Coached section", null, null, binder);
    dbInstance.commit();
    List<Section> sections = portfolioService.getSections(binder);
    Section section = sections.get(0);
    portfolioService.appendNewPage(owner, "Reviewed page", "", null, null, section);
    portfolioService.addAccessRights(section, identity, PortfolioRoles.coach);
    dbInstance.commit();
    List<Page> pages = portfolioService.getPages(section);
    Page page = pages.get(0);
    portfolioService.addAccessRights(page, identity, PortfolioRoles.reviewer);
    // load right
    List<AccessRights> rights = portfolioService.getAccessRights(binder, identity);
    Assert.assertNotNull(rights);
    Assert.assertEquals(2, rights.size());
}
Also used : AccessRights(org.olat.modules.portfolio.model.AccessRights) SynchedBinder(org.olat.modules.portfolio.model.SynchedBinder) Binder(org.olat.modules.portfolio.Binder) Page(org.olat.modules.portfolio.Page) Identity(org.olat.core.id.Identity) Section(org.olat.modules.portfolio.Section) Test(org.junit.Test)

Example 83 with Binder

use of org.olat.modules.portfolio.Binder in project OpenOLAT by OpenOLAT.

the class PortfolioServiceTest method syncBinder.

@Test
public void syncBinder() {
    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());
    // add 2 sections
    for (int i = 0; i < 2; i++) {
        portfolioService.appendNewSection("Section " + i, "Section " + i, null, null, templateBinder);
        dbInstance.commit();
    }
    List<Section> templateSections = portfolioService.getSections(templateBinder);
    Assert.assertNotNull(templateSections);
    Assert.assertEquals(3, templateSections.size());
    // user get a the binder from the template
    Binder binder = portfolioService.assignBinder(id, templateBinder, templateEntry, "ac-234", new Date());
    dbInstance.commit();
    Assert.assertNotNull(binder);
    boolean inUse = portfolioService.isTemplateInUse(templateBinder, templateEntry, "ac-234");
    Assert.assertTrue(inUse);
    // update the template with 2 more sections
    for (int i = 2; i < 4; i++) {
        portfolioService.appendNewSection("Section " + i, "Section " + i, null, null, templateBinder);
        dbInstance.commit();
    }
    SynchedBinder synchedBinder = portfolioService.loadAndSyncBinder(binder);
    Assert.assertNotNull(synchedBinder);
    dbInstance.commit();
    Assert.assertTrue(synchedBinder.isChanged());
    Assert.assertEquals(binder, synchedBinder.getBinder());
    List<Section> synchedSections = portfolioService.getSections(synchedBinder.getBinder());
    Assert.assertEquals(5, synchedSections.size());
}
Also used : SynchedBinder(org.olat.modules.portfolio.model.SynchedBinder) Binder(org.olat.modules.portfolio.Binder) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) Section(org.olat.modules.portfolio.Section) SynchedBinder(org.olat.modules.portfolio.model.SynchedBinder) Date(java.util.Date) Test(org.junit.Test)

Example 84 with Binder

use of org.olat.modules.portfolio.Binder in project OpenOLAT by OpenOLAT.

the class PortfolioServiceTest method binderAccessRights.

@Test
public void binderAccessRights() {
    Identity owner = JunitTestHelper.createAndPersistIdentityAsRndUser("port-u-2");
    String title = "My private binder";
    String summary = "My live";
    Binder binder = portfolioService.createNewBinder(title, summary, null, owner);
    dbInstance.commitAndCloseSession();
    // load right
    List<AccessRights> rights = portfolioService.getAccessRights(binder);
    Assert.assertNotNull(rights);
    Assert.assertEquals(1, rights.size());
    AccessRights ownerRight = rights.get(0);
    Assert.assertEquals(binder.getKey(), ownerRight.getBinderKey());
    Assert.assertEquals(owner, ownerRight.getIdentity());
    Assert.assertEquals(PortfolioRoles.owner, ownerRight.getRole());
}
Also used : AccessRights(org.olat.modules.portfolio.model.AccessRights) SynchedBinder(org.olat.modules.portfolio.model.SynchedBinder) Binder(org.olat.modules.portfolio.Binder) Identity(org.olat.core.id.Identity) Test(org.junit.Test)

Example 85 with Binder

use of org.olat.modules.portfolio.Binder in project OpenOLAT by OpenOLAT.

the class PortfolioServiceTest method searchOwnedBinders.

@Test
public void searchOwnedBinders() {
    Identity owner = JunitTestHelper.createAndPersistIdentityAsRndUser("binder-owner-");
    Binder binder = portfolioService.createNewBinder("Binder 2", "Binder with one section.", null, owner);
    dbInstance.commitAndCloseSession();
    portfolioService.appendNewSection("First section", "My first section.", null, null, binder);
    dbInstance.commitAndCloseSession();
    portfolioService.appendNewSection("Second section", "My second section.", null, null, binder);
    dbInstance.commitAndCloseSession();
    List<Section> sections = portfolioService.getSections(binder);
    for (int i = 0; i < 2; i++) {
        Section section = sections.get(1);
        portfolioService.appendNewPage(owner, "Page-1-" + i, "", null, null, section);
        portfolioService.appendNewPage(owner, "Page-2-" + i, "", null, null, section);
    }
    List<BinderStatistics> rows = portfolioService.searchOwnedBinders(owner);
    Assert.assertNotNull(rows);
    Assert.assertEquals(1, rows.size());
    BinderStatistics myBinder = rows.get(0);
    Assert.assertEquals(2, myBinder.getNumOfSections());
    Assert.assertEquals(4, myBinder.getNumOfPages());
}
Also used : SynchedBinder(org.olat.modules.portfolio.model.SynchedBinder) Binder(org.olat.modules.portfolio.Binder) Identity(org.olat.core.id.Identity) BinderStatistics(org.olat.modules.portfolio.model.BinderStatistics) Section(org.olat.modules.portfolio.Section) Test(org.junit.Test)

Aggregations

Binder (org.olat.modules.portfolio.Binder)144 Section (org.olat.modules.portfolio.Section)72 Identity (org.olat.core.id.Identity)70 Test (org.junit.Test)68 SynchedBinder (org.olat.modules.portfolio.model.SynchedBinder)58 Page (org.olat.modules.portfolio.Page)44 RepositoryEntry (org.olat.repository.RepositoryEntry)34 Assignment (org.olat.modules.portfolio.Assignment)30 ArrayList (java.util.ArrayList)22 SectionRef (org.olat.modules.portfolio.SectionRef)22 AssessedBinder (org.olat.modules.portfolio.model.AssessedBinder)20 AssessmentSection (org.olat.modules.portfolio.AssessmentSection)16 OLATResourceable (org.olat.core.id.OLATResourceable)14 BinderSecurityCallback (org.olat.modules.portfolio.BinderSecurityCallback)14 PortfolioService (org.olat.modules.portfolio.PortfolioService)14 BinderImpl (org.olat.modules.portfolio.model.BinderImpl)14 AccessRights (org.olat.modules.portfolio.model.AccessRights)12 Date (java.util.Date)10 WindowControl (org.olat.core.gui.control.WindowControl)10 AssessmentSectionImpl (org.olat.modules.portfolio.model.AssessmentSectionImpl)8