use of org.olat.course.assessment.AssessmentMode in project openolat by klemens.
the class PodcastHandler method createLaunchController.
@Override
public MainLayoutController createLaunchController(RepositoryEntry re, RepositoryEntrySecurity reSecurity, UserRequest ureq, WindowControl wControl) {
boolean isAdmin = ureq.getUserSession().getRoles().isOLATAdmin();
boolean isOwner = reSecurity.isOwner();
final FeedSecurityCallback callback = new FeedResourceSecurityCallback(isAdmin, isOwner);
SubscriptionContext subsContext = new SubscriptionContext(re.getOlatResource(), re.getSoftkey());
callback.setSubscriptionContext(subsContext);
return new FeedRuntimeController(ureq, wControl, re, reSecurity, new RuntimeControllerCreator() {
@Override
public Controller create(UserRequest uureq, WindowControl wwControl, TooledStackedPanel toolbarPanel, RepositoryEntry entry, RepositoryEntrySecurity security, AssessmentMode assessmentMode) {
CoreSpringFactory.getImpl(UserCourseInformationsManager.class).updateUserCourseInformations(entry.getOlatResource(), uureq.getIdentity());
return new FeedMainController(entry.getOlatResource(), uureq, wwControl, null, null, PodcastUIFactory.getInstance(uureq.getLocale()), callback, null);
}
});
}
use of org.olat.course.assessment.AssessmentMode in project openolat by klemens.
the class WikiHandler method createLaunchController.
@Override
public MainLayoutController createLaunchController(RepositoryEntry re, RepositoryEntrySecurity reSecurity, UserRequest ureq, WindowControl wControl) {
// first handle special case: disabled wiki for security (XSS Attacks) reasons
BaseSecurityModule securityModule = CoreSpringFactory.getImpl(BaseSecurityModule.class);
if (!securityModule.isWikiEnabled()) {
return RepositoyUIFactory.createRepoEntryDisabledDueToSecurityMessageController(ureq, wControl);
}
// check role
boolean isOLatAdmin = ureq.getUserSession().getRoles().isOLATAdmin();
boolean isGuestOnly = ureq.getUserSession().getRoles().isGuestOnly();
boolean isResourceOwner = false;
if (isOLatAdmin) {
isResourceOwner = true;
} else {
isResourceOwner = reSecurity.isOwner();
}
OLATResource res = re.getOlatResource();
BusinessControl bc = wControl.getBusinessControl();
final ContextEntry ce = bc.popLauncherContextEntry();
SubscriptionContext subsContext = new SubscriptionContext(res, WikiManager.WIKI_RESOURCE_FOLDER_NAME);
final WikiSecurityCallback callback = new WikiSecurityCallbackImpl(null, isOLatAdmin, isGuestOnly, false, isResourceOwner, subsContext);
RepositoryEntryRuntimeController runtime = new RepositoryEntryRuntimeController(ureq, wControl, re, reSecurity, new RuntimeControllerCreator() {
@Override
public Controller create(UserRequest uureq, WindowControl wwControl, TooledStackedPanel toolbarPanel, RepositoryEntry entry, RepositoryEntrySecurity security, AssessmentMode assessmentMode) {
CoreSpringFactory.getImpl(UserCourseInformationsManager.class).updateUserCourseInformations(entry.getOlatResource(), uureq.getIdentity());
Controller controller;
if (ce != null) {
// jump to a certain context
OLATResourceable ores = ce.getOLATResourceable();
String typeName = ores.getResourceableTypeName();
String page = typeName.substring("page=".length());
controller = new WikiMainController(uureq, wwControl, entry.getOlatResource(), callback, page);
} else {
controller = new WikiMainController(uureq, wwControl, entry.getOlatResource(), callback, null);
}
return new OLATResourceableListeningWrapperController(uureq, wwControl, entry.getOlatResource(), controller, null, uureq.getIdentity());
}
});
return runtime;
}
use of org.olat.course.assessment.AssessmentMode in project openolat by klemens.
the class AssessmentModeManagerTest method isInAssessmentMode_manualLeadingTime.
/**
* Manual with leading time -> in assessment mode
*/
@Test
public void isInAssessmentMode_manualLeadingTime() {
RepositoryEntry entry = JunitTestHelper.createAndPersistRepositoryEntry();
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();
boolean entryNow = assessmentModeMgr.isInAssessmentMode(entry, now);
Assert.assertTrue(entryNow);
}
use of org.olat.course.assessment.AssessmentMode in project openolat by klemens.
the class AssessmentModeManagerTest method createMinimalAssessmentmode.
/**
* Create a minimal assessment mode which start one hour before now
* and stop two hours after now.
*
* @param entry
* @return
*/
private AssessmentMode createMinimalAssessmentmode(RepositoryEntry entry) {
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);
return mode;
}
use of org.olat.course.assessment.AssessmentMode in project openolat by klemens.
the class AssessmentModeManagerTest method loadAssessmentMode_repositoryEntry.
@Test
public void loadAssessmentMode_repositoryEntry() {
RepositoryEntry entry = JunitTestHelper.createAndPersistRepositoryEntry();
AssessmentMode mode = createMinimalAssessmentmode(entry);
mode = assessmentModeMgr.persist(mode);
dbInstance.commitAndCloseSession();
Assert.assertNotNull(mode);
// check
List<AssessmentMode> currentModes = assessmentModeMgr.getAssessmentModeFor(entry);
Assert.assertNotNull(currentModes);
Assert.assertEquals(1, currentModes.size());
Assert.assertTrue(currentModes.contains(mode));
}
Aggregations