Skip to content
Snippets Groups Projects
Commit 1be842b3 authored by dfurrer's avatar dfurrer
Browse files

OO-1675: extended confirmation window when leaving a course

parent 61a8e14c
No related branches found
No related tags found
No related merge requests found
/**
* <a href="http://www.openolat.org">
* OpenOLAT - Online Learning and Training</a><br>
* <p>
* Licensed under the Apache License, Version 2.0 (the "License"); <br>
* you may not use this file except in compliance with the License.<br>
* You may obtain a copy of the License at the
* <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache homepage</a>
* <p>
* Unless required by applicable law or agreed to in writing,<br>
* software distributed under the License is distributed on an "AS IS" BASIS, <br>
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br>
* See the License for the specific language governing permissions and <br>
* limitations under the License.
* <p>
* Initial code contributed and copyrighted by<br>
* frentix GmbH, http://www.frentix.com
* <p>
*/
package org.olat.course.run;
import org.olat.core.gui.UserRequest;
import org.olat.core.gui.components.form.flexible.FormItem;
import org.olat.core.gui.components.form.flexible.FormItemContainer;
import org.olat.core.gui.components.form.flexible.elements.FormLink;
import org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement;
import org.olat.core.gui.components.form.flexible.impl.FormBasicController;
import org.olat.core.gui.components.form.flexible.impl.FormEvent;
import org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer;
import org.olat.core.gui.components.link.Link;
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.util.StringHelper;
import org.olat.core.util.Util;
import org.olat.repository.RepositoryEntry;
import org.olat.repository.RepositoryService;
/**
*
* Initial date: 10.09.2015<br>
* @author dfurrer, dirk.furrer@frentix.com, http://www.frentix.com
*
*/
public class ConfirmLeaveController extends FormBasicController {
private FormLink leaveButton;
private final RepositoryEntry entry;
private MultipleSelectionElement acknowledgeEl;
public ConfirmLeaveController(UserRequest ureq, WindowControl wControl, RepositoryEntry entry) {
super(ureq, wControl, "confirm_leave");
setTranslator(Util.createPackageTranslator(RepositoryService.class, getLocale(), getTranslator()));
this.entry = entry;
initForm(ureq);
}
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
if(formLayout instanceof FormLayoutContainer) {
FormLayoutContainer layoutCont = FormLayoutContainer.createDefaultFormLayout("confirm", getTranslator());
formLayout.add("confirm", layoutCont);
layoutCont.setRootForm(mainForm);
uifactory.addStaticTextElement("rows", "course.leave.entry", StringHelper.escapeHtml(entry.getDisplayname()), layoutCont);
String[] acknowledge = new String[] { translate("course.leave.acknowledge.msg") };
acknowledgeEl = uifactory.addCheckboxesHorizontal("confirm", "details.delete.acknowledge", layoutCont, new String[]{ "" }, acknowledge);
FormLayoutContainer buttonsCont = FormLayoutContainer.createButtonLayout("buttons", getTranslator());
layoutCont.add(buttonsCont);
leaveButton = uifactory.addFormLink("sign.out", buttonsCont, Link.BUTTON);
uifactory.addFormCancelButton("cancel", buttonsCont, ureq, getWindowControl());
}
}
@Override
protected void doDispose() {
//
}
@Override
protected boolean validateFormLogic(UserRequest ureq) {
acknowledgeEl.clearError();
if(!acknowledgeEl.isAtLeastSelected(1)) {
acknowledgeEl.setErrorKey("details.delete.acknowledge.error", null);
return false;
}else{
return true;
}
}
@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
if(leaveButton == source) {
if(validateFormLogic(ureq)) {
fireEvent(ureq, Event.DONE_EVENT);
}
}
}
@Override
protected void formOK(UserRequest ureq) {
//
}
@Override
protected void formCancelled(UserRequest ureq) {
fireEvent(ureq, Event.CANCELLED_EVENT);
}
}
...@@ -52,12 +52,11 @@ import org.olat.core.gui.control.Event; ...@@ -52,12 +52,11 @@ import org.olat.core.gui.control.Event;
import org.olat.core.gui.control.VetoableCloseController; import org.olat.core.gui.control.VetoableCloseController;
import org.olat.core.gui.control.WindowControl; import org.olat.core.gui.control.WindowControl;
import org.olat.core.gui.control.creator.ControllerCreator; import org.olat.core.gui.control.creator.ControllerCreator;
import org.olat.core.gui.control.generic.closablewrapper.CloseableModalController;
import org.olat.core.gui.control.generic.dtabs.Activateable2; import org.olat.core.gui.control.generic.dtabs.Activateable2;
import org.olat.core.gui.control.generic.dtabs.DTab; import org.olat.core.gui.control.generic.dtabs.DTab;
import org.olat.core.gui.control.generic.dtabs.DTabs; import org.olat.core.gui.control.generic.dtabs.DTabs;
import org.olat.core.gui.control.generic.messages.MessageUIFactory; import org.olat.core.gui.control.generic.messages.MessageUIFactory;
import org.olat.core.gui.control.generic.modal.DialogBoxController;
import org.olat.core.gui.control.generic.modal.DialogBoxUIFactory;
import org.olat.core.gui.control.generic.popup.PopupBrowserWindow; import org.olat.core.gui.control.generic.popup.PopupBrowserWindow;
import org.olat.core.id.Identity; import org.olat.core.id.Identity;
import org.olat.core.id.OLATResourceable; import org.olat.core.id.OLATResourceable;
...@@ -146,6 +145,8 @@ public class CourseRuntimeController extends RepositoryEntryRuntimeController im ...@@ -146,6 +145,8 @@ public class CourseRuntimeController extends RepositoryEntryRuntimeController im
private static final String CMD_START_GROUP_PREFIX = "cmd.group.start.ident."; private static final String CMD_START_GROUP_PREFIX = "cmd.group.start.ident.";
private Delayed delayedClose; private Delayed delayedClose;
private CloseableModalController cmc;
//tools //tools
private Link folderLink, private Link folderLink,
assessmentLink, archiverLink, assessmentLink, archiverLink,
...@@ -161,7 +162,7 @@ public class CourseRuntimeController extends RepositoryEntryRuntimeController im ...@@ -161,7 +162,7 @@ public class CourseRuntimeController extends RepositoryEntryRuntimeController im
private Dropdown myCourse, glossary; private Dropdown myCourse, glossary;
private CourseAreasController areasCtrl; private CourseAreasController areasCtrl;
private DialogBoxController leaveDialogBox; private ConfirmLeaveController leaveDialogBox;
private ArchiverMainController archiverCtrl; private ArchiverMainController archiverCtrl;
private CustomDBMainController databasesCtrl; private CustomDBMainController databasesCtrl;
private FolderRunController courseFolderCtrl; private FolderRunController courseFolderCtrl;
...@@ -772,8 +773,10 @@ public class CourseRuntimeController extends RepositoryEntryRuntimeController im ...@@ -772,8 +773,10 @@ public class CourseRuntimeController extends RepositoryEntryRuntimeController im
toolControllerDone(ureq); toolControllerDone(ureq);
} }
} else if(source == leaveDialogBox) { } else if(source == leaveDialogBox) {
if (DialogBoxUIFactory.isYesEvent(event) || DialogBoxUIFactory.isOkEvent(event)) { if (event.equals(Event.DONE_EVENT)) {
doLeave(ureq); doLeave(ureq);
}else{
cmc.deactivate();
} }
} }
...@@ -826,6 +829,7 @@ public class CourseRuntimeController extends RepositoryEntryRuntimeController im ...@@ -826,6 +829,7 @@ public class CourseRuntimeController extends RepositoryEntryRuntimeController im
removeAsListenerAndDispose(statsToolCtr); removeAsListenerAndDispose(statsToolCtr);
removeAsListenerAndDispose(membersCtrl); removeAsListenerAndDispose(membersCtrl);
removeAsListenerAndDispose(areasCtrl); removeAsListenerAndDispose(areasCtrl);
removeAsListenerAndDispose(leaveDialogBox);
assessmentToolCtr = null; assessmentToolCtr = null;
courseFolderCtrl = null; courseFolderCtrl = null;
courseLayoutCtrl = null; courseLayoutCtrl = null;
...@@ -1008,10 +1012,13 @@ public class CourseRuntimeController extends RepositoryEntryRuntimeController im ...@@ -1008,10 +1012,13 @@ public class CourseRuntimeController extends RepositoryEntryRuntimeController im
} }
private void doConfirmLeave(UserRequest ureq) { private void doConfirmLeave(UserRequest ureq) {
String reName = StringHelper.escapeHtml(getRepositoryEntry().getDisplayname());
String title = translate("sign.out"); String title = translate("sign.out");
String text = translate("sign.out.dialog.text", reName);
leaveDialogBox = activateYesNoDialog(ureq, title, text, leaveDialogBox); leaveDialogBox = new ConfirmLeaveController(ureq, getWindowControl(), this.getRepositoryEntry());
listenTo(leaveDialogBox);
cmc = new CloseableModalController(getWindowControl(), "close", leaveDialogBox.getInitialComponent(), true, title);
listenTo(cmc);
cmc.activate();
} }
private void doLeave(UserRequest ureq) { private void doLeave(UserRequest ureq) {
...@@ -1425,7 +1432,7 @@ public class CourseRuntimeController extends RepositoryEntryRuntimeController im ...@@ -1425,7 +1432,7 @@ public class CourseRuntimeController extends RepositoryEntryRuntimeController im
// use a one-column main layout // use a one-column main layout
LayoutMain3ColsController layoutCtr = new LayoutMain3ColsController(lureq, lwControl, glossaryController); LayoutMain3ColsController layoutCtr = new LayoutMain3ColsController(lureq, lwControl, glossaryController);
// dispose glossary on layout dispose // dispose glossary on layout dispose
layoutCtr.addDisposableChildController(glossaryController); layoutCtr.addDisposableChildController(glossaryController);
return layoutCtr; return layoutCtr;
} }
} }
......
<div class="o_error">
<i class="o_icon o_icon-lg o_icon_important"> </i> $r.translate("course.leave.confirm.hint")
</div>
$r.render("confirm")
\ No newline at end of file
...@@ -48,7 +48,7 @@ course.noaccess.title=Keinen Zugriff auf diesen Kurs ...@@ -48,7 +48,7 @@ course.noaccess.title=Keinen Zugriff auf diesen Kurs
course.presence.message.enter=Bearbeite Kurs\: course.presence.message.enter=Bearbeite Kurs\:
course.presence.message.leave=Verlasse Kurs\: course.presence.message.leave=Verlasse Kurs\:
coursenoaccess.title=Keinen Zugriff auf diesen Kurs coursenoaccess.title=Keinen Zugriff auf diesen Kurs
error.editoralreadylocked=Der Kurs wird momentan von {0} editiert und ist deshalb gesperrt. error.editoralreadylocked=Der Kurs wird momentan von {0} editiert und ist deshalb gesperrt.
error.invalid.group=Sie wurden aus dieser Gruppe ausgetragen. Die Gruppe kann nicht mehr angezeigt werden. error.invalid.group=Sie wurden aus dieser Gruppe ausgetragen. Die Gruppe kann nicht mehr angezeigt werden.
error.noglossary=Das Glossar ist zurzeit nicht verf\u00FCgbar. error.noglossary=Das Glossar ist zurzeit nicht verf\u00FCgbar.
error.accesscontrol=Zugang verweigert error.accesscontrol=Zugang verweigert
...@@ -60,6 +60,8 @@ header.tools.participatedGroups=Meine Gruppen ...@@ -60,6 +60,8 @@ header.tools.participatedGroups=Meine Gruppen
header.tools.waitingListGroups=Auf Warteliste header.tools.waitingListGroups=Auf Warteliste
msg.nodenotavailableanymore=Es haben sich Berechtigungen ver\u00E4ndert, so dass Sie den gew\u00FCnschten Kursbaustein nicht mehr aufrufen k\u00F6nnen. msg.nodenotavailableanymore=Es haben sich Berechtigungen ver\u00E4ndert, so dass Sie den gew\u00FCnschten Kursbaustein nicht mehr aufrufen k\u00F6nnen.
participants.in.course={0} Kursteilnehmer anwesend participants.in.course={0} Kursteilnehmer anwesend
participants.in.course.desc=Anzahl Personen, die momentan diesen Kurs besuchen. participants.in.course.desc=Anzahl Personen, die momentan diesen Kurs besuchen.
warn.cannotactivatesinceintool=Es ist bereits ein anderes Kurswerkzeug desselben Kurses gestartet. Bitte schliessen Sie das aktivierte Kurswerkzeug, bevor Sie ein neues starten. warn.cannotactivatesinceintool=Es ist bereits ein anderes Kurswerkzeug desselben Kurses gestartet. Bitte schliessen Sie das aktivierte Kurswerkzeug, bevor Sie ein neues starten.
course.leave.confirm.hint=Wollen Sie wirklich aus diesem Kurs austreten? Sie verlieren damit die entsprechende Kurs- oder Gruppenmitgliedschaft und werden diesen Kurs in Zukunft nicht mehr betreten k\u00F6nnen.
\ No newline at end of file course.leave.entry=Kurs
course.leave.acknowledge.msg=Mitgliedschaft beenden
\ No newline at end of file
...@@ -62,3 +62,6 @@ msg.nodenotavailableanymore=Your access rights have been altered in the meantime ...@@ -62,3 +62,6 @@ msg.nodenotavailableanymore=Your access rights have been altered in the meantime
participants.in.course={0} course participants present participants.in.course={0} course participants present
participants.in.course.desc=Number of course participants in this course participants.in.course.desc=Number of course participants in this course
warn.cannotactivatesinceintool=Another course tool of the same course is already active. Please deactivate this tool before starting a new one. warn.cannotactivatesinceintool=Another course tool of the same course is already active. Please deactivate this tool before starting a new one.
course.leave.confirm.hint=Do you really want to leave this course? This deletes your respective course or group membership, and you will not be able to access this course in the future.
course.leave.entry=Course
course.leave.acknowledge.msg=Delete membership
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment