Search in sources :

Example 81 with Page

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

the class PageDAOTest method deletePart.

@Test
public void deletePart() {
    Page page = pageDao.createAndPersist("Page 10", "A page with content.", null, null, true, null, null);
    dbInstance.commitAndCloseSession();
    HTMLPart htmlPart = new HTMLPart();
    PageBody reloadedBody = pageDao.loadPageBodyByKey(page.getBody().getKey());
    pageDao.persistPart(reloadedBody, htmlPart);
    dbInstance.commitAndCloseSession();
    TitlePart titlePart = new TitlePart();
    reloadedBody = pageDao.loadPageBodyByKey(page.getBody().getKey());
    pageDao.persistPart(reloadedBody, titlePart, 0);
    dbInstance.commitAndCloseSession();
    // reload
    Page reloadedPage = pageDao.loadByKey(page.getKey());
    pageDao.deletePage(reloadedPage);
    dbInstance.commit();
}
Also used : HTMLPart(org.olat.modules.portfolio.model.HTMLPart) TitlePart(org.olat.modules.portfolio.model.TitlePart) Page(org.olat.modules.portfolio.Page) PageBody(org.olat.modules.portfolio.PageBody) Test(org.junit.Test)

Example 82 with Page

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

the class PageDAOTest method createBinderWithSectionAndPageAndPart.

@Test
public void createBinderWithSectionAndPageAndPart() {
    BinderImpl binder = binderDao.createAndPersist("Binder p1", "A binder with a page", null, null);
    Section section = binderDao.createSection("Section", "First section", null, null, binder);
    dbInstance.commitAndCloseSession();
    Section reloadedSection = binderDao.loadSectionByKey(section.getKey());
    Page page = pageDao.createAndPersist("Page 1", "A page with content.", null, null, true, reloadedSection, null);
    dbInstance.commitAndCloseSession();
    HTMLPart htmlPart = new HTMLPart();
    PageBody reloadedBody = pageDao.loadPageBodyByKey(page.getBody().getKey());
    pageDao.persistPart(reloadedBody, htmlPart);
    dbInstance.commitAndCloseSession();
    // reload
    Page reloadedPage = pageDao.loadByKey(page.getKey());
    Assert.assertNotNull(reloadedPage);
    List<PagePart> parts = reloadedPage.getBody().getParts();
    Assert.assertNotNull(parts);
    Assert.assertEquals(1, parts.size());
    Assert.assertEquals(htmlPart, parts.get(0));
    // reload only pages
    List<PagePart> onlyParts = pageDao.getParts(page.getBody());
    Assert.assertNotNull(onlyParts);
    Assert.assertEquals(1, onlyParts.size());
    Assert.assertEquals(htmlPart, onlyParts.get(0));
}
Also used : PagePart(org.olat.modules.portfolio.PagePart) HTMLPart(org.olat.modules.portfolio.model.HTMLPart) BinderImpl(org.olat.modules.portfolio.model.BinderImpl) Page(org.olat.modules.portfolio.Page) Section(org.olat.modules.portfolio.Section) PageBody(org.olat.modules.portfolio.PageBody) Test(org.junit.Test)

Example 83 with Page

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

the class PageDAOTest method persistPart.

@Test
public void persistPart() {
    Page page = pageDao.createAndPersist("Page 1", "A page with content.", null, null, true, null, null);
    dbInstance.commitAndCloseSession();
    HTMLPart htmlPart = new HTMLPart();
    PageBody reloadedBody = pageDao.loadPageBodyByKey(page.getBody().getKey());
    pageDao.persistPart(reloadedBody, htmlPart);
    dbInstance.commitAndCloseSession();
    TitlePart titlePart = new TitlePart();
    reloadedBody = pageDao.loadPageBodyByKey(page.getBody().getKey());
    pageDao.persistPart(reloadedBody, titlePart, 0);
    dbInstance.commitAndCloseSession();
    // reload
    List<PagePart> reloadedPageParts = pageDao.getParts(reloadedBody);
    Assert.assertNotNull(reloadedPageParts);
    Assert.assertEquals(2, reloadedPageParts.size());
    Assert.assertEquals(titlePart, reloadedPageParts.get(0));
    Assert.assertEquals(htmlPart, reloadedPageParts.get(1));
}
Also used : PagePart(org.olat.modules.portfolio.PagePart) HTMLPart(org.olat.modules.portfolio.model.HTMLPart) TitlePart(org.olat.modules.portfolio.model.TitlePart) Page(org.olat.modules.portfolio.Page) PageBody(org.olat.modules.portfolio.PageBody) Test(org.junit.Test)

