Search in sources :

Example 86 with AssessmentMode

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());
}
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 87 with AssessmentMode

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));
}
Also used : AssessmentMode(org.olat.course.assessment.AssessmentMode) RepositoryEntry(org.olat.repository.RepositoryEntry) Date(java.util.Date) Test(org.junit.Test)

Example 88 with AssessmentMode

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));
}
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 89 with AssessmentMode

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;
}
Also used : UserSessionManager(org.olat.core.util.session.UserSessionManager) TransientAssessmentMode(org.olat.course.assessment.model.TransientAssessmentMode) AssessmentMode(org.olat.course.assessment.AssessmentMode) UserSession(org.olat.core.util.UserSession) AssessmentModeManager(org.olat.course.assessment.AssessmentModeManager) AssessmentModule(org.olat.course.assessment.AssessmentModule)

Example 90 with AssessmentMode

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);
}
Also used : TransientAssessmentMode(org.olat.course.assessment.model.TransientAssessmentMode) AssessmentMode(org.olat.course.assessment.AssessmentMode) ArrayList(java.util.ArrayList) List(java.util.List)

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