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

OO-4082: add a security if the part doesn't have a section

parent e604e7bb
No related branches found
No related tags found
No related merge requests found
......@@ -794,6 +794,10 @@ public class AssessmentTestComposerController extends MainLayoutBasicController
private void doInsert(UserRequest ureq, List<QuestionItemView> items) {
TreeNode selectedNode = menuTree.getSelectedNode();
TreeNode sectionNode = getNearestSection(selectedNode);
if(sectionNode == null) {
showWarning("error.missing.section");
return;
}
boolean allOk = true;
String firstItemId = null;
......@@ -843,6 +847,10 @@ public class AssessmentTestComposerController extends MainLayoutBasicController
private void doInsert(UserRequest ureq, AssessmentItemsPackage importPackage) {
TreeNode selectedNode = menuTree.getSelectedNode();
TreeNode sectionNode = getNearestSection(selectedNode);
if(sectionNode == null) {
showWarning("error.missing.section");
return;
}
String firstItemId = null;
boolean errorOnImport = false;
......@@ -988,7 +996,7 @@ public class AssessmentTestComposerController extends MainLayoutBasicController
TreeNode rootNode = menuTree.getTreeModel().getRootNode();
AssessmentTest assessmentTest = (AssessmentTest)rootNode.getUserObject();
List<TestPart> parts = assessmentTest.getTestParts();
if(parts != null && parts.size() > 0) {
if(parts != null && !parts.isEmpty()) {
parentPart = parts.get(0);
} else {
showWarning("error.cannot.create.section");
......@@ -1032,6 +1040,10 @@ public class AssessmentTestComposerController extends MainLayoutBasicController
private void doNewAssessmentItem(UserRequest ureq, TreeNode selectedNode, AssessmentItemBuilder itemBuilder) {
try {
TreeNode sectionNode = getNearestSection(selectedNode);
if(sectionNode == null) {
showWarning("error.missing.section");
return;
}
AssessmentSection section = (AssessmentSection)sectionNode.getUserObject();
AssessmentItemRef itemRef = new AssessmentItemRef(section);
......
......@@ -49,6 +49,7 @@ error.mimetype=$org.olat.core.commons.modules.bc\:WrongMimeType
error.min.score.bigger.max=Minimal erreichbare Punktzahl muss kleiner als then maximal erreichbare Punktzahl sein.
error.missing.fib=Die Frage mussen mindestens einen L\u00FCckentext oder eine Numerische Eingabe enthalten.
error.missing.hottext=Die Frage mussen mindestens einen Hottext enthalten.
error.missing.section=Sie m\u00FCssen mindestens eine Sektion im Test oder Test Part haben.
error.need.correct.answer=Sie m\u00FCssen mindestens eine Antwort als korrekt markieren.
error.positive.double=Falsches Zahlenformat, nur positive Nummer sind erlaubt. Beispiele\: 15.0, 5.5, 10
error.singlechoice=Genau ein ausw\u00E4hlen
......
......@@ -49,6 +49,7 @@ error.mimetype=$org.olat.core.commons.modules.bc\:WrongMimeType
error.min.score.bigger.max=Min. score must be bigger than the max. score.
error.missing.fib=The question need at least a gap text or a numerical input.
error.missing.hottext=The question need at least a hottext.
error.missing.section=You must have at least one section in your test or test part.
error.need.correct.answer=You need a least one correct answer.
error.positive.double=Only positive number are allowed. Example\: 15.0, 5.5, 10
error.singlechoice=Choose exactly one
......
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