use of uk.ac.ed.ph.jqtiplus.types.Identifier in project openolat by klemens.
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.types.Identifier 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.types.Identifier 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.types.Identifier in project openolat by klemens.
the class CorrectionIdentityAssessmentItemListController method loadModel.
private void loadModel(boolean reset) {
ResolvedAssessmentTest resolvedAssessmentTest = model.getResolvedAssessmentTest();
Map<Identifier, AssessmentItemRef> identifierToRefs = new HashMap<>();
for (AssessmentItemRef itemRef : resolvedAssessmentTest.getAssessmentItemRefs()) {
identifierToRefs.put(itemRef.getIdentifier(), itemRef);
}
List<AssessmentItemSession> allItemSessions = qtiService.getAssessmentItemSessions(candidateSession);
Map<String, AssessmentItemSession> identifierToItemSessions = new HashMap<>();
for (AssessmentItemSession itemSession : allItemSessions) {
identifierToItemSessions.put(itemSession.getAssessmentItemIdentifier(), itemSession);
}
// reorder to match the list of assessment items
List<CorrectionIdentityAssessmentItemRow> rows = new ArrayList<>();
TestSessionState testSessionState = model.getTestSessionStates().get(assessedIdentity);
List<TestPlanNode> nodes = testSessionState.getTestPlan().getTestPlanNodeList();
for (TestPlanNode node : nodes) {
if (node.getTestNodeType() == TestNodeType.ASSESSMENT_ITEM_REF) {
TestPlanNodeKey key = node.getKey();
AssessmentItemRef itemRef = identifierToRefs.get(key.getIdentifier());
AssessmentItemSession itemSession = identifierToItemSessions.get(key.getIdentifier().toString());
ResolvedAssessmentItem resolvedAssessmentItem = resolvedAssessmentTest.getResolvedAssessmentItem(itemRef);
ManifestMetadataBuilder metadata = model.getMetadata(itemRef);
AssessmentItem item = resolvedAssessmentItem.getRootNodeLookup().extractIfSuccessful();
ItemSessionState itemSessionState = testSessionState.getItemSessionStates().get(key);
boolean manualCorrection = model.isManualCorrection(itemRef);
CorrectionIdentityAssessmentItemRow row = new CorrectionIdentityAssessmentItemRow(assessedIdentity, item, itemRef, metadata, candidateSession, itemSession, itemSessionState, manualCorrection);
row.setTitle(title);
row.setTitleCssClass("o_icon_user");
rows.add(row);
}
}
tableModel.setObjects(rows);
tableEl.reset(reset, reset, true);
}
use of uk.ac.ed.ph.jqtiplus.types.Identifier in project openolat by klemens.
the class FeedbackResultComponentRenderer method render.
@Override
public void render(Renderer renderer, StringOutput sb, Component source, URLBuilder ubu, Translator translator, RenderResult renderResult, String[] args) {
FeedbackResultComponent cmp = (FeedbackResultComponent) source;
ResolvedAssessmentItem resolvedAssessmentItem = cmp.getResolvedAssessmentItem();
ItemSessionState itemSessionState = cmp.getItemSessionState();
AssessmentRenderer assessmentRenderer = new AssessmentRenderer(renderer);
AssessmentItem assessmentItem = resolvedAssessmentItem.getRootNodeLookup().extractIfSuccessful();
for (ModalFeedback modalFeedback : assessmentItem.getModalFeedbacks()) {
Identifier outcomeIdentifier = modalFeedback.getOutcomeIdentifier();
if (QTI21Constants.CORRECT_SOLUTION_IDENTIFIER.equals(outcomeIdentifier)) {
sb.append("<div class='modalFeedback'>");
renderAssessmentItemCorrectSolutionModalFeedback(assessmentRenderer, sb, modalFeedback, cmp, resolvedAssessmentItem, itemSessionState, ubu, translator);
sb.append("</div>");
}
}
}
Aggregations