use of org.olat.ims.qti21.model.xml.ModalFeedbackCondition in project OpenOLAT by OpenOLAT.
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.ModalFeedbackCondition in project OpenOLAT by OpenOLAT.
the class ModalFeedbackBuilder method extractConditions.
public void extractConditions() {
ResponseCondition feedbackRule = findFeedbackResponseCondition(modalFeedback.getIdentifier(), QTI21Constants.FEEDBACKMODAL_IDENTIFIER);
ResponseIf responseIf = feedbackRule.getResponseIf();
if (responseIf != null && responseIf.getExpressions() != null && responseIf.getExpressions().size() == 1 && responseIf.getExpressions().get(0) instanceof And && responseIf.getResponseRules().size() == 1 && responseIf.getResponseRules().get(0) instanceof SetOutcomeValue) {
And and = (And) responseIf.getExpression();
List<Expression> conditionElements = and.getExpressions();
List<ModalFeedbackCondition> extractedConditions = new ArrayList<>();
for (Expression conditionElement : conditionElements) {
ModalFeedbackCondition condition = extractCondition(conditionElement);
if (condition != null) {
extractedConditions.add(condition);
}
}
if (extractedConditions != null) {
conditions = extractedConditions;
}
}
}
use of org.olat.ims.qti21.model.xml.ModalFeedbackCondition in project openolat by klemens.
the class ModalFeedbackBuilder method extractConditions.
public void extractConditions() {
ResponseCondition feedbackRule = findFeedbackResponseCondition(modalFeedback.getIdentifier(), QTI21Constants.FEEDBACKMODAL_IDENTIFIER);
ResponseIf responseIf = feedbackRule.getResponseIf();
if (responseIf != null && responseIf.getExpressions() != null && responseIf.getExpressions().size() == 1 && responseIf.getExpressions().get(0) instanceof And && responseIf.getResponseRules().size() == 1 && responseIf.getResponseRules().get(0) instanceof SetOutcomeValue) {
And and = (And) responseIf.getExpression();
List<Expression> conditionElements = and.getExpressions();
List<ModalFeedbackCondition> extractedConditions = new ArrayList<>();
for (Expression conditionElement : conditionElements) {
ModalFeedbackCondition condition = extractCondition(conditionElement);
if (condition != null) {
extractedConditions.add(condition);
}
}
if (extractedConditions != null) {
conditions = extractedConditions;
}
}
}
use of org.olat.ims.qti21.model.xml.ModalFeedbackCondition 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);
}
Aggregations