Search in sources :

Example 81 with Section

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

the class AssignmentDAOTest method loadAssignments_binder.

@Test
public void loadAssignments_binder() {
    Identity owner = JunitTestHelper.createAndPersistIdentityAsRndUser("assign-2");
    Binder binder = portfolioService.createNewBinder("Assignment binder 2", "Difficult!", null, owner);
    dbInstance.commit();
    portfolioService.appendNewSection("Section", "Assignment section", null, null, binder);
    dbInstance.commit();
    // create assignment
    List<Section> sections = portfolioService.getSections(binder);
    Assignment assignment = assignmentDao.createAssignment("Load assignment", "Load by binder", "The difficult content", null, AssignmentType.essay, AssignmentStatus.template, sections.get(0), false, false, false, null);
    dbInstance.commitAndCloseSession();
    // load the assignment
    List<Assignment> assignments = assignmentDao.loadAssignments(binder, null);
    Assert.assertNotNull(assignments);
    Assert.assertEquals(1, assignments.size());
    Assert.assertEquals(assignment, assignments.get(0));
}
Also used : Assignment(org.olat.modules.portfolio.Assignment) Binder(org.olat.modules.portfolio.Binder) Identity(org.olat.core.id.Identity) Section(org.olat.modules.portfolio.Section) Test(org.junit.Test)

Example 82 with Section

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

the class AssignmentDAOTest method loadAssignments_section.

@Test
public void loadAssignments_section() {
    Identity owner = JunitTestHelper.createAndPersistIdentityAsRndUser("assign-4");
    Binder binder = portfolioService.createNewBinder("Assignment binder 4", "Difficult!", null, owner);
    dbInstance.commit();
    portfolioService.appendNewSection("Section", "Assignment section", null, null, binder);
    dbInstance.commit();
    // create assignment
    List<Section> sections = portfolioService.getSections(binder);
    Section section = sections.get(0);
    Assignment assignment = assignmentDao.createAssignment("Load assignment", "Load by section", "The another content", null, AssignmentType.essay, AssignmentStatus.template, section, false, false, false, null);
    dbInstance.commitAndCloseSession();
    // load the assignment
    List<Assignment> assignments = assignmentDao.loadAssignments(section, null);
    Assert.assertNotNull(assignments);
    Assert.assertEquals(1, assignments.size());
    Assert.assertEquals(assignment, assignments.get(0));
}
Also used : Assignment(org.olat.modules.portfolio.Assignment) Binder(org.olat.modules.portfolio.Binder) Identity(org.olat.core.id.Identity) Section(org.olat.modules.portfolio.Section) Test(org.junit.Test)

Example 83 with Section

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

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 84 with Section

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

the class BinderDAOTest method loadSections.

@Test
public void loadSections() {
    String title = "Binder 3";
    String summary = "Binder with two sections.";
    Binder binder = binderDao.createAndPersist(title, summary, null, null);
    dbInstance.commitAndCloseSession();
    String section1Title = "1. section";
    String section1Desc = "My first section.";
    binder = binderDao.loadByKey(binder.getKey());
    Section section1 = binderDao.createSection(section1Title, section1Desc, null, null, binder);
    dbInstance.commitAndCloseSession();
    String section2Title = "2. section";
    String section2Desc = "My second section.";
    binder = binderDao.loadByKey(binder.getKey());
    Section section2 = binderDao.createSection(section2Title, section2Desc, null, null, binder);
    dbInstance.commitAndCloseSession();
    List<Section> sections = binderDao.getSections(binder);
    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) Section(org.olat.modules.portfolio.Section) Test(org.junit.Test)

Example 85 with Section

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

the class MediaDAOTest method usedInBinders.

@Test
public void usedInBinders() {
    Identity author = JunitTestHelper.createAndPersistIdentityAsRndUser("pf-media-2");
    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 page = pageDao.createAndPersist("Page 1", "A page with content.", null, null, true, reloadedSection, null);
    Media media = mediaDao.createMedia("Media", "Binder", "Une citation sur les classeurs", TextHandler.TEXT_MEDIA, "[Media:0]", null, 10, author);
    dbInstance.commitAndCloseSession();
    MediaPart mediaPart = new MediaPart();
    mediaPart.setMedia(media);
    PageBody reloadedBody = pageDao.loadPageBodyByKey(page.getBody().getKey());
    pageDao.persistPart(reloadedBody, mediaPart);
    dbInstance.commitAndCloseSession();
    // reload
    List<BinderPageUsage> binders = mediaDao.usedInBinders(media);
    Assert.assertNotNull(binders);
    Assert.assertEquals(1, binders.size());
    Assert.assertTrue(binders.get(0).getBinderKey().equals(binder.getKey()));
}
Also used : Binder(org.olat.modules.portfolio.Binder) MediaPart(org.olat.modules.portfolio.model.MediaPart) BinderPageUsage(org.olat.modules.portfolio.model.BinderPageUsage) Media(org.olat.modules.portfolio.Media) Page(org.olat.modules.portfolio.Page) Identity(org.olat.core.id.Identity) Section(org.olat.modules.portfolio.Section) PageBody(org.olat.modules.portfolio.PageBody) 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