Search in sources :

Example 61 with Binder

use of org.olat.modules.portfolio.Binder 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 62 with Binder

use of org.olat.modules.portfolio.Binder 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 63 with Binder

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

the class BinderDAOTest method getOwnedBinders.

@Test
public void getOwnedBinders() {
    Identity owner = JunitTestHelper.createAndPersistIdentityAsRndUser("binder-owner");
    Binder binder = portfolioService.createNewBinder("My own binder", "", "", owner);
    dbInstance.commit();
    Binder deletedBinder = portfolioService.createNewBinder("My own deleted binder", "", "", owner);
    deletedBinder.setBinderStatus(BinderStatus.deleted);
    deletedBinder = portfolioService.updateBinder(deletedBinder);
    dbInstance.commitAndCloseSession();
    List<Binder> ownedBinders = binderDao.getOwnedBinders(owner);
    Assert.assertNotNull(ownedBinders);
    Assert.assertEquals(1, ownedBinders.size());
    Assert.assertTrue(ownedBinders.contains(binder));
    Assert.assertFalse(ownedBinders.contains(deletedBinder));
}
Also used : Binder(org.olat.modules.portfolio.Binder) Identity(org.olat.core.id.Identity) Test(org.junit.Test)

Example 64 with Binder

use of org.olat.modules.portfolio.Binder 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 65 with Binder

use of org.olat.modules.portfolio.Binder 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)

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