Search in sources :

Example 61 with AssessmentMode

use of org.olat.course.assessment.AssessmentMode 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 62 with AssessmentMode

use of org.olat.course.assessment.AssessmentMode 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 63 with AssessmentMode

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

the class AssessmentModeManagerTest method loadAssessmentMode_identityInCourse.

@Test
public void loadAssessmentMode_identityInCourse() {
    RepositoryEntry entry = JunitTestHelper.createAndPersistRepositoryEntry();
    Identity author = JunitTestHelper.createAndPersistIdentityAsRndUser("as-mode-4");
    Identity participant = JunitTestHelper.createAndPersistIdentityAsRndUser("as-mode-5");
    Identity coach = JunitTestHelper.createAndPersistIdentityAsRndUser("as-mode-6");
    repositoryEntryRelationDao.addRole(participant, entry, GroupRoles.participant.name());
    repositoryEntryRelationDao.addRole(coach, entry, GroupRoles.coach.name());
    repositoryEntryRelationDao.addRole(author, entry, GroupRoles.owner.name());
    AssessmentMode mode = createMinimalAssessmentmode(entry);
    mode.setTargetAudience(AssessmentMode.Target.courseAndGroups);
    mode.setApplySettingsForCoach(false);
    mode = assessmentModeMgr.persist(mode);
    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.assertTrue(currentCoachModes.isEmpty());
    // check author
    List<AssessmentMode> currentAuthorModes = assessmentModeMgr.getAssessmentModeFor(author);
    Assert.assertNotNull(currentAuthorModes);
    Assert.assertTrue(currentAuthorModes.isEmpty());
}
Also used : AssessmentMode(org.olat.course.assessment.AssessmentMode) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) Test(org.junit.Test)

Example 64 with AssessmentMode

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

the class AssessmentModeManagerTest method isInAssessmentMode.

@Test
public void isInAssessmentMode() {
    RepositoryEntry entry = JunitTestHelper.createAndPersistRepositoryEntry();
    RepositoryEntry entryReference = JunitTestHelper.createAndPersistRepositoryEntry();
    AssessmentMode mode = createMinimalAssessmentmode(entry);
    mode = assessmentModeMgr.persist(mode);
    dbInstance.commitAndCloseSession();
    Assert.assertNotNull(mode);
    // check
    Date now = new Date();
    boolean entryNow = assessmentModeMgr.isInAssessmentMode(entry, now);
    Assert.assertTrue(entryNow);
    // no assessment for this course
    boolean entryReferenceNow = assessmentModeMgr.isInAssessmentMode(entryReference, now);
    Assert.assertFalse(entryReferenceNow);
    // out of assessment scope
    Calendar cal = Calendar.getInstance();
    cal.setTime(now);
    cal.add(Calendar.DATE, -1);
    Date aDayBefore = cal.getTime();
    boolean entryReferencePast = assessmentModeMgr.isInAssessmentMode(entryReference, aDayBefore);
    Assert.assertFalse(entryReferencePast);
}
Also used : AssessmentMode(org.olat.course.assessment.AssessmentMode) Calendar(java.util.Calendar) RepositoryEntry(org.olat.repository.RepositoryEntry) Date(java.util.Date) Test(org.junit.Test)

Example 65 with AssessmentMode

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

the class AssessmentModeManagerTest method deleteBusinessGroupFromRepositoryEntry.