Example 84 with Page

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

the class PageUserInfosDAOTest method createPageUserInfos.

@Test
public void createPageUserInfos() {
    Identity coach = JunitTestHelper.createAndPersistIdentityAsRndUser("pui-1");
    BinderImpl binder = binderDao.createAndPersist("Binder pui1", "A binder with a page for infos", null, null);
    Section section = binderDao.createSection("Section", "First section", null, null, binder);
    Page page = pageDao.createAndPersist("New page", "A brand new page.", null, null, true, section, null);
    dbInstance.commitAndCloseSession();
    PageUserInformations infos = pageUserInfosDao.create(PageUserStatus.incoming, page, coach);
    Assert.assertNotNull(infos);
    Assert.assertEquals(coach, infos.getIdentity());
    Assert.assertEquals(page, infos.getPage());
    Assert.assertEquals(PageUserStatus.incoming, infos.getStatus());
    Assert.assertFalse(infos.isMark());
    dbInstance.commit();
}
Also used : PageUserInformations(org.olat.modules.portfolio.PageUserInformations) BinderImpl(org.olat.modules.portfolio.model.BinderImpl) Page(org.olat.modules.portfolio.Page) Identity(org.olat.core.id.Identity) Section(org.olat.modules.portfolio.Section) Test(org.junit.Test)

Example 85 with Page

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

the class PageUserInfosDAOTest method updatePageUserInfosRestricted.

@Test
public void updatePageUserInfosRestricted() {
    Identity coach = JunitTestHelper.createAndPersistIdentityAsRndUser("pui-4");
    BinderImpl binder = binderDao.createAndPersist("Binder pui4", "A binder with a page for infos to batch update", null, null);
    Section section = binderDao.createSection("Section", "First section", null, null, binder);
    Page page = pageDao.createAndPersist("New page", "A brand new page.", null, null, true, section, null);
    PageUserInformations infos = pageUserInfosDao.create(PageUserStatus.inProcess, page, coach);
    dbInstance.commitAndCloseSession();
    // update
    pageUserInfosDao.updateStatus(page, PageUserStatus.done, PageUserStatus.inProcess);
    dbInstance.commitAndCloseSession();
    // check nothing changed
    PageUserInformations reloadedInfos = pageUserInfosDao.getPageUserInfos(page, coach);
    Assert.assertNotNull(reloadedInfos);
    Assert.assertEquals(infos, reloadedInfos);
    Assert.assertEquals(PageUserStatus.done, reloadedInfos.getStatus());
    dbInstance.commit();
}
Also used : PageUserInformations(org.olat.modules.portfolio.PageUserInformations) BinderImpl(org.olat.modules.portfolio.model.BinderImpl) Page(org.olat.modules.portfolio.Page) Identity(org.olat.core.id.Identity) Section(org.olat.modules.portfolio.Section) Test(org.junit.Test)

Aggregations

Page (org.olat.modules.portfolio.Page)136 Section (org.olat.modules.portfolio.Section)98 Test (org.junit.Test)70 Identity (org.olat.core.id.Identity)64 Binder (org.olat.modules.portfolio.Binder)44 ArrayList (java.util.ArrayList)32 BinderImpl (org.olat.modules.portfolio.model.BinderImpl)32 AssessmentSection (org.olat.modules.portfolio.AssessmentSection)26 SynchedBinder (org.olat.modules.portfolio.model.SynchedBinder)26 Assignment (org.olat.modules.portfolio.Assignment)24 RepositoryEntry (org.olat.repository.RepositoryEntry)22 HashMap (java.util.HashMap)20 SectionRef (org.olat.modules.portfolio.SectionRef)20 PageUserInformations (org.olat.modules.portfolio.PageUserInformations)18 AssessedPage (org.olat.modules.portfolio.model.AssessedPage)16 PageBody (org.olat.modules.portfolio.PageBody)14 OLATResourceable (org.olat.core.id.OLATResourceable)12 AccessRights (org.olat.modules.portfolio.model.AccessRights)12 CategoryToElement (org.olat.modules.portfolio.CategoryToElement)10 Date (java.util.Date)8