use of org.olat.modules.portfolio.Section in project OpenOLAT by OpenOLAT.
the class PageListDataModel method filter.
public List<Section> filter(Section section) {
if (section == null) {
super.setObjects(backup);
return null;
} else if (backup == null) {
return new ArrayList<>();
}
Set<Section> sectionSet = new HashSet<>();
List<Section> sectionList = new ArrayList<>();
List<PortfolioElementRow> sectionRows = new ArrayList<>();
for (PortfolioElementRow row : backup) {
if (row.getSection() != null) {
if (!sectionSet.contains(row.getSection())) {
sectionSet.add(row.getSection());
sectionList.add(row.getSection());
}
if (section.equals(row.getSection())) {
sectionRows.add(row);
}
}
}
super.setObjects(sectionRows);
return sectionList;
}
use of org.olat.modules.portfolio.Section in project OpenOLAT by OpenOLAT.
the class AssignmentDAOTest method createBinderWithAssignment.
@Test
public void createBinderWithAssignment() {
Identity owner = JunitTestHelper.createAndPersistIdentityAsRndUser("assign-1");
Binder binder = portfolioService.createNewBinder("Assignment binder 1", "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("Difficult", "Very difficult", "The difficult content", null, AssignmentType.essay, AssignmentStatus.template, sections.get(0), false, false, false, null);
dbInstance.commitAndCloseSession();
Assert.assertNotNull(assignment);
Assert.assertNotNull(assignment.getKey());
Assert.assertNotNull(assignment.getCreationDate());
Assert.assertNotNull(assignment.getLastModified());
}
use of org.olat.modules.portfolio.Section in project OpenOLAT by OpenOLAT.
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 OpenOLAT.
the class AssignmentDAOTest method loadAssignments_binder_search.
@Test
public void loadAssignments_binder_search() {
Identity owner = JunitTestHelper.createAndPersistIdentityAsRndUser("assign-3");
Binder binder = portfolioService.createNewBinder("Assignment binder 3", "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 content unkown search", null, AssignmentType.essay, AssignmentStatus.template, sections.get(0), false, false, false, null);
dbInstance.commitAndCloseSession();
// search the assignment
List<Assignment> assignments = assignmentDao.loadAssignments(binder, "unkown");
Assert.assertNotNull(assignments);
Assert.assertEquals(1, assignments.size());
Assert.assertEquals(assignment, assignments.get(0));
// dummy search
List<Assignment> emptyAssignments = assignmentDao.loadAssignments(binder, "sdhfks");
Assert.assertNotNull(emptyAssignments);
Assert.assertEquals(0, emptyAssignments.size());
}
use of org.olat.modules.portfolio.Section in project OpenOLAT by OpenOLAT.
the class EvaluationFormResponseDAOTest method createResponseforPortfolio.
@Test
public void createResponseforPortfolio() {
// prepare a test case with the binder up to the page body
Identity id = JunitTestHelper.createAndPersistIdentityAsRndUser("eva-1");
BinderImpl binder = binderDao.createAndPersist("Binder evaluation 1", "A binder with an evaluation", null, null);
Section section = binderDao.createSection("Section", "First section", null, null, binder);
dbInstance.commit();
Section reloadedSection = binderDao.loadSectionByKey(section.getKey());
Page page = pageDao.createAndPersist("Page 1", "A page with an evalutation.", null, null, true, reloadedSection, null);
dbInstance.commit();
RepositoryEntry formEntry = createFormEntry("Eva. form for responses");
PageBody reloadedBody = pageDao.loadPageBodyByKey(page.getBody().getKey());
EvaluationFormSession session = evaluationFormSessionDao.createSessionForPortfolio(id, reloadedBody, formEntry);
dbInstance.commit();
// create a response
String responseIdentifier = UUID.randomUUID().toString();
BigDecimal numericalValue = new BigDecimal("2.2");
String stringuifiedResponse = numericalValue.toPlainString();
Path fileResponse = Paths.get("this", "is", "a", "path");
EvaluationFormResponse response = evaluationFormResponseDao.createResponse(responseIdentifier, numericalValue, stringuifiedResponse, fileResponse, session);
dbInstance.commit();
Assert.assertNotNull(response);
Assert.assertNotNull(response.getKey());
Assert.assertNotNull(response.getCreationDate());
Assert.assertNotNull(response.getLastModified());
Assert.assertEquals(session, response.getSession());
Assert.assertEquals(numericalValue, response.getNumericalResponse());
Assert.assertEquals(stringuifiedResponse, response.getStringuifiedResponse());
Assert.assertEquals(fileResponse, response.getFileResponse());
Assert.assertEquals(responseIdentifier, response.getResponseIdentifier());
}
Aggregations