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

OO-2343: validate null or empty directed pairs in match editor

parent e991c5bb
No related branches found
No related tags found
No related merge requests found
...@@ -202,27 +202,34 @@ public class MatchEditorController extends FormBasicController { ...@@ -202,27 +202,34 @@ public class MatchEditorController extends FormBasicController {
if(singleMultiEl.isOneSelected() && singleMultiEl.isSelected(0)) { if(singleMultiEl.isOneSelected() && singleMultiEl.isSelected(0)) {
Map<String,String> sourseTargetMap = new HashMap<>(); Map<String,String> sourseTargetMap = new HashMap<>();
String[] directedPairsIds = ureq.getHttpReq().getParameterValues("qtiworks_response_" + itemBuilder.getResponseIdentifier()); String[] directedPairsIds = ureq.getHttpReq().getParameterValues("qtiworks_response_" + itemBuilder.getResponseIdentifier());
for(String directedPairIds: directedPairsIds) { if(directedPairsIds == null || directedPairsIds.length == 0) {
String[] pairs = directedPairIds.split(" "); for(MatchWrapper sourceWrapper:sourceWrappers) {
String sourceId = pairs[0]; sourceWrapper.setErrorSingleChoice(true);
String targetId = pairs[1]; allOk &= false;
if(sourseTargetMap.containsKey(sourceId)) { }
for(MatchWrapper sourceWrapper:sourceWrappers) { } else {
if(sourceId.equals(sourceWrapper.getIdentifierString())) { for(String directedPairIds: directedPairsIds) {
sourceWrapper.setErrorSingleChoice(true); String[] pairs = directedPairIds.split(" ");
String sourceId = pairs[0];
String targetId = pairs[1];
if(sourseTargetMap.containsKey(sourceId)) {
for(MatchWrapper sourceWrapper:sourceWrappers) {
if(sourceId.equals(sourceWrapper.getIdentifierString())) {
sourceWrapper.setErrorSingleChoice(true);
}
} }
allOk &= false;
} else {
sourseTargetMap.put(sourceId, targetId);
} }
allOk &= false;
} else {
sourseTargetMap.put(sourceId, targetId);
} }
}
for(MatchWrapper sourceWrapper:sourceWrappers) {
for(MatchWrapper sourceWrapper:sourceWrappers) { String sourceId = sourceWrapper.getIdentifierString();
String sourceId = sourceWrapper.getIdentifierString(); if(!sourseTargetMap.containsKey(sourceId)) {
if(!sourseTargetMap.containsKey(sourceId)) { sourceWrapper.setErrorSingleChoice(true);
sourceWrapper.setErrorSingleChoice(true); allOk &= false;
allOk &= false; }
} }
} }
} }
......
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