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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations