@Override public final VariableDeclaration isValidLocalVariableReference(final ComplexReferenceIdentifier variableReferenceIdentifier) { if (variableReferenceIdentifier.isDotted()) { return null; } return isValidLocalVariableReference(Identifier.assumedLegal(variableReferenceIdentifier.toString())); }
@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())); }
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); }
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 Identifier itemRefIdentifier = Identifier.assumedLegal(components[0]); final Identifier itemVarIdentifier = Identifier.assumedLegal(components[2]); for (final AssessmentItemRef itemRef : assessmentItemRefs) { if (itemRefIdentifier.equals(itemRef.getIdentifier())) {
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; }
@Override protected final Value evaluateValidSelf(final ProcessingContext context, final Value[] childValues, final int depth) { logger.debug("{}Evaluation of expression {} on variable {} started.", new Object[] { formatIndent(depth), getQtiClassName(), getIdentifier() }); final ComplexReferenceIdentifier referenceIdentifier = getIdentifier(); Value result; if (context.isSubjectItem()) { /* Variable reference within item */ final ItemProcessingContext itemProcessingContext = (ItemProcessingContext) context; result = evaluateInThisItem(itemProcessingContext, Identifier.assumedLegal(referenceIdentifier.toString())); } else { /* Variable reference in test */ final TestProcessingContext testProcessingContext = (TestProcessingContext) context; result = testProcessingContext.dereferenceVariable(this, referenceIdentifier, this); } return result; }
responseDeclaration.setIdentifier(Identifier.assumedLegal("RESPONSE")); responseDeclaration.setCardinality(Cardinality.SINGLE); responseDeclaration.setBaseType(BaseType.IDENTIFIER); prompt.getInlineStatics().add(new TextRun(prompt, "Pick the correct answer")); final SimpleChoice simpleChoice1 = new SimpleChoice(choiceInteraction); simpleChoice1.setIdentifier(Identifier.assumedLegal("CHOICE1")); simpleChoice1.getFlowStatics().add(new TextRun(simpleChoice1, "Choice 1")); choiceInteraction.getSimpleChoices().add(simpleChoice1); final SimpleChoice simpleChoice2 = new SimpleChoice(choiceInteraction); simpleChoice2.setIdentifier(Identifier.assumedLegal("CHOICE2")); simpleChoice2.getFlowStatics().add(new TextRun(simpleChoice1, "Choice 2")); choiceInteraction.getSimpleChoices().add(simpleChoice2);
responseDeclaration.setIdentifier(Identifier.assumedLegal("RESPONSE")); responseDeclaration.setCardinality(Cardinality.SINGLE); responseDeclaration.setBaseType(BaseType.IDENTIFIER); prompt.getInlineStatics().add(new TextRun(prompt, "Pick the correct answer")); final SimpleChoice simpleChoice1 = new SimpleChoice(choiceInteraction); simpleChoice1.setIdentifier(Identifier.assumedLegal("CHOICE1")); simpleChoice1.getFlowStatics().add(new TextRun(simpleChoice1, "Choice 1")); choiceInteraction.getSimpleChoices().add(simpleChoice1); final SimpleChoice simpleChoice2 = new SimpleChoice(choiceInteraction); simpleChoice2.setIdentifier(Identifier.assumedLegal("CHOICE2")); simpleChoice2.getFlowStatics().add(new TextRun(simpleChoice1, "Choice 2")); choiceInteraction.getSimpleChoices().add(simpleChoice2);
score.setIdentifier(Identifier.assumedLegal("SCORE")); score.setCardinality(Cardinality.SINGLE); score.setBaseType(BaseType.FLOAT);