Search in sources :

Example 1 with AssessmentMode

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;
}
Also used : TooledStackedPanel(org.olat.core.gui.components.stack.TooledStackedPanel) AssessmentMode(org.olat.course.assessment.AssessmentMode) StateSite(org.olat.core.id.context.StateSite) VisibleTreeFilter(org.olat.course.run.userview.VisibleTreeFilter) RunMainController(org.olat.course.run.RunMainController) ICourse(org.olat.course.ICourse) RepositoryEntry(org.olat.repository.RepositoryEntry) WindowControl(org.olat.core.gui.control.WindowControl) MainLayoutController(org.olat.core.gui.control.generic.layout.MainLayoutController) RunMainController(org.olat.course.run.RunMainController) CourseRuntimeController(org.olat.course.run.CourseRuntimeController) Controller(org.olat.core.gui.control.Controller) RuntimeControllerCreator(org.olat.repository.ui.RepositoryEntryRuntimeController.RuntimeControllerCreator) UserCourseEnvironmentImpl(org.olat.course.run.userview.UserCourseEnvironmentImpl) RepositoryEntrySecurity(org.olat.repository.model.RepositoryEntrySecurity) CourseRuntimeController(org.olat.course.run.CourseRuntimeController) UserSession(org.olat.core.util.UserSession) TreeEvaluation(org.olat.course.run.userview.TreeEvaluation) MainLayoutController(org.olat.core.gui.control.generic.layout.MainLayoutController) RepositoryManager(org.olat.repository.RepositoryManager) CourseNode(org.olat.course.nodes.CourseNode) NodeEvaluation(org.olat.course.run.userview.NodeEvaluation) UserRequest(org.olat.core.gui.UserRequest) RepositoryService(org.olat.repository.RepositoryService)

Example 2 with AssessmentMode

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

Example 3 with AssessmentMode

use of org.olat.course.assessment.AssessmentMode in project OpenOLAT by OpenOLAT.

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 4 with AssessmentMode

use of org.olat.course.assessment.AssessmentMode in project OpenOLAT by OpenOLAT.

the class AssessmentModeManagerTest method loadAssessmentModes.

@Test
public void loadAssessmentModes() {
    RepositoryEntry entry = JunitTestHelper.createAndPersistRepositoryEntry();
    AssessmentMode mode = assessmentModeMgr.createAssessmentMode(entry);
    mode.setName("Assessment to load");
    mode.setBegin(new Date());
    mode.setEnd(new Date());
    mode.setTargetAudience(Target.course);
    AssessmentMode savedMode = assessmentModeMgr.persist(mode);
    dbInstance.commitAndCloseSession();
    Assert.assertNotNull(savedMode);
    List<AssessmentMode> assessmentModes = assessmentModeMgr.getAssessmentModeFor(entry);
    Assert.assertNotNull(assessmentModes);
    Assert.assertEquals(1, assessmentModes.size());
    Assert.assertEquals(savedMode, assessmentModes.get(0));
}
Also used : AssessmentMode(org.olat.course.assessment.AssessmentMode) RepositoryEntry(org.olat.repository.RepositoryEntry) Date(java.util.Date) Test(org.junit.Test)

Example 5 with AssessmentMode

use of org.olat.course.assessment.AssessmentMode in project OpenOLAT by OpenOLAT.

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)

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