use of org.olat.course.assessment.AssessmentMode in project openolat by klemens.
the class AssessmentModeManagerTest method createAssessmentMode.
@Test
public void createAssessmentMode() {
RepositoryEntry entry = JunitTestHelper.createAndPersistRepositoryEntry();
AssessmentMode mode = assessmentModeMgr.createAssessmentMode(entry);
mode.setName("Assessment in sight");
mode.setDescription("Assessment description");
Calendar cal = Calendar.getInstance();
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MILLISECOND, 0);
cal.add(Calendar.DATE, 2);
Date begin = cal.getTime();
cal.add(Calendar.HOUR_OF_DAY, 2);
Date end = cal.getTime();
mode.setBegin(begin);
mode.setEnd(end);
mode.setLeadTime(15);
mode.setTargetAudience(Target.course);
mode.setRestrictAccessElements(true);
mode.setElementList("173819739,239472389");
mode.setRestrictAccessIps(true);
mode.setIpList("192.168.1.123");
mode.setSafeExamBrowser(true);
mode.setSafeExamBrowserKey("785rhqg47368ahfahl");
mode.setSafeExamBrowserHint("Use the SafeExamBrowser");
mode.setApplySettingsForCoach(true);
AssessmentMode savedMode = assessmentModeMgr.persist(mode);
dbInstance.commitAndCloseSession();
Assert.assertNotNull(savedMode);
Assert.assertNotNull(savedMode.getKey());
Assert.assertNotNull(savedMode.getCreationDate());
Assert.assertNotNull(savedMode.getLastModified());
// reload and check
AssessmentMode reloadedMode = assessmentModeMgr.getAssessmentModeById(savedMode.getKey());
Assert.assertNotNull(reloadedMode);
Assert.assertEquals(savedMode.getKey(), reloadedMode.getKey());
Assert.assertNotNull(reloadedMode.getCreationDate());
Assert.assertNotNull(reloadedMode.getLastModified());
Assert.assertEquals(savedMode, reloadedMode);
Assert.assertEquals("Assessment in sight", reloadedMode.getName());
Assert.assertEquals("Assessment description", reloadedMode.getDescription());
Assert.assertEquals(begin, reloadedMode.getBegin());
Assert.assertEquals(end, reloadedMode.getEnd());
Assert.assertEquals(15, reloadedMode.getLeadTime());
Assert.assertEquals(Target.course, reloadedMode.getTargetAudience());
Assert.assertTrue(reloadedMode.isRestrictAccessElements());
Assert.assertEquals("173819739,239472389", reloadedMode.getElementList());
Assert.assertTrue(reloadedMode.isRestrictAccessIps());
Assert.assertEquals("192.168.1.123", reloadedMode.getIpList());
Assert.assertTrue(reloadedMode.isApplySettingsForCoach());
Assert.assertTrue(reloadedMode.isSafeExamBrowser());
Assert.assertEquals("785rhqg47368ahfahl", reloadedMode.getSafeExamBrowserKey());
Assert.assertEquals("Use the SafeExamBrowser", reloadedMode.getSafeExamBrowserHint());
}
use of org.olat.course.assessment.AssessmentMode in project openolat by klemens.
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 klemens.
the class AssessmentModeManagerTest method getCurrentAssessmentMode_manualNowLeadingTime.
/**
* Manual with lead time -> in the current list
*/
@Test
public void getCurrentAssessmentMode_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.getCurrentAssessmentMode(entry, now);
Assert.assertNotNull(currentModes);
Assert.assertEquals(1, currentModes.size());
Assert.assertTrue(currentModes.contains(mode));
}
use of org.olat.course.assessment.AssessmentMode in project openolat by klemens.
the class AuthHelper method initializeLogin.
/**
* ONLY for authentication provider OLAT Authenticate Identity and do the
* necessary work. Returns true if successfull, false otherwise.
*
* @param identity
* @param authProvider
* @param ureq
* @return boolean
*/
private static int initializeLogin(Identity identity, String authProvider, UserRequest ureq, boolean rest) {
// continue only if user has login permission.
if (identity == null)
return LOGIN_FAILED;
// test if a user may not logon, since he/she is in the PERMISSION_LOGON
if (!BaseSecurityManager.getInstance().isIdentityVisible(identity)) {
log.audit("was denied login");
return LOGIN_DENIED;
}
UserSessionManager sessionManager = CoreSpringFactory.getImpl(UserSessionManager.class);
// if the user sending the cookie did not log out and we are logging in
// again, then we need to make sure everything is cleaned up. we cleanup in all cases.
UserSession usess = ureq.getUserSession();
// prepare for a new user: clear all the instance vars of the userSession
// note: does not invalidate the session, since it is reused
sessionManager.signOffAndClear(usess);
// init the UserSession for the new User
// we can set the identity and finish the log in process
usess.setIdentity(identity);
setRolesFor(identity, usess);
// check if loginDenied or maxSession (only for non-admin)
if ((loginBlocked && !usess.getRoles().isOLATAdmin()) || (((maxSessions != MAX_SESSION_NO_LIMIT) && (sessionManager.getUserSessionsCnt() >= maxSessions)) && !usess.getRoles().isOLATAdmin())) {
log.audit("Login was blocked for username=" + usess.getIdentity().getName() + ", loginBlocked=" + loginBlocked + " NbrOfSessions=" + sessionManager.getUserSessionsCnt());
sessionManager.signOffAndClear(usess);
return LOGIN_NOTAVAILABLE;
}
// need to block the all things for assessment?
if (usess.getRoles() != null && usess.getRoles().isOLATAdmin()) {
usess.setAssessmentModes(Collections.<TransientAssessmentMode>emptyList());
} else {
AssessmentModule assessmentModule = CoreSpringFactory.getImpl(AssessmentModule.class);
if (assessmentModule.isAssessmentModeEnabled()) {
AssessmentModeManager assessmentManager = CoreSpringFactory.getImpl(AssessmentModeManager.class);
List<AssessmentMode> modes = assessmentManager.getAssessmentModeFor(identity);
if (modes.isEmpty()) {
usess.setAssessmentModes(Collections.<TransientAssessmentMode>emptyList());
} else {
usess.setAssessmentModes(TransientAssessmentMode.create(modes));
}
}
}
// set the language
usess.setLocale(I18nManager.getInstance().getLocaleOrDefault(identity.getUser().getPreferences().getLanguage()));
// update fontsize in users session globalsettings
Windows.getWindows(ureq).getWindowManager().setFontSize(Integer.parseInt(identity.getUser().getPreferences().getFontsize()));
// calculate session info and attach it to the user session
setSessionInfoFor(identity, authProvider, ureq, rest);
// confirm signedOn
sessionManager.signOn(usess);
// set users web delivery mode
Windows.getWindows(ureq).getWindowManager().setAjaxWanted(ureq);
// update web delivery mode in session info
usess.getSessionInfo().setWebModeFromUreq(ureq);
return LOGIN_OK;
}
use of org.olat.course.assessment.AssessmentMode in project openolat by klemens.
the class AssessmentModeListController method event.
@Override
public void event(UserRequest ureq, Controller source, Event event) {
if (editCtrl == source) {
loadModel();
toolbarPanel.popUpToController(this);
removeAsListenerAndDispose(editCtrl);
editCtrl = null;
} else if (deleteDialogBox == source) {
if (DialogBoxUIFactory.isYesEvent(event) || DialogBoxUIFactory.isOkEvent(event)) {
@SuppressWarnings("unchecked") List<AssessmentMode> rows = (List<AssessmentMode>) deleteDialogBox.getUserObject();
doDelete(rows);
}
} else if (startDialogBox == source) {
if (DialogBoxUIFactory.isYesEvent(event) || DialogBoxUIFactory.isOkEvent(event)) {
AssessmentMode row = (AssessmentMode) startDialogBox.getUserObject();
doStart(row);
}
} else if (stopDialogBox == source) {
if (DialogBoxUIFactory.isYesEvent(event) || DialogBoxUIFactory.isOkEvent(event)) {
AssessmentMode row = (AssessmentMode) stopDialogBox.getUserObject();
doStop(row);
}
}
super.event(ureq, source, event);
}
Aggregations