Search in sources :

Example 56 with Binder

use of org.olat.modules.portfolio.Binder 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 57 with Binder

use of org.olat.modules.portfolio.Binder 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 58 with Binder

use of org.olat.modules.portfolio.Binder 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 59 with Binder

use of org.olat.modules.portfolio.Binder 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 60 with Binder

use of org.olat.modules.portfolio.Binder 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

Binder (org.olat.modules.portfolio.Binder)144 Section (org.olat.modules.portfolio.Section)72 Identity (org.olat.core.id.Identity)70 Test (org.junit.Test)68 SynchedBinder (org.olat.modules.portfolio.model.SynchedBinder)58 Page (org.olat.modules.portfolio.Page)44 RepositoryEntry (org.olat.repository.RepositoryEntry)34 Assignment (org.olat.modules.portfolio.Assignment)30 ArrayList (java.util.ArrayList)22 SectionRef (org.olat.modules.portfolio.SectionRef)22 AssessedBinder (org.olat.modules.portfolio.model.AssessedBinder)20 AssessmentSection (org.olat.modules.portfolio.AssessmentSection)16 OLATResourceable (org.olat.core.id.OLATResourceable)14 BinderSecurityCallback (org.olat.modules.portfolio.BinderSecurityCallback)14 PortfolioService (org.olat.modules.portfolio.PortfolioService)14 BinderImpl (org.olat.modules.portfolio.model.BinderImpl)14 AccessRights (org.olat.modules.portfolio.model.AccessRights)12 Date (java.util.Date)10 WindowControl (org.olat.core.gui.control.WindowControl)10 AssessmentSectionImpl (org.olat.modules.portfolio.model.AssessmentSectionImpl)8