Search in sources :

Example 76 with Section

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

the class PortfolioServiceTest method assignTemplate.

@Test
public void assignTemplate() {
    Identity owner = JunitTestHelper.createAndPersistIdentityAsRndUser("port-u-7");
    Identity id = JunitTestHelper.createAndPersistIdentityAsRndUser("port-u-8");
    // create a template
    String title = "Template binder";
    String summary = "Binder used as a template";
    Binder template = portfolioService.createNewBinder(title, summary, null, owner);
    dbInstance.commit();
    for (int i = 0; i < 4; i++) {
        portfolioService.appendNewSection("Section " + i, "Section " + i, null, null, template);
        dbInstance.commit();
    }
    dbInstance.commitAndCloseSession();
    List<Section> templateSections = portfolioService.getSections(template);
    Assert.assertNotNull(templateSections);
    Assert.assertEquals(4, templateSections.size());
    // user copy the template
    Binder binder = portfolioService.assignBinder(id, template, null, null, new Date());
    dbInstance.commitAndCloseSession();
    Assert.assertNotNull(binder);
    Assert.assertNotNull(binder.getKey());
    Assert.assertNotNull(binder.getCopyDate());
    Assert.assertNotNull(template.getTitle(), binder.getTitle());
    List<Section> reloadedSections = portfolioService.getSections(binder);
    Assert.assertNotNull(reloadedSections);
    Assert.assertEquals(4, reloadedSections.size());
    Assert.assertEquals(templateSections.get(0).getTitle(), reloadedSections.get(0).getTitle());
    Assert.assertEquals("Section 1", reloadedSections.get(1).getTitle());
    Assert.assertEquals(templateSections.get(2).getTitle(), reloadedSections.get(2).getTitle());
    Assert.assertEquals("Section 3", reloadedSections.get(3).getTitle());
    Assert.assertEquals(templateSections.get(0), ((SectionImpl) reloadedSections.get(0)).getTemplateReference());
    Assert.assertEquals(templateSections.get(1), ((SectionImpl) reloadedSections.get(1)).getTemplateReference());
    Assert.assertEquals(templateSections.get(2), ((SectionImpl) reloadedSections.get(2)).getTemplateReference());
    Assert.assertEquals(templateSections.get(3), ((SectionImpl) reloadedSections.get(3)).getTemplateReference());
}
Also used : SynchedBinder(org.olat.modules.portfolio.model.SynchedBinder) Binder(org.olat.modules.portfolio.Binder) Identity(org.olat.core.id.Identity) Section(org.olat.modules.portfolio.Section) Date(java.util.Date) Test(org.junit.Test)

Example 77 with Section

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

the class PortfolioServiceTest method removeAssignment.

@Test
public void removeAssignment() {
    Identity owner = JunitTestHelper.createAndPersistIdentityAsRndUser("port-u-10");
    RepositoryEntry templateEntry = createTemplate(owner, "Template", "TE");
    dbInstance.commitAndCloseSession();
    // make the binder and the section
    Binder templateBinder = portfolioService.getBinderByResource(templateEntry.getOlatResource());
    SectionRef sectionRef = portfolioService.getSections(templateBinder).get(0);
    dbInstance.commit();
    // make 4 assignments
    Section templateSection = portfolioService.getSection(sectionRef);
    Assignment assignment_1 = portfolioService.addAssignment("1 Assignment", "", "", AssignmentType.essay, templateSection, false, false, false, null);
    Assignment assignment_2 = portfolioService.addAssignment("2 Assignment", "", "", AssignmentType.essay, templateSection, false, false, false, null);
    Assignment assignment_3 = portfolioService.addAssignment("3 Assignment", "", "", AssignmentType.essay, templateSection, false, false, false, null);
    Assignment assignment_4 = portfolioService.addAssignment("3 Assignment", "", "", AssignmentType.essay, templateSection, false, false, false, null);
    dbInstance.commitAndCloseSession();
    boolean ok = portfolioService.deleteAssignment(assignment_3);
    Assert.assertTrue(ok);
    dbInstance.commitAndCloseSession();
    List<Assignment> assignments = portfolioService.getSection(sectionRef).getAssignments();
    Assert.assertNotNull(assignments);
    Assert.assertEquals(3, assignments.size());
    Assert.assertTrue(assignments.contains(assignment_1));
    Assert.assertTrue(assignments.contains(assignment_2));
    Assert.assertFalse(assignments.contains(assignment_3));
    Assert.assertTrue(assignments.contains(assignment_4));
}
Also used : Assignment(org.olat.modules.portfolio.Assignment) SynchedBinder(org.olat.modules.portfolio.model.SynchedBinder) Binder(org.olat.modules.portfolio.Binder) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) SectionRef(org.olat.modules.portfolio.SectionRef) Section(org.olat.modules.portfolio.Section) Test(org.junit.Test)

Example 78 with Section

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

the class PortfolioServiceTest method removeAssignment_usedOne.

