Search in sources :

Example 41 with Section

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;
}
Also used : PortfolioElementRow(org.olat.modules.portfolio.ui.model.PortfolioElementRow) ArrayList(java.util.ArrayList) Section(org.olat.modules.portfolio.Section) HashSet(java.util.HashSet)

Example 42 with Section

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());
}
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 43 with Section

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));
}
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 44 with Section

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());
}
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 45 with Section

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());
}
Also used : Path(java.nio.file.Path) EvaluationFormSession(org.olat.modules.forms.EvaluationFormSession) BinderImpl(org.olat.modules.portfolio.model.BinderImpl) Page(org.olat.modules.portfolio.Page) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) EvaluationFormResponse(org.olat.modules.forms.EvaluationFormResponse) Section(org.olat.modules.portfolio.Section) PageBody(org.olat.modules.portfolio.PageBody) BigDecimal(java.math.BigDecimal) 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