use of uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleChoice in project openolat by klemens.
the class SimpleChoiceAssessmentItemBuilder method getAnswers.
@Override
public List<Answer> getAnswers() {
List<SimpleChoice> simpleChoices = getChoices();
List<Answer> answers = new ArrayList<>(simpleChoices.size());
for (SimpleChoice choice : simpleChoices) {
String choiceContent = getHtmlHelper().flowStaticString(choice.getFlowStatics());
String label = FilterFactory.getHtmlTagAndDescapingFilter().filter(choiceContent);
answers.add(new Answer(choice.getIdentifier(), label));
}
return answers;
}
use of uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleChoice in project openolat by klemens.
the class AssessmentItemFactory method appendSimpleChoice.
public static SimpleChoice appendSimpleChoice(ChoiceInteraction choiceInteraction, String text, String prefix) {
SimpleChoice newChoice = createSimpleChoice(choiceInteraction, text, prefix);
choiceInteraction.getNodeGroups().getSimpleChoiceGroup().getSimpleChoices().add(newChoice);
return newChoice;
}
use of uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleChoice in project openolat by klemens.
the class AssessmentItemFactory method appendSimpleChoice.
public static SimpleChoice appendSimpleChoice(ChoiceInteraction choiceInteraction, String text, Identifier identifier) {
SimpleChoice newChoice = new SimpleChoice(choiceInteraction);
newChoice.setIdentifier(identifier);
P firstChoiceText = AssessmentItemFactory.getParagraph(newChoice, text);
newChoice.getFlowStatics().add(firstChoiceText);
choiceInteraction.getNodeGroups().getSimpleChoiceGroup().getSimpleChoices().add(newChoice);
return newChoice;
}
use of uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleChoice in project openolat by klemens.
the class QTI12To21Converter method convertSingleChoice.
private AssessmentItemBuilder convertSingleChoice(Item item) {
SingleChoiceAssessmentItemBuilder itemBuilder = new SingleChoiceAssessmentItemBuilder("Single choice", "New answer", qtiSerializer);
convertItemBasics(item, itemBuilder);
itemBuilder.clearMapping();
itemBuilder.clearSimpleChoices();
itemBuilder.setScoreEvaluationMode(ScoreEvaluation.allCorrectAnswers);
ChoiceInteraction interaction = itemBuilder.getChoiceInteraction();
Question question = item.getQuestion();
itemBuilder.setShuffle(question.isShuffle());
convertOrientation(question, itemBuilder);
List<Response> responses = question.getResponses();
Map<String, Identifier> identToIdentifier = new HashMap<>();
for (Response response : responses) {
String responseText = response.getContent().renderAsHtmlForEditor();
responseText = blockedHtml(responseText);
SimpleChoice newChoice;
if (StringHelper.isHtml(responseText)) {
newChoice = AssessmentItemFactory.createSimpleChoice(interaction, "", itemBuilder.getQuestionType().getPrefix());
htmlBuilder.appendHtml(newChoice, responseText);
} else {
newChoice = AssessmentItemFactory.createSimpleChoice(interaction, responseText, itemBuilder.getQuestionType().getPrefix());
}
itemBuilder.addSimpleChoice(newChoice);
identToIdentifier.put(response.getIdent(), newChoice.getIdentifier());
if (response.isCorrect()) {
itemBuilder.setCorrectAnswer(newChoice.getIdentifier());
}
}
convertFeedbackPerAnswers(item, itemBuilder, identToIdentifier);
double correctScore = question.getSingleCorrectScore();
if (correctScore >= 0.0d) {
itemBuilder.setMinScore(0.0d);
itemBuilder.setMaxScore(correctScore);
}
return itemBuilder;
}
use of uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleChoice in project openolat by klemens.
the class CSVToAssessmentItemConverter method processChoice_smc.
private void processChoice_smc(String[] parts, SimpleChoiceAssessmentItemBuilder choiceBuilder) {
double point = parseFloat(parts[0], 1.0f);
String content = parts[1];
ChoiceInteraction interaction = choiceBuilder.getChoiceInteraction();
SimpleChoice newChoice = AssessmentItemFactory.createSimpleChoice(interaction, content, choiceBuilder.getQuestionType().getPrefix());
choiceBuilder.addSimpleChoice(newChoice);
choiceBuilder.setMapping(newChoice.getIdentifier(), point);
if (point > 0.0) {
if (choiceBuilder instanceof MultipleChoiceAssessmentItemBuilder) {
((MultipleChoiceAssessmentItemBuilder) choiceBuilder).addCorrectAnswer(newChoice.getIdentifier());
} else {
((SingleChoiceAssessmentItemBuilder) choiceBuilder).setCorrectAnswer(newChoice.getIdentifier());
}
}
}
Aggregations