@Test
public void removeAssignment_usedOne() {
    Identity owner = JunitTestHelper.createAndPersistIdentityAsRndUser("port-u-10");
    Identity id = JunitTestHelper.createAndPersistIdentityAsRndUser("port-u-11");
    RepositoryEntry templateEntry = createTemplate(owner, "Template", "TE");
    dbInstance.commitAndCloseSession();
    // make 2 sections
    Binder templateBinder = portfolioService.getBinderByResource(templateEntry.getOlatResource());
    SectionRef sectionRef = portfolioService.getSections(templateBinder).get(0);
    dbInstance.commit();
    // make 4 assignments
    Section templateSection = portfolioService.getSection(sectionRef);
    Assignment assignment_1 = portfolioService.addAssignment("1 Assignment", "", "", AssignmentType.essay, templateSection, false, false, false, null);
    Assignment assignment_2 = portfolioService.addAssignment("2 Assignment", "", "", AssignmentType.essay, templateSection, false, false, false, null);
    Assignment assignment_3 = portfolioService.addAssignment("3 Assignment", "", "", AssignmentType.essay, templateSection, false, false, false, null);
    Assignment assignment_4 = portfolioService.addAssignment("4 Assignment", "", "", AssignmentType.essay, templateSection, false, false, false, null);
    dbInstance.commit();
    List<Assignment> templateAssignments = portfolioService.getAssignments(templateBinder, null);
    Assert.assertEquals(4, templateAssignments.size());
    Assert.assertTrue(templateAssignments.contains(assignment_1));
    Assert.assertTrue(templateAssignments.contains(assignment_2));
    Assert.assertTrue(templateAssignments.contains(assignment_3));
    Assert.assertTrue(templateAssignments.contains(assignment_4));
    // synched and check the sections order
    Binder binder = portfolioService.assignBinder(id, templateBinder, templateEntry, null, null);
    SynchedBinder synchedBinder = portfolioService.loadAndSyncBinder(binder);
    binder = synchedBinder.getBinder();
    dbInstance.commitAndCloseSession();
    List<Assignment> assignments = portfolioService.getAssignments(binder, null);
    portfolioService.startAssignment(assignments.get(0).getKey(), id);
    portfolioService.startAssignment(assignments.get(1).getKey(), id);
    portfolioService.startAssignment(assignments.get(2).getKey(), id);
    portfolioService.startAssignment(assignments.get(3).getKey(), id);
    dbInstance.commit();
    List<Section> sections = portfolioService.getSections(binder);
    List<Page> pages = portfolioService.getPages(sections.get(0));
    Assert.assertEquals(4, pages.size());
    // delete an assignment
    boolean ok = portfolioService.deleteAssignment(assignment_3);
    Assert.assertTrue(ok);
    dbInstance.commitAndCloseSession();
    // sync the binder
    SynchedBinder reSynchedBinder = portfolioService.loadAndSyncBinder(binder);
    binder = reSynchedBinder.getBinder();
    dbInstance.commitAndCloseSession();
    // deleting an assignment doesn't delete the pages
    List<Page> allPages = portfolioService.getPages(sections.get(0));
    Assert.assertEquals(4, allPages.size());
    // sync twice
    SynchedBinder reReSynchedBinder = portfolioService.loadAndSyncBinder(binder);
    binder = reReSynchedBinder.getBinder();
    dbInstance.commitAndCloseSession();
}
Also used : Assignment(org.olat.modules.portfolio.Assignment) SynchedBinder(org.olat.modules.portfolio.model.SynchedBinder) Binder(org.olat.modules.portfolio.Binder) Page(org.olat.modules.portfolio.Page) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) SectionRef(org.olat.modules.portfolio.SectionRef) Section(org.olat.modules.portfolio.Section) SynchedBinder(org.olat.modules.portfolio.model.SynchedBinder) Test(org.junit.Test)

Example 79 with Section

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

the class AssessmentSectionDAOTest method createAssessmentSection.

@Test
public void createAssessmentSection() {
    Identity owner = JunitTestHelper.createAndPersistIdentityAsRndUser("aowner-1");
    // create a binder with a section
    Binder binder = portfolioService.createNewBinder("ABinder", "Assessment on binder", null, owner);
    dbInstance.commit();
    portfolioService.appendNewSection("Section", "Coached section", null, null, binder);
    dbInstance.commit();
    List<Section> sections = portfolioService.getSections(binder);
    // create the assessment point
    Boolean passed = Boolean.TRUE;
    Section section = sections.get(0);
    BigDecimal score = new BigDecimal("3.5");
    AssessmentSection assessmentSection = assessmentSectionDao.createAssessmentSection(score, passed, section, owner);
    dbInstance.commitAndCloseSession();
    Assert.assertNotNull(assessmentSection);
    Assert.assertNotNull(assessmentSection.getKey());
    Assert.assertNotNull(assessmentSection.getCreationDate());
    Assert.assertNotNull(assessmentSection.getLastModified());
    Assert.assertEquals(section, assessmentSection.getSection());
    Assert.assertEquals(passed, assessmentSection.getPassed());
    Assert.assertEquals(score, assessmentSection.getScore());
    // reload the assessment point
    AssessmentSection reloadedAssessmentSection = assessmentSectionDao.loadByKey(assessmentSection.getKey());
    Assert.assertNotNull(reloadedAssessmentSection);
    Assert.assertEquals(assessmentSection, reloadedAssessmentSection);
}
Also used : Binder(org.olat.modules.portfolio.Binder) AssessmentSection(org.olat.modules.portfolio.AssessmentSection) Identity(org.olat.core.id.Identity) AssessmentSection(org.olat.modules.portfolio.AssessmentSection) Section(org.olat.modules.portfolio.Section) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Example 80 with Section

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

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)

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