Skip to content
Snippets Groups Projects
Commit ec7404ea authored by uhensler's avatar uhensler
Browse files

Merge branch 'OpenOLAT_13.2'

Conflicts:
	src/main/java/org/olat/core/dispatcher/mapper/MapperDispatcher.java
	src/main/java/org/olat/modules/forms/model/jpa/RubricStatisticImpl.java
	src/test/java/org/olat/selenium/page/qti/QTI21Page.java
parents a1dcb4ca a9e67d98
No related branches found
No related tags found
No related merge requests found
...@@ -31,13 +31,13 @@ import java.io.IOException; ...@@ -31,13 +31,13 @@ import java.io.IOException;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import org.apache.logging.log4j.Logger;
import org.olat.core.CoreSpringFactory; import org.olat.core.CoreSpringFactory;
import org.olat.core.commons.persistence.DBFactory; import org.olat.core.commons.persistence.DBFactory;
import org.olat.core.dispatcher.Dispatcher; import org.olat.core.dispatcher.Dispatcher;
import org.olat.core.dispatcher.DispatcherModule; import org.olat.core.dispatcher.DispatcherModule;
import org.olat.core.gui.media.MediaResource; import org.olat.core.gui.media.MediaResource;
import org.olat.core.gui.media.ServletUtil; import org.olat.core.gui.media.ServletUtil;
import org.apache.logging.log4j.Logger;
import org.olat.core.logging.Tracing; import org.olat.core.logging.Tracing;
import org.olat.core.util.UserSession; import org.olat.core.util.UserSession;
import org.olat.core.util.session.UserSessionManager; import org.olat.core.util.session.UserSessionManager;
...@@ -91,10 +91,11 @@ public class MapperDispatcher implements Dispatcher { ...@@ -91,10 +91,11 @@ public class MapperDispatcher implements Dispatcher {
// e.g. non-cacheable: 23423 // e.g. non-cacheable: 23423
// e.g. cacheable: my.mapper.path // e.g. cacheable: my.mapper.path
UserSession usess = CoreSpringFactory.getImpl(UserSessionManager.class).getUserSession(hreq); UserSession usess = CoreSpringFactory.getImpl(UserSessionManager.class).getUserSession(hreq);
Mapper m = CoreSpringFactory.getImpl(MapperService.class).getMapperById(usess, smappath); MapperService mapperService = CoreSpringFactory.getImpl(MapperService.class);
Mapper m = mapperService.getMapperById(usess, smappath);
if (m == null) { if (m == null) {
//an anonymous mapper? //an anonymous mapper?
m = CoreSpringFactory.getImpl(MapperService.class).getMapperById(null, smappath); m = mapperService.getMapperById(null, smappath);
if(m == null) { if(m == null) {
log.warn("Call to mapped resource, but mapper does not exist for path::" + smappath); log.warn("Call to mapped resource, but mapper does not exist for path::" + smappath);
DispatcherModule.sendNotFound(pathInfo, hres); DispatcherModule.sendNotFound(pathInfo, hres);
......
...@@ -437,14 +437,21 @@ public class Form { ...@@ -437,14 +437,21 @@ public class Form {
} }
private final void submit(UserRequest ureq, Event validationOkEvent) { private final void submit(UserRequest ureq, Event validationOkEvent) {
boolean isValid = validate(ureq);
formWrapperComponent.fireValidation(ureq, isValid, validationOkEvent);
isValidAndSubmitted = isValid;
hasAlreadyFired = true;
}
public boolean validate(UserRequest ureq) {
ValidatingFormComponentVisitor vfcv = new ValidatingFormComponentVisitor(); ValidatingFormComponentVisitor vfcv = new ValidatingFormComponentVisitor();
FormComponentTraverser ct = new FormComponentTraverser(vfcv, formLayout, false); FormComponentTraverser ct = new FormComponentTraverser(vfcv, formLayout, false);
ct.visitAll(ureq); ct.visitAll(ureq);
// validate all form elements and gather validation status // validate all form elements and gather validation status
ValidationStatus[] status = vfcv.getStatus(); ValidationStatus[] status = vfcv.getStatus();
//
boolean isValid = status == null || status.length == 0; boolean isValid = status == null || status.length == 0;
// let the businesslogic validate this is implemented by the outside listener // let the business logic validate this is implemented by the outside listener
for (Iterator<FormBasicController> iterator = formListeners.iterator(); iterator.hasNext();) { for (Iterator<FormBasicController> iterator = formListeners.iterator(); iterator.hasNext();) {
FormBasicController fbc = iterator.next(); FormBasicController fbc = iterator.next();
...@@ -452,10 +459,7 @@ public class Form { ...@@ -452,10 +459,7 @@ public class Form {
//let further validate even if one fails. //let further validate even if one fails.
isValid = fbc.validateFormLogic(ureq) && isValid; isValid = fbc.validateFormLogic(ureq) && isValid;
} }
return isValid;
formWrapperComponent.fireValidation(ureq, isValid, validationOkEvent);
isValidAndSubmitted = isValid;
hasAlreadyFired = true;
} }
......
...@@ -21,6 +21,8 @@ ...@@ -21,6 +21,8 @@
package org.olat.course.editor; package org.olat.course.editor;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -130,7 +132,10 @@ public class MultiSPController extends FormBasicController { ...@@ -130,7 +132,10 @@ public class MultiSPController extends FormBasicController {
if(item instanceof VFSContainer) { if(item instanceof VFSContainer) {
VFSContainer container = (VFSContainer)item; VFSContainer container = (VFSContainer)item;
for(VFSItem subItem:container.getItems(new MultiSPVFSItemFilter())) { List<VFSItem> subItems = container.getItems(new MultiSPVFSItemFilter());
Collections.sort(subItems, new VFSItemNameComparator());
for(VFSItem subItem:subItems) {
MultipleSelectionElement sel = initTreeRec(level + 1, subItem, layoutcont); MultipleSelectionElement sel = initTreeRec(level + 1, subItem, layoutcont);
node.getChildren().add(sel); node.getChildren().add(sel);
} }
...@@ -233,7 +238,8 @@ public class MultiSPController extends FormBasicController { ...@@ -233,7 +238,8 @@ public class MultiSPController extends FormBasicController {
} }
//recurse //recurse
for(MultipleSelectionElement childElement:node.getChildren()) { List<MultipleSelectionElement> childElements = node.getChildren();
for(MultipleSelectionElement childElement:childElements) {
create(childElement, course, parentNode); create(childElement, course, parentNode);
} }
} }
...@@ -336,11 +342,29 @@ public class MultiSPController extends FormBasicController { ...@@ -336,11 +342,29 @@ public class MultiSPController extends FormBasicController {
} }
} }
public class MultiSPVFSItemFilter implements VFSItemFilter { public static class MultiSPVFSItemFilter implements VFSItemFilter {
@Override @Override
public boolean accept(VFSItem vfsItem) { public boolean accept(VFSItem vfsItem) {
String name = vfsItem.getName(); String name = vfsItem.getName();
return !name.startsWith("."); return !name.startsWith(".");
} }
} }
public static class VFSItemNameComparator implements Comparator<VFSItem> {
@Override
public int compare(VFSItem o1, VFSItem o2) {
if(o1 == null && o2 == null) return 0;
if(o1 == null) return -1;
if(o2 == null) return 1;
String n1 = o1.getName();
String n2 = o2.getName();
if(n1 == null && n2 == null) return 0;
if(n1 == null) return -1;
if(n2 == null) return 1;
return n1.compareToIgnoreCase(n2);
}
}
} }
\ No newline at end of file
...@@ -518,6 +518,14 @@ ...@@ -518,6 +518,14 @@
jEl.css('height', jEl.attr('height') + "px"); jEl.css('height', jEl.attr('height') + "px");
} }
}); });
jQuery('#collapse_${itemResult.interactionResults.solutionFormItem.name} div.o_oo_hotcontainer>div').each(function(index, el) {
var jEl = jQuery(el);
if(jEl.css('height') == '0px') {
var containerEl = jEl.closest("div.o_oo_hotcontainer");
jEl.css('height', containerEl.css('height'));
jEl.css('background-size', containerEl.css('width') + " " + containerEl.css('height'));
}
});
}) })
}); });
/* ]]> */ /* ]]> */
......
...@@ -181,13 +181,17 @@ public class RubricStatisticImpl implements RubricStatistic { ...@@ -181,13 +181,17 @@ public class RubricStatisticImpl implements RubricStatistic {
Double mean = sumAverage.getAverage(); Double mean = sumAverage.getAverage();
if (mean == null) return null; if (mean == null) return null;
List<Double> scaledValues = getScaledValues(stepCounts);
if (scaledValues.size() < 2) return null;
double temp = 0; double temp = 0;
for(double a: scaledValues) int size = 0;
temp += (a-mean)*(a-mean); for (int step = 1; step <= rubric.getSteps(); step++) {
return temp/(scaledValues.size() - 1); double value = rubric.getScaleType().getStepValue(rubric.getSteps(), step, rubric.getWeight());
int count = stepCounts.get(step - 1).intValue();
for (int i = 0; i < count; i++) {
temp += (value-mean)*(value-mean);
size++;
}
}
return size > 2? temp/(size - 1): null;
} }
private Double getStdDev(List<Long> stepCounts) { private Double getStdDev(List<Long> stepCounts) {
...@@ -197,21 +201,6 @@ public class RubricStatisticImpl implements RubricStatistic { ...@@ -197,21 +201,6 @@ public class RubricStatisticImpl implements RubricStatistic {
return Math.sqrt(getVariance(stepCounts)); return Math.sqrt(getVariance(stepCounts));
} }
private List<Double> getScaledValues(List<Long> stepCounts) {
List<Double> scaledValues = new ArrayList<>();
for (int step = 1; step <= rubric.getSteps(); step++) {
Long count = stepCounts.get(step - 1);
if (count != null) {
double stepValue = rubric.getScaleType().getStepValue(rubric.getSteps(), step, rubric.getWeight());
for (int i = 0; i < count; i++) {
double scaledValue = stepValue * step;
scaledValues.add(Double.valueOf(scaledValue));
}
}
}
return scaledValues;
}
private void calculateTotalStatistics() { private void calculateTotalStatistics() {
Long numberOfNoResponses = countedNoResponses.stream().mapToLong(CalculatedLong::getValue).sum(); Long numberOfNoResponses = countedNoResponses.stream().mapToLong(CalculatedLong::getValue).sum();
List<Long> totalStepCounts = getTotalStepCounts(); List<Long> totalStepCounts = getTotalStepCounts();
......
...@@ -92,8 +92,6 @@ public class EvaluationFormExecutionController extends FormBasicController imple ...@@ -92,8 +92,6 @@ public class EvaluationFormExecutionController extends FormBasicController imple
private boolean readOnly; private boolean readOnly;
private boolean showDoneButton; private boolean showDoneButton;
private boolean immediateSave = false;
private EvaluationFormSession session; private EvaluationFormSession session;
private final EvaluationFormResponses responses; private final EvaluationFormResponses responses;
...@@ -268,11 +266,9 @@ public class EvaluationFormExecutionController extends FormBasicController imple ...@@ -268,11 +266,9 @@ public class EvaluationFormExecutionController extends FormBasicController imple
@Override @Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) { protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
if (saveLink == source) { if (saveLink == source) {
immediateSave = true; if(mainForm.validate(ureq)) {
mainForm.submit(ureq); doSaveResponses();
} else if (doneLink == source) { }
immediateSave = false;
mainForm.submit(ureq);
} }
super.formInnerEvent(ureq, source, event); super.formInnerEvent(ureq, source, event);
} }
...@@ -290,7 +286,7 @@ public class EvaluationFormExecutionController extends FormBasicController imple ...@@ -290,7 +286,7 @@ public class EvaluationFormExecutionController extends FormBasicController imple
@Override @Override
protected void formOK(UserRequest ureq) { protected void formOK(UserRequest ureq) {
boolean responsesSaved = doSaveResponses(); boolean responsesSaved = doSaveResponses();
if (!immediateSave && responsesSaved) { if (responsesSaved) {
doConfirmDone(ureq); doConfirmDone(ureq);
} }
} }
...@@ -340,7 +336,7 @@ public class EvaluationFormExecutionController extends FormBasicController imple ...@@ -340,7 +336,7 @@ public class EvaluationFormExecutionController extends FormBasicController imple
List<ValidationMessage> messages = new ArrayList<>(); List<ValidationMessage> messages = new ArrayList<>();
validate(ureq, messages); validate(ureq, messages);
if (messages.size() > 0) { if (!messages.isEmpty()) {
for (ValidationMessage message : messages) { for (ValidationMessage message : messages) {
sb.append("<p class='o_warning'>").append(message.getMessage()).append("</p>"); sb.append("<p class='o_warning'>").append(message.getMessage()).append("</p>");
} }
......
...@@ -103,7 +103,7 @@ public class TextInputController extends FormBasicController implements Evaluati ...@@ -103,7 +103,7 @@ public class TextInputController extends FormBasicController implements Evaluati
@Override @Override
protected boolean validateFormLogic(UserRequest ureq) { protected boolean validateFormLogic(UserRequest ureq) {
boolean allOk = true; boolean allOk = super.validateFormLogic(ureq);
if (textInput.isNumeric()) { if (textInput.isNumeric()) {
String val = singleRowEl.getValue(); String val = singleRowEl.getValue();
...@@ -117,7 +117,7 @@ public class TextInputController extends FormBasicController implements Evaluati ...@@ -117,7 +117,7 @@ public class TextInputController extends FormBasicController implements Evaluati
} }
} }
return allOk & super.validateFormLogic(ureq); return allOk;
} }
@Override @Override
......
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