use of uk.ac.ed.ph.jqtiplus.value.RecordValue in project openolat by klemens.
the class AssessmentRenderFunctions method renderRecordCardinalityValue.
public static void renderRecordCardinalityValue(StringOutput sb, Value value, String delimiter, String mappingIndicator) {
if (value != null && value.hasCardinality(Cardinality.RECORD)) {
RecordValue oValue = (RecordValue) value;
boolean hasDelimiter = StringHelper.containsNonWhitespace(delimiter);
boolean hasMappingIndicator = StringHelper.containsNonWhitespace(mappingIndicator);
int count = 0;
for (Map.Entry<Identifier, SingleValue> entry : oValue.entrySet()) {
if (hasDelimiter && count++ > 0)
sb.append(delimiter);
String identifierString = entry.getKey().toString();
sb.append(identifierString);
if (hasMappingIndicator) {
sb.append(mappingIndicator);
}
renderSingleCardinalityValue(sb, entry.getValue());
}
}
}
use of uk.ac.ed.ph.jqtiplus.value.RecordValue in project openolat by klemens.
the class AssessmentRenderFunctions method isMathsContentValue.
// <xsl:sequence select="boolean($valueHolder[@cardinality='record'
// and qw:value[@baseType='string' and @fieldIdentifier='MathsContentClass'
// and string(qw:value)='org.qtitools.mathassess']])"/>
public static boolean isMathsContentValue(Value value) {
if (value.hasCardinality(Cardinality.RECORD)) {
RecordValue recordValue = (RecordValue) value;
for (Map.Entry<Identifier, SingleValue> entry : recordValue.entrySet()) {
final Identifier itemIdentifier = entry.getKey();
final SingleValue itemValue = entry.getValue();
if (itemValue.hasBaseType(BaseType.STRING) && MATHS_CONTENT_RECORD_VARIABLE_IDENTIFIER.equals(itemIdentifier)) {
return true;
}
}
}
return false;
}
use of uk.ac.ed.ph.jqtiplus.value.RecordValue in project OpenOLAT by OpenOLAT.
the class AssessmentObjectVelocityRenderDecorator method getResponseValueForField.
public String getResponseValueForField(Value value, String field) {
String responseValue;
// for math entry interaction
if (value instanceof RecordValue) {
Identifier fieldIdentifier = Identifier.assumedLegal(field);
RecordValue recordValue = (RecordValue) value;
SingleValue sValue = recordValue.get(fieldIdentifier);
responseValue = sValue == null ? null : sValue.toQtiString();
} else {
responseValue = null;
}
return responseValue;
}
use of uk.ac.ed.ph.jqtiplus.value.RecordValue in project OpenOLAT by OpenOLAT.
the class AssessmentRenderFunctions method extractMathsContentPmathml.
/*
<xsl:function name="qw:extract-maths-content-pmathml" as="element(m:math)">
<xsl:param name="valueHolder" as="element()"/>
<xsl:choose>
<xsl:when test="qw:is-maths-content-value($valueHolder)">
<xsl:variable name="pmathmlString" select="$valueHolder/qw:value[@fieldIdentifier='PMathML']" as="xs:string"/>
<xsl:variable name="pmathmlDocNode" select="saxon:parse($pmathmlString)" as="document-node()"/>
<xsl:copy-of select="$pmathmlDocNode/*"/>
</xsl:when>
<xsl:otherwise>
<xsl:message terminate="yes">
Expected value <xsl:copy-of select="$valueHolder"/> to be a MathsContent value
</xsl:message>
</xsl:otherwise>
</xsl:choose>
</xsl:function>
*/
public static String extractMathsContentPmathml(Value value) {
if (value.hasCardinality(Cardinality.RECORD)) {
RecordValue recordValue = (RecordValue) value;
for (Map.Entry<Identifier, SingleValue> entry : recordValue.entrySet()) {
final Identifier itemIdentifier = entry.getKey();
final SingleValue itemValue = entry.getValue();
if (itemValue.hasBaseType(BaseType.STRING) && FIELD_PMATHML_IDENTIFIER.equals(itemIdentifier)) {
return ((StringValue) itemValue).stringValue();
}
}
}
return "";
}
use of uk.ac.ed.ph.jqtiplus.value.RecordValue in project OpenOLAT by OpenOLAT.
the class AssessmentRenderFunctions method isMathsContentValue.
// <xsl:sequence select="boolean($valueHolder[@cardinality='record'
// and qw:value[@baseType='string' and @fieldIdentifier='MathsContentClass'
// and string(qw:value)='org.qtitools.mathassess']])"/>
public static boolean isMathsContentValue(Value value) {
if (value.hasCardinality(Cardinality.RECORD)) {
RecordValue recordValue = (RecordValue) value;
for (Map.Entry<Identifier, SingleValue> entry : recordValue.entrySet()) {
final Identifier itemIdentifier = entry.getKey();
final SingleValue itemValue = entry.getValue();
if (itemValue.hasBaseType(BaseType.STRING) && MATHS_CONTENT_RECORD_VARIABLE_IDENTIFIER.equals(itemIdentifier)) {
return true;
}
}
}
return false;
}
Aggregations