Skip to content
Snippets Groups Projects
Commit e991c5bb authored by srosse's avatar srosse
Browse files

OO-2396: fix rs if the start date is null, validate the start date if it is mandatory

parent 2939fcc0
No related branches found
No related tags found
No related merge requests found
...@@ -21,7 +21,6 @@ package org.olat.course.nodes.iq; ...@@ -21,7 +21,6 @@ package org.olat.course.nodes.iq;
import java.io.File; import java.io.File;
import java.net.URI; import java.net.URI;
import java.text.DateFormat;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicBoolean;
...@@ -250,10 +249,10 @@ public class QTI21AssessmentRunController extends BasicController implements Gen ...@@ -250,10 +249,10 @@ public class QTI21AssessmentRunController extends BasicController implements Gen
} else if(showResultsOnHomePage) { } else if(showResultsOnHomePage) {
Date startDate = config.getDateValue(IQEditController.CONFIG_KEY_RESULTS_START_DATE); Date startDate = config.getDateValue(IQEditController.CONFIG_KEY_RESULTS_START_DATE);
Date endDate = config.getDateValue(IQEditController.CONFIG_KEY_RESULTS_END_DATE); Date endDate = config.getDateValue(IQEditController.CONFIG_KEY_RESULTS_END_DATE);
String visibilityStartDate = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, ureq.getLocale()).format(startDate); String visibilityStartDate = Formatter.getInstance(getLocale()).formatDate(startDate);
String visibilityEndDate = "-"; String visibilityEndDate = "-";
if(endDate != null) { if(endDate != null) {
visibilityEndDate = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, ureq.getLocale()).format(endDate); visibilityEndDate = Formatter.getInstance(getLocale()).formatDate(endDate);
} }
String visibilityPeriod = getTranslator().translate("showResults.visibility", new String[] { visibilityStartDate, visibilityEndDate}); String visibilityPeriod = getTranslator().translate("showResults.visibility", new String[] { visibilityStartDate, visibilityEndDate});
mainVC.contextPut("visibilityPeriod", visibilityPeriod); mainVC.contextPut("visibilityPeriod", visibilityPeriod);
...@@ -272,9 +271,13 @@ public class QTI21AssessmentRunController extends BasicController implements Gen ...@@ -272,9 +271,13 @@ public class QTI21AssessmentRunController extends BasicController implements Gen
if(showResultsActive) { if(showResultsActive) {
Date startDate = modConfig.getDateValue(IQEditController.CONFIG_KEY_RESULTS_START_DATE); Date startDate = modConfig.getDateValue(IQEditController.CONFIG_KEY_RESULTS_START_DATE);
Date endDate = modConfig.getDateValue(IQEditController.CONFIG_KEY_RESULTS_END_DATE); Date endDate = modConfig.getDateValue(IQEditController.CONFIG_KEY_RESULTS_END_DATE);
Date currentDate = new Date(); if(startDate == null && endDate == null) {
if(startDate != null && currentDate.after(startDate) && (endDate == null || currentDate.before(endDate))) {
isVisible = true; isVisible = true;
} else {
Date currentDate = new Date();
if(startDate != null && currentDate.after(startDate) && (endDate == null || currentDate.before(endDate))) {
isVisible = true;
}
} }
} else { } else {
isVisible = true; isVisible = true;
......
...@@ -259,6 +259,14 @@ public class QTI21EditForm extends FormBasicController { ...@@ -259,6 +259,14 @@ public class QTI21EditForm extends FormBasicController {
allOk &= false; allOk &= false;
} }
} }
startDateElement.clearError();
if(showResultsDateDependentButton.isSelected(0)) {
if(startDateElement.getDate() == null) {
startDateElement.setErrorKey("form.legende.mandatory", null);
allOk &= false;
}
}
return allOk & super.validateFormLogic(ureq); return allOk & super.validateFormLogic(ureq);
} }
...@@ -318,8 +326,10 @@ public class QTI21EditForm extends FormBasicController { ...@@ -318,8 +326,10 @@ public class QTI21EditForm extends FormBasicController {
modConfig.setBooleanEntry(IQEditController.CONFIG_KEY_ENABLESCOREINFO, scoreInfo.isSelected(0)); modConfig.setBooleanEntry(IQEditController.CONFIG_KEY_ENABLESCOREINFO, scoreInfo.isSelected(0));
modConfig.setBooleanEntry(IQEditController.CONFIG_KEY_DATE_DEPENDENT_RESULTS, showResultsDateDependentButton.isSelected(0)); modConfig.setBooleanEntry(IQEditController.CONFIG_KEY_DATE_DEPENDENT_RESULTS, showResultsDateDependentButton.isSelected(0));
modConfig.setDateValue(IQEditController.CONFIG_KEY_RESULTS_START_DATE, startDateElement.getDate()); modConfig.setDateValue(IQEditController.CONFIG_KEY_RESULTS_START_DATE, startDateElement.getDate());
modConfig.setDateValue(IQEditController.CONFIG_KEY_RESULTS_END_DATE, endDateElement.getDate()); modConfig.setDateValue(IQEditController.CONFIG_KEY_RESULTS_END_DATE, endDateElement.getDate());
modConfig.setBooleanEntry(IQEditController.CONFIG_KEY_RESULT_ON_HOME_PAGE, showResultsOnHomePage.isSelected(0)); modConfig.setBooleanEntry(IQEditController.CONFIG_KEY_RESULT_ON_HOME_PAGE, showResultsOnHomePage.isSelected(0));
if(showResultsOnFinishEl.isAtLeastSelected(1) || showResultsOnHomePage.isSelected(0)) { if(showResultsOnFinishEl.isAtLeastSelected(1) || showResultsOnHomePage.isSelected(0)) {
......
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