@Test
public void deleteBusinessGroupFromRepositoryEntry() {
    Identity author = JunitTestHelper.createAndPersistIdentityAsRndUser("as-mode-9");
    RepositoryEntry entry = JunitTestHelper.deployBasicCourse(author);
    Identity participant1 = JunitTestHelper.createAndPersistIdentityAsRndUser("as-mode-10");
    Identity participant2 = JunitTestHelper.createAndPersistIdentityAsRndUser("as-mode-11");
    BusinessGroup businessGroup1 = businessGroupService.createBusinessGroup(author, "as-mode-12", "", null, null, null, null, false, false, entry);
    BusinessGroup businessGroup2 = businessGroupService.createBusinessGroup(author, "as-mode-13", "", null, null, null, null, false, false, entry);
    businessGroupRelationDao.addRole(participant1, businessGroup1, GroupRoles.participant.name());
    businessGroupRelationDao.addRole(participant2, businessGroup2, GroupRoles.participant.name());
    AssessmentMode mode = createMinimalAssessmentmode(entry);
    mode.setTargetAudience(AssessmentMode.Target.groups);
    mode.setApplySettingsForCoach(false);
    mode = assessmentModeMgr.persist(mode);
    AssessmentModeToGroup modeToGroup1 = assessmentModeMgr.createAssessmentModeToGroup(mode, businessGroup1);
    AssessmentModeToGroup modeToGroup2 = assessmentModeMgr.createAssessmentModeToGroup(mode, businessGroup2);
    mode.getGroups().add(modeToGroup1);
    mode.getGroups().add(modeToGroup2);
    mode = assessmentModeMgr.merge(mode, true);
    dbInstance.commitAndCloseSession();
    Assert.assertNotNull(mode);
    // check participant 1
    List<AssessmentMode> currentModes1 = assessmentModeMgr.getAssessmentModeFor(participant1);
    Assert.assertNotNull(currentModes1);
    Assert.assertEquals(1, currentModes1.size());
    Assert.assertTrue(currentModes1.contains(mode));
    // check participant 2
    List<AssessmentMode> currentModes2 = assessmentModeMgr.getAssessmentModeFor(participant2);
    Assert.assertNotNull(currentModes2);
    Assert.assertEquals(1, currentModes2.size());
    Assert.assertTrue(currentModes2.contains(mode));
    // remove business group 1
    businessGroupService.deleteBusinessGroup(businessGroup2);
    dbInstance.commitAndCloseSession();
    // check participant 1
    List<AssessmentMode> afterDeleteModes1 = assessmentModeMgr.getAssessmentModeFor(participant1);
    Assert.assertNotNull(afterDeleteModes1);
    Assert.assertEquals(1, afterDeleteModes1.size());
    Assert.assertTrue(afterDeleteModes1.contains(mode));
    // check participant 2
    List<AssessmentMode> afterDeleteModes2 = assessmentModeMgr.getAssessmentModeFor(participant2);
    Assert.assertNotNull(afterDeleteModes2);
    Assert.assertEquals(0, afterDeleteModes2.size());
}
Also used : AssessmentMode(org.olat.course.assessment.AssessmentMode) BusinessGroup(org.olat.group.BusinessGroup) AssessmentModeToGroup(org.olat.course.assessment.AssessmentModeToGroup) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) Test(org.junit.Test)

Aggregations

AssessmentMode (org.olat.course.assessment.AssessmentMode)94 RepositoryEntry (org.olat.repository.RepositoryEntry)62 Test (org.junit.Test)52 Date (java.util.Date)32 Identity (org.olat.core.id.Identity)28 BusinessGroup (org.olat.group.BusinessGroup)24 Calendar (java.util.Calendar)20 AssessmentModeToGroup (org.olat.course.assessment.AssessmentModeToGroup)16 TransientAssessmentMode (org.olat.course.assessment.model.TransientAssessmentMode)16 ArrayList (java.util.ArrayList)12 BGArea (org.olat.group.area.BGArea)12 UserRequest (org.olat.core.gui.UserRequest)10 TooledStackedPanel (org.olat.core.gui.components.stack.TooledStackedPanel)10 Controller (org.olat.core.gui.control.Controller)10 WindowControl (org.olat.core.gui.control.WindowControl)10 MainLayoutController (org.olat.core.gui.control.generic.layout.MainLayoutController)10 AssessmentModeToArea (org.olat.course.assessment.AssessmentModeToArea)10 RepositoryEntrySecurity (org.olat.repository.model.RepositoryEntrySecurity)10 RuntimeControllerCreator (org.olat.repository.ui.RepositoryEntryRuntimeController.RuntimeControllerCreator)10 StepsMainRunController (org.olat.core.gui.control.generic.wizard.StepsMainRunController)8