Search in sources :

Example 41 with BinderImpl

use of org.olat.modules.portfolio.model.BinderImpl in project OpenOLAT by OpenOLAT.

the class BinderDAO method createAndPersist.

public BinderImpl createAndPersist(String title, String summary, String imagePath, RepositoryEntry entry) {
    BinderImpl binder = new BinderImpl();
    binder.setCreationDate(new Date());
    binder.setLastModified(binder.getCreationDate());
    binder.setTitle(title);
    binder.setSummary(summary);
    binder.setImagePath(imagePath);
    binder.setStatus(BinderStatus.open.name());
    binder.setBaseGroup(groupDao.createGroup());
    if (entry != null) {
        binder.setOlatResource(entry.getOlatResource());
    }
    dbInstance.getCurrentEntityManager().persist(binder);
    return binder;
}
Also used : BinderImpl(org.olat.modules.portfolio.model.BinderImpl) Date(java.util.Date)

Example 42 with BinderImpl

use of org.olat.modules.portfolio.model.BinderImpl in project openolat by klemens.

the class PageDAOTest method createBinderWithSectionAndPages.

@Test
public void createBinderWithSectionAndPages() {
    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());
    for (int i = 0; i < 5; i++) {
        pageDao.createAndPersist("New page " + i, "A brand new page.", null, null, true, reloadedSection, null);
    }
    dbInstance.commitAndCloseSession();
    List<Page> pages = pageDao.getPages(binder, null);
    Assert.assertNotNull(pages);
    Assert.assertEquals(5, pages.size());
}
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 43 with BinderImpl

use of org.olat.modules.portfolio.model.BinderImpl in project openolat by klemens.

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 44 with BinderImpl

use of org.olat.modules.portfolio.model.BinderImpl in project openolat by klemens.

the class PageUserInfosDAOTest method deletePageUserInfosRestricted_page.

@Test
public void deletePageUserInfosRestricted_page() {
    Identity coach = JunitTestHelper.createAndPersistIdentityAsRndUser("pui-6");
    BinderImpl binder = binderDao.createAndPersist("Binder pui6", "A binder with a page for infos to delete", 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();
    // check that we have something to delete
    PageUserInformations reloadedInfos = pageUserInfosDao.getPageUserInfos(page, coach);
    Assert.assertNotNull(reloadedInfos);
    Assert.assertEquals(infos, reloadedInfos);
    // update
    pageUserInfosDao.delete(page);
    dbInstance.commitAndCloseSession();
    // check that we have deleted something
    PageUserInformations deletedInfos = pageUserInfosDao.getPageUserInfos(page, coach);
    Assert.assertNull(deletedInfos);
}
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 45 with BinderImpl

use of org.olat.modules.portfolio.model.BinderImpl in project openolat by klemens.

the class PageUserInfosDAOTest method getPageUserInfos.

@Test
public void getPageUserInfos() {
    Identity coach = JunitTestHelper.createAndPersistIdentityAsRndUser("pui-2");
    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);
    PageUserInformations infos = pageUserInfosDao.create(PageUserStatus.inProcess, page, coach);
    dbInstance.commitAndCloseSession();
    PageUserInformations reloadedInfos = pageUserInfosDao.getPageUserInfos(page, coach);
    Assert.assertNotNull(reloadedInfos);
    Assert.assertEquals(infos, reloadedInfos);
    Assert.assertEquals(coach, reloadedInfos.getIdentity());
    Assert.assertEquals(page, reloadedInfos.getPage());
    Assert.assertEquals(PageUserStatus.inProcess, reloadedInfos.getStatus());
    Assert.assertFalse(reloadedInfos.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)

Aggregations

BinderImpl (org.olat.modules.portfolio.model.BinderImpl)64 Section (org.olat.modules.portfolio.Section)40 Test (org.junit.Test)38 Page (org.olat.modules.portfolio.Page)32 Identity (org.olat.core.id.Identity)22 Binder (org.olat.modules.portfolio.Binder)14 PageUserInformations (org.olat.modules.portfolio.PageUserInformations)12 RepositoryEntry (org.olat.repository.RepositoryEntry)12 OLATResource (org.olat.resource.OLATResource)10 ICourse (org.olat.course.ICourse)8 CourseNode (org.olat.course.nodes.CourseNode)8 PortfolioCourseNode (org.olat.course.nodes.PortfolioCourseNode)8 UserCourseEnvironment (org.olat.course.run.userview.UserCourseEnvironment)8 AssessmentEntry (org.olat.modules.assessment.AssessmentEntry)8 AssessedBinder (org.olat.modules.portfolio.model.AssessedBinder)8 SynchedBinder (org.olat.modules.portfolio.model.SynchedBinder)8 Date (java.util.Date)6 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)6 PageBody (org.olat.modules.portfolio.PageBody)6 BigDecimal (java.math.BigDecimal)4