diff --git a/src/main/java/org/olat/basesecurity/AuthHelper.java b/src/main/java/org/olat/basesecurity/AuthHelper.java index 9a383db92f55dafbb6a768346d0941630b090be0..ab2fdc8c76b1ede9d14a8bb4f463433d882131ca 100644 --- a/src/main/java/org/olat/basesecurity/AuthHelper.java +++ b/src/main/java/org/olat/basesecurity/AuthHelper.java @@ -28,6 +28,7 @@ package org.olat.basesecurity; import java.net.InetAddress; import java.net.UnknownHostException; import java.util.Collection; +import java.util.Collections; import java.util.Date; import java.util.HashMap; import java.util.List; @@ -310,7 +311,9 @@ public class AuthHelper { //need to block the all things for assessment? AssessmentModeManager assessmentManager = CoreSpringFactory.getImpl(AssessmentModeManager.class); List<AssessmentMode> modes = assessmentManager.getAssessmentModeFor(identity); - if(!modes.isEmpty()) { + if(modes.isEmpty()) { + usess.setAssessmentModes(Collections.<TransientAssessmentMode>emptyList()); + } else { usess.setAssessmentModes(TransientAssessmentMode.create(modes)); } diff --git a/src/main/java/org/olat/course/assessment/AssessmentModeCoordinationService.java b/src/main/java/org/olat/course/assessment/AssessmentModeCoordinationService.java index ea2f4d1b59ca37f95e507bc58112ffe266434ac5..cc693f1865b40778a005fed9d1275d1831386171 100644 --- a/src/main/java/org/olat/course/assessment/AssessmentModeCoordinationService.java +++ b/src/main/java/org/olat/course/assessment/AssessmentModeCoordinationService.java @@ -19,6 +19,10 @@ */ package org.olat.course.assessment; +import java.util.Date; + +import org.olat.course.assessment.AssessmentMode.Status; + /** * * Initial date: 06.01.2015<br> @@ -26,6 +30,23 @@ package org.olat.course.assessment; * */ public interface AssessmentModeCoordinationService { + + /** + * You can start manually if... + * @param assessmentMode + * @return + */ + public boolean canStart(AssessmentMode assessmentMode); + + /** + * You can stop manually if... + * + * @param assessmentMode + * @return + */ + public boolean canStop(AssessmentMode assessmentMode); + + public Status evaluateStatus(Date begin, int leadtime, Date end, int followup); public AssessmentMode startAssessment(AssessmentMode assessmentMode); diff --git a/src/main/java/org/olat/course/assessment/AssessmentModeManager.java b/src/main/java/org/olat/course/assessment/AssessmentModeManager.java index 0ba8036cce0c631dfbfd5cf94bb9036f864cd6ce..8cf6833e8a2a40078b8adad30a3966121023c0f7 100644 --- a/src/main/java/org/olat/course/assessment/AssessmentModeManager.java +++ b/src/main/java/org/olat/course/assessment/AssessmentModeManager.java @@ -50,7 +50,16 @@ public interface AssessmentModeManager { public AssessmentModeToArea createAssessmentModeToArea(AssessmentMode mode, BGArea area); - public AssessmentMode save(AssessmentMode assessmentMode); + + public AssessmentMode persist(AssessmentMode assessmentMode); + + /** + * This method will trigger the multi-user events. + * @param assessmentMode + * @param forceStatus + * @return + */ + public AssessmentMode merge(AssessmentMode assessmentMode, boolean forceStatus); public void delete(AssessmentMode assessmentMode); diff --git a/src/main/java/org/olat/course/assessment/manager/AssessmentModeCoordinationServiceImpl.java b/src/main/java/org/olat/course/assessment/manager/AssessmentModeCoordinationServiceImpl.java index fa80cf24e159d60261b6e4e3c7e559d52143e4dd..03a5767a2fa1ee9542f7db64a1ca827e823ecd54 100644 --- a/src/main/java/org/olat/course/assessment/manager/AssessmentModeCoordinationServiceImpl.java +++ b/src/main/java/org/olat/course/assessment/manager/AssessmentModeCoordinationServiceImpl.java @@ -29,8 +29,8 @@ import org.olat.core.util.coordinate.CoordinatorManager; import org.olat.course.assessment.AssessmentMode; import org.olat.course.assessment.AssessmentMode.Status; import org.olat.course.assessment.AssessmentModeCoordinationService; -import org.olat.course.assessment.AssessmentModeManager; import org.olat.course.assessment.AssessmentModeNotificationEvent; +import org.olat.course.assessment.model.AssessmentModeImpl; import org.olat.course.assessment.model.TransientAssessmentMode; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -49,13 +49,13 @@ public class AssessmentModeCoordinationServiceImpl implements AssessmentModeCoor @Autowired private CoordinatorManager coordinatorManager; @Autowired - private AssessmentModeManager assessmentModeManager; + private AssessmentModeManagerImpl assessmentModeManager; protected void beat() { Date now = now(); List<AssessmentMode> currentModes = assessmentModeManager.getAssessmentModes(now); for(AssessmentMode currentMode:currentModes) { - sendEvent(currentMode, now); + sendEvent(currentMode, now, false); } } @@ -74,15 +74,42 @@ public class AssessmentModeCoordinationServiceImpl implements AssessmentModeCoor return cal.getTime(); } - protected AssessmentMode syncManuallySetStatus(AssessmentMode mode) { - return sendEvent(mode, now()); + protected AssessmentMode syncManuallySetStatus(AssessmentMode mode, boolean forceStatus) { + return sendEvent(mode, now(), forceStatus); } protected AssessmentMode syncAutomicallySetStatus(AssessmentMode mode) { - return sendEvent(mode, now()); + return sendEvent(mode, now(), true); + } + + public Status evaluateStatus(Date begin, int leadtime, Date end, int followup) { + Status status; + Date now = now(); + + Date beginWithLeadTime = assessmentModeManager.evaluateLeadTime(begin, leadtime); + Date endWithFollowupTime = assessmentModeManager.evaluateFollowupTime(end, followup); + if(beginWithLeadTime.compareTo(now) > 0) { + status = Status.none; + } else if(beginWithLeadTime.compareTo(now) <= 0 && begin.compareTo(now) >= 0) { + status = Status.leadtime; + } else if(begin.compareTo(now) <= 0 && end.compareTo(now) >= 0) { + status = Status.assessment; + } else if(end.compareTo(now) <= 0 && endWithFollowupTime.compareTo(now) >= 0) { + if(followup > 0) { + status = Status.followup; + } else { + status = Status.end; + } + } else if(endWithFollowupTime.compareTo(now) < 0) { + status = Status.end; + } else { + status = null; + } + + return status; } - private AssessmentMode sendEvent(AssessmentMode mode, Date now) { + private AssessmentMode sendEvent(AssessmentMode mode, Date now, boolean forceStatus) { if(mode.getBeginWithLeadTime().compareTo(now) > 0) { mode = ensureStatusOfMode(mode, Status.none); sendEvent(AssessmentModeNotificationEvent.BEFORE, mode, @@ -91,7 +118,16 @@ public class AssessmentModeCoordinationServiceImpl implements AssessmentModeCoor mode = ensureStatusOfMode(mode, Status.leadtime); sendEvent(AssessmentModeNotificationEvent.LEADTIME, mode, assessmentModeManager.getAssessedIdentityKeys(mode)); - } else if(!mode.isManualBeginEnd()) { + } else if(mode.isManualBeginEnd() && !forceStatus) { + //what to do in manual mode + if(mode.getStatus() == Status.followup) { + if(mode.getEndWithFollowupTime().compareTo(now) < 0) { + mode = ensureStatusOfMode(mode, Status.end); + sendEvent(AssessmentModeNotificationEvent.END, mode, + assessmentModeManager.getAssessedIdentityKeys(mode)); + } + } + } else { if(mode.getBegin().compareTo(now) <= 0 && mode.getEnd().compareTo(now) >= 0) { mode = ensureStatusOfMode(mode, Status.assessment); sendEvent(AssessmentModeNotificationEvent.START_ASSESSMENT, mode, @@ -107,7 +143,7 @@ public class AssessmentModeCoordinationServiceImpl implements AssessmentModeCoor sendEvent(AssessmentModeNotificationEvent.STOP_WARNING, mode, null); } } else if(mode.getEnd().compareTo(now) <= 0 && mode.getEndWithFollowupTime().compareTo(now) >= 0) { - if(mode.getLeadTime() > 0) { + if(mode.getFollowupTime() > 0) { mode = ensureStatusOfMode(mode, Status.followup); sendEvent(AssessmentModeNotificationEvent.STOP_ASSESSMENT, mode, assessmentModeManager.getAssessedIdentityKeys(mode)); @@ -142,8 +178,33 @@ public class AssessmentModeCoordinationServiceImpl implements AssessmentModeCoor .fireEventToListenersOf(event, AssessmentModeNotificationEvent.ASSESSMENT_MODE_NOTIFICATION); } + @Override + public boolean canStart(AssessmentMode assessmentMode) { + boolean canStart; + Status status = assessmentMode.getStatus(); + if(status == Status.end) { + canStart = false; + } else { + canStart = true; + } + return canStart; + } + + @Override + public boolean canStop(AssessmentMode assessmentMode) { + boolean canStop; + Status status = assessmentMode.getStatus(); + if(status == Status.leadtime || status == Status.assessment) { + canStop = true; + } else { + canStop = false; + } + return canStop; + } + @Override public AssessmentMode startAssessment(AssessmentMode mode) { + mode = assessmentModeManager.getAssessmentModeById(mode.getKey()); mode = ensureStatusOfMode(mode, Status.assessment); Set<Long> assessedIdentityKeys = assessmentModeManager.getAssessedIdentityKeys(mode); sendEvent(AssessmentModeNotificationEvent.START_ASSESSMENT, mode, assessedIdentityKeys); @@ -152,9 +213,14 @@ public class AssessmentModeCoordinationServiceImpl implements AssessmentModeCoor @Override public AssessmentMode stopAssessment(AssessmentMode mode) { + mode = assessmentModeManager.getAssessmentModeById(mode.getKey()); Set<Long> assessedIdentityKeys = assessmentModeManager.getAssessedIdentityKeys(mode); - if(mode.getLeadTime() > 0) { - mode = ensureStatusOfMode(mode, Status.leadtime); + if(mode.getFollowupTime() > 0) { + Date followupTime = assessmentModeManager.evaluateFollowupTime(now(), mode.getFollowupTime()); + ((AssessmentModeImpl)mode).setEndWithFollowupTime(followupTime); + mode.setStatus(Status.followup); + mode = dbInstance.getCurrentEntityManager().merge(mode); + dbInstance.commit(); sendEvent(AssessmentModeNotificationEvent.STOP_ASSESSMENT, mode, assessedIdentityKeys); } else { mode = ensureStatusOfMode(mode, Status.end); diff --git a/src/main/java/org/olat/course/assessment/manager/AssessmentModeManagerImpl.java b/src/main/java/org/olat/course/assessment/manager/AssessmentModeManagerImpl.java index 9a7a386fea0f6629008ecb9d5113c11467bebb47..5908996910385d1ad1cc46bcc937ccf2b29bb3cc 100644 --- a/src/main/java/org/olat/course/assessment/manager/AssessmentModeManagerImpl.java +++ b/src/main/java/org/olat/course/assessment/manager/AssessmentModeManagerImpl.java @@ -88,30 +88,58 @@ public class AssessmentModeManagerImpl implements AssessmentModeManager { mode.setManualBeginEnd(false); return mode; } - - @Override - public AssessmentMode save(AssessmentMode assessmentMode) { - assessmentMode.setLastModified(new Date()); - - //update begin with lead time - Date begin = assessmentMode.getBegin(); + + protected Date evaluateLeadTime(Date begin, int leadtime) { Calendar cal = Calendar.getInstance(); cal.setTime(begin); cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); - if(assessmentMode.getLeadTime() > 0) { - cal.add(Calendar.MINUTE, -assessmentMode.getLeadTime()); + if(leadtime > 0) { + cal.add(Calendar.MINUTE, -leadtime); } - ((AssessmentModeImpl)assessmentMode).setBeginWithLeadTime(cal.getTime()); - - Date end = assessmentMode.getEnd(); + return cal.getTime(); + } + + protected Date evaluateFollowupTime(Date end, int followupTime) { + Calendar cal = Calendar.getInstance(); cal.setTime(end); cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); - if(assessmentMode.getFollowupTime() > 0) { - cal.add(Calendar.MINUTE, assessmentMode.getFollowupTime()); + if(followupTime > 0) { + cal.add(Calendar.MINUTE, followupTime); } - ((AssessmentModeImpl)assessmentMode).setEndWithFollowupTime(cal.getTime()); + return cal.getTime(); + } + + @Override + public AssessmentMode persist(AssessmentMode assessmentMode) { + assessmentMode.setLastModified(new Date()); + + //update begin with lead time + Date begin = assessmentMode.getBegin(); + Date beginWithLeadTime = evaluateLeadTime(begin, assessmentMode.getLeadTime()); + ((AssessmentModeImpl)assessmentMode).setBeginWithLeadTime(beginWithLeadTime); + Date end = assessmentMode.getEnd(); + Date endWithFollowupTime = this.evaluateFollowupTime(end, assessmentMode.getFollowupTime()); + ((AssessmentModeImpl)assessmentMode).setEndWithFollowupTime(endWithFollowupTime); + + dbInstance.getCurrentEntityManager().persist(assessmentMode); + dbInstance.commit(); + return assessmentMode; + } + + @Override + public AssessmentMode merge(AssessmentMode assessmentMode, boolean forceStatus) { + assessmentMode.setLastModified(new Date()); + + //update begin with lead time + Date begin = assessmentMode.getBegin(); + Date beginWithLeadTime = evaluateLeadTime(begin, assessmentMode.getLeadTime()); + ((AssessmentModeImpl)assessmentMode).setBeginWithLeadTime(beginWithLeadTime); + + Date end = assessmentMode.getEnd(); + Date endWithFollowupTime = this.evaluateFollowupTime(end, assessmentMode.getFollowupTime()); + ((AssessmentModeImpl)assessmentMode).setEndWithFollowupTime(endWithFollowupTime); AssessmentMode reloadedMode; if(assessmentMode.getKey() == null) { @@ -123,7 +151,7 @@ public class AssessmentModeManagerImpl implements AssessmentModeManager { } dbInstance.commit(); if(reloadedMode.isManualBeginEnd()) { - reloadedMode = assessmentModeCoordinationService.syncManuallySetStatus(reloadedMode); + reloadedMode = assessmentModeCoordinationService.syncManuallySetStatus(reloadedMode, forceStatus); } else { reloadedMode = assessmentModeCoordinationService.syncAutomicallySetStatus(reloadedMode); } @@ -253,7 +281,7 @@ public class AssessmentModeManagerImpl implements AssessmentModeManager { StringBuilder sb = new StringBuilder(); sb.append("select mode from courseassessmentmode mode where ") - .append(" (mode.beginWithLeadTime<=:now and mode.endWithFollowupTime>=:now)") + .append(" (mode.beginWithLeadTime<=:now and mode.endWithFollowupTime>=:now and mode.manualBeginEnd=false )") .append(" or mode.statusString in ('").append(Status.leadtime.name()).append("','") .append(Status.assessment.name()).append("','").append(Status.followup.name()).append("')"); diff --git a/src/main/java/org/olat/course/assessment/ui/AssessmentModeEditController.java b/src/main/java/org/olat/course/assessment/ui/AssessmentModeEditController.java index a83b6125bbb71f33d2d0f2cf8b8abffcbb5fc572..03d4e0f9f68b6a9972cc18380f302e12202db0db 100644 --- a/src/main/java/org/olat/course/assessment/ui/AssessmentModeEditController.java +++ b/src/main/java/org/olat/course/assessment/ui/AssessmentModeEditController.java @@ -20,6 +20,7 @@ package org.olat.course.assessment.ui; import java.util.ArrayList; +import java.util.Date; import java.util.HashSet; import java.util.Iterator; import java.util.List; @@ -44,13 +45,17 @@ import org.olat.core.gui.control.Controller; import org.olat.core.gui.control.Event; import org.olat.core.gui.control.WindowControl; import org.olat.core.gui.control.generic.closablewrapper.CloseableModalController; +import org.olat.core.gui.control.generic.modal.DialogBoxController; +import org.olat.core.gui.control.generic.modal.DialogBoxUIFactory; import org.olat.core.id.OLATResourceable; import org.olat.core.util.StringHelper; import org.olat.core.util.resource.OresHelper; import org.olat.course.CourseFactory; import org.olat.course.ICourse; import org.olat.course.assessment.AssessmentMode; +import org.olat.course.assessment.AssessmentMode.Status; import org.olat.course.assessment.AssessmentMode.Target; +import org.olat.course.assessment.AssessmentModeCoordinationService; import org.olat.course.assessment.AssessmentModeManager; import org.olat.course.assessment.AssessmentModeToArea; import org.olat.course.assessment.AssessmentModeToGroup; @@ -88,6 +93,7 @@ public class AssessmentModeEditController extends FormBasicController { private MultipleSelectionElement ipsEl, safeExamBrowserEl, forCoachEl, courseElementsRestrictionEl; private CloseableModalController cmc; + private DialogBoxController confirmCtrl; private AreaSelectionController areaChooseCtrl; private GroupSelectionController groupChooseCtrl; private ChooseElementsController chooseElementsCtrl; @@ -109,6 +115,8 @@ public class AssessmentModeEditController extends FormBasicController { @Autowired private AssessmentModeManager assessmentModeMgr; @Autowired + private AssessmentModeCoordinationService modeCoordinationService; + @Autowired private BusinessGroupService businessGroupService; public AssessmentModeEditController(UserRequest ureq, WindowControl wControl, @@ -335,6 +343,10 @@ public class AssessmentModeEditController extends FormBasicController { } cmc.deactivate(); cleanUp(); + } else if(confirmCtrl == source) { + if(DialogBoxUIFactory.isYesEvent(event) || DialogBoxUIFactory.isOkEvent(event)) { + save(ureq, true); + } } else if(cmc == source) { cmc.deactivate(); } @@ -411,6 +423,33 @@ public class AssessmentModeEditController extends FormBasicController { @Override protected void formOK(UserRequest ureq) { + Date begin = beginEl.getDate(); + Date end = endEl.getDate(); + int followupTime = followupTimeEl.getIntValue(); + int leadTime = leadTimeEl.getIntValue(); + + Status currentStatus = assessmentMode.getStatus(); + Status nextStatus = modeCoordinationService.evaluateStatus(begin, leadTime, end, followupTime); + + if(currentStatus == nextStatus) { + save(ureq, true); + } else { + String title = translate("confirm.status.change.title"); + + String text; + switch(nextStatus) { + case none: text = translate("confirm.status.change.none"); break; + case leadtime: text = translate("confirm.status.change.leadtime"); break; + case assessment: text = translate("confirm.status.change.assessment"); break; + case followup: text = translate("confirm.status.change.followup"); break; + case end: text = translate("confirm.status.change.end"); break; + default: text = "ERROR"; + } + confirmCtrl = activateOkCancelDialog(ureq, title, text, confirmCtrl); + } + } + + private void save(UserRequest ureq, boolean forceStatus) { if(assessmentMode.getKey() != null) { assessmentMode = assessmentModeMgr.getAssessmentModeById(assessmentMode.getKey()); } @@ -482,7 +521,7 @@ public class AssessmentModeEditController extends FormBasicController { //mode need to be persisted for the following relations if(assessmentMode.getKey() == null) { - assessmentMode = assessmentModeMgr.save(assessmentMode); + assessmentMode = assessmentModeMgr.persist(assessmentMode); } //update groups @@ -535,7 +574,7 @@ public class AssessmentModeEditController extends FormBasicController { } } - assessmentMode = assessmentModeMgr.save(assessmentMode); + assessmentMode = assessmentModeMgr.merge(assessmentMode, forceStatus); fireEvent(ureq, Event.CHANGED_EVENT); } diff --git a/src/main/java/org/olat/course/assessment/ui/AssessmentModeGuardController.java b/src/main/java/org/olat/course/assessment/ui/AssessmentModeGuardController.java index e35e6789031434bb0bf07051fae801f07262566c..411aca0a86fe69becda602df7aee7c0a18cbc1ef 100644 --- a/src/main/java/org/olat/course/assessment/ui/AssessmentModeGuardController.java +++ b/src/main/java/org/olat/course/assessment/ui/AssessmentModeGuardController.java @@ -57,6 +57,7 @@ import org.springframework.beans.factory.annotation.Autowired; */ public class AssessmentModeGuardController extends BasicController implements GenericEventListener { + private final Link mainContinueButton; private final VelocityContainer mainVC; private final CloseableModalController cmc; @@ -87,6 +88,13 @@ public class AssessmentModeGuardController extends BasicController implements Ge mainVC = createVelocityContainer("choose_mode"); mainVC.contextPut("guards", guards); + + mainContinueButton = LinkFactory.createCustomLink("continue-main", "continue-main", "current.mode.continue", Link.BUTTON, mainVC, this); + mainContinueButton.setCustomEnabledLinkCSS("btn btn-primary"); + mainContinueButton.setCustomDisabledLinkCSS("o_disabled btn btn-default"); + mainContinueButton.setVisible(false); + mainVC.put("continue-main", mainContinueButton); + syncAssessmentModes(ureq); cmc = new CloseableModalController(getWindowControl(), translate("close"), mainVC, true, translate("current.mode"), false); @@ -134,14 +142,16 @@ public class AssessmentModeGuardController extends BasicController implements Ge } } guards.setList(modeWrappers); + mainContinueButton.setVisible(modeWrappers.isEmpty()); mainVC.setDirty(true); } private ResourceGuard syncAssessmentMode(UserRequest ureq, TransientAssessmentMode mode) { Date now = new Date(); Date beginWithLeadTime = mode.getBeginWithLeadTime(); - Date endWithLeadTime = mode.getEndWithFollowupTime(); - if(beginWithLeadTime.after(now)) { + if(!mode.isManual() && beginWithLeadTime.after(now)) { + return null; + } else if(mode.isManual() && (Status.end.equals(mode.getStatus()) || Status.none.equals(mode.getStatus()))) { return null; } @@ -149,10 +159,6 @@ public class AssessmentModeGuardController extends BasicController implements Ge if(guard == null) { guard = createGuard(mode); } - - String state; - Date begin = mode.getBegin(); - Date end = mode.getEnd(); StringBuilder sb = new StringBuilder(); boolean allowed = true; @@ -174,10 +180,59 @@ public class AssessmentModeGuardController extends BasicController implements Ge guard.getCountDown().setDate(mode.getBegin()); + String state; if(allowed) { Link go = guard.getGo(); Link cont = guard.getContinue(); + state = updateButtons(mode, now, go, cont); + } else { + state = "error"; + } + + guard.sync(state, sb.toString(), mode, getLocale()); + return guard; + } + + private String updateButtons(TransientAssessmentMode mode, Date now, Link go, Link cont) { + String state; + if(mode.isManual()) { + if(Status.leadtime == mode.getStatus()) { + state = Status.leadtime.name(); + go.setEnabled(false); + go.setVisible(true); + cont.setEnabled(false); + cont.setVisible(false); + } else if(Status.assessment == mode.getStatus()) { + state = Status.assessment.name(); + go.setEnabled(true); + go.setVisible(true); + cont.setEnabled(false); + cont.setVisible(false); + } else if(Status.followup == mode.getStatus()) { + state = Status.followup.name(); + go.setEnabled(false); + go.setVisible(false); + cont.setEnabled(false); + cont.setVisible(false); + } else if(Status.end == mode.getStatus()) { + state = Status.end.name(); + go.setEnabled(false); + go.setVisible(false); + cont.setEnabled(true); + cont.setVisible(true); + } else { + state = "error"; + go.setEnabled(false); + go.setVisible(false); + cont.setEnabled(false); + cont.setVisible(false); + } + } else { + Date begin = mode.getBegin(); + Date beginWithLeadTime = mode.getBeginWithLeadTime(); + Date end = mode.getEnd(); + Date endWithLeadTime = mode.getEndWithFollowupTime(); if(beginWithLeadTime.compareTo(now) <= 0 && begin.compareTo(now) > 0) { state = Status.leadtime.name(); go.setEnabled(false); @@ -209,12 +264,10 @@ public class AssessmentModeGuardController extends BasicController implements Ge cont.setEnabled(false); cont.setVisible(false); } - } else { - state = "error"; } - guard.sync(state, sb.toString(), mode, getLocale()); - return guard; + return state; + } private ResourceGuard createGuard(TransientAssessmentMode mode) { @@ -281,7 +334,7 @@ public class AssessmentModeGuardController extends BasicController implements Ge if("go".equals(link.getCommand())) { ResourceGuard guard = (ResourceGuard)link.getUserObject(); launchAssessmentMode(ureq, guard.getReference()); - } else if("continue".equals(link.getCommand())) { + } else if("continue".equals(link.getCommand()) || "continue-main".equals(link.getCommand())) { ResourceGuard guard = (ResourceGuard)link.getUserObject(); continueAfterAssessmentMode(ureq, guard); } diff --git a/src/main/java/org/olat/course/assessment/ui/AssessmentModeListController.java b/src/main/java/org/olat/course/assessment/ui/AssessmentModeListController.java index 329563677f206ea9da5d6e4b53f31e1b943963f5..a85203d887cbb1c97fe4e5d0b8387ef24ba96212 100644 --- a/src/main/java/org/olat/course/assessment/ui/AssessmentModeListController.java +++ b/src/main/java/org/olat/course/assessment/ui/AssessmentModeListController.java @@ -124,13 +124,13 @@ public class AssessmentModeListController extends FormBasicController implements new TimeCellRenderer(getTranslator()))); columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(Cols.target.i18nKey(), Cols.target.ordinal(), new TargetAudienceCellRenderer(getTranslator()))); - columnsModel.addFlexiColumnModel(new StaticFlexiColumnModel("start", Cols.manual.ordinal(), "start", + columnsModel.addFlexiColumnModel(new StaticFlexiColumnModel("start", Cols.start.ordinal(), "start", new BooleanCellRenderer(new StaticFlexiCellRenderer(translate("start"), "start"), null))); - columnsModel.addFlexiColumnModel(new StaticFlexiColumnModel("stop", Cols.manual.ordinal(), "stop", + columnsModel.addFlexiColumnModel(new StaticFlexiColumnModel("stop", Cols.stop.ordinal(), "stop", new BooleanCellRenderer(new StaticFlexiCellRenderer(translate("stop"), "stop"), null))); columnsModel.addFlexiColumnModel(new StaticFlexiColumnModel("edit", translate("edit"), "edit")); - model = new AssessmentModeListModel(columnsModel); + model = new AssessmentModeListModel(columnsModel, assessmentModeCoordinationService); tableEl = uifactory.addTableElement(getWindowControl(), "table", model, 20, false, getTranslator(), formLayout); tableEl.setMultiSelect(true); } @@ -259,9 +259,11 @@ public class AssessmentModeListController extends FormBasicController implements private void doStart(UserRequest ureq, AssessmentMode mode) { assessmentModeCoordinationService.startAssessment(mode); + loadModel(); } private void doStop(UserRequest ureq, AssessmentMode mode) { assessmentModeCoordinationService.stopAssessment(mode); + loadModel(); } } diff --git a/src/main/java/org/olat/course/assessment/ui/AssessmentModeListModel.java b/src/main/java/org/olat/course/assessment/ui/AssessmentModeListModel.java index e88f7489299408f021242bce5bcd900c54fd3c5d..80a51c7c7b21e5eb258cacb753c34765b3798ec6 100644 --- a/src/main/java/org/olat/course/assessment/ui/AssessmentModeListModel.java +++ b/src/main/java/org/olat/course/assessment/ui/AssessmentModeListModel.java @@ -24,6 +24,7 @@ import java.util.List; import org.olat.core.gui.components.form.flexible.impl.elements.table.DefaultFlexiTableDataModel; import org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableColumnModel; import org.olat.course.assessment.AssessmentMode; +import org.olat.course.assessment.AssessmentModeCoordinationService; import org.olat.course.assessment.model.TransientAssessmentMode; /** @@ -34,13 +35,16 @@ import org.olat.course.assessment.model.TransientAssessmentMode; */ public class AssessmentModeListModel extends DefaultFlexiTableDataModel<AssessmentMode> { - public AssessmentModeListModel(FlexiTableColumnModel columnsModel) { + private final AssessmentModeCoordinationService coordinationService; + + public AssessmentModeListModel(FlexiTableColumnModel columnsModel, AssessmentModeCoordinationService coordinationService) { super(columnsModel); + this.coordinationService = coordinationService; } @Override public AssessmentModeListModel createCopyWithEmptyList() { - return new AssessmentModeListModel(getTableColumnModel()); + return new AssessmentModeListModel(getTableColumnModel(), coordinationService); } @Override @@ -54,7 +58,20 @@ public class AssessmentModeListModel extends DefaultFlexiTableDataModel<Assessme case leadTime: return mode.getLeadTime(); case followupTime: return mode.getFollowupTime(); case target: return mode.getTargetAudience(); - case manual: return mode.isManualBeginEnd(); + case start: { + boolean canStart = mode.isManualBeginEnd(); + if(canStart) { + canStart = coordinationService.canStart(mode); + } + return canStart; + } + case stop: { + boolean canStop = mode.isManualBeginEnd(); + if(canStop) { + canStop = coordinationService.canStop(mode); + } + return canStop; + } } return null; } @@ -83,7 +100,8 @@ public class AssessmentModeListModel extends DefaultFlexiTableDataModel<Assessme leadTime("table.header.leadTime"), followupTime("table.header.followupTime"), target("table.header.target"), - manual(""); + start(""), + stop(""); private final String i18nKey; diff --git a/src/main/java/org/olat/course/assessment/ui/_content/choose_mode.html b/src/main/java/org/olat/course/assessment/ui/_content/choose_mode.html index 8d0fc3efc3e047dfe075cfe90f08946991ab4e82..4302cfa2e9d558a039d7f117d803c62b91ad0f07 100644 --- a/src/main/java/org/olat/course/assessment/ui/_content/choose_mode.html +++ b/src/main/java/org/olat/course/assessment/ui/_content/choose_mode.html @@ -30,4 +30,6 @@ #else <div class="o_error">$mode.errors</div> #end -#end \ No newline at end of file +#end + +<div class="o_button_group">$r.render("continue-main")</div> \ No newline at end of file diff --git a/src/main/java/org/olat/course/assessment/ui/_i18n/LocalStrings_de.properties b/src/main/java/org/olat/course/assessment/ui/_i18n/LocalStrings_de.properties index ee9bd8bd1eaf311f308691a525a3a226f01c7fb0..4dfcabb94a54fd66199ff8f10c54f84eaf90c660 100644 --- a/src/main/java/org/olat/course/assessment/ui/_i18n/LocalStrings_de.properties +++ b/src/main/java/org/olat/course/assessment/ui/_i18n/LocalStrings_de.properties @@ -8,6 +8,12 @@ choose.groups=Gruppen ausw choose.start.element=Kursbaustein auswählen confirm.delete.title=Prüfungsettings löschen confirm.delete.text=Wollen Sie wirklich diese Prüfungsettings "{0}" löschen? +confirm.status.change.title=Status von PrüfungsSettings wird geändert +confirm.status.change.none=Prüfung wird als nicht gestartet gesetzt. +confirm.status.change.leadtime=Prüfung wird in Vorlaufzeit. +confirm.status.change.assessment=Prüfung wirg gestartet. +confirm.status.change.followup=Prüfung wird in Nachlaufzeit. +confirm.status.change.end=Prüfung wird beendet. current.mode=Aktuelle Prüfung current.mode.continue=Zur OpenOLAT current.mode.desc=Im folgenden Kurs ist für den aktuellen Zeitraum eine Pr\u00FCfung für Sie vorgesehen. Während dieser Prüfung können keine anderen Funktionen in OpenOLAT verwendet werden: