use of org.olat.ims.qti21.model.xml.AssessmentItemBuilder in project OpenOLAT by OpenOLAT.
the class CSVToAssessmentItemConverter method processQuestion.
private void processQuestion(String[] parts) {
if (currentItem == null)
return;
String content = parts[1];
if (StringHelper.containsNonWhitespace(content)) {
AssessmentItemBuilder itemBuilder = currentItem.getItemBuilder();
itemBuilder.setQuestion("<p>" + content + "</p>");
}
}
use of org.olat.ims.qti21.model.xml.AssessmentItemBuilder in project OpenOLAT by OpenOLAT.
the class CSVToAssessmentItemConverter method processFeedbackWrongAnswer.
private void processFeedbackWrongAnswer(String[] parts) {
if (currentItem == null || parts.length < 2)
return;
String feedback = parts[1];
if (StringHelper.containsNonWhitespace(feedback)) {
AssessmentItemBuilder itemBuilder = currentItem.getItemBuilder();
itemBuilder.createIncorrectFeedback().setText(feedback);
}
}
use of org.olat.ims.qti21.model.xml.AssessmentItemBuilder in project OpenOLAT by OpenOLAT.
the class CSVToAssessmentItemConverter method processHint.
private void processHint(String[] parts) {
if (currentItem == null || parts.length < 2)
return;
String feedback = parts[1];
if (StringHelper.containsNonWhitespace(feedback)) {
AssessmentItemBuilder itemBuilder = currentItem.getItemBuilder();
itemBuilder.createHint().setText(feedback);
}
}
use of org.olat.ims.qti21.model.xml.AssessmentItemBuilder in project openolat by klemens.
the class QTI12To21Converter method convertFeedbackPerAnswers.
private void convertFeedbackPerAnswers(Item item, AssessmentItemBuilder itemBuilder, Map<String, Identifier> identToIdentifier) {
Question question = item.getQuestion();
List<ModalFeedbackBuilder> additionalFeedbacks = new ArrayList<>();
for (Response response : question.getResponses()) {
if (response instanceof ChoiceResponse) {
Material responseFeedbackMat = QTIEditHelper.getFeedbackOlatRespMaterial(item, response.getIdent());
if (responseFeedbackMat != null) {
String feedbackCondition = responseFeedbackMat.renderAsHtmlForEditor();
feedbackCondition = blockedHtml(feedbackCondition);
ModalFeedbackCondition condition = new ModalFeedbackCondition();
condition.setVariable(Variable.response);
condition.setOperator(Operator.equals);
condition.setValue(identToIdentifier.get(response.getIdent()).toString());
List<ModalFeedbackCondition> conditions = new ArrayList<>(1);
conditions.add(condition);
ModalFeedbackBuilder feedback = new ModalFeedbackBuilder(itemBuilder.getAssessmentItem(), ModalFeedbackType.additional);
feedback.setFeedbackConditions(conditions);
feedback.setText(feedbackCondition);
additionalFeedbacks.add(feedback);
}
}
}
itemBuilder.setAdditionalFeedbackBuilders(additionalFeedbacks);
}
use of org.olat.ims.qti21.model.xml.AssessmentItemBuilder 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;
}
Aggregations