use of uk.ac.ed.ph.jqtiplus.node.item.template.declaration.TemplateDeclaration in project OpenOLAT by OpenOLAT.
the class AssessmentRenderFunctions method isTemplateDeclarationAMathVariable.
public static final boolean isTemplateDeclarationAMathVariable(AssessmentItem assessmentItem, String identifierString) {
Identifier identifier = Identifier.assumedLegal(identifierString);
TemplateDeclaration templateDeclaration = assessmentItem.getTemplateDeclaration(identifier);
return templateDeclaration == null ? false : templateDeclaration.getMathVariable();
}
use of uk.ac.ed.ph.jqtiplus.node.item.template.declaration.TemplateDeclaration in project OpenOLAT by OpenOLAT.
the class AssessmentItemChecker method checkSetCorrectResponse.
/**
* responseDeclaration -> float
*
* templateVraiable -> integer
*
* setCorrectResponse
* -> variable -> integer doesn't match float -> issue
* @param item
* @return
*/
private static boolean checkSetCorrectResponse(AssessmentItem item) {
boolean allOk = true;
List<SetCorrectResponse> setCorrectResponses = QueryUtils.search(SetCorrectResponse.class, item);
for (SetCorrectResponse setCorrectResponse : setCorrectResponses) {
Identifier responseIdentifier = setCorrectResponse.getIdentifier();
ResponseDeclaration responseDeclaration = item.getResponseDeclaration(responseIdentifier);
BaseType baseType = responseDeclaration.getBaseType();
Expression expression = setCorrectResponse.getExpression();
if (expression instanceof Variable) {
Variable variable = (Variable) expression;
ComplexReferenceIdentifier cpxVariableIdentifier = variable.getIdentifier();
Identifier variableIdentifier = Identifier.assumedLegal(cpxVariableIdentifier.toString());
TemplateDeclaration templateDeclaration = item.getTemplateDeclaration(variableIdentifier);
if (templateDeclaration != null && !templateDeclaration.hasBaseType(baseType)) {
templateDeclaration.setBaseType(baseType);
allOk &= false;
}
}
}
return allOk;
}
use of uk.ac.ed.ph.jqtiplus.node.item.template.declaration.TemplateDeclaration in project openolat by klemens.
the class AssessmentItemCheckerTest method checkAndCorrect_notTemplateDeclaration.
@Test
public void checkAndCorrect_notTemplateDeclaration() throws URISyntaxException {
URL itemUrl = OnyxToAssessmentItemBuilderTest.class.getResource("resources/ims/template_image.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 klemens.
the class AssessmentRenderFunctions method isTemplateDeclarationAMathVariable.
public static final boolean isTemplateDeclarationAMathVariable(AssessmentItem assessmentItem, String identifierString) {
Identifier identifier = Identifier.assumedLegal(identifierString);
TemplateDeclaration templateDeclaration = assessmentItem.getTemplateDeclaration(identifier);
return templateDeclaration == null ? false : templateDeclaration.getMathVariable();
}
use of uk.ac.ed.ph.jqtiplus.node.item.template.declaration.TemplateDeclaration in project openolat by klemens.
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