use of uk.ac.ed.ph.jqtiplus.node.item.template.declaration.TemplateDeclaration in project OpenOLAT by OpenOLAT.
the class AssessmentItemCheckerTest method checkAndCorrect_hottextOpenOLAT.
@Test
public void checkAndCorrect_hottextOpenOLAT() throws URISyntaxException {
URL itemUrl = OnyxToAssessmentItemBuilderTest.class.getResource("resources/openolat/hottext-score-all-11-4-0.xml");
AssessmentItem assessmentItem = loadAssessmentItem(itemUrl);
boolean ok = AssessmentItemChecker.checkAndCorrect(assessmentItem);
Assert.assertTrue(ok);
TemplateDeclaration templateDeclaration = assessmentItem.getTemplateDeclaration(Identifier.assumedLegal("SOLUTION1"));
Assert.assertNull(templateDeclaration);
}
use of uk.ac.ed.ph.jqtiplus.node.item.template.declaration.TemplateDeclaration in project OpenOLAT by OpenOLAT.
the class AssessmentItemCheckerTest method checkAndCorrect_rightType.
@Test
public void checkAndCorrect_rightType() throws URISyntaxException {
URL itemUrl = OnyxToAssessmentItemBuilderTest.class.getResource("resources/umpc/addition.xml");
AssessmentItem assessmentItem = loadAssessmentItem(itemUrl);
boolean ok = AssessmentItemChecker.checkAndCorrect(assessmentItem);
Assert.assertTrue(ok);
TemplateDeclaration solutionDeclaration = assessmentItem.getTemplateDeclaration(Identifier.assumedLegal("SOLUTION1"));
Assert.assertEquals(BaseType.FLOAT, solutionDeclaration.getBaseType());
}
use of uk.ac.ed.ph.jqtiplus.node.item.template.declaration.TemplateDeclaration in project OpenOLAT by OpenOLAT.
the class AssessmentItemCheckerTest method checkAndCorrect_wrongType.
@Test
public void checkAndCorrect_wrongType() throws URISyntaxException {
URL itemUrl = OnyxToAssessmentItemBuilderTest.class.getResource("resources/onyx/set-correct-response-wrong-type-5-11.xml");
AssessmentItem assessmentItem = loadAssessmentItem(itemUrl);
boolean ok = AssessmentItemChecker.checkAndCorrect(assessmentItem);
Assert.assertFalse(ok);
TemplateDeclaration solutionDeclaration = assessmentItem.getTemplateDeclaration(Identifier.assumedLegal("solution"));
Assert.assertEquals(BaseType.FLOAT, solutionDeclaration.getBaseType());
}
use of uk.ac.ed.ph.jqtiplus.node.item.template.declaration.TemplateDeclaration in project OpenOLAT by OpenOLAT.
the class AssessmentItemComponentRenderer method renderPrintedVariable.
@Override
protected void renderPrintedVariable(AssessmentRenderer renderer, StringOutput sb, AssessmentObjectComponent component, ResolvedAssessmentItem resolvedAssessmentItem, ItemSessionState itemSessionState, PrintedVariable printedVar) {
Identifier identifier = printedVar.getIdentifier();
Value templateValue = itemSessionState.getTemplateValues().get(identifier);
Value outcomeValue = itemSessionState.getOutcomeValues().get(identifier);
sb.append("<span class='printedVariable'>");
if (outcomeValue != null) {
OutcomeDeclaration outcomeDeclaration = resolvedAssessmentItem.getRootNodeLookup().extractIfSuccessful().getOutcomeDeclaration(identifier);
renderPrintedVariable(renderer, sb, printedVar, outcomeDeclaration, outcomeValue);
} else if (templateValue != null) {
TemplateDeclaration templateDeclaration = resolvedAssessmentItem.getRootNodeLookup().extractIfSuccessful().getTemplateDeclaration(identifier);
renderPrintedVariable(renderer, sb, printedVar, templateDeclaration, templateValue);
} else {
sb.append("(variable ").append(identifier.toString()).append(" was not found)");
}
sb.append("</span>");
}
use of uk.ac.ed.ph.jqtiplus.node.item.template.declaration.TemplateDeclaration in project OpenOLAT by OpenOLAT.
the class AssessmentTestComponentRenderer method renderPrintedVariable.
@Override
protected void renderPrintedVariable(AssessmentRenderer renderer, StringOutput sb, AssessmentObjectComponent component, ResolvedAssessmentItem resolvedAssessmentItem, ItemSessionState itemSessionState, PrintedVariable printedVar) {
AssessmentTestComponent testCmp = (AssessmentTestComponent) component;
Identifier identifier = printedVar.getIdentifier();
sb.append("<span class='printedVariable'>");
if (itemSessionState == null) {
Value outcomeValue = testCmp.getTestSessionController().getTestSessionState().getOutcomeValue(identifier);
if (outcomeValue != null) {
OutcomeDeclaration outcomeDeclaration = testCmp.getAssessmentTest().getOutcomeDeclaration(identifier);
renderPrintedVariable(renderer, sb, printedVar, outcomeDeclaration, outcomeValue);
}
} else {
Value templateValue = itemSessionState.getTemplateValues().get(identifier);
Value outcomeValue = itemSessionState.getOutcomeValues().get(identifier);
if (outcomeValue != null) {
OutcomeDeclaration outcomeDeclaration = resolvedAssessmentItem.getRootNodeLookup().extractIfSuccessful().getOutcomeDeclaration(identifier);
renderPrintedVariable(renderer, sb, printedVar, outcomeDeclaration, outcomeValue);
} else if (templateValue != null) {
TemplateDeclaration templateDeclaration = resolvedAssessmentItem.getRootNodeLookup().extractIfSuccessful().getTemplateDeclaration(identifier);
renderPrintedVariable(renderer, sb, printedVar, templateDeclaration, templateValue);
} else {
sb.append("(variable ").append(identifier.toString()).append(" was not found)");
}
}
sb.append("</span>");
}
Aggregations