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