use of org.olat.ims.qti.editor.beecom.objects.FIBResponse in project openolat by klemens.
the class QTIWordExport method renderItem.
public static void renderItem(Item item, OpenXMLDocument document, boolean withResponses, Translator translator) {
Element el = DocumentFactory.getInstance().createElement("dummy");
item.addToElement(el);
Element itemEl = (Element) el.elements().get(0);
org.olat.ims.qti.container.qtielements.Item foo = new org.olat.ims.qti.container.qtielements.Item(itemEl);
RenderInstructions renderInstructions = new RenderInstructions();
renderInstructions.put(RenderInstructions.KEY_STATICS_PATH, "/");
renderInstructions.put(RenderInstructions.KEY_LOCALE, translator.getLocale());
renderInstructions.put(RenderInstructions.KEY_RENDER_TITLE, Boolean.TRUE);
if (item.getQuestion() != null) {
Map<String, String> iinput = new HashMap<String, String>();
String questionType = null;
String questionScore = null;
Question question = item.getQuestion();
if (question instanceof ChoiceQuestion) {
ChoiceQuestion choice = (ChoiceQuestion) question;
if (question.getType() == Question.TYPE_SC) {
questionType = translator.translate("item.type.sc");
fetchPointsOfMultipleChoices(itemEl, choice, iinput);
} else if (question.getType() == Question.TYPE_MC) {
questionType = translator.translate("item.type.mc");
fetchPointsOfMultipleChoices(itemEl, choice, iinput);
} else if (question.getType() == Question.TYPE_KPRIM) {
questionType = translator.translate("item.type.kprim");
fetchPointsOfKPrim(itemEl, choice, iinput);
}
} else if (question instanceof FIBQuestion) {
questionType = translator.translate("item.type.sc");
for (Response response : question.getResponses()) {
FIBResponse fibResponse = (FIBResponse) response;
if ("BLANK".equals(fibResponse.getType())) {
iinput.put(fibResponse.getIdent(), fibResponse.getCorrectBlank());
}
}
} else if (question instanceof EssayQuestion) {
questionType = translator.translate("item.type.essay");
}
if (question != null && question.getMaxValue() > 0.0f) {
questionScore = AssessmentHelper.getRoundedScore(question.getMaxValue());
questionScore = translator.translate("item.score.long", new String[] { questionScore });
}
renderInstructions.put(RenderInstructions.KEY_RENDER_CORRECT_RESPONSES, new Boolean(withResponses));
renderInstructions.put(RenderInstructions.KEY_CORRECT_RESPONSES_MAP, iinput);
renderInstructions.put(RenderInstructions.KEY_QUESTION_TYPE, questionType);
renderInstructions.put(RenderInstructions.KEY_QUESTION_SCORE, questionScore);
renderInstructions.put(RenderInstructions.KEY_QUESTION_OO_TYPE, new Integer(question.getType()));
}
foo.renderOpenXML(document, renderInstructions);
}
use of org.olat.ims.qti.editor.beecom.objects.FIBResponse in project openolat by klemens.
the class QTIStatisticsManagerImpl method getStatisticAnswerOptionsFIB.
@Override
public List<StatisticFIBOption> getStatisticAnswerOptionsFIB(Item item, QTIStatisticSearchParams searchParams) {
List<StatisticFIBOption> options = new ArrayList<>();
Map<String, StatisticFIBOption> optionMap = new HashMap<>();
boolean groupBy = true;
List<Response> responses = item.getQuestion().getResponses();
for (Response response : responses) {
if (response instanceof FIBResponse) {
FIBResponse fibResponse = (FIBResponse) response;
if (FIBResponse.TYPE_BLANK.equals(fibResponse.getType())) {
String ident = fibResponse.getIdent();
String[] correctFIBs = fibResponse.getCorrectBlank().split(";");
if (correctFIBs == null || correctFIBs.length == 0) {
continue;
}
StatisticFIBOption option = new StatisticFIBOption();
option.setCorrectBlank(correctFIBs[0]);
option.setAlternatives(Arrays.asList(correctFIBs));
boolean caseSensitive = "Yes".equals(fibResponse.getCaseSensitive());
groupBy &= !caseSensitive;
option.setCaseSensitive(caseSensitive);
option.setPoints(fibResponse.getPoints());
options.add(option);
optionMap.put(ident, option);
}
}
}
List<StatisticAnswerOption> answerOptions = getStatisticAnswerOptionsOfItem(item.getIdent(), searchParams, groupBy);
for (StatisticAnswerOption answerOption : answerOptions) {
long count = answerOption.getCount();
String concatenedAnswer = answerOption.getAnswer();
Map<String, String> parsedAnswerMap = QTIResultManager.parseResponseStrAnswers(concatenedAnswer);
for (Map.Entry<String, String> parsedAnswerEntry : parsedAnswerMap.entrySet()) {
String ident = parsedAnswerEntry.getKey();
StatisticFIBOption option = optionMap.get(ident);
if (option == null) {
continue;
}
String text = parsedAnswerEntry.getValue();
boolean correct;
if (option.isCaseSensitive()) {
correct = option.getAlternatives().contains(text);
} else {
correct = false;
for (String alt : option.getAlternatives()) {
if (alt.equalsIgnoreCase(text)) {
correct = true;
}
}
}
if (correct) {
option.setNumOfCorrect(option.getNumOfCorrect() + count);
} else {
option.setNumOfIncorrect(option.getNumOfIncorrect() + count);
option.getWrongAnswers().add(text);
}
}
}
return options;
}
Aggregations