use of org.olat.course.assessment.AssessmentMode in project OpenOLAT by OpenOLAT.
the class AssessmentModeListController method doAdd.
private void doAdd(UserRequest ureq) {
removeAsListenerAndDispose(editCtrl);
AssessmentMode newMode = assessmentModeMgr.createAssessmentMode(entry);
editCtrl = new AssessmentModeEditController(ureq, getWindowControl(), entry.getOlatResource(), newMode);
listenTo(editCtrl);
toolbarPanel.pushController(translate("new.mode"), editCtrl);
}
use of org.olat.course.assessment.AssessmentMode in project OpenOLAT by OpenOLAT.
the class AssessmentModeOverviewListController method loadModel.
private void loadModel() {
Date today = CalendarUtils.removeTime(new Date());
List<AssessmentMode> modes = asssessmentModeManager.getPlannedAssessmentMode(courseEntry, today);
if (modes.size() > 10) {
Calendar cal = Calendar.getInstance();
cal.add(Calendar.DATE, 1);
Date tomorrow = CalendarUtils.removeTime(cal.getTime());
List<AssessmentMode> nextModes = new ArrayList<>(25);
for (AssessmentMode mode : modes) {
Date begin = mode.getBegin();
if (tomorrow.after(begin) || nextModes.size() < 10) {
nextModes.add(mode);
}
}
modes = nextModes;
}
model.setObjects(modes);
tableEl.reset(true, true, true);
}
use of org.olat.course.assessment.AssessmentMode in project OpenOLAT by OpenOLAT.
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 OpenOLAT.
the class CourseSite method createController.
@Override
protected MainLayoutController createController(UserRequest ureq, WindowControl wControl, SiteConfiguration config) {
RepositoryManager rm = RepositoryManager.getInstance();
RepositoryService rs = CoreSpringFactory.getImpl(RepositoryService.class);
RepositoryEntry entry = rm.lookupRepositoryEntryBySoftkey(repositorySoftKey, false);
if (entry == null) {
return getAlternativeController(ureq, wControl, config);
}
MainLayoutController c;
ICourse course = CourseFactory.loadCourse(entry);
UserSession usess = ureq.getUserSession();
// course-launch-state depending course-settings
RepositoryEntrySecurity reSecurity = rm.isAllowed(ureq, entry);
boolean isAllowedToLaunch = reSecurity.canLaunch();
boolean hasAccess = false;
if (isAllowedToLaunch) {
// either check with securityCallback or use access-settings from course-nodes
if (siteSecCallback != null) {
hasAccess = siteSecCallback.isAllowedToLaunchSite(ureq);
} else if (usess.isInAssessmentModeProcess() && !usess.matchLockResource(course)) {
hasAccess = false;
} else {
// check within course: accessibility of course root node
CourseNode rootNode = course.getRunStructure().getRootNode();
UserCourseEnvironmentImpl uce = new UserCourseEnvironmentImpl(ureq.getUserSession().getIdentityEnvironment(), course.getCourseEnvironment());
NodeEvaluation nodeEval = rootNode.eval(uce.getConditionInterpreter(), new TreeEvaluation(), new VisibleTreeFilter());
boolean mayAccessWholeTreeUp = NavigationHandler.mayAccessWholeTreeUp(nodeEval);
hasAccess = mayAccessWholeTreeUp && nodeEval.isVisible();
}
}
// load course (admins always see content) or alternative controller if course is not launchable
if (hasAccess || usess.getRoles().isOLATAdmin()) {
rs.incrementLaunchCounter(entry);
// build up the context path for linked course
WindowControl bwControl = BusinessControlFactory.getInstance().createBusinessWindowControl(ureq, entry, new StateSite(this), wControl, true);
CourseRuntimeController runCtr = new CourseRuntimeController(ureq, bwControl, entry, reSecurity, new RuntimeControllerCreator() {
@Override
public Controller create(UserRequest uureq, WindowControl wwControl, TooledStackedPanel toolbarPanel, RepositoryEntry re, RepositoryEntrySecurity security, AssessmentMode assessmentMode) {
return new RunMainController(uureq, wwControl, toolbarPanel, CourseFactory.loadCourse(re), re, security, assessmentMode);
}
}, false, true);
// Configure run controller
// a: don't show close link, is opened as site not tab
runCtr.setCourseCloseEnabled(false);
// b: don't show toolbar
if (!showToolController) {
runCtr.setToolControllerEnabled(false);
}
c = runCtr;
} else {
// access restricted (not in group / author) -> show controller
// defined in olat_extensions (type autoCreator)
c = getAlternativeController(ureq, wControl, config);
}
return c;
}
use of org.olat.course.assessment.AssessmentMode in project OpenOLAT by OpenOLAT.
the class AssessmentModeManagerTest method getCurrentAssessmentMode.
@Test
public void getCurrentAssessmentMode() {
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.getCurrentAssessmentMode(entry, now);
Assert.assertNotNull(currentModes);
Assert.assertEquals(1, currentModes.size());
Assert.assertTrue(currentModes.contains(mode));
}
Aggregations