use of uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.GapChoice in project openolat by klemens.
the class GapMatchInteractionArchive method writeInteractionData.
@Override
public int writeInteractionData(AssessmentItem item, AssessmentResponse response, Interaction interaction, int itemNumber, Row dataRow, int col, OpenXMLWorkbook workbook) {
List<Gap> gaps = getGaps(interaction);
if (gaps.size() > 0) {
GapMatchInteraction gapMatchInteraction = (GapMatchInteraction) interaction;
Set<String> correctAnswers = CorrectResponsesUtil.getCorrectDirectPairResponses(item, interaction, false);
String stringuifiedResponse = response == null ? null : response.getStringuifiedResponse();
List<String> responses = CorrectResponsesUtil.parseResponses(stringuifiedResponse);
for (Gap gap : gaps) {
String gapIdentifier = gap.getIdentifier().toString();
String gapResponse = null;
for (String r : responses) {
if (r.endsWith(gapIdentifier)) {
gapResponse = r;
}
}
if (gapResponse != null) {
String[] gapResponsePair = gapResponse.split(" ");
if (gapResponsePair.length > 1) {
String gapResponseAssociation = gapResponsePair[0];
Identifier gapResponseIdentifier = Identifier.assumedLegal(gapResponseAssociation);
GapChoice choice = gapMatchInteraction.getGapChoice(gapResponseIdentifier);
String value = null;
if (choice != null) {
value = getTextContent(choice);
}
boolean correct = correctAnswers.contains(gapResponse);
if (correct) {
dataRow.addCell(col++, value, workbook.getStyles().getCorrectStyle());
} else {
dataRow.addCell(col++, value);
}
} else {
col++;
}
} else {
col++;
}
}
} else {
col++;
}
return col;
}
use of uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.GapChoice in project OpenOLAT by OpenOLAT.
the class GapMatchInteractionArchive method writeInteractionData.
@Override
public int writeInteractionData(AssessmentItem item, AssessmentResponse response, Interaction interaction, int itemNumber, Row dataRow, int col, OpenXMLWorkbook workbook) {
List<Gap> gaps = getGaps(interaction);
if (gaps.size() > 0) {
GapMatchInteraction gapMatchInteraction = (GapMatchInteraction) interaction;
Set<String> correctAnswers = CorrectResponsesUtil.getCorrectDirectPairResponses(item, interaction, false);
String stringuifiedResponse = response == null ? null : response.getStringuifiedResponse();
List<String> responses = CorrectResponsesUtil.parseResponses(stringuifiedResponse);
for (Gap gap : gaps) {
String gapIdentifier = gap.getIdentifier().toString();
String gapResponse = null;
for (String r : responses) {
if (r.endsWith(gapIdentifier)) {
gapResponse = r;
}
}
if (gapResponse != null) {
String[] gapResponsePair = gapResponse.split(" ");
if (gapResponsePair.length > 1) {
String gapResponseAssociation = gapResponsePair[0];
Identifier gapResponseIdentifier = Identifier.assumedLegal(gapResponseAssociation);
GapChoice choice = gapMatchInteraction.getGapChoice(gapResponseIdentifier);
String value = null;
if (choice != null) {
value = getTextContent(choice);
}
boolean correct = correctAnswers.contains(gapResponse);
if (correct) {
dataRow.addCell(col++, value, workbook.getStyles().getCorrectStyle());
} else {
dataRow.addCell(col++, value);
}
} else {
col++;
}
} else {
col++;
}
}
} else {
col++;
}
return col;
}
use of uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.GapChoice in project OpenOLAT by OpenOLAT.
the class AssessmentObjectVelocityRenderDecorator method getVisibleOrderedChoices.
public List<GapChoice> getVisibleOrderedChoices(GapMatchInteraction interaction) {
List<GapChoice> 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.getGapChoice(choiceOrder));
}
} else {
choices = new ArrayList<>(interaction.getGapChoices());
}
return choices.stream().filter((choice) -> isVisible(choice, itemSessionState)).collect(Collectors.toList());
}
use of uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.GapChoice in project openolat by klemens.
the class AssessmentObjectVelocityRenderDecorator method getVisibleOrderedChoices.
public List<GapChoice> getVisibleOrderedChoices(GapMatchInteraction interaction) {
List<GapChoice> 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.getGapChoice(choiceOrder));
}
} else {
choices = new ArrayList<>(interaction.getGapChoices());
}
return choices.stream().filter((choice) -> isVisible(choice, itemSessionState)).collect(Collectors.toList());
}
Aggregations