예제 #1
0
 @Override
 public VariableDeclaration isValidLocalVariableReference(
     final Identifier variableReferenceIdentifier) {
   final List<VariableDeclaration> variableDeclarations =
       resolvedAssessmentItem.resolveVariableReference(variableReferenceIdentifier);
   if (variableDeclarations == null) {
     /* Item lookup failed, which is impossible here */
     throw new QtiLogicException("Unexpected logic branch");
   } else if (variableDeclarations.size() == 1) {
     /* Found and unique, which is what we want */
     final VariableDeclaration declaration = variableDeclarations.get(0);
     if (declaration.hasValidSignature()) {
       return declaration;
     }
   }
   return null;
 }
예제 #2
0
 @Override
 public final VariableDeclaration checkLocalVariableReference(
     final QtiNode owner, final Identifier variableReferenceIdentifier) {
   final List<VariableDeclaration> variableDeclarations =
       resolvedAssessmentItem.resolveVariableReference(variableReferenceIdentifier);
   if (variableDeclarations == null) {
     /* Item lookup failed, which is impossible here */
     throw new QtiLogicException("Unexpected logic branch");
   } else if (variableDeclarations.size() == 1) {
     /* Found and unique, which is what we want */
     final VariableDeclaration declaration = variableDeclarations.get(0);
     if (!declaration.hasValidSignature()) {
       fireValidationWarning(
           owner,
           "Item variable referenced by identifier '"
               + variableReferenceIdentifier
               + "' has an invalid cardinality/baseType combination so no further validation will be performed on this reference");
       return null;
     }
     return declaration;
   } else if (variableDeclarations.isEmpty()) {
     /* No variable found */
     fireValidationError(
         owner,
         "Item variable referenced by identifier '"
             + variableReferenceIdentifier
             + "' has not been declared");
     return null;
   } else {
     /* Multiple matches for identifier */
     fireValidationError(
         owner,
         variableDeclarations.size()
             + " item variables have been declared with the same identifier '"
             + variableDeclarations
             + "'");
     return null;
   }
 }