use of uk.ac.ed.ph.jqtiplus.node.item.interaction.graphic.HotspotChoice in project openolat by klemens.
the class QTI21StatisticsManagerImpl method getHotspotInteractionStatistics.
@Override
public List<HotspotChoiceStatistics> getHotspotInteractionStatistics(String itemRefIdent, AssessmentItem assessmentItem, HotspotInteraction hotspotInteraction, QTI21StatisticSearchParams searchParams) {
List<RawData> results = getRawDatas(itemRefIdent, hotspotInteraction.getResponseIdentifier().toString(), searchParams);
List<HotspotChoice> hotspotChoices = hotspotInteraction.getHotspotChoices();
long[] counts = new long[hotspotChoices.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 = hotspotChoices.size(); i-- > 0; ) {
String identifier = hotspotChoices.get(i).getIdentifier().toString();
if (stringuifiedResponse.contains(identifier)) {
counts[i] += numOfAnswers.longValue();
}
}
}
}
List<HotspotChoiceStatistics> choicesStatistics = new ArrayList<>();
for (int i = 0; i < hotspotChoices.size(); i++) {
choicesStatistics.add(new HotspotChoiceStatistics(hotspotChoices.get(i), counts[i]));
}
return choicesStatistics;
}
use of uk.ac.ed.ph.jqtiplus.node.item.interaction.graphic.HotspotChoice in project openolat by klemens.
the class GraphicOrderInteractionArchive method writeHeader2.
@Override
public int writeHeader2(AssessmentItem item, Interaction interaction, int itemNumber, int interactionNumber, Row dataRow, int col, OpenXMLWorkbook workbook) {
GraphicOrderInteraction orderInteraction = (GraphicOrderInteraction) interaction;
List<HotspotChoice> choices = orderInteraction.getHotspotChoices();
if (choices.size() > 0) {
for (int i = 0; i < choices.size(); i++) {
String header = (itemNumber + 1) + "_GO" + i;
dataRow.addCell(col++, header, workbook.getStyles().getHeaderStyle());
}
} else {
col++;
}
return col;
}
use of uk.ac.ed.ph.jqtiplus.node.item.interaction.graphic.HotspotChoice in project openolat by klemens.
the class GraphicOrderInteractionArchive method writeInteractionData.
@Override
public int writeInteractionData(AssessmentItem item, AssessmentResponse response, Interaction interaction, int itemNumber, Row dataRow, int col, OpenXMLWorkbook workbook) {
GraphicOrderInteraction orderInteraction = (GraphicOrderInteraction) interaction;
List<HotspotChoice> choices = orderInteraction.getHotspotChoices();
if (choices.size() > 0) {
String stringuifiedResponse = response == null ? null : response.getStringuifiedResponse();
List<String> responses = CorrectResponsesUtil.parseResponses(stringuifiedResponse);
List<Identifier> correctAnswers = CorrectResponsesUtil.getCorrectOrderedIdentifierResponses(item, interaction);
for (int i = 0; i < choices.size(); i++) {
String currentResponse = null;
if (responses.size() > i) {
currentResponse = responses.get(i);
}
String correctAnswer = null;
if (correctAnswers.size() > i) {
correctAnswer = correctAnswers.get(i).toString();
}
if (correctAnswer != null && correctAnswer.equals(currentResponse)) {
dataRow.addCell(col++, currentResponse, workbook.getStyles().getCorrectStyle());
} else {
dataRow.addCell(col++, currentResponse, null);
}
}
} else {
col++;
}
return col;
}
use of uk.ac.ed.ph.jqtiplus.node.item.interaction.graphic.HotspotChoice in project openolat by klemens.
the class HotspotChoiceScoreController method sync.
@Override
public void sync(UserRequest ureq, AssessmentItemBuilder assessmentItemBuilder) {
if (itemBuilder == assessmentItemBuilder) {
Set<Identifier> choiceIdentifiers = new HashSet<>();
for (HotspotChoice choice : itemBuilder.getHotspotChoices()) {
HotspotChoiceWrapper wrapper = getHotspotChoiceWrapper(choice);
if (wrapper == null) {
wrappers.add(createHotspotChoiceWrapper(choice));
}
choiceIdentifiers.add(choice.getIdentifier());
}
for (Iterator<HotspotChoiceWrapper> wrapperIt = wrappers.iterator(); wrapperIt.hasNext(); ) {
HotspotChoiceWrapper wrapper = wrapperIt.next();
if (!choiceIdentifiers.contains(wrapper.getChoice().getIdentifier())) {
wrapperIt.remove();
}
}
updateBackground();
}
}
use of uk.ac.ed.ph.jqtiplus.node.item.interaction.graphic.HotspotChoice in project openolat by klemens.
the class HotspotEditorController method updateHotspotsPosition.
/**
* If the image is too small, translate the hotspots to match
* approximatively the new image.
*
* @param backgroundSize
*/
private void updateHotspotsPosition(Size backgroundSize) {
if (backgroundSize == null || choiceWrappers.isEmpty())
return;
int width = backgroundSize.getWidth();
int height = backgroundSize.getHeight();
if (width <= 0 || height <= 0)
return;
for (HotspotWrapper wrapper : choiceWrappers) {
HotspotChoice choice = wrapper.getChoice();
if (choice != null) {
if (Shape.CIRCLE.equals(choice.getShape())) {
translateCircle(choice.getCoords(), width, height);
} else if (Shape.RECT.equals(choice.getShape())) {
translateRect(choice.getCoords(), width, height);
}
}
}
}
Aggregations