Search in sources :

Example 1 with Hottext

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

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)

Example 2 with Hottext

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

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 3 with Hottext

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

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 4 with Hottext

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

the class QTI21StatisticsManagerImpl method getHottextInteractionStatistics.

@Override
public List<ChoiceStatistics> getHottextInteractionStatistics(String itemRefIdent, AssessmentItem assessmentItem, HottextInteraction hottextInteraction, QTI21StatisticSearchParams searchParams) {
    List<RawData> results = getRawDatas(itemRefIdent, hottextInteraction.getResponseIdentifier().toString(), searchParams);
    List<Hottext> hottexts = QueryUtils.search(Hottext.class, hottextInteraction);
    long[] counts = new long[hottexts.size()];
    for (int i = counts.length; i-- > 0; ) {
        counts[i] = 0l;
    }
    for (RawData result : results) {
        Long numOfAnswers = result.getCount();
        ;
        if (numOfAnswers != null && numOfAnswers.longValue() > 0) {
            String stringuifiedResponse = result.getStringuifiedResponse();
            for (int i = hottexts.size(); i-- > 0; ) {
                String identifier = hottexts.get(i).getIdentifier().toString();
                if (stringuifiedResponse.contains(identifier)) {
                    counts[i] += numOfAnswers.longValue();
                }
            }
        }
    }
    List<ChoiceStatistics> choicesStatistics = new ArrayList<>();
    for (int i = 0; i < hottexts.size(); i++) {
        choicesStatistics.add(new ChoiceStatistics(hottexts.get(i), counts[i]));
    }
    return choicesStatistics;
}
Also used : ChoiceStatistics(org.olat.ims.qti21.model.statistics.ChoiceStatistics) HotspotChoiceStatistics(org.olat.ims.qti21.model.statistics.HotspotChoiceStatistics) ArrayList(java.util.ArrayList) Hottext(uk.ac.ed.ph.jqtiplus.node.item.interaction.content.Hottext)

Example 5 with Hottext

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

the class QTI21StatisticsManagerImpl method getHottextInteractionStatistics.

@Override
public List<ChoiceStatistics> getHottextInteractionStatistics(String itemRefIdent, AssessmentItem assessmentItem, HottextInteraction hottextInteraction, QTI21StatisticSearchParams searchParams) {
    List<RawData> results = getRawDatas(itemRefIdent, hottextInteraction.getResponseIdentifier().toString(), searchParams);
    List<Hottext> hottexts = QueryUtils.search(Hottext.class, hottextInteraction);
    long[] counts = new long[hottexts.size()];
    for (int i = counts.length; i-- > 0; ) {
        counts[i] = 0l;
    }
    for (RawData result : results) {
        Long numOfAnswers = result.getCount();
        ;
        if (numOfAnswers != null && numOfAnswers.longValue() > 0) {
            String stringuifiedResponse = result.getStringuifiedResponse();
            for (int i = hottexts.size(); i-- > 0; ) {
                String identifier = hottexts.get(i).getIdentifier().toString();
                if (stringuifiedResponse.contains(identifier)) {
                    counts[i] += numOfAnswers.longValue();
                }
            }
        }
    }
    List<ChoiceStatistics> choicesStatistics = new ArrayList<>();
    for (int i = 0; i < hottexts.size(); i++) {
        choicesStatistics.add(new ChoiceStatistics(hottexts.get(i), counts[i]));
    }
    return choicesStatistics;
}
Also used : ChoiceStatistics(org.olat.ims.qti21.model.statistics.ChoiceStatistics) HotspotChoiceStatistics(org.olat.ims.qti21.model.statistics.HotspotChoiceStatistics) ArrayList(java.util.ArrayList) Hottext(uk.ac.ed.ph.jqtiplus.node.item.interaction.content.Hottext)

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