Search in sources :

Example 31 with Section

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

the class BinderDAOTest method createBinderWithSection_2steps.

@Test
public void createBinderWithSection_2steps() {
    String title = "Binder 2";
    String summary = "Binder with one section.";
    Binder binder = binderDao.createAndPersist(title, summary, null, null);
    dbInstance.commitAndCloseSession();
    String section1Title = "First section";
    String section1Desc = "My first section.";
    binder = binderDao.loadByKey(binder.getKey());
    Section section1 = binderDao.createSection(section1Title, section1Desc, null, null, binder);
    dbInstance.commitAndCloseSession();
    String section2Title = "Second section";
    String section2Desc = "My second section.";
    binder = binderDao.loadByKey(binder.getKey());
    Section section2 = binderDao.createSection(section2Title, section2Desc, null, null, binder);
    dbInstance.commitAndCloseSession();
    Binder reloadedBinder = binderDao.loadByKey(binder.getKey());
    List<Section> sections = ((BinderImpl) reloadedBinder).getSections();
    Assert.assertNotNull(sections);
    Assert.assertEquals(2, sections.size());
    Assert.assertEquals(section1, sections.get(0));
    Assert.assertEquals(section2, sections.get(1));
}
Also used : Binder(org.olat.modules.portfolio.Binder) BinderImpl(org.olat.modules.portfolio.model.BinderImpl) Section(org.olat.modules.portfolio.Section) Test(org.junit.Test)

Example 32 with Section

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

the class CategoryDAOTest method getCategorizedSectionsAndPages.

@Test
public void getCategorizedSectionsAndPages() {
    Identity author = JunitTestHelper.createAndPersistIdentityAsRndUser("pf-1");
    Binder binder = portfolioService.createNewBinder("Binder about Verne", "A binder with a single page", null, author);
    Section section = binderDao.createSection("Section", "First section", null, null, binder);
    dbInstance.commitAndCloseSession();
    Section reloadedSection = binderDao.loadSectionByKey(section.getKey());
    Page page = pageDao.createAndPersist("Jules Verne", "Deux ans de vacances", null, null, true, reloadedSection, null);
    dbInstance.commitAndCloseSession();
    List<String> categoriesSection = new ArrayList<>();
    categoriesSection.add("Jules");
    categoriesSection.add("Verne");
    portfolioService.updateCategories(section, categoriesSection);
    List<String> categoriesPage = new ArrayList<>();
    categoriesPage.add("Aventure");
    categoriesPage.add("Vacances");
    portfolioService.updateCategories(page, categoriesPage);
    dbInstance.commitAndCloseSession();
    // load by section
    List<CategoryToElement> categories = categoryDao.getCategorizedSectionAndPages(section);
    Assert.assertNotNull(categories);
    Assert.assertEquals(4, categories.size());
    // load by binder
    List<CategoryToElement> categoriesByBinder = categoryDao.getCategorizedSectionsAndPages(binder);
    Assert.assertNotNull(categoriesByBinder);
    Assert.assertEquals(4, categoriesByBinder.size());
}
Also used : Binder(org.olat.modules.portfolio.Binder) CategoryToElement(org.olat.modules.portfolio.CategoryToElement) ArrayList(java.util.ArrayList) Page(org.olat.modules.portfolio.Page) Identity(org.olat.core.id.Identity) Section(org.olat.modules.portfolio.Section) Test(org.junit.Test)

Example 33 with Section

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

the class CategoryDAOTest method getCategorizedOwnedPages.

@Test
public void getCategorizedOwnedPages() {
    Identity author = JunitTestHelper.createAndPersistIdentityAsRndUser("pf-1");
    Binder binder = portfolioService.createNewBinder("Binder p2", "A binder with 2 page", null, author);
    Section section = binderDao.createSection("Section", "First section", null, null, binder);
    dbInstance.commitAndCloseSession();
    Section reloadedSection = binderDao.loadSectionByKey(section.getKey());
    Page page1 = pageDao.createAndPersist("Jules Verne", "Cing semaine en ballon", null, null, true, reloadedSection, null);
    Page page2 = pageDao.createAndPersist("J. Verne", "Une ville flottante", null, null, true, reloadedSection, null);
    Page page3 = pageDao.createAndPersist("Verne", "Les Tribulations d'un Chinois en Chine", null, null, true, reloadedSection, null);
    dbInstance.commitAndCloseSession();
    List<String> categories1 = new ArrayList<>();
    categories1.add("Jules");
    categories1.add("Verne");
    categories1.add("Aventure");
    categories1.add("Voyage");
    portfolioService.updateCategories(page1, categories1);
    List<String> categories2 = new ArrayList<>();
    categories2.add("Jules");
    categories2.add("Verne");
    categories2.add("Anticipation");
    categories2.add("Technologie");
    portfolioService.updateCategories(page2, categories2);
    List<String> categories3 = new ArrayList<>();
    categories3.add("Jules");
    categories3.add("Verne");
    categories3.add("Aventure");
    categories3.add("Chine");
    portfolioService.updateCategories(page3, categories3);
    dbInstance.commitAndCloseSession();
    List<CategoryToElement> categories = categoryDao.getCategorizedOwnedPages(author);
    Assert.assertNotNull(categories);
    Assert.assertEquals(12, categories.size());
}
Also used : Binder(org.olat.modules.portfolio.Binder) CategoryToElement(org.olat.modules.portfolio.CategoryToElement) ArrayList(java.util.ArrayList) Page(org.olat.modules.portfolio.Page) Identity(org.olat.core.id.Identity) Section(org.olat.modules.portfolio.Section) Test(org.junit.Test)

