use of uk.ac.ed.ph.jqtiplus.node.ForeignElement in project OpenOLAT by OpenOLAT.
the class AssessmentObjectComponentRenderer method renderMath.
protected void renderMath(AssessmentRenderer renderer, StringOutput out, AssessmentObjectComponent component, ResolvedAssessmentItem resolvedAssessmentItem, ItemSessionState itemSessionState, QtiNode mathElement) {
if (mathElement instanceof ForeignElement) {
ForeignElement fElement = (ForeignElement) mathElement;
boolean mi = fElement.getQtiClassName().equals("mi");
boolean ci = fElement.getQtiClassName().equals("ci");
if (ci || mi) {
AssessmentItem assessmentItem = resolvedAssessmentItem.getRootNodeLookup().extractIfSuccessful();
String text = contentAsString(fElement);
Identifier identifier = Identifier.assumedLegal(text);
Value templateValue = getTemplateValue(itemSessionState, text);
Value outcomeValue = getOutcomeValue(itemSessionState, text);
Value responseValue = getResponseValue(assessmentItem, itemSessionState, identifier, renderer.isSolutionMode());
if (templateValue != null && isTemplateDeclarationAMathVariable(assessmentItem, text)) {
if (ci) {
substituteCi(out, templateValue);
} else if (mi) {
substituteMi(out, templateValue);
}
} else if (outcomeValue != null) {
if (ci) {
substituteCi(out, outcomeValue);
} else if (mi) {
substituteMi(out, outcomeValue);
}
} else if (responseValue != null) {
if (ci) {
substituteCi(out, responseValue);
} else if (mi) {
substituteMi(out, responseValue);
}
} else {
renderStartHtmlTag(out, component, resolvedAssessmentItem, fElement, null);
fElement.getChildren().forEach((child) -> renderMath(renderer, out, component, resolvedAssessmentItem, itemSessionState, child));
renderEndTag(out, fElement);
}
} else {
renderStartHtmlTag(out, component, resolvedAssessmentItem, fElement, null);
fElement.getChildren().forEach((child) -> renderMath(renderer, out, component, resolvedAssessmentItem, itemSessionState, child));
renderEndTag(out, fElement);
}
} else if (mathElement instanceof TextRun) {
out.append(((TextRun) mathElement).getTextContent());
}
}
use of uk.ac.ed.ph.jqtiplus.node.ForeignElement in project openolat by klemens.
the class AssessmentObjectComponentRenderer method renderMath.
protected void renderMath(AssessmentRenderer renderer, StringOutput out, AssessmentObjectComponent component, ResolvedAssessmentItem resolvedAssessmentItem, ItemSessionState itemSessionState, QtiNode mathElement) {
if (mathElement instanceof ForeignElement) {
ForeignElement fElement = (ForeignElement) mathElement;
boolean mi = fElement.getQtiClassName().equals("mi");
boolean ci = fElement.getQtiClassName().equals("ci");
if (ci || mi) {
AssessmentItem assessmentItem = resolvedAssessmentItem.getRootNodeLookup().extractIfSuccessful();
String text = contentAsString(fElement);
Identifier identifier = Identifier.assumedLegal(text);
Value templateValue = getTemplateValue(itemSessionState, text);
Value outcomeValue = getOutcomeValue(itemSessionState, text);
Value responseValue = getResponseValue(assessmentItem, itemSessionState, identifier, renderer.isSolutionMode());
if (templateValue != null && isTemplateDeclarationAMathVariable(assessmentItem, text)) {
if (ci) {
substituteCi(out, templateValue);
} else if (mi) {
substituteMi(out, templateValue);
}
} else if (outcomeValue != null) {
if (ci) {
substituteCi(out, outcomeValue);
} else if (mi) {
substituteMi(out, outcomeValue);
}
} else if (responseValue != null) {
if (ci) {
substituteCi(out, responseValue);
} else if (mi) {
substituteMi(out, responseValue);
}
} else {
renderStartHtmlTag(out, component, resolvedAssessmentItem, fElement, null);
fElement.getChildren().forEach((child) -> renderMath(renderer, out, component, resolvedAssessmentItem, itemSessionState, child));
renderEndTag(out, fElement);
}
} else {
renderStartHtmlTag(out, component, resolvedAssessmentItem, fElement, null);
fElement.getChildren().forEach((child) -> renderMath(renderer, out, component, resolvedAssessmentItem, itemSessionState, child));
renderEndTag(out, fElement);
}
} else if (mathElement instanceof TextRun) {
out.append(((TextRun) mathElement).getTextContent());
}
}
Aggregations