@Override protected void validateThis( final ValidationContext context, final ResponseDeclaration responseDeclaration) { final int maxChoices = getMaxChoices(); final int minChoices = getMinChoices(); if (maxChoices != 0 && minChoices > maxChoices) { context.fireValidationError( this, "Minimum number of choices can't be bigger than maximum number"); } if (responseDeclaration != null) { if (responseDeclaration.getBaseType() != null && !responseDeclaration.getBaseType().isIdentifier()) { context.fireValidationError(this, "Response variable must have identifier base type"); } if (getMaxChoices() == 1 && !responseDeclaration.getCardinality().isSingle() && !responseDeclaration.getCardinality().isMultiple()) { context.fireValidationError( this, "Response variable must have single or multiple cardinality"); } if (getMaxChoices() != 1 && !responseDeclaration.getCardinality().isMultiple()) { context.fireValidationError(this, "Response variable must have multiple cardinality"); } } }
@Override public void validateThis( final ValidationContext context, final ResponseDeclaration responseDeclaration) { final Integer minChoices = getMinChoices(); final Integer maxChoices = getMaxChoices(); if (minChoices != null && minChoices.intValue() < 1) { context.fireValidationError(this, "Minimum number of choices can't be less than one"); } if (maxChoices != null && minChoices != null && maxChoices.intValue() < minChoices.intValue()) { context.fireValidationError( this, "Maximum number of choices must be greater or equal to minimum number of choices"); } if (maxChoices != null && maxChoices.intValue() > getHotspotChoices().size()) { context.fireValidationError( this, "Maximum number of choices cannot be larger than the number of choice children"); } if (responseDeclaration != null) { if (responseDeclaration.getBaseType() != null && !responseDeclaration.getBaseType().isIdentifier()) { context.fireValidationError(this, "Response variable must have identifier base type"); } if (!responseDeclaration.getCardinality().isOrdered()) { context.fireValidationError(this, "Response variable must have ordered cardinality"); } } }
/** * Partial implementation of {@link #validateThis(ValidationContext)} that checks the input/output * variable signatures. * * <p>Subclasses should override this to do additional validation. * * <p>NB: I'm not currently keen on the way this bit of logic works so it is subject to change in * future, but overridden methods in subclasses should be safe enough. */ @Override protected void validateThis(final ValidationContext context) { final Cardinality[] requiredCardinalities = getParentRequiredCardinalities(context); final Cardinality[] producedCardinalities = getProducedCardinalities(context); if (!check(requiredCardinalities, producedCardinalities)) { context.fireCardinalityValidationError(this, requiredCardinalities, producedCardinalities); } final BaseType[] requiredBaseTypes = getParentRequiredBaseTypes(context); final BaseType[] producedBaseTypes = getProducedBaseTypes(context); if (!check(requiredBaseTypes, producedBaseTypes)) { context.fireBaseTypeValidationError(this, requiredBaseTypes, producedBaseTypes); } }
@Override protected void validateThis(final ValidationContext context) { if (getResponseRules().size() == 0) { context.fireValidationWarning( this, "Node " + getQtiClassName() + " should contain some rules."); } }
public boolean isThisExpressionValid(final ValidationContext context) { context.setCheckpoint(NotificationLevel.ERROR); validateThis(context); return context.clearCheckpoint() == 0; }