use of org.olat.course.assessment.AssessmentMode in project openolat by klemens.
the class AssessmentModeManagerTest method removeBusinessGroupFromRepositoryEntry.
@Test
public void removeBusinessGroupFromRepositoryEntry() {
Identity author = JunitTestHelper.createAndPersistIdentityAsRndUser("as-mode-4");
RepositoryEntry entry = JunitTestHelper.deployBasicCourse(author);
Identity participant1 = JunitTestHelper.createAndPersistIdentityAsRndUser("as-mode-5");
Identity participant2 = JunitTestHelper.createAndPersistIdentityAsRndUser("as-mode-6");
BusinessGroup businessGroup1 = businessGroupService.createBusinessGroup(author, "as-mode-7", "", null, null, null, null, false, false, entry);
BusinessGroup businessGroup2 = businessGroupService.createBusinessGroup(author, "as-mode-8", "", 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
businessGroupRelationDao.deleteRelation(businessGroup1, entry);
dbInstance.commitAndCloseSession();
// check participant 1
List<AssessmentMode> afterDeleteModes1 = assessmentModeMgr.getAssessmentModeFor(participant1);
Assert.assertNotNull(afterDeleteModes1);
Assert.assertEquals(0, afterDeleteModes1.size());
// check participant 2
List<AssessmentMode> afterDeleteModes2 = assessmentModeMgr.getAssessmentModeFor(participant2);
Assert.assertNotNull(afterDeleteModes2);
Assert.assertEquals(1, afterDeleteModes2.size());
Assert.assertTrue(afterDeleteModes2.contains(mode));
}
use of org.olat.course.assessment.AssessmentMode in project openolat by klemens.
the class AssessmentModeManagerTest method loadAssessmentModes.
@Test
public void loadAssessmentModes() {
RepositoryEntry entry = JunitTestHelper.createAndPersistRepositoryEntry();
AssessmentMode mode = assessmentModeMgr.createAssessmentMode(entry);
mode.setName("Assessment to load");
mode.setBegin(new Date());
mode.setEnd(new Date());
mode.setTargetAudience(Target.course);
AssessmentMode savedMode = assessmentModeMgr.persist(mode);
dbInstance.commitAndCloseSession();
Assert.assertNotNull(savedMode);
List<AssessmentMode> assessmentModes = assessmentModeMgr.getAssessmentModeFor(entry);
Assert.assertNotNull(assessmentModes);
Assert.assertEquals(1, assessmentModes.size());
Assert.assertEquals(savedMode, assessmentModes.get(0));
}
use of org.olat.course.assessment.AssessmentMode 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();
}
use of org.olat.course.assessment.AssessmentMode in project openolat by klemens.
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());
}
use of org.olat.course.assessment.AssessmentMode in project openolat by klemens.
the class AssessmentModeManagerTest method loadCurrentAssessmentModes_manualNowLeadingTime.
/**
* Manual with lead time -> in the current list
*/
@Test
public void loadCurrentAssessmentModes_manualNowLeadingTime() {
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.setLeadTime(120);
mode = assessmentModeMgr.persist(mode);
dbInstance.commitAndCloseSession();
// check
Date now = new Date();
List<AssessmentMode> currentModes = assessmentModeMgr.getAssessmentModes(now);
Assert.assertNotNull(currentModes);
Assert.assertTrue(currentModes.contains(mode));
}
Aggregations