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