@Override public boolean equals(final Object object) { if (!(object instanceof PairValue)) { return false; } final PairValue other = (PairValue) object; return sourceValue.equals(other.sourceValue) && destValue.equals(other.destValue) || sourceValue.equals(other.destValue) && destValue.equals(other.sourceValue); }
/** * @throws QtiParseException if either value is not a valid identifier */ public AbstractPairValue(final String sourceValue, final String destValue) { this.sourceValue = Identifier.parseString(sourceValue); this.destValue = Identifier.parseString(destValue); }
public TestPlanNodeKey(final Identifier identifier, final int abstractPartGlobalIndex, final int instanceNumber) { this.identifier = identifier; this.abstractPartGlobalIndex = abstractPartGlobalIndex; this.instanceNumber = instanceNumber; this.stringRepresentation = identifier.toString() + ":" + abstractPartGlobalIndex + ":" + instanceNumber; }
/** * Parses the given Identifier String, making sure it follows the required syntax. * <p> * Use this factory method for user-supplied identifiers. * * @throws QtiParseException if value is not a valid identifier */ public static Identifier parseString(final String value) { verifyIdentifier(value); return new Identifier(value); }
/** * Gets a list of all the variables assigned to by the CAS implementation. * * @return writable variables */ public List<VariableDeclaration> getAllCASWriteableVariableDeclarations() { final List<VariableDeclaration> declarations = new ArrayList<VariableDeclaration>(); for (final VariableDeclaration decl : getAllWriteableVariableDeclarations()) { final Identifier identifier = decl.getIdentifier(); if (identifier.toString().matches(IDENTIFIER_REGEX_VALUE) && !identifier.equals(QtiConstants.VARIABLE_DURATION_IDENTIFIER) && !identifier.equals(QtiConstants.VARIABLE_NUMBER_OF_ATTEMPTS_IDENTIFIER)) { declarations.add(decl); } } return declarations; }
private static ItemSessionState createItemSessionState() { final ItemSessionState itemSessionState = new ItemSessionState(); final Map<Identifier, SingleValue> recordMap = new HashMap<Identifier, SingleValue>(); recordMap.put(Identifier.parseString("PMathML"), new StringValue("Hello")); recordMap.put(Identifier.parseString("Number"), new IntegerValue(5)); final Value rv = RecordValue.createRecordValue(recordMap); itemSessionState.setShuffledInteractionChoiceOrder(Identifier.parseString("dave"), Arrays.asList(Identifier.parseString("a"))); itemSessionState.setResponseValue(Identifier.parseString("RESPONSE"), MultipleValue.createMultipleValue(new StringValue("Bad"), new StringValue("Thing"))); itemSessionState.setTemplateValue(Identifier.parseString("TEMPLATE"), NullValue.INSTANCE); itemSessionState.setOutcomeValue(Identifier.parseString("RECORD"), rv); itemSessionState.setUnboundResponseIdentifiers(new HashSet<Identifier>(Arrays.asList(Identifier.assumedLegal("RESPONSE")))); itemSessionState.setRawResponseData(Identifier.assumedLegal("A"), new StringResponseData("1", "2")); return itemSessionState; }
if (components.length==1) { final List<VariableDeclaration> variableDeclarations = tryTestVariableDeclaration(Identifier.parseString(components[0])); for (final VariableDeclaration variableDeclaration : variableDeclarations) { result.add(new ResolvedTestVariableReference(variableDeclaration)); final Identifier itemRefIdentifier = Identifier.assumedLegal(components[0]); final Identifier itemVarIdentifier = Identifier.assumedLegal(components[1]); for (final AssessmentItemRef itemRef : assessmentItemRefs) { if (itemRefIdentifier.equals(itemRef.getIdentifier())) { final List<VariableDeclaration> itemVariableDeclarations = tryItemVariableDeclaration(itemRef, itemVarIdentifier); if (itemVariableDeclarations!=null) { final Identifier itemRefIdentifier = Identifier.assumedLegal(components[0]); final Identifier itemVarIdentifier = Identifier.assumedLegal(components[2]); for (final AssessmentItemRef itemRef : assessmentItemRefs) { if (itemRefIdentifier.equals(itemRef.getIdentifier())) { final List<VariableDeclaration> itemVariableDeclarations = tryItemVariableDeclaration(itemRef, itemVarIdentifier); if (itemVariableDeclarations!=null) {
@Override public final VariableDeclaration isValidLocalVariableReference(final ComplexReferenceIdentifier variableReferenceIdentifier) { if (variableReferenceIdentifier.isDotted()) { return null; } return isValidLocalVariableReference(Identifier.assumedLegal(variableReferenceIdentifier.toString())); }
/** * Creates an {@link Identifier} from the given String, without checking its syntax. * This should ONLY be used for identifiers that are known to be valid, such as the ones * defined in the QTI specification. */ public static Identifier assumedLegal(final String value) { return new Identifier(value); }
private void recordOutcomeVariables(final CandidateSession candidateSession, final AbstractResult resultNode) { candidateSessionOutcomeDao.deleteForCandidateSession(candidateSession); for (final ItemVariable itemVariable : resultNode.getItemVariables()) { if (itemVariable instanceof OutcomeVariable || QtiConstants.VARIABLE_DURATION_IDENTIFIER.equals(itemVariable.getIdentifier())) { final CandidateSessionOutcome outcome = new CandidateSessionOutcome(); outcome.setCandidateSession(candidateSession); outcome.setOutcomeIdentifier(itemVariable.getIdentifier().toString()); outcome.setBaseType(itemVariable.getBaseType()); outcome.setCardinality(itemVariable.getCardinality()); outcome.setStringValue(stringifyQtiValue(itemVariable.getComputedValue())); candidateSessionOutcomeDao.persist(outcome); } } }
@Override public final VariableDeclaration checkLocalVariableReference(final QtiNode owner, final ComplexReferenceIdentifier variableReferenceIdentifier) { if (variableReferenceIdentifier.isDotted()) { fireValidationWarning(owner, "Variable references containing period (.) characters cannot be used here"); return null; } return checkLocalVariableReference(owner, Identifier.assumedLegal(variableReferenceIdentifier.toString())); }
@Override public int hashCode() { return identifierValue.hashCode(); }
@Override public String toQtiString() { return identifierValue.toString(); } }
@Override protected Identifier parseItemValue(final String value) { return Identifier.parseString(value); }
if (branchTargetIdentifier!=null) { final ItemSessionState currentItemState = expectItemRefState(currentItemNode); if (BranchRule.EXIT_TEST.equals(branchTargetIdentifier) || BranchRule.EXIT_TESTPART.equals(branchTargetIdentifier)) { logger.debug("branchRule requested {}", branchTargetIdentifier); currentItemState.setBranchRuleTarget(branchTargetIdentifier.toString()); if (BranchRule.EXIT_TEST.equals(branchTargetIdentifier) && testSessionState.getTestPlan().getTestPartNodes().size() > 1) { exitCurrentTestPart(currentTestPartNode, timestamp); markRemainingTestPartNodesAsJumped(currentTestPartNode); return null; else if (BranchRule.EXIT_SECTION.equals(branchTargetIdentifier)) { currentItemState.setBranchRuleTarget(BranchRule.EXIT_SECTION.toString());
private static TestPlan createTestPlan() { final TestPlanNode rootNode = TestPlanNode.createRoot(); final EffectiveItemSessionControl effectiveItemSessionControl = EffectiveItemSessionControl.createDefault(); final TestPlanNode part1 = new TestPlanNode(TestNodeType.TEST_PART, new TestPlanNodeKey(Identifier.assumedLegal("PART1"), 1, 1), effectiveItemSessionControl); final TestPlanNode part2 = new TestPlanNode(TestNodeType.TEST_PART, new TestPlanNodeKey(Identifier.assumedLegal("PART2"), 1, 1), effectiveItemSessionControl); rootNode.addChild(part1); rootNode.addChild(part2); final TestPlanNode section1 = new TestPlanNode(TestNodeType.ASSESSMENT_SECTION, new TestPlanNodeKey(Identifier.assumedLegal("SECTION1"), 2, 1), effectiveItemSessionControl); part1.addChild(section1); final TestPlanNode item1 = new TestPlanNode(TestNodeType.ASSESSMENT_ITEM_REF, new TestPlanNodeKey(Identifier.assumedLegal("ITEM"), 3, 1), effectiveItemSessionControl, "Title", URI.create("urn:x")); final TestPlanNode item2 = new TestPlanNode(TestNodeType.ASSESSMENT_ITEM_REF, new TestPlanNodeKey(Identifier.assumedLegal("ITEM"), 3, 2), effectiveItemSessionControl, "Title 2", URI.create("urn:y")); section1.addChild(item1); section1.addChild(item2); return new TestPlan(rootNode); }
@Override public boolean equals(final Object object) { if (!(object instanceof IdentifierValue)) { return false; } final IdentifierValue other = (IdentifierValue) object; return identifierValue.equals(other.identifierValue); }
@Override protected String itemToQtiString(final Identifier item) { return item.toString(); } }