use of org.olat.course.assessment.AssessmentMode in project openolat by klemens.
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);
}
use of org.olat.course.assessment.AssessmentMode in project openolat by klemens.
the class AssessmentModeManagerTest method loadAssessmentMode_identityInCourse_coach.
@Test
public void loadAssessmentMode_identityInCourse_coach() {
RepositoryEntry entry = JunitTestHelper.createAndPersistRepositoryEntry();
Identity author = JunitTestHelper.createAndPersistIdentityAsRndUser("as-mode-7");
Identity participant = JunitTestHelper.createAndPersistIdentityAsRndUser("as-mode-8");
Identity coach = JunitTestHelper.createAndPersistIdentityAsRndUser("as-mode-9");
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(true);
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.assertEquals(1, currentCoachModes.size());
Assert.assertTrue(currentCoachModes.contains(mode));
// check author
List<AssessmentMode> currentAuthorModes = assessmentModeMgr.getAssessmentModeFor(author);
Assert.assertNotNull(currentAuthorModes);
Assert.assertTrue(currentAuthorModes.isEmpty());
}
use of org.olat.course.assessment.AssessmentMode in project openolat by klemens.
the class AssessmentModeManagerTest method getAssessedIdentities_course_areas.
@Test
public void getAssessedIdentities_course_areas() {
Identity author = JunitTestHelper.createAndPersistIdentityAsRndUser("as-mode-20");
RepositoryEntry entry = JunitTestHelper.deployBasicCourse(author);
Identity participant1 = JunitTestHelper.createAndPersistIdentityAsRndUser("as-mode-21");
Identity coach1 = JunitTestHelper.createAndPersistIdentityAsRndUser("as-mode-22");
BusinessGroup businessGroup = businessGroupService.createBusinessGroup(null, "as-mode-5", "", null, null, null, null, false, false, entry);
businessGroupRelationDao.addRole(participant1, businessGroup, GroupRoles.participant.name());
businessGroupRelationDao.addRole(coach1, businessGroup, GroupRoles.coach.name());
Identity participant2 = JunitTestHelper.createAndPersistIdentityAsRndUser("as-mode-23");
Identity coach2 = JunitTestHelper.createAndPersistIdentityAsRndUser("as-mode-24");
repositoryEntryRelationDao.addRole(participant2, entry, GroupRoles.participant.name());
repositoryEntryRelationDao.addRole(coach2, entry, GroupRoles.coach.name());
repositoryEntryRelationDao.addRole(author, entry, GroupRoles.owner.name());
AssessmentMode mode = createMinimalAssessmentmode(entry);
mode.setTargetAudience(AssessmentMode.Target.courseAndGroups);
mode.setApplySettingsForCoach(true);
mode = assessmentModeMgr.persist(mode);
BGArea area = areaMgr.createAndPersistBGArea("area for people", "", entry.getOlatResource());
areaMgr.addBGToBGArea(businessGroup, area);
AssessmentModeToArea modeToArea = assessmentModeMgr.createAssessmentModeToArea(mode, area);
mode.getAreas().add(modeToArea);
mode = assessmentModeMgr.merge(mode, true);
dbInstance.commitAndCloseSession();
Assert.assertNotNull(mode);
Set<Long> assessedIdentityKeys = assessmentModeMgr.getAssessedIdentityKeys(mode);
Assert.assertNotNull(assessedIdentityKeys);
Assert.assertEquals(4, assessedIdentityKeys.size());
Assert.assertFalse(assessedIdentityKeys.contains(author.getKey()));
Assert.assertTrue(assessedIdentityKeys.contains(coach1.getKey()));
Assert.assertTrue(assessedIdentityKeys.contains(participant1.getKey()));
Assert.assertTrue(assessedIdentityKeys.contains(coach2.getKey()));
Assert.assertTrue(assessedIdentityKeys.contains(participant2.getKey()));
}
use of org.olat.course.assessment.AssessmentMode in project openolat by klemens.
the class AssessmentModeManagerTest method deleteAreaFromRepositoryEntry.
@Test
public void deleteAreaFromRepositoryEntry() {
// prepare the setup
Identity author = JunitTestHelper.createAndPersistIdentityAsRndUser("as-mode-14");
Identity participant = JunitTestHelper.createAndPersistIdentityAsRndUser("as-mode-15");
RepositoryEntry entry = JunitTestHelper.deployBasicCourse(author);
AssessmentMode mode = createMinimalAssessmentmode(entry);
mode.setTargetAudience(AssessmentMode.Target.groups);
mode = assessmentModeMgr.persist(mode);
dbInstance.commitAndCloseSession();
Assert.assertNotNull(mode);
BusinessGroup businessGroupForArea = businessGroupService.createBusinessGroup(author, "as_mode_1", "", null, null, null, null, false, false, null);
businessGroupRelationDao.addRole(participant, businessGroupForArea, GroupRoles.participant.name());
BGArea area = areaMgr.createAndPersistBGArea("little area", "My little secret area", entry.getOlatResource());
areaMgr.addBGToBGArea(businessGroupForArea, area);
dbInstance.commitAndCloseSession();
AssessmentModeToArea modeToArea = assessmentModeMgr.createAssessmentModeToArea(mode, area);
mode.getAreas().add(modeToArea);
mode = assessmentModeMgr.merge(mode, true);
dbInstance.commitAndCloseSession();
// check the participant modes
List<AssessmentMode> currentModes = assessmentModeMgr.getAssessmentModeFor(participant);
Assert.assertNotNull(currentModes);
Assert.assertEquals(1, currentModes.size());
Assert.assertTrue(currentModes.contains(mode));
// delete
areaMgr.deleteBGArea(area);
dbInstance.commitAndCloseSession();
// check the participant modes after deleting the area
List<AssessmentMode> afterDeleteModes = assessmentModeMgr.getAssessmentModeFor(participant);
Assert.assertNotNull(afterDeleteModes);
Assert.assertEquals(0, afterDeleteModes.size());
}
use of org.olat.course.assessment.AssessmentMode in project openolat by klemens.
the class AssessmentModeManagerTest method getCurrentAssessmentMode_manualNow.
/**
* Manual without lead time -> not in the current list
*/
@Test
public void getCurrentAssessmentMode_manualNow() {
RepositoryEntry entry = JunitTestHelper.createAndPersistRepositoryEntry();
// manual now
AssessmentMode mode = assessmentModeMgr.createAssessmentMode(entry);
mode.setName("Assessment to load");
Calendar cal = Calendar.getInstance();
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MILLISECOND, 0);
cal.add(Calendar.HOUR_OF_DAY, -1);
mode.setBegin(cal.getTime());
cal.add(Calendar.HOUR_OF_DAY, 2);
mode.setEnd(cal.getTime());
mode.setTargetAudience(Target.course);
mode.setManualBeginEnd(true);
mode = assessmentModeMgr.persist(mode);
dbInstance.commitAndCloseSession();
// check
Date now = new Date();
List<AssessmentMode> currentModes = assessmentModeMgr.getCurrentAssessmentMode(entry, now);
Assert.assertNotNull(currentModes);
Assert.assertTrue(currentModes.isEmpty());
}
Aggregations