use of uk.ac.ed.ph.jqtiplus.node.item.interaction.InlineChoiceInteraction in project OpenOLAT by OpenOLAT.
the class AssessmentObjectVelocityRenderDecorator method getVisibleOrderedChoices.
/*
<xsl:function name="qw:get-visible-ordered-choices" as="element()*">
<xsl:param name="interaction" as="element()"/>
<xsl:param name="choices" as="element()*"/>
<xsl:variable name="orderedChoices" as="element()*">
<xsl:choose>
<xsl:when test="$interaction/@shuffle='true'">
<xsl:for-each select="qw:get-shuffled-choice-order($interaction)">
<xsl:sequence select="$choices[@identifier=current()]"/>
</xsl:for-each>
</xsl:when>
<xsl:otherwise>
<xsl:sequence select="$choices"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:sequence select="qw:filter-visible($orderedChoices)"/>
</xsl:function>
*/
public List<InlineChoice> getVisibleOrderedChoices(InlineChoiceInteraction interaction) {
List<InlineChoice> choices;
if (interaction.getShuffle()) {
// <xsl:variable name="shuffledChoiceOrders" select="$itemSessionState/qw:shuffledInteractionChoiceOrder"
// as="element(qw:shuffledInteractionChoiceOrder)*"/>
// <xsl:variable name="choiceSequence" as="xs:string?"
// select="$shuffledChoiceOrders[@responseIdentifier=$interaction/@responseIdentifier]/@choiceSequence"/>
List<Identifier> choiceOrders = itemSessionState.getShuffledInteractionChoiceOrder(interaction.getResponseIdentifier());
choices = new ArrayList<>();
for (Identifier choiceOrder : choiceOrders) {
choices.add(interaction.getInlineChoice(choiceOrder));
}
} else {
choices = interaction.getInlineChoices();
}
return choices.stream().filter((choice) -> isVisible(choice, itemSessionState)).collect(Collectors.toList());
}
use of uk.ac.ed.ph.jqtiplus.node.item.interaction.InlineChoiceInteraction in project openolat by klemens.
the class InlineChoiceInteractionArchive method writeInteractionData.
@Override
public int writeInteractionData(AssessmentItem item, AssessmentResponse response, Interaction interaction, int itemNumber, Row dataRow, int col, OpenXMLWorkbook workbook) {
InlineChoiceInteraction choiceInteraction = (InlineChoiceInteraction) interaction;
List<Identifier> correctAnswers = CorrectResponsesUtil.getCorrectIdentifierResponses(item, interaction);
String stringuifiedResponse = response == null ? null : response.getStringuifiedResponse();
if (StringHelper.containsNonWhitespace(stringuifiedResponse)) {
String inlineResponse = CorrectResponsesUtil.stripResponse(stringuifiedResponse);
Identifier responseIdentifier = Identifier.assumedLegal(inlineResponse);
boolean correct = false;
for (Identifier correctAnswer : correctAnswers) {
if (responseIdentifier.equals(correctAnswer)) {
correct = true;
break;
}
}
InlineChoice selectedChoice = choiceInteraction.getInlineChoice(responseIdentifier);
if (selectedChoice != null) {
String value = getTextContent(selectedChoice);
if (correct) {
dataRow.addCell(col++, value, workbook.getStyles().getCorrectStyle());
} else {
dataRow.addCell(col++, value);
}
} else {
col++;
}
} else {
col++;
}
return col;
}
use of uk.ac.ed.ph.jqtiplus.node.item.interaction.InlineChoiceInteraction in project OpenOLAT by OpenOLAT.
the class InlineChoiceInteractionArchive method writeInteractionData.
@Override
public int writeInteractionData(AssessmentItem item, AssessmentResponse response, Interaction interaction, int itemNumber, Row dataRow, int col, OpenXMLWorkbook workbook) {
InlineChoiceInteraction choiceInteraction = (InlineChoiceInteraction) interaction;
List<Identifier> correctAnswers = CorrectResponsesUtil.getCorrectIdentifierResponses(item, interaction);
String stringuifiedResponse = response == null ? null : response.getStringuifiedResponse();
if (StringHelper.containsNonWhitespace(stringuifiedResponse)) {
String inlineResponse = CorrectResponsesUtil.stripResponse(stringuifiedResponse);
Identifier responseIdentifier = Identifier.assumedLegal(inlineResponse);
boolean correct = false;
for (Identifier correctAnswer : correctAnswers) {
if (responseIdentifier.equals(correctAnswer)) {
correct = true;
break;
}
}
InlineChoice selectedChoice = choiceInteraction.getInlineChoice(responseIdentifier);
if (selectedChoice != null) {
String value = getTextContent(selectedChoice);
if (correct) {
dataRow.addCell(col++, value, workbook.getStyles().getCorrectStyle());
} else {
dataRow.addCell(col++, value);
}
} else {
col++;
}
} else {
col++;
}
return col;
}
use of uk.ac.ed.ph.jqtiplus.node.item.interaction.InlineChoiceInteraction in project openolat by klemens.
the class AssessmentObjectVelocityRenderDecorator method getVisibleOrderedChoices.
/*
<xsl:function name="qw:get-visible-ordered-choices" as="element()*">
<xsl:param name="interaction" as="element()"/>
<xsl:param name="choices" as="element()*"/>
<xsl:variable name="orderedChoices" as="element()*">
<xsl:choose>
<xsl:when test="$interaction/@shuffle='true'">
<xsl:for-each select="qw:get-shuffled-choice-order($interaction)">
<xsl:sequence select="$choices[@identifier=current()]"/>
</xsl:for-each>
</xsl:when>
<xsl:otherwise>
<xsl:sequence select="$choices"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:sequence select="qw:filter-visible($orderedChoices)"/>
</xsl:function>
*/
public List<InlineChoice> getVisibleOrderedChoices(InlineChoiceInteraction interaction) {
List<InlineChoice> choices;
if (interaction.getShuffle()) {
// <xsl:variable name="shuffledChoiceOrders" select="$itemSessionState/qw:shuffledInteractionChoiceOrder"
// as="element(qw:shuffledInteractionChoiceOrder)*"/>
// <xsl:variable name="choiceSequence" as="xs:string?"
// select="$shuffledChoiceOrders[@responseIdentifier=$interaction/@responseIdentifier]/@choiceSequence"/>
List<Identifier> choiceOrders = itemSessionState.getShuffledInteractionChoiceOrder(interaction.getResponseIdentifier());
choices = new ArrayList<>();
for (Identifier choiceOrder : choiceOrders) {
choices.add(interaction.getInlineChoice(choiceOrder));
}
} else {
choices = interaction.getInlineChoices();
}
return choices.stream().filter((choice) -> isVisible(choice, itemSessionState)).collect(Collectors.toList());
}
Aggregations