Example 34 with Section

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

the class PageDAOTest method loadPageByBody.

@Test
public void loadPageByBody() {
    BinderImpl binder = binderDao.createAndPersist("Binder body", "A binder with a page and a page body", null, null);
    Section section = binderDao.createSection("Section", "Body section", null, null, binder);
    dbInstance.commitAndCloseSession();
    Section reloadedSection = binderDao.loadSectionByKey(section.getKey());
    Page page = pageDao.createAndPersist("Page 1", "A page with body.", null, null, true, reloadedSection, null);
    dbInstance.commitAndCloseSession();
    Page reloadedPage = pageDao.loadByBody(page.getBody());
    Assert.assertNotNull(reloadedPage);
    Assert.assertEquals(page, reloadedPage);
}
Also used : BinderImpl(org.olat.modules.portfolio.model.BinderImpl) Page(org.olat.modules.portfolio.Page) Section(org.olat.modules.portfolio.Section) Test(org.junit.Test)

Example 35 with Section

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

the class PageDAOTest method getLastPage.

@Test
public void getLastPage() {
    // an owned binder
    Identity author = JunitTestHelper.createAndPersistIdentityAsRndUser("pf-1");
    Binder binder = portfolioService.createNewBinder("Binder p2", "A binder with 2 page", null, author);
    Section section = binderDao.createSection("Section", "First section", null, null, binder);
    dbInstance.commitAndCloseSession();
    Section reloadedSection = binderDao.loadSectionByKey(section.getKey());
    Page page1 = pageDao.createAndPersist("Page 1", "A page with content.", null, null, true, reloadedSection, null);
    sleep(1500);
    Page page2 = pageDao.createAndPersist("Page 2", "A page with content.", null, null, true, reloadedSection, null);
    sleep(1500);
    Page page3 = portfolioService.appendNewPage(author, "Page 3", "A page with content.", null, null, null);
    dbInstance.commitAndCloseSession();
    Assert.assertNotNull(page1);
    // reload
    Page lastBinderPage = pageDao.getLastPage(author, true);
    Assert.assertNotNull(lastBinderPage);
    Assert.assertEquals(page2, lastBinderPage);
    // reload
    Page lastFloatingPage = pageDao.getLastPage(author, false);
    Assert.assertNotNull(lastFloatingPage);
    Assert.assertEquals(page3, lastFloatingPage);
}
Also used : 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)

Aggregations

Section (org.olat.modules.portfolio.Section)190 Page (org.olat.modules.portfolio.Page)100 Test (org.junit.Test)86 Identity (org.olat.core.id.Identity)80 Binder (org.olat.modules.portfolio.Binder)72 AssessmentSection (org.olat.modules.portfolio.AssessmentSection)68 Assignment (org.olat.modules.portfolio.Assignment)48 BinderImpl (org.olat.modules.portfolio.model.BinderImpl)40 SynchedBinder (org.olat.modules.portfolio.model.SynchedBinder)38 ArrayList (java.util.ArrayList)36 RepositoryEntry (org.olat.repository.RepositoryEntry)26 SectionRef (org.olat.modules.portfolio.SectionRef)24 HashMap (java.util.HashMap)22 Date (java.util.Date)16 PageUserInformations (org.olat.modules.portfolio.PageUserInformations)14 BigDecimal (java.math.BigDecimal)12 FormLink (org.olat.core.gui.components.form.flexible.elements.FormLink)12 SectionImpl (org.olat.modules.portfolio.model.SectionImpl)12 PortfolioElementRow (org.olat.modules.portfolio.ui.model.PortfolioElementRow)12 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)10