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));
}
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));
}
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));
}
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));
}
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()));
}
Aggregations