use of org.olat.course.assessment.AssessmentMode in project OpenOLAT by OpenOLAT.
the class AssessmentModeManagerTest method loadCurrentAssessmentModes_manualNow.
/**
* Manual without lead time -> not in the current list
*/
@Test
public void loadCurrentAssessmentModes_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.getAssessmentModes(now);
Assert.assertNotNull(currentModes);
Assert.assertFalse(currentModes.contains(mode));
}
use of org.olat.course.assessment.AssessmentMode in project OpenOLAT by OpenOLAT.
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 OpenOLAT.
the class AssessmentModeManagerTest method loadAssessmentMode_identityInArea.
/**
* Check an assessment linked to an area with one participant
*/
@Test
public void loadAssessmentMode_identityInArea() {
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(author, "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(false);
mode = assessmentModeMgr.persist(mode);
AssessmentModeToGroup modeToGroup = assessmentModeMgr.createAssessmentModeToGroup(mode, businessGroup);
mode.getGroups().add(modeToGroup);
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.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 OpenOLAT.
the class AssessmentModeManagerTest method loadCurrentAssessmentModes.
@Test
public void loadCurrentAssessmentModes() {
RepositoryEntry entry = JunitTestHelper.createAndPersistRepositoryEntry();
AssessmentMode mode = createMinimalAssessmentmode(entry);
mode = assessmentModeMgr.persist(mode);
dbInstance.commitAndCloseSession();
Assert.assertNotNull(mode);
// check
Date now = new Date();
List<AssessmentMode> currentModes = assessmentModeMgr.getAssessmentModes(now);
Assert.assertNotNull(currentModes);
Assert.assertFalse(currentModes.isEmpty());
Assert.assertTrue(currentModes.contains(mode));
}
use of org.olat.course.assessment.AssessmentMode in project OpenOLAT by OpenOLAT.
the class ConfirmExtraTimeController method currentAssessmentModeMessage.
private void currentAssessmentModeMessage(FormLayoutContainer layoutCont) {
Formatter formatter = Formatter.getInstance(getLocale());
List<String> modes = new ArrayList<>();
for (AssessmentMode assessmentMode : assessmentModes) {
String title = assessmentMode.getName();
String begin = formatter.formatDateAndTime(assessmentMode.getBegin());
String end = formatter.formatDateAndTime(assessmentMode.getEnd());
modes.add(translate("warning.assessment.mode.date", new String[] { title, begin, end }));
}
layoutCont.contextPut("assessmemtModeMessages", modes);
}
Aggregations