diff --git a/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/bundle/AuthorMessages.properties b/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/bundle/AuthorMessages.properties index fb6f23874a0e..70f7e263ad3d 100644 --- a/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/bundle/AuthorMessages.properties +++ b/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/bundle/AuthorMessages.properties @@ -180,6 +180,7 @@ invalid_min_scale=Min decimal places greater than scale value invalid_max=Max must be a valid number (0.0) invalid_max_scale=Max decimal places greater than scale value unique_names=Variables, Global Variables and Formulas must have unique names +repeated_formula_names_instructions=There are repeated names on formulas {{ }} in the instructions variable_name_empty=Variable name cannot be empty. Variables must begin with an alpha character and can only contain alpha, numeric, and underscore characters and are wrapped in single curly braces (i.e. {x} ) variable_name_invalid=Variable name is invalid. Variables must begin with an alpha character and can only contain alpha, numeric, and underscore characters and are wrapped in single curly braces (i.e. {x} ) formula_name_empty=Formula name cannot be empty. Formula names must begin with an alpha character and can only contain alpha, numeric, and underscore characters and are wrapped in double curly braces (i.e. {{y}} ) diff --git a/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/bundle/AuthorMessages_es.properties b/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/bundle/AuthorMessages_es.properties index 8350b11880ec..3c12b41136f5 100644 --- a/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/bundle/AuthorMessages_es.properties +++ b/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/bundle/AuthorMessages_es.properties @@ -181,7 +181,7 @@ invalid_min_scale=El n\u00famero de decimales m\u00ednimo supera la escala invalid_max=Max debe ser un n\u00famero v\u00e1lido (0.0) invalid_max_scale=El n\u00famero de decimales m\u00e1ximo supera la escala unique_names=Las variables, las variables globales y las f\u00f3rmulas deben tener nombres exclusivos - +repeated_formula_names_instructions=No puede haber nombres repetidos en las formulas {{ }} de las instrucciones variable_name_empty=El nombre de la variable no puede estar vac\u00edo. Las variables deben comenzar con un car\u00e1cter alfab\u00e9tico (no num\u00e9rico) y s\u00f3lo pueden contener caracteres alfanum\u00e9ricos y guiones bajos y deben estar envueltas en llaves individuales (por ejemplo, {x}) variable_name_invalid=El nombre de la variable no es v\u00e1lido. Las variables deben comenzar con un car\u00e1cter alfab\u00e9tico y s\u00f3lo pueden contener caracteres alfanum\u00e9ricos y guiones bajos y deben estar envueltas en llaves individuales (por ejemplo, {x}) formula_name_invalid=El nombre de la f\u00f3rmula no es v\u00e1lido. Los nombres de f\u00f3rmula deben comenzar con un car\u00e1cter alfab\u00e9tico y s\u00f3lo pueden contener caracteres alfanum\u00e9ricos, y guiones bajos y deben estar envueltas en llaves dobles (por ejemplo, {{y}}) diff --git a/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/CalculatedQuestionExtractListener.java b/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/CalculatedQuestionExtractListener.java index c65c847a0332..71e558838c85 100644 --- a/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/CalculatedQuestionExtractListener.java +++ b/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/CalculatedQuestionExtractListener.java @@ -27,6 +27,7 @@ import java.util.Collection; import java.util.Collections; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Map.Entry; @@ -136,6 +137,9 @@ public List validate(ItemBean item,boolean extracting) { errors.addAll(validateExtractedNames(corrvariableNames, corrformulaNames, globalVariableNames)); errors.addAll(validateExtractedNames(incorrvariableNames, incorrformulaNames, globalVariableNames)); + //checking if there are duplicated formula names on instructions. + errors.addAll(checkDuplicatesFormulaNamesOnInstructions(formulaNames)); + // checking if there are variable names on feedback which are not in instructions. errors.addAll(checkVariableNamesOnFeedback(variableNames, corrvariableNames, VARIABLE_ON_CORRECT_FEEDBACK_NOT_IN_INSTRUCTIONS)); errors.addAll(checkVariableNamesOnFeedback(variableNames, incorrvariableNames, VARIABLE_ON_INCORRECT_FEEDBACK_NOT_IN_INSTRUCTIONS)); @@ -853,4 +857,20 @@ private static List checkGlobalVariableNamesFeedabackOnGlobalVariables(M return errors; } + /** + * checkDuplicatesFormulaNamesOnInstructions() check if there are duplicated formula names + * @param formulasNames + * @return + */ + private static List checkDuplicatesFormulaNamesOnInstructions(List formulasNames) { + List errors = new ArrayList(); + + HashSet set = new HashSet<>(formulasNames); + if (set.size() < formulasNames.size()) { + errors.add(getErrorMessage("repeated_formula_names_instructions")); + } + + return errors; + } + }