diff --git a/src/main/java/org/olat/course/nodes/SurveyCourseNode.java b/src/main/java/org/olat/course/nodes/SurveyCourseNode.java index ba62f0aa5ee269142f0322134c7c6214467b380b..c1f81af063af335f58b85ef2dd893aa50d177461 100644 --- a/src/main/java/org/olat/course/nodes/SurveyCourseNode.java +++ b/src/main/java/org/olat/course/nodes/SurveyCourseNode.java @@ -36,6 +36,7 @@ import org.olat.course.editor.NodeEditController; import org.olat.course.editor.StatusDescription; import org.olat.course.nodes.survey.SurveyEditController; import org.olat.course.nodes.survey.SurveyRunController; +import org.olat.course.nodes.survey.SurveyRunSecurityCallback; import org.olat.course.run.navigation.NodeRunConstructionResult; import org.olat.course.run.userview.NodeEvaluation; import org.olat.course.run.userview.UserCourseEnvironment; @@ -59,6 +60,14 @@ public class SurveyCourseNode extends AbstractAccessableCourseNode { public static final int CURRENT_VERSION = 1; public static final String CONFIG_KEY_REPOSITORY_SOFTKEY = "repository.softkey"; + public static final String CONFIG_KEY_EXECUTION_BY_OWNER = "execution.by.owner"; + public static final String CONFIG_KEY_EXECUTION_BY_COACH = "execution.by.coach"; + public static final String CONFIG_KEY_EXECUTION_BY_PARTICIPANT = "execution.by.participant"; + public static final String CONFIG_KEY_EXECUTION_BY_GUEST = "execution.by.guest"; + public static final String CONFIG_KEY_REPORT_FOR_OWNER = "report.for.owner"; + public static final String CONFIG_KEY_REPORT_FOR_COACH = "report.for.coach"; + public static final String CONFIG_KEY_REPORT_FOR_PARTICIPANT = "report.for.participant"; + public static final String CONFIG_KEY_REPORT_FOR_GUEST = "report.for.guest"; public SurveyCourseNode() { super(TYPE); @@ -111,10 +120,16 @@ public class SurveyCourseNode extends AbstractAccessableCourseNode { public NodeRunConstructionResult createNodeRunConstructionResult(UserRequest ureq, WindowControl wControl, UserCourseEnvironment userCourseEnv, NodeEvaluation ne, String nodecmd) { OLATResourceable ores = userCourseEnv.getCourseEnvironment().getCourseGroupManager().getCourseEntry(); - Controller runCtrl = new SurveyRunController(ureq, wControl, ores, this); + SurveyRunSecurityCallback secCallback = new SurveyRunSecurityCallback(getModuleConfiguration(), userCourseEnv); + Controller runCtrl = new SurveyRunController(ureq, wControl, ores, this, secCallback); Controller ctrl = TitledWrapperHelper.getWrapper(ureq, wControl, runCtrl, this, SURVEY_ICON); return new NodeRunConstructionResult(ctrl); } + + @Override + public Controller createPreviewController(UserRequest ureq, WindowControl wControl, UserCourseEnvironment userCourseEnv, NodeEvaluation ne) { + return createNodeRunConstructionResult(ureq, wControl, userCourseEnv, ne, null).getRunController(); + } @SuppressWarnings("deprecation") @Override @@ -128,7 +143,14 @@ public class SurveyCourseNode extends AbstractAccessableCourseNode { public void updateModuleConfigDefaults(boolean isNewNode) { ModuleConfiguration config = getModuleConfiguration(); if (isNewNode) { - // + config.setBooleanEntry(CONFIG_KEY_EXECUTION_BY_OWNER, true); + config.setBooleanEntry(CONFIG_KEY_EXECUTION_BY_COACH, true); + config.setBooleanEntry(CONFIG_KEY_EXECUTION_BY_PARTICIPANT, true); + config.setBooleanEntry(CONFIG_KEY_EXECUTION_BY_GUEST, true); + config.setBooleanEntry(CONFIG_KEY_REPORT_FOR_OWNER, true); + config.setBooleanEntry(CONFIG_KEY_REPORT_FOR_COACH, true); + config.setBooleanEntry(CONFIG_KEY_REPORT_FOR_PARTICIPANT, true); + config.setBooleanEntry(CONFIG_KEY_REPORT_FOR_GUEST, true); } config.setConfigurationVersion(CURRENT_VERSION); } diff --git a/src/main/java/org/olat/course/nodes/survey/SurveyConfigController.java b/src/main/java/org/olat/course/nodes/survey/SurveyConfigController.java index 3c25a846141bef4b15f5624bfb0e80e04382d6eb..c885f6e75735ee9436eeabe71e1b559ff5a0b4c8 100644 --- a/src/main/java/org/olat/course/nodes/survey/SurveyConfigController.java +++ b/src/main/java/org/olat/course/nodes/survey/SurveyConfigController.java @@ -19,12 +19,16 @@ */ package org.olat.course.nodes.survey; +import java.util.Collection; +import java.util.stream.Stream; + import org.olat.NewControllerFactory; import org.olat.core.commons.fullWebApp.LayoutMain3ColsPreviewController; 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.elements.StaticTextElement; import org.olat.core.gui.components.form.flexible.impl.FormBasicController; import org.olat.core.gui.components.form.flexible.impl.FormEvent; @@ -56,12 +60,35 @@ import org.springframework.beans.factory.annotation.Autowired; * */ public class SurveyConfigController extends FormBasicController { + + public static final String EXECUTION_BY_OWNER = "edit.execution.by.owner"; + public static final String EXECUTION_BY_COACH = "edit.execution.by.coach"; + public static final String EXECUTION_BY_PARTICIPANT = "edit.execution.by.participant"; + public static final String EXECUTION_BY_GUEST = "edit.execution.by.guest"; + public static final String[] EXECUTION_KEYS = new String[] { + EXECUTION_BY_OWNER, + EXECUTION_BY_COACH, + EXECUTION_BY_PARTICIPANT, + EXECUTION_BY_GUEST + }; + public static final String REPORT_FOR_OWNER = "edit.report.for.owner"; + public static final String REPORT_FOR_COACH = "edit.report.for.coach"; + public static final String REPORT_FOR_PARTICIPANT = "edit.report.for.participant"; + public static final String REPORT_FOR_GUEST = "edit.report.for.guest"; + public static final String[] REPORT_KEYS = new String[] { + REPORT_FOR_OWNER, + REPORT_FOR_COACH, + REPORT_FOR_PARTICIPANT, + REPORT_FOR_GUEST + }; private StaticTextElement questionnaireNotChoosen; private FormLink questionnaireLink; private FormLink chooseLink; private FormLink replaceLink; private FormLink editLink; + private MultipleSelectionElement executeRolesEl; + private MultipleSelectionElement reportRolesEl; private CloseableModalController cmc; private ReferencableEntriesSearchController searchCtrl; @@ -103,8 +130,28 @@ public class SurveyConfigController extends FormBasicController { replaceLink = uifactory.addFormLink("edit.replace", buttonsCont, "btn btn-default o_xsmall"); editLink = uifactory.addFormLink("edit.edit", buttonsCont, "btn btn-default o_xsmall"); + executeRolesEl = uifactory.addCheckboxesVertical("edit.execution", formLayout, EXECUTION_KEYS, translateKeys(EXECUTION_KEYS), 1); + executeRolesEl.select(EXECUTION_BY_OWNER, moduleConfiguration.getBooleanSafe(SurveyCourseNode.CONFIG_KEY_EXECUTION_BY_OWNER)); + executeRolesEl.select(EXECUTION_BY_COACH, moduleConfiguration.getBooleanSafe(SurveyCourseNode.CONFIG_KEY_EXECUTION_BY_COACH)); + executeRolesEl.select(EXECUTION_BY_PARTICIPANT, moduleConfiguration.getBooleanSafe(SurveyCourseNode.CONFIG_KEY_EXECUTION_BY_PARTICIPANT)); + executeRolesEl.select(EXECUTION_BY_GUEST, moduleConfiguration.getBooleanSafe(SurveyCourseNode.CONFIG_KEY_EXECUTION_BY_GUEST)); + executeRolesEl.addActionListener(FormEvent.ONCHANGE); + + reportRolesEl = uifactory.addCheckboxesVertical("edit.report",formLayout, REPORT_KEYS, translateKeys(REPORT_KEYS), 1); + reportRolesEl.select(REPORT_FOR_OWNER, moduleConfiguration.getBooleanSafe(SurveyCourseNode.CONFIG_KEY_REPORT_FOR_OWNER)); + reportRolesEl.select(REPORT_FOR_COACH, moduleConfiguration.getBooleanSafe(SurveyCourseNode.CONFIG_KEY_REPORT_FOR_COACH)); + reportRolesEl.select(REPORT_FOR_PARTICIPANT, moduleConfiguration.getBooleanSafe(SurveyCourseNode.CONFIG_KEY_REPORT_FOR_PARTICIPANT)); + reportRolesEl.select(REPORT_FOR_GUEST, moduleConfiguration.getBooleanSafe(SurveyCourseNode.CONFIG_KEY_REPORT_FOR_GUEST)); + reportRolesEl.addActionListener(FormEvent.ONCHANGE); + updateUI(); } + + private String[] translateKeys(String[] keys) { + return Stream.of(keys) + .map(key -> getTranslator().translate(key)) + .toArray(String[]::new); + } private void updateUI() { boolean replacePossible = evaluationFormManager.isFormUpdateable(survey); @@ -136,6 +183,10 @@ public class SurveyConfigController extends FormBasicController { doEditQuestionnaire(ureq); } else if (source == questionnaireLink) { doPreviewQuestionnaire(ureq); + } else if (source == executeRolesEl) { + doUpdateExecutionRoles(ureq); + } else if (source == reportRolesEl) { + doUpdateReportRoles(ureq); } super.formInnerEvent(ureq, source, event); } @@ -215,6 +266,24 @@ public class SurveyConfigController extends FormBasicController { listenTo(previewCtr); } + private void doUpdateExecutionRoles(UserRequest ureq) { + Collection<String> selectedKeys = executeRolesEl.getSelectedKeys(); + moduleConfiguration.setBooleanEntry(SurveyCourseNode.CONFIG_KEY_EXECUTION_BY_OWNER, selectedKeys.contains(EXECUTION_BY_OWNER)); + moduleConfiguration.setBooleanEntry(SurveyCourseNode.CONFIG_KEY_EXECUTION_BY_COACH, selectedKeys.contains(EXECUTION_BY_COACH)); + moduleConfiguration.setBooleanEntry(SurveyCourseNode.CONFIG_KEY_EXECUTION_BY_PARTICIPANT, selectedKeys.contains(EXECUTION_BY_PARTICIPANT)); + moduleConfiguration.setBooleanEntry(SurveyCourseNode.CONFIG_KEY_EXECUTION_BY_GUEST, selectedKeys.contains(EXECUTION_BY_GUEST)); + fireEvent(ureq, NodeEditController.NODECONFIG_CHANGED_EVENT); + } + + private void doUpdateReportRoles(UserRequest ureq) { + Collection<String> selectedKeys = reportRolesEl.getSelectedKeys(); + moduleConfiguration.setBooleanEntry(SurveyCourseNode.CONFIG_KEY_REPORT_FOR_OWNER, selectedKeys.contains(REPORT_FOR_OWNER)); + moduleConfiguration.setBooleanEntry(SurveyCourseNode.CONFIG_KEY_REPORT_FOR_COACH, selectedKeys.contains(REPORT_FOR_COACH)); + moduleConfiguration.setBooleanEntry(SurveyCourseNode.CONFIG_KEY_REPORT_FOR_PARTICIPANT, selectedKeys.contains(REPORT_FOR_PARTICIPANT)); + moduleConfiguration.setBooleanEntry(SurveyCourseNode.CONFIG_KEY_REPORT_FOR_GUEST, selectedKeys.contains(REPORT_FOR_GUEST)); + fireEvent(ureq, NodeEditController.NODECONFIG_CHANGED_EVENT); + } + @Override protected void formOK(UserRequest ureq) { // diff --git a/src/main/java/org/olat/course/nodes/survey/SurveyEditController.java b/src/main/java/org/olat/course/nodes/survey/SurveyEditController.java index 8232f5c03139124b4f00c97758818b19568299b3..a35539a4a49cc3477b5e5aef595592e9921a42e0 100644 --- a/src/main/java/org/olat/course/nodes/survey/SurveyEditController.java +++ b/src/main/java/org/olat/course/nodes/survey/SurveyEditController.java @@ -23,6 +23,7 @@ import org.olat.core.gui.UserRequest; import org.olat.core.gui.components.Component; import org.olat.core.gui.components.tabbedpane.TabbedPane; import org.olat.core.gui.components.velocity.VelocityContainer; +import org.olat.core.gui.control.Controller; import org.olat.core.gui.control.ControllerEventListener; import org.olat.core.gui.control.Event; import org.olat.core.gui.control.WindowControl; @@ -86,6 +87,13 @@ public class SurveyEditController extends ActivateableTabbableDefaultController return tabPane; } + @Override + public void event(UserRequest ureq, Controller source, Event event) { + if (source == surveyConfigController) { + fireEvent(ureq, event); + } + } + @Override protected void event(UserRequest ureq, Component source, Event event) { // diff --git a/src/main/java/org/olat/course/nodes/survey/SurveyRunController.java b/src/main/java/org/olat/course/nodes/survey/SurveyRunController.java index 93adaeca6d79ad2b55f60629ffdd46aad61a7361..b0bd1518f8d3fd83dd23143ca3a3bb9d68383ad1 100644 --- a/src/main/java/org/olat/course/nodes/survey/SurveyRunController.java +++ b/src/main/java/org/olat/course/nodes/survey/SurveyRunController.java @@ -26,12 +26,15 @@ 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.controller.BasicController; +import org.olat.core.gui.control.generic.messages.MessageUIFactory; +import org.olat.core.gui.translator.Translator; import org.olat.core.id.Identity; import org.olat.core.id.OLATResourceable; +import org.olat.core.util.Util; import org.olat.course.nodes.SurveyCourseNode; import org.olat.modules.forms.EvaluationFormManager; import org.olat.modules.forms.EvaluationFormParticipation; -import org.olat.modules.forms.EvaluationFormParticipationStatus; +import org.olat.modules.forms.EvaluationFormParticipationIdentifier; import org.olat.modules.forms.EvaluationFormSession; import org.olat.modules.forms.EvaluationFormSurvey; import org.olat.modules.forms.ui.EvaluationFormExecutionController; @@ -48,34 +51,66 @@ public class SurveyRunController extends BasicController { private final VelocityContainer mainVC; private EvaluationFormExecutionController executionCtrl; + private final SurveyRunSecurityCallback secCallback; private EvaluationFormSurvey survey; + private EvaluationFormParticipation participation; @Autowired private EvaluationFormManager evaluationFormManager; - public SurveyRunController(UserRequest ureq, WindowControl wControl, OLATResourceable ores, - SurveyCourseNode courseNode) { + public SurveyRunController(UserRequest ureq, WindowControl wControl, OLATResourceable ores, SurveyCourseNode courseNode, + SurveyRunSecurityCallback secCallback) { super(ureq, wControl); + this.secCallback = secCallback; mainVC = createVelocityContainer("run"); - + survey = evaluationFormManager.loadSurvey(ores, courseNode.getIdent()); - EvaluationFormParticipation participation = loadOrCreateParticipation(survey); - if (EvaluationFormParticipationStatus.done.equals(participation.getStatus())) { + if (secCallback.canParticipate()) { + participation = loadOrCreateParticipation(ureq); + } + + if (secCallback.canViewReporting(participation)) { doShowReporting(ureq); + } else if (secCallback.hasParticipated(participation)) { + doShowParticipationDone(ureq); + } else if (secCallback.isReadOnly()) { + doShowReadOnly(ureq); + } else if (secCallback.canExecute(participation)) { + doShowExecution(ureq, wControl); } else { - doShowExecution(ureq, wControl, participation); + doShowNoAccess(ureq); } putInitialPanel(mainVC); } - private EvaluationFormParticipation loadOrCreateParticipation(EvaluationFormSurvey survey) { - Identity executor = getIdentity(); - EvaluationFormParticipation participation = evaluationFormManager.loadParticipationByExecutor(survey, executor); - if (participation == null) { - participation = evaluationFormManager.createParticipation(survey, executor); + private EvaluationFormParticipation loadOrCreateParticipation(UserRequest ureq) { + if (secCallback.isGuestOnly()) { + String sessionId = ureq.getUserSession().getSessionInfo().getSession().getId(); + EvaluationFormParticipationIdentifier identifier = new EvaluationFormParticipationIdentifier("course-node", sessionId); + return loadOrCreateParticipation(identifier); + } + return loadOrCreateParticipation(getIdentity()); + } + + private EvaluationFormParticipation loadOrCreateParticipation(EvaluationFormParticipationIdentifier identifier) { + EvaluationFormParticipation loadedParticipation = evaluationFormManager.loadParticipationByIdentifier(survey, identifier); + if (loadedParticipation == null) { + loadedParticipation = evaluationFormManager.createParticipation(survey, identifier); + loadedParticipation.setAnonymous(true); + loadedParticipation = evaluationFormManager.updateParticipation(loadedParticipation); } - return participation; + return loadedParticipation; + } + + private EvaluationFormParticipation loadOrCreateParticipation(Identity executor) { + EvaluationFormParticipation loadedParticipation = evaluationFormManager.loadParticipationByExecutor(survey, executor); + if (loadedParticipation == null) { + loadedParticipation = evaluationFormManager.createParticipation(survey, executor); + loadedParticipation.setAnonymous(true); + loadedParticipation = evaluationFormManager.updateParticipation(loadedParticipation); + } + return loadedParticipation; } private EvaluationFormSession loadOrCreateSesssion(EvaluationFormParticipation participation) { @@ -89,29 +124,57 @@ public class SurveyRunController extends BasicController { @Override protected void event(UserRequest ureq, Controller source, Event event) { if (source == executionCtrl && event == Event.DONE_EVENT) { - doHideExecution(); doShowReporting(ureq); } super.event(ureq, source, event); } - private void doShowExecution(UserRequest ureq, WindowControl wControl, - EvaluationFormParticipation participation) { + private void doShowExecution(UserRequest ureq, WindowControl wControl) { + removeAllComponents(); EvaluationFormSession session = loadOrCreateSesssion(participation); executionCtrl = new EvaluationFormExecutionController(ureq, wControl, session); listenTo(executionCtrl); mainVC.put("execution", executionCtrl.getInitialComponent()); } - private void doHideExecution() { - mainVC.remove("execution"); - } - private void doShowReporting(UserRequest ureq) { + removeAllComponents(); + participation = loadOrCreateParticipation(ureq); Controller reportingCtrl = new SurveyReportingController(ureq, getWindowControl(), survey); mainVC.put("reporting", reportingCtrl.getInitialComponent()); } + private void doShowNoAccess(UserRequest ureq) { + String title = getTranslator().translate("run.noaccess.title"); + String message = getTranslator().translate("run.noaccess.message"); + doShowMessage(ureq, title, message); + } + + private void doShowReadOnly(UserRequest ureq) { + Translator trans = Util.createPackageTranslator(SurveyCourseNode.class, getLocale()); + String title = trans.translate("freezenoaccess.title"); + String message = trans.translate("freezenoaccess.message"); + doShowMessage(ureq, title, message); + } + + private void doShowParticipationDone(UserRequest ureq) { + String title = getTranslator().translate("run.participation.done.title"); + String message = getTranslator().translate("run.participation.done.message"); + doShowMessage(ureq, title, message); + } + + private void doShowMessage(UserRequest ureq, String title, String message) { + removeAllComponents(); + Controller ctrl = MessageUIFactory.createInfoMessage(ureq, getWindowControl(), title, message); + mainVC.put("message", ctrl.getInitialComponent()); + } + + private void removeAllComponents() { + mainVC.remove("message"); + mainVC.remove("execution"); + mainVC.remove("reporting"); + } + @Override protected void event(UserRequest ureq, Component source, Event event) { // diff --git a/src/main/java/org/olat/course/nodes/survey/SurveyRunSecurityCallback.java b/src/main/java/org/olat/course/nodes/survey/SurveyRunSecurityCallback.java new file mode 100644 index 0000000000000000000000000000000000000000..30713443240c269a184bdcc1f97857676088bde9 --- /dev/null +++ b/src/main/java/org/olat/course/nodes/survey/SurveyRunSecurityCallback.java @@ -0,0 +1,141 @@ +/** + * <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.nodes.survey; + +import org.olat.course.nodes.SurveyCourseNode; +import org.olat.course.run.userview.UserCourseEnvironment; +import org.olat.modules.ModuleConfiguration; +import org.olat.modules.forms.EvaluationFormParticipation; +import org.olat.modules.forms.EvaluationFormParticipationStatus; + +/** + * + * Initial date: 02.05.2018<br> + * @author uhensler, urs.hensler@frentix.com, http://www.frentix.com + * + */ +public class SurveyRunSecurityCallback { + + private final boolean courseReadOnly; + private final boolean guestOnly; + private final boolean executor; + private final boolean reportViewer; + + public SurveyRunSecurityCallback(ModuleConfiguration moduleConfiguration, UserCourseEnvironment userCourseEnv) { + this.courseReadOnly = userCourseEnv.isCourseReadOnly(); + this.guestOnly = userCourseEnv.getIdentityEnvironment().getRoles().isGuestOnly(); + this.executor = hasExecutionRole(moduleConfiguration, userCourseEnv); + this.reportViewer = hasReportRole(moduleConfiguration, userCourseEnv); + } + + boolean isGuestOnly() { + return guestOnly; + } + + boolean isExecutor() { + return executor; + } + + boolean isReportViewer() { + return reportViewer; + } + + private boolean hasExecutionRole(ModuleConfiguration moduleConfiguration, UserCourseEnvironment userCourseEnv) { + if (moduleConfiguration.getBooleanSafe(SurveyCourseNode.CONFIG_KEY_EXECUTION_BY_GUEST) + && guestOnly) { + return true; + } + + if (moduleConfiguration.getBooleanSafe(SurveyCourseNode.CONFIG_KEY_EXECUTION_BY_PARTICIPANT) + && userCourseEnv.isParticipant()) { + return true; + } + + if (moduleConfiguration.getBooleanSafe(SurveyCourseNode.CONFIG_KEY_EXECUTION_BY_COACH) + && userCourseEnv.isCoach()) { + return true; + } + + if (moduleConfiguration.getBooleanSafe(SurveyCourseNode.CONFIG_KEY_EXECUTION_BY_OWNER) + && userCourseEnv.isAdmin()) { + return true; + } + + return false; + } + + private boolean hasReportRole(ModuleConfiguration moduleConfiguration, UserCourseEnvironment userCourseEnv) { + if (moduleConfiguration.getBooleanSafe(SurveyCourseNode.CONFIG_KEY_REPORT_FOR_GUEST) + && guestOnly) { + return true; + } + + if (moduleConfiguration.getBooleanSafe(SurveyCourseNode.CONFIG_KEY_REPORT_FOR_PARTICIPANT) + && userCourseEnv.isParticipant()) { + return true; + } + + if (moduleConfiguration.getBooleanSafe(SurveyCourseNode.CONFIG_KEY_REPORT_FOR_OWNER) + && userCourseEnv.isCoach()) { + return true; + } + + if (moduleConfiguration.getBooleanSafe(SurveyCourseNode.CONFIG_KEY_REPORT_FOR_OWNER) + && userCourseEnv.isAdmin()) { + return true; + } + + return false; + } + + boolean canParticipate() { + return isExecutor() && !courseReadOnly; + } + + boolean hasParticipated(EvaluationFormParticipation participation) { + return participation != null && EvaluationFormParticipationStatus.done.equals(participation.getStatus()); + } + + boolean canExecute(EvaluationFormParticipation participation) { + return participation != null && isExecutor() && !hasParticipated(participation); + } + + boolean canViewReporting(EvaluationFormParticipation participation) { + if (isReportViewer()) { + if (!isExecutor()) { + return true; + } + if (hasParticipated(participation)) { + return true; + } + if (isReadOnly()) { + return true; + } + } + return false; + } + + boolean isReadOnly() { + return courseReadOnly && isExecutor(); + } + + + +} diff --git a/src/main/java/org/olat/course/nodes/survey/_content/run.html b/src/main/java/org/olat/course/nodes/survey/_content/run.html index 8647d62994d91e145d3a898e093886e1ef5c8462..ee33cbd599f754eeee1c6fc2d827c1b104f1c1dd 100644 --- a/src/main/java/org/olat/course/nodes/survey/_content/run.html +++ b/src/main/java/org/olat/course/nodes/survey/_content/run.html @@ -1,6 +1,9 @@ -#if($r.available("reporting")) - $r.render("reporting") +#if($r.available("message")) + $r.render("message") #end #if($r.available("execution")) $r.render("execution") +#end +#if($r.available("reporting")) + $r.render("reporting") #end \ No newline at end of file diff --git a/src/main/java/org/olat/course/nodes/survey/_i18n/LocalStrings_de.properties b/src/main/java/org/olat/course/nodes/survey/_i18n/LocalStrings_de.properties index bd6a5cfb4db1813050d33a8b152d78154738dd92..35e847a2ee65b33afa87ace8ec6515038bf71d8f 100644 --- a/src/main/java/org/olat/course/nodes/survey/_i18n/LocalStrings_de.properties +++ b/src/main/java/org/olat/course/nodes/survey/_i18n/LocalStrings_de.properties @@ -3,15 +3,29 @@ course.node.link.text=Umfrage edit.choose=W\u00E4hlen, erstellen oder importieren edit.choose.questionnaire=Fragebogen ausw\u00E4hlen edit.edit=Bearbeiten +edit.execution=Teilnahme druch +edit.execution.by.owner=Besitzer +edit.execution.by.coach=Betreuer +edit.execution.by.participant=Teilnehmer +edit.execution.by.guest=G\u00E4ste edit.preview=Vorschau edit.questionnaire=Fragebogen edit.questionnaire.link={0} edit.questionnaire.not.choosen=Kein Fragebogen ausw\u00E4hlt edit.replace=Ersetzen +edit.report=Resultate sichtbar f\u00fcr +edit.report.for.owner=Besitzer +edit.report.for.coach=Betreuer +edit.report.for.participant=Teilnehmer +edit.report.for.guest=G\u00E4ste edit.title=Umfrage error.repo.no.key.long=F\u00FCr "{0}" muss in der Konfiguration ein Fragebogen im Reiter "Umfrage" ausgew\u00E4hlt werden. error.repo.no.key.short=Es ist kein Fragebogen ausw\u00E4hlt. error.repo.entry.missing=Der Fragebogen, welchen Sie anzeigen m\u00F6chten, wurde in der Zwischenzeit aus der Ablage der Lernressourcen gel\u00F6scht. error.repo.entry.not.replaceable=Der Fragebogen kann nicht mehr ge\u00E4ndert werden. pane.tab.accessibility=Zugang -pane.tab.config=Umfrage \ No newline at end of file +pane.tab.config=Umfrage +run.participation.done.message=Sie haben den Fragebogen bereits ausgef\u00fcllt. Vielen Dank f\u00fcr Ihre Teilnahme. +run.participation.done.title=Fragebogen ausgef\u00fcllt +run.noaccess.message=Dieser Teil des Kurses ist f\u00FCr Sie nicht zug\u00E4nglich. +run.noaccess.title=Kein Zugang \ No newline at end of file diff --git a/src/main/java/org/olat/course/nodes/survey/_i18n/LocalStrings_en.properties b/src/main/java/org/olat/course/nodes/survey/_i18n/LocalStrings_en.properties index a80fcb80bb8e86d0d96d880ae14d6cdd2eaf3db6..66e5bdde1d06c4569c0c1061f0b0807a5101ac5b 100644 --- a/src/main/java/org/olat/course/nodes/survey/_i18n/LocalStrings_en.properties +++ b/src/main/java/org/olat/course/nodes/survey/_i18n/LocalStrings_en.properties @@ -3,15 +3,29 @@ course.node.link.text=Survey edit.choose=Choose, create or import edit.choose.questionnaire=Choose questionnaire edit.edit=Edit +edit.execution=Participation by +edit.execution.by.owner=Owners +edit.execution.by.coach=Coaches +edit.execution.by.participant=Participants +edit.execution.by.guest=Guests edit.preview=Preview edit.questionnaire=Questionnaire edit.questionnaire.link={0} edit.questionnaire.not.choosen=No questionnaire chosen edit.replace=Replace +edit.report=Results visible for +edit.report.for.owner=Owners +edit.report.for.coach=Coaches +edit.report.for.participant=Participants +edit.report.for.guest=Guests edit.title=Survey error.repo.no.key.long=For "{0}" you have to select a questionnaire in the tab "Survey" within the configuration section. error.repo.no.key.short=No questionnaire chosen. error.repo.entry.missing=This survey has been deleted in the meantime within the storage folder of learning resources. error.repo.entry.not.replaceable=The questionnaire can not be replaced anymore. pane.tab.accessibility=Access -pane.tab.config=Survey \ No newline at end of file +pane.tab.config=Survey +run.participation.done.message=You have already finished this survey. Thank you or your participation. +run.participation.done.title=Survey finished +run.noaccess.message=This part of the course is not accessible for you. +run.noaccess.title=No access \ No newline at end of file diff --git a/src/main/java/org/olat/modules/forms/EvaluationFormManager.java b/src/main/java/org/olat/modules/forms/EvaluationFormManager.java index a41fc14f1ae00c8cfc5838b8ee618776c68d66cb..937f6f336ad820a95cf7c1d506b08a3b9c515914 100644 --- a/src/main/java/org/olat/modules/forms/EvaluationFormManager.java +++ b/src/main/java/org/olat/modules/forms/EvaluationFormManager.java @@ -62,6 +62,8 @@ public interface EvaluationFormManager { public EvaluationFormParticipation createParticipation(EvaluationFormSurvey survey, Identity executor); public EvaluationFormParticipation createParticipation(EvaluationFormSurvey survey, EvaluationFormParticipationIdentifier identifier); + + public EvaluationFormParticipation updateParticipation(EvaluationFormParticipation participation); public EvaluationFormParticipation loadParticipationByExecutor(EvaluationFormSurvey survey, IdentityRef executor); @@ -82,7 +84,7 @@ public interface EvaluationFormManager { public EvaluationFormSession createSession(EvaluationFormParticipation participation); - public EvaluationFormSession loadSessionByParticipation(EvaluationFormParticipation participation); + public EvaluationFormSession loadSessionByParticipation(EvaluationFormParticipation EvaluationFormParticipation); public EvaluationFormSession finishSession(EvaluationFormSession session); diff --git a/src/main/java/org/olat/modules/forms/EvaluationFormParticipation.java b/src/main/java/org/olat/modules/forms/EvaluationFormParticipation.java index 499c82d0d435e32ca33725c35720413538e9fa78..f1d35be642401b640edc5c14e6c5dab57c4f6da0 100644 --- a/src/main/java/org/olat/modules/forms/EvaluationFormParticipation.java +++ b/src/main/java/org/olat/modules/forms/EvaluationFormParticipation.java @@ -58,6 +58,8 @@ public interface EvaluationFormParticipation extends CreateInfo, ModifiedInfo { * @return whether it is an anonymous participation or not */ public boolean isAnonymous(); + + public void setAnonymous(boolean anonymous); /** * The executor of the participation. A participation must not have an executor. diff --git a/src/main/java/org/olat/modules/forms/manager/EvaluationFormManagerImpl.java b/src/main/java/org/olat/modules/forms/manager/EvaluationFormManagerImpl.java index 31c46161ff6d93d48c0404137e5932cf997d2802..cb7b8ac46d9f92e979ee88d0a476b7c8b11dfe8a 100644 --- a/src/main/java/org/olat/modules/forms/manager/EvaluationFormManagerImpl.java +++ b/src/main/java/org/olat/modules/forms/manager/EvaluationFormManagerImpl.java @@ -105,6 +105,11 @@ public class EvaluationFormManagerImpl implements EvaluationFormManager { return evaluationFormParticipationDao.createParticipation(survey, identifier, false, null); } + @Override + public EvaluationFormParticipation updateParticipation(EvaluationFormParticipation participation) { + return evaluationFormParticipationDao.updateParticipation(participation); + } + @Override public EvaluationFormParticipation loadParticipationByExecutor(EvaluationFormSurvey survey, IdentityRef executor) { return evaluationFormParticipationDao.loadByExecutor(survey, executor); @@ -143,8 +148,16 @@ public class EvaluationFormManagerImpl implements EvaluationFormManager { @Override public EvaluationFormSession finishSession(EvaluationFormSession session) { - evaluationFormParticipationDao.changeStatus(session.getParticipation(), EvaluationFormParticipationStatus.done); - return evaluationFormSessionDao.changeStatusOfSession(session, EvaluationFormSessionStatus.done); + EvaluationFormSession finishedSesssion = session; + EvaluationFormParticipation participation = session.getParticipation(); + if (participation != null) { + evaluationFormParticipationDao.changeStatus(session.getParticipation(), EvaluationFormParticipationStatus.done); + if (participation.isAnonymous()) { + finishedSesssion = evaluationFormSessionDao.makeAnonymous(session); + } + } + finishedSesssion = evaluationFormSessionDao.changeStatus(finishedSesssion, EvaluationFormSessionStatus.done); + return finishedSesssion; } @Override diff --git a/src/main/java/org/olat/modules/forms/manager/EvaluationFormParticipationDAO.java b/src/main/java/org/olat/modules/forms/manager/EvaluationFormParticipationDAO.java index a4cdb2a7aab6fc1fc5a6aff86688dabf8daad279..b2bffd6ee165008c3a3157102d818ab781962f32 100644 --- a/src/main/java/org/olat/modules/forms/manager/EvaluationFormParticipationDAO.java +++ b/src/main/java/org/olat/modules/forms/manager/EvaluationFormParticipationDAO.java @@ -70,7 +70,15 @@ class EvaluationFormParticipationDAO { return participation; } - private EvaluationFormParticipation update(EvaluationFormParticipation participationImpl) { + EvaluationFormParticipation updateParticipation(EvaluationFormParticipation participation) { + if (participation instanceof EvaluationFormParticipationImpl) { + EvaluationFormParticipationImpl participationImpl = (EvaluationFormParticipationImpl) participation; + return update(participationImpl); + } + return participation; + } + + private EvaluationFormParticipation update(EvaluationFormParticipationImpl participationImpl) { participationImpl.setLastModified(new Date()); return dbInstance.getCurrentEntityManager().merge(participationImpl); } diff --git a/src/main/java/org/olat/modules/forms/manager/EvaluationFormSessionDAO.java b/src/main/java/org/olat/modules/forms/manager/EvaluationFormSessionDAO.java index 15beb640e037d309b4d8845da86ceee15eb08174..b6bc82d55a537ca060cf5e5d36ddd58a373bfd3f 100644 --- a/src/main/java/org/olat/modules/forms/manager/EvaluationFormSessionDAO.java +++ b/src/main/java/org/olat/modules/forms/manager/EvaluationFormSessionDAO.java @@ -25,7 +25,6 @@ import java.util.List; import org.olat.basesecurity.IdentityRef; import org.olat.core.commons.persistence.DB; import org.olat.core.id.Identity; -import org.olat.core.id.OLATResourceable; import org.olat.modules.forms.EvaluationFormParticipation; import org.olat.modules.forms.EvaluationFormSession; import org.olat.modules.forms.EvaluationFormSessionStatus; @@ -59,17 +58,6 @@ public class EvaluationFormSessionDAO { dbInstance.getCurrentEntityManager().persist(session); return session; } - - - public EvaluationFormSession createSession(OLATResourceable ores, String subIdent, Identity identity, - RepositoryEntry formEntry) { - EvaluationFormSessionImpl session = createSession(identity, formEntry); - session.setResName(ores.getResourceableTypeName()); - session.setResId(ores.getResourceableId()); - session.setResSubident(subIdent); - dbInstance.getCurrentEntityManager().persist(session); - return session; - } public EvaluationFormSession createSessionForPortfolio(Identity identity, PageBody body, RepositoryEntry formEntry) { EvaluationFormSessionImpl session = createSession(identity, formEntry); @@ -102,7 +90,21 @@ public class EvaluationFormSessionDAO { return sessions == null || sessions.isEmpty() ? null : sessions.get(0); } - public boolean hasSessions(EvaluationFormSurvey survey) { + EvaluationFormSession makeAnonymous(EvaluationFormSession session) { + if (session instanceof EvaluationFormSessionImpl) { + EvaluationFormSessionImpl sessionImpl = (EvaluationFormSessionImpl) session; + sessionImpl.setParticipation(null); + return update(sessionImpl); + } + return session; + } + + private EvaluationFormSessionImpl update(EvaluationFormSessionImpl sessionImpl) { + sessionImpl.setLastModified(new Date()); + return dbInstance.getCurrentEntityManager().merge(sessionImpl); + } + + boolean hasSessions(EvaluationFormSurvey survey) { if (survey == null) return false; StringBuilder sb = new StringBuilder(); @@ -143,10 +145,10 @@ public class EvaluationFormSessionDAO { public EvaluationFormSession changeStatusOfSessionForPortfolioEvaluation(IdentityRef identity, PageBody anchor, EvaluationFormSessionStatus status) { EvaluationFormSession session = getSessionForPortfolioEvaluation(identity, anchor); - return changeStatusOfSession(session, status); + return changeStatus(session, status); } - public EvaluationFormSession changeStatusOfSession(EvaluationFormSession session, EvaluationFormSessionStatus newStatus) { + public EvaluationFormSession changeStatus(EvaluationFormSession session, EvaluationFormSessionStatus newStatus) { if(session != null) { if(newStatus == EvaluationFormSessionStatus.done && session.getEvaluationFormSessionStatus() != EvaluationFormSessionStatus.done) { ((EvaluationFormSessionImpl)session).setSubmissionDate(new Date()); diff --git a/src/main/java/org/olat/modules/forms/model/jpa/EvaluationFormSessionImpl.java b/src/main/java/org/olat/modules/forms/model/jpa/EvaluationFormSessionImpl.java index 326c7dcf665d1f6480f79b24ab82540cb76f7c75..de13d9b653e2a7d1ea4307ce6e5491e1c9f217e5 100644 --- a/src/main/java/org/olat/modules/forms/model/jpa/EvaluationFormSessionImpl.java +++ b/src/main/java/org/olat/modules/forms/model/jpa/EvaluationFormSessionImpl.java @@ -86,13 +86,6 @@ public class EvaluationFormSessionImpl implements EvaluationFormSession, Persist @JoinColumn(name="fk_participation", nullable=true, insertable=true, updatable=false) private EvaluationFormParticipation participation; - @Column(name="e_resname", nullable=true, insertable=true, updatable=false) - private String resName; - @Column(name="e_resid", nullable=true, insertable=true, updatable=false) - private Long resId; - @Column(name="e_sub_ident", nullable=true, insertable=true, updatable=false) - private String resSubident; - @ManyToOne(targetEntity=IdentityImpl.class,fetch=FetchType.LAZY,optional=true) @JoinColumn(name="fk_identity", nullable=true, insertable=true, updatable=false) private Identity identity; @@ -196,30 +189,6 @@ public class EvaluationFormSessionImpl implements EvaluationFormSession, Persist this.participation = participation; } - public String getResName() { - return resName; - } - - public void setResName(String resName) { - this.resName = resName; - } - - public Long getResId() { - return resId; - } - - public void setResId(Long resId) { - this.resId = resId; - } - - public String getResSubident() { - return resSubident; - } - - public void setResSubident(String resSubident) { - this.resSubident = resSubident; - } - @Override public Identity getIdentity() { return identity; diff --git a/src/test/java/org/olat/modules/forms/manager/EvaluationFormMangerImplTest.java b/src/test/java/org/olat/modules/forms/manager/EvaluationFormMangerImplTest.java new file mode 100644 index 0000000000000000000000000000000000000000..d1d12fe1b3fcffb6b62651bf1f89fd281ff25023 --- /dev/null +++ b/src/test/java/org/olat/modules/forms/manager/EvaluationFormMangerImplTest.java @@ -0,0 +1,130 @@ +/** + * <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.modules.forms.manager; + +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +import org.junit.Before; +import org.junit.Test; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.olat.modules.forms.EvaluationFormParticipation; +import org.olat.modules.forms.EvaluationFormParticipationStatus; +import org.olat.modules.forms.EvaluationFormSession; +import org.olat.modules.forms.EvaluationFormSessionStatus; +import org.olat.modules.forms.EvaluationFormSurvey; +import org.olat.repository.RepositoryEntry; + +/** + * + * Initial date: 03.05.2018<br> + * @author uhensler, urs.hensler@frentix.com, http://www.frentix.com + * + */ +public class EvaluationFormMangerImplTest { + + @Mock + private EvaluationFormSurveyDAO surveyDaoMock; + @Mock + private EvaluationFormParticipationDAO particopationDaoMock; + @Mock + private EvaluationFormSessionDAO sessionDaoMock; + + + @InjectMocks + private EvaluationFormManagerImpl sut; + + @Before + public void setUp() { + MockitoAnnotations.initMocks(this); + } + + @Test + public void shouldUpdateFormOfSurveyIfItNoSessions() { + EvaluationFormSurvey surveyMock = mock(EvaluationFormSurvey.class); + RepositoryEntry formEntryMock = mock(RepositoryEntry.class); + when(sessionDaoMock.hasSessions(surveyMock)).thenReturn(Boolean.FALSE); + + sut.updateSurveyForm(surveyMock, formEntryMock); + + verify(surveyDaoMock).updateForm(surveyMock, formEntryMock); + } + + @Test + public void shouldNotUpdateFormOfSurveyIfItHasSessions() { + EvaluationFormSurvey surveyMock = mock(EvaluationFormSurvey.class); + RepositoryEntry formEntryMock = mock(RepositoryEntry.class); + when(sessionDaoMock.hasSessions(surveyMock)).thenReturn(Boolean.TRUE); + + sut.updateSurveyForm(surveyMock, formEntryMock); + + verify(surveyDaoMock, never()).updateForm(surveyMock, formEntryMock); + } + + + @Test + public void shouldMakeParticipationDoneWhenFinishingSession() { + EvaluationFormSession sessionMock = mock(EvaluationFormSession.class); + EvaluationFormParticipation participationMock = mock(EvaluationFormParticipation.class); + when(sessionMock.getParticipation()).thenReturn(participationMock); + + sut.finishSession(sessionMock); + + verify(particopationDaoMock).changeStatus(participationMock, EvaluationFormParticipationStatus.done); + } + + @Test + public void shouldMakeSessionDoneWhenFinishingSession() { + EvaluationFormSession sessionMock = mock(EvaluationFormSession.class); + + sut.finishSession(sessionMock); + + verify(sessionDaoMock).changeStatus(sessionMock, EvaluationFormSessionStatus.done); + } + + @Test + public void shouldMakeSessionAnonymousWhenFinishingSessionIfParticipationIsAnonymous() { + EvaluationFormSession sessionMock = mock(EvaluationFormSession.class); + EvaluationFormParticipation participationMock = mock(EvaluationFormParticipation.class); + when(participationMock.isAnonymous()).thenReturn(Boolean.TRUE); + when(sessionMock.getParticipation()).thenReturn(participationMock); + + sut.finishSession(sessionMock); + + verify(sessionDaoMock).makeAnonymous(sessionMock); + } + + @Test + public void shouldMakeSessionNotAnonymousWhenFinishingSessionIfParticipationIsNotAnonymous() { + EvaluationFormSession sessionMock = mock(EvaluationFormSession.class); + EvaluationFormParticipation participationMock = mock(EvaluationFormParticipation.class); + when(participationMock.isAnonymous()).thenReturn(Boolean.FALSE); + when(sessionMock.getParticipation()).thenReturn(participationMock); + + sut.finishSession(sessionMock); + + verify(sessionDaoMock, never()).makeAnonymous(sessionMock); + } + +} diff --git a/src/test/java/org/olat/modules/forms/manager/EvaluationFormParticipationDAOTest.java b/src/test/java/org/olat/modules/forms/manager/EvaluationFormParticipationDAOTest.java index fa61f9b8b8844a339b3f100850ea20ae20ba8eb2..79ccfcd374713610ec8842650b48b4a8df4bc982 100644 --- a/src/test/java/org/olat/modules/forms/manager/EvaluationFormParticipationDAOTest.java +++ b/src/test/java/org/olat/modules/forms/manager/EvaluationFormParticipationDAOTest.java @@ -96,7 +96,20 @@ public class EvaluationFormParticipationDAOTest extends OlatTestCase { assertThat(loadedParticipation.getStatus()).isEqualTo(newStatus); } - + + @Test + public void shouldUpdateParticipation() { + String identifierKey = UUID.randomUUID().toString(); + EvaluationFormParticipationIdentifier identifier = new EvaluationFormParticipationIdentifier(IDENTIFIER_TYPE, + identifierKey); + EvaluationFormParticipation participation = sut.createParticipation(evaTestHelper.createSurvey(), identifier, false, null); + dbInstance.commit(); + + participation.setAnonymous(true); + EvaluationFormParticipation updateedParticipation = sut.updateParticipation(participation); + + assertThat(updateedParticipation.isAnonymous()).isTrue(); + } @Test public void shouldLoadBySurveyAndExecutor() { diff --git a/src/test/java/org/olat/modules/forms/manager/EvaluationFormSessionDAOTest.java b/src/test/java/org/olat/modules/forms/manager/EvaluationFormSessionDAOTest.java index 3390af3e19a2c58573a331a907a8cae5fbf5b9ed..9d934b52d2065a7268df05e3bd391b2bf36682c6 100644 --- a/src/test/java/org/olat/modules/forms/manager/EvaluationFormSessionDAOTest.java +++ b/src/test/java/org/olat/modules/forms/manager/EvaluationFormSessionDAOTest.java @@ -21,14 +21,11 @@ package org.olat.modules.forms.manager; import static org.assertj.core.api.Assertions.assertThat; -import java.util.UUID; - import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.olat.core.commons.persistence.DB; import org.olat.core.id.Identity; -import org.olat.core.id.OLATResourceable; import org.olat.modules.forms.EvaluationFormParticipation; import org.olat.modules.forms.EvaluationFormSession; import org.olat.modules.forms.EvaluationFormSurvey; @@ -83,22 +80,17 @@ public class EvaluationFormSessionDAOTest extends OlatTestCase { assertThat(session.getSurvey()).isEqualTo(participation.getSurvey()); } - //TODO uh remove @Test - public void shouldCreateSessionLegacy() { - OLATResourceable ores = JunitTestHelper.createRandomResource(); - String subIdent = "sub"; - Identity identity = JunitTestHelper.createAndPersistIdentityAsRndUser(UUID.randomUUID().toString()); - RepositoryEntry formEntry = evaTestHelper.createFormEntry(); + public void shouldMakeSessionAnonymous() { + EvaluationFormParticipation participation = evaTestHelper.createParticipation(); + EvaluationFormSession session = evaluationFormSessionDao.createSession(participation); + dbInstance.commit(); - EvaluationFormSession session = evaluationFormSessionDao.createSession(ores, subIdent, identity, formEntry); + EvaluationFormSession anonymousSession = evaluationFormSessionDao.makeAnonymous(session); - assertThat(session).isNotNull(); - assertThat(session.getKey()).isNotNull(); - assertThat(session.getCreationDate()).isNotNull(); - assertThat(session.getLastModified()).isNotNull(); - assertThat(session.getIdentity()).isEqualTo(identity); + assertThat(anonymousSession.getParticipation()).isNull(); } + @Test public void shouldLoadByParticipation() { diff --git a/src/test/java/org/olat/test/AllTestsJunit4.java b/src/test/java/org/olat/test/AllTestsJunit4.java index abda7841a0a0d35293f2305b4eebce7c874cf9ed..2b8c524dfe76033f4d6e3208c89380697d496d7b 100644 --- a/src/test/java/org/olat/test/AllTestsJunit4.java +++ b/src/test/java/org/olat/test/AllTestsJunit4.java @@ -368,6 +368,7 @@ import org.junit.runners.Suite; org.olat.modules.card2brain.manager.Card2BrainManagerImplTest.class, org.olat.modules.edubase.manager.EdubaseManagerImplTest.class, org.olat.modules.fo.WordCountTest.class, + org.olat.modules.forms.manager.EvaluationFormMangerImplTest.class, org.olat.modules.forms.model.xml.ScaleTypeTest.class, org.olat.modules.qpool.manager.QuestionPoolServiceImplTest.class, org.olat.modules.qpool.manager.QuestionPoolUserDataDeletableTest.class,