Search in sources :

Example 6 with AssessmentModeToArea

use of org.olat.course.assessment.AssessmentModeToArea in project openolat by klemens.

the class AssessmentModeManagerTest method createAssessmentModeToArea.

@Test
public void createAssessmentModeToArea() {
    Identity author = JunitTestHelper.createAndPersistIdentityAsRndUser("as-mode-1");
    RepositoryEntry entry = JunitTestHelper.deployBasicCourse(author);
    BusinessGroup businessGroup = businessGroupService.createBusinessGroup(author, "as_mode_1", "", null, null, null, null, false, false, null);
    BGArea area = areaMgr.createAndPersistBGArea("little area", "My little secret area", entry.getOlatResource());
    areaMgr.addBGToBGArea(businessGroup, area);
    AssessmentMode mode = createMinimalAssessmentmode(entry);
    mode = assessmentModeMgr.persist(mode);
    dbInstance.commitAndCloseSession();
    Assert.assertNotNull(mode);
    AssessmentModeToArea modeToArea = assessmentModeMgr.createAssessmentModeToArea(mode, area);
    mode.getAreas().add(modeToArea);
    AssessmentMode savedMode = assessmentModeMgr.merge(mode, true);
    dbInstance.commitAndCloseSession();
    AssessmentMode reloadedMode = assessmentModeMgr.getAssessmentModeById(mode.getKey());
    Assert.assertEquals(mode, reloadedMode);
    Assert.assertEquals(savedMode, reloadedMode);
    Assert.assertNotNull(reloadedMode.getAreas());
    Assert.assertEquals(1, reloadedMode.getAreas().size());
    Assert.assertEquals(modeToArea, reloadedMode.getAreas().iterator().next());
    dbInstance.commitAndCloseSession();
}
Also used : AssessmentModeToArea(org.olat.course.assessment.AssessmentModeToArea) AssessmentMode(org.olat.course.assessment.AssessmentMode) BusinessGroup(org.olat.group.BusinessGroup) BGArea(org.olat.group.area.BGArea) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) Test(org.junit.Test)

Example 7 with AssessmentModeToArea

use of org.olat.course.assessment.AssessmentModeToArea in project openolat by klemens.

the class AssessmentModeManagerTest method deleteAssessmentMode.

@Test
public void deleteAssessmentMode() {
    // prepare the setup
    Identity author = JunitTestHelper.createAndPersistIdentityAsRndUser("as-mode-1");
    RepositoryEntry entry = JunitTestHelper.deployBasicCourse(author);
    BusinessGroup businessGroup = businessGroupService.createBusinessGroup(author, "as_mode_1", "", null, null, null, null, false, false, null);
    AssessmentMode mode = createMinimalAssessmentmode(entry);
    mode = assessmentModeMgr.persist(mode);
    dbInstance.commitAndCloseSession();
    Assert.assertNotNull(mode);
    AssessmentModeToGroup modeToGroup = assessmentModeMgr.createAssessmentModeToGroup(mode, businessGroup);
    mode.getGroups().add(modeToGroup);
    AssessmentMode savedMode = assessmentModeMgr.merge(mode, true);
    dbInstance.commitAndCloseSession();
    BusinessGroup businessGroupForArea = businessGroupService.createBusinessGroup(author, "as_mode_1", "", null, null, null, null, false, false, null);
    BGArea area = areaMgr.createAndPersistBGArea("little area", "My little secret area", entry.getOlatResource());
    areaMgr.addBGToBGArea(businessGroupForArea, area);
    dbInstance.commitAndCloseSession();
    AssessmentModeToArea modeToArea = assessmentModeMgr.createAssessmentModeToArea(savedMode, area);
    savedMode.getAreas().add(modeToArea);
    savedMode = assessmentModeMgr.merge(savedMode, true);
    dbInstance.commitAndCloseSession();
    // delete
    assessmentModeMgr.delete(savedMode);
    dbInstance.commit();
    // check
    AssessmentMode deletedMode = assessmentModeMgr.getAssessmentModeById(mode.getKey());
    Assert.assertNull(deletedMode);
}
Also used : AssessmentModeToArea(org.olat.course.assessment.AssessmentModeToArea) AssessmentMode(org.olat.course.assessment.AssessmentMode) BusinessGroup(org.olat.group.BusinessGroup) BGArea(org.olat.group.area.BGArea) AssessmentModeToGroup(org.olat.course.assessment.AssessmentModeToGroup) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) Test(org.junit.Test)

Example 8 with AssessmentModeToArea

use of org.olat.course.assessment.AssessmentModeToArea in project OpenOLAT by OpenOLAT.

the class AssessmentModeManagerTest method loadAssessmentMode_identityInArea_coach.

/**
 * Check an assessment linked to an area with one participant
 */
@Test
public void loadAssessmentMode_identityInArea_coach() {
    Identity author = JunitTestHelper.createAndPersistIdentityAsRndUser("as-mode-12");
    RepositoryEntry entry = JunitTestHelper.deployBasicCourse(author);
    Identity participant = JunitTestHelper.createAndPersistIdentityAsRndUser("as-mode-13");
    Identity coach = JunitTestHelper.createAndPersistIdentityAsRndUser("as-mode-14");
    BusinessGroup businessGroup = businessGroupService.createBusinessGroup(null, "as-mode-3", "", null, null, null, null, false, false, entry);
    businessGroupRelationDao.addRole(participant, businessGroup, GroupRoles.participant.name());
    businessGroupRelationDao.addRole(coach, businessGroup, GroupRoles.coach.name());
    BGArea area = areaMgr.createAndPersistBGArea("area for people", "", entry.getOlatResource());
    areaMgr.addBGToBGArea(businessGroup, area);
    AssessmentMode mode = createMinimalAssessmentmode(entry);
    mode.setTargetAudience(AssessmentMode.Target.courseAndGroups);
    mode.setApplySettingsForCoach(true);
    mode = assessmentModeMgr.persist(mode);
    AssessmentModeToArea modeToArea = assessmentModeMgr.createAssessmentModeToArea(mode, area);
    mode.getAreas().add(modeToArea);
    mode = assessmentModeMgr.merge(mode, true);
    dbInstance.commitAndCloseSession();
    Assert.assertNotNull(mode);
    // check participant
    List<AssessmentMode> currentModes = assessmentModeMgr.getAssessmentModeFor(participant);
    Assert.assertNotNull(currentModes);
    Assert.assertEquals(1, currentModes.size());
    Assert.assertTrue(currentModes.contains(mode));
    // check coach
    List<AssessmentMode> currentCoachModes = assessmentModeMgr.getAssessmentModeFor(coach);
    Assert.assertNotNull(currentCoachModes);
    Assert.assertEquals(1, currentCoachModes.size());
    Assert.assertTrue(currentCoachModes.contains(mode));
    // check author
    List<AssessmentMode> currentAuthorModes = assessmentModeMgr.getAssessmentModeFor(author);
    Assert.assertNotNull(currentAuthorModes);
    Assert.assertTrue(currentAuthorModes.isEmpty());
}
Also used : AssessmentModeToArea(org.olat.course.assessment.AssessmentModeToArea) AssessmentMode(org.olat.course.assessment.AssessmentMode) BusinessGroup(org.olat.group.BusinessGroup) BGArea(org.olat.group.area.BGArea) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) Test(org.junit.Test)

Example 9 with AssessmentModeToArea

use of org.olat.course.assessment.AssessmentModeToArea in project OpenOLAT by OpenOLAT.

the class AssessmentModeManagerTest method createAssessmentModeToArea.

@Test
public void createAssessmentModeToArea() {
    Identity author = JunitTestHelper.createAndPersistIdentityAsRndUser("as-mode-1");
    RepositoryEntry entry = JunitTestHelper.deployBasicCourse(author);
    BusinessGroup businessGroup = businessGroupService.createBusinessGroup(author, "as_mode_1", "", null, null, null, null, false, false, null);
    BGArea area = areaMgr.createAndPersistBGArea("little area", "My little secret area", entry.getOlatResource());
    areaMgr.addBGToBGArea(businessGroup, area);
    AssessmentMode mode = createMinimalAssessmentmode(entry);
    mode = assessmentModeMgr.persist(mode);
    dbInstance.commitAndCloseSession();
    Assert.assertNotNull(mode);
    AssessmentModeToArea modeToArea = assessmentModeMgr.createAssessmentModeToArea(mode, area);
    mode.getAreas().add(modeToArea);
    AssessmentMode savedMode = assessmentModeMgr.merge(mode, true);
    dbInstance.commitAndCloseSession();
    AssessmentMode reloadedMode = assessmentModeMgr.getAssessmentModeById(mode.getKey());
    Assert.assertEquals(mode, reloadedMode);
    Assert.assertEquals(savedMode, reloadedMode);
    Assert.assertNotNull(reloadedMode.getAreas());
    Assert.assertEquals(1, reloadedMode.getAreas().size());
    Assert.assertEquals(modeToArea, reloadedMode.getAreas().iterator().next());
    dbInstance.commitAndCloseSession();
}
Also used : AssessmentModeToArea(org.olat.course.assessment.AssessmentModeToArea) AssessmentMode(org.olat.course.assessment.AssessmentMode) BusinessGroup(org.olat.group.BusinessGroup) BGArea(org.olat.group.area.BGArea) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) Test(org.junit.Test)

Example 10 with AssessmentModeToArea

use of org.olat.course.assessment.AssessmentModeToArea in project OpenOLAT by OpenOLAT.

the class AssessmentModeManagerTest method deleteAssessmentMode.

@Test
public void deleteAssessmentMode() {
    // prepare the setup
    Identity author = JunitTestHelper.createAndPersistIdentityAsRndUser("as-mode-1");
    RepositoryEntry entry = JunitTestHelper.deployBasicCourse(author);
    BusinessGroup businessGroup = businessGroupService.createBusinessGroup(author, "as_mode_1", "", null, null, null, null, false, false, null);
    AssessmentMode mode = createMinimalAssessmentmode(entry);
    mode = assessmentModeMgr.persist(mode);
    dbInstance.commitAndCloseSession();
    Assert.assertNotNull(mode);
    AssessmentModeToGroup modeToGroup = assessmentModeMgr.createAssessmentModeToGroup(mode, businessGroup);
    mode.getGroups().add(modeToGroup);
    AssessmentMode savedMode = assessmentModeMgr.merge(mode, true);
    dbInstance.commitAndCloseSession();
    BusinessGroup businessGroupForArea = businessGroupService.createBusinessGroup(author, "as_mode_1", "", null, null, null, null, false, false, null);
    BGArea area = areaMgr.createAndPersistBGArea("little area", "My little secret area", entry.getOlatResource());
    areaMgr.addBGToBGArea(businessGroupForArea, area);
    dbInstance.commitAndCloseSession();
    AssessmentModeToArea modeToArea = assessmentModeMgr.createAssessmentModeToArea(savedMode, area);
    savedMode.getAreas().add(modeToArea);
    savedMode = assessmentModeMgr.merge(savedMode, true);
    dbInstance.commitAndCloseSession();
    // delete
    assessmentModeMgr.delete(savedMode);
    dbInstance.commit();
    // check
    AssessmentMode deletedMode = assessmentModeMgr.getAssessmentModeById(mode.getKey());
    Assert.assertNull(deletedMode);
}
Also used : AssessmentModeToArea(org.olat.course.assessment.AssessmentModeToArea) AssessmentMode(org.olat.course.assessment.AssessmentMode) BusinessGroup(org.olat.group.BusinessGroup) BGArea(org.olat.group.area.BGArea) AssessmentModeToGroup(org.olat.course.assessment.AssessmentModeToGroup) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) Test(org.junit.Test)

Aggregations

AssessmentModeToArea (org.olat.course.assessment.AssessmentModeToArea)16 BusinessGroup (org.olat.group.BusinessGroup)16 BGArea (org.olat.group.area.BGArea)16 RepositoryEntry (org.olat.repository.RepositoryEntry)12 Test (org.junit.Test)10 Identity (org.olat.core.id.Identity)10 AssessmentMode (org.olat.course.assessment.AssessmentMode)10 AssessmentModeToGroup (org.olat.course.assessment.AssessmentModeToGroup)8 HashSet (java.util.HashSet)4 Target (org.olat.course.assessment.AssessmentMode.Target)4 ArrayList (java.util.ArrayList)2 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)2 ICourse (org.olat.course.ICourse)2 Status (org.olat.course.assessment.AssessmentMode.Status)2 CourseNode (org.olat.course.nodes.CourseNode)2 CourseEditorTreeModel (org.olat.course.tree.CourseEditorTreeModel)2