Search in sources :

Example 6 with Hottext

use of uk.ac.ed.ph.jqtiplus.node.item.interaction.content.Hottext in project OpenOLAT by OpenOLAT.

the class HottextAssessmentItemBuilder method getAnswers.

@Override
public List<Answer> getAnswers() {
    List<Hottext> hottexts = getChoices();
    List<Answer> answers = new ArrayList<>(hottexts.size());
    for (Hottext hottext : hottexts) {
        String answer = new AssessmentHtmlBuilder().inlineStaticString(hottext.getInlineStatics());
        answer = FilterFactory.getHtmlTagAndDescapingFilter().filter(answer);
        answers.add(new Answer(hottext.getIdentifier(), answer));
    }
    return answers;
}
Also used : ArrayList(java.util.ArrayList) AssessmentItemFactory.appendHottext(org.olat.ims.qti21.model.xml.AssessmentItemFactory.appendHottext) Hottext(uk.ac.ed.ph.jqtiplus.node.item.interaction.content.Hottext) AssessmentHtmlBuilder(org.olat.ims.qti21.model.xml.AssessmentHtmlBuilder)

Example 7 with Hottext

use of uk.ac.ed.ph.jqtiplus.node.item.interaction.content.Hottext in project openolat by klemens.

the class HottextInteractionArchive method writeInteractionData.

@Override
public int writeInteractionData(AssessmentItem item, AssessmentResponse response, Interaction interaction, int itemNumber, Row dataRow, int col, OpenXMLWorkbook workbook) {
    String stringuifiedResponse = response == null ? null : response.getStringuifiedResponse();
    List<String> responses = CorrectResponsesUtil.parseResponses(stringuifiedResponse);
    List<Identifier> correctAnswers = CorrectResponsesUtil.getCorrectIdentifierResponses(item, interaction);
    List<Hottext> texts = getHottexts(interaction);
    for (int i = 0; i < texts.size(); i++) {
        Hottext text = texts.get(i);
        Identifier textIdentifier = text.getIdentifier();
        // user select this hot text
        if (responses.contains(text.getIdentifier().toString())) {
            String content = getContent(text);
            // correct -> must be clicked
            boolean correct = correctAnswers.contains(textIdentifier);
            if (correct) {
                dataRow.addCell(col++, content, workbook.getStyles().getCorrectStyle());
            } else {
                dataRow.addCell(col++, content, null);
            }
        } else {
            // correct -> must not be clicked
            boolean correct = !correctAnswers.contains(textIdentifier);
            if (correct) {
                dataRow.addCell(col++, "", workbook.getStyles().getCorrectStyle());
            } else {
                col++;
            }
        }
    }
    return col;
}
Also used : Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier) Hottext(uk.ac.ed.ph.jqtiplus.node.item.interaction.content.Hottext)

Example 8 with Hottext

use of uk.ac.ed.ph.jqtiplus.node.item.interaction.content.Hottext in project openolat by klemens.

the class AssessmentItemFactory method appendHottext.

public static Hottext appendHottext(P parent, Identifier responseId, String text) {
    Hottext hottext = new Hottext(parent);
    hottext.setIdentifier(responseId);
    hottext.getInlineStatics().add(new TextRun(hottext, text));
    parent.getInlines().add(hottext);
    return hottext;
}
Also used : Hottext(uk.ac.ed.ph.jqtiplus.node.item.interaction.content.Hottext) TextRun(uk.ac.ed.ph.jqtiplus.node.content.basic.TextRun)

Aggregations

Hottext (uk.ac.ed.ph.jqtiplus.node.item.interaction.content.Hottext)8 ArrayList (java.util.ArrayList)4 ChoiceStatistics (org.olat.ims.qti21.model.statistics.ChoiceStatistics)2 HotspotChoiceStatistics (org.olat.ims.qti21.model.statistics.HotspotChoiceStatistics)2 AssessmentHtmlBuilder (org.olat.ims.qti21.model.xml.AssessmentHtmlBuilder)2 AssessmentItemFactory.appendHottext (org.olat.ims.qti21.model.xml.AssessmentItemFactory.appendHottext)2 TextRun (uk.ac.ed.ph.jqtiplus.node.content.basic.TextRun)2 Identifier (uk.ac.ed.ph.jqtiplus.types.Identifier)2