use of org.olat.ims.qti21.model.xml.ModalFeedbackBuilder in project OpenOLAT by OpenOLAT.
the class FeedbacksEditorController method formOK.
@Override
protected void formOK(UserRequest ureq) {
if (restrictedEdit || readOnly)
return;
hintForm.commit();
hintForm.setVisible(!hintForm.isEmpty());
correctSolutionForm.commit();
correctSolutionForm.setVisible(!correctSolutionForm.isEmpty());
correctForm.commit();
correctForm.setVisible(!correctForm.isEmpty());
incorrectForm.commit();
incorrectForm.setVisible(!incorrectForm.isEmpty());
answeredForm.commit();
answeredForm.setVisible(!answeredForm.isEmpty());
emptyForm.commit();
emptyForm.setVisible(!emptyForm.isEmpty());
List<RuledFeedbackForm> validAdditionalForms = new ArrayList<>();
List<ModalFeedbackBuilder> additionalBuilders = new ArrayList<>();
for (RuledFeedbackForm additionalForm : additionalForms) {
ModalFeedbackBuilder additionalBuilder = additionalForm.commit();
if (additionalBuilder != null) {
additionalBuilders.add(additionalBuilder);
validAdditionalForms.add(additionalForm);
}
}
itemBuilder.setAdditionalFeedbackBuilders(additionalBuilders);
additionalForms.clear();
additionalForms.addAll(validAdditionalForms);
updateAddButtons();
fireEvent(ureq, new AssessmentItemEvent(AssessmentItemEvent.ASSESSMENT_ITEM_CHANGED, itemBuilder.getAssessmentItem()));
}
use of org.olat.ims.qti21.model.xml.ModalFeedbackBuilder in project OpenOLAT by OpenOLAT.
the class FeedbacksEditorController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
setFormContextHelp("Test editor QTI 2.1 in detail#details_testeditor_feedback");
formLayout.setElementCssClass("o_sel_assessment_item_feedbacks");
DropdownItem dropdownEl = uifactory.addDropdownMenu("add.feedback.menu", null, formLayout, getTranslator());
dropdownEl.setOrientation(DropdownOrientation.right);
dropdownEl.setElementCssClass("o_sel_add_feedbacks");
dropdownEl.setVisible(!restrictedEdit && !readOnly);
dropdownEl.setEmbbeded(true);
addHintButton = uifactory.addFormLink("add.hint.feedback", formLayout, Link.LINK);
addHintButton.setElementCssClass("o_sel_add_hint");
addHintButton.setVisible(enable.isEnabled(ModalFeedbackType.hint));
dropdownEl.addElement(addHintButton);
addCorrectSolutionButton = uifactory.addFormLink("add.correctSolution.feedback", formLayout, Link.LINK);
addCorrectSolutionButton.setElementCssClass("o_sel_add_correct_solution");
addCorrectSolutionButton.setVisible(enable.isEnabled(ModalFeedbackType.correctSolution));
dropdownEl.addElement(addCorrectSolutionButton);
addCorrectButton = uifactory.addFormLink("add.correct.feedback", formLayout, Link.LINK);
addCorrectButton.setElementCssClass("o_sel_add_correct");
addCorrectButton.setVisible(enable.isEnabled(ModalFeedbackType.correct));
dropdownEl.addElement(addCorrectButton);
addIncorrectButton = uifactory.addFormLink("add.incorrect.feedback", formLayout, Link.LINK);
addIncorrectButton.setElementCssClass("o_sel_add_incorrect");
addIncorrectButton.setVisible(enable.isEnabled(ModalFeedbackType.incorrect));
dropdownEl.addElement(addIncorrectButton);
addAnsweredButton = uifactory.addFormLink("add.answered.feedback", formLayout, Link.LINK);
addAnsweredButton.setElementCssClass("o_sel_add_answered");
addAnsweredButton.setVisible(enable.isEnabled(ModalFeedbackType.answered));
dropdownEl.addElement(addAnsweredButton);
addEmptyButton = uifactory.addFormLink("add.empty.feedback", formLayout, Link.LINK);
addEmptyButton.setElementCssClass("o_sel_add_empty");
addEmptyButton.setVisible(enable.isEnabled(ModalFeedbackType.empty));
dropdownEl.addElement(addEmptyButton);
addAdditionalButton = uifactory.addFormLink("add.additional.feedback", formLayout, Link.LINK);
addAdditionalButton.setElementCssClass("o_sel_add_conditional");
dropdownEl.addElement(addAdditionalButton);
ModalFeedbackBuilder hint = itemBuilder.getHint();
hintForm = new SimpleFeedbackForm(hint, ModalFeedbackType.hint);
hintForm.initForm(ureq, formLayout);
hintForm.setVisible(!hintForm.isEmpty());
ModalFeedbackBuilder correctSolution = itemBuilder.getCorrectSolutionFeedback();
correctSolutionForm = new SimpleFeedbackForm(correctSolution, ModalFeedbackType.correctSolution);
correctSolutionForm.initForm(ureq, formLayout);
correctSolutionForm.setVisible(!correctSolutionForm.isEmpty());
ModalFeedbackBuilder correct = itemBuilder.getCorrectFeedback();
correctForm = new SimpleFeedbackForm(correct, ModalFeedbackType.correct);
correctForm.initForm(ureq, formLayout);
correctForm.setVisible(!correctForm.isEmpty());
ModalFeedbackBuilder incorrect = itemBuilder.getIncorrectFeedback();
incorrectForm = new SimpleFeedbackForm(incorrect, ModalFeedbackType.incorrect);
incorrectForm.initForm(ureq, formLayout);
incorrectForm.setVisible(!incorrectForm.isEmpty());
ModalFeedbackBuilder answered = itemBuilder.getAnsweredFeedback();
answeredForm = new SimpleFeedbackForm(answered, ModalFeedbackType.answered);
answeredForm.initForm(ureq, formLayout);
answeredForm.setVisible(!answeredForm.isEmpty());
ModalFeedbackBuilder empty = itemBuilder.getEmptyFeedback();
emptyForm = new SimpleFeedbackForm(empty, ModalFeedbackType.empty);
emptyForm.initForm(ureq, formLayout);
emptyForm.setVisible(!emptyForm.isEmpty());
List<ModalFeedbackBuilder> additionals = itemBuilder.getAdditionalFeedbackBuilders();
if (additionals != null && additionals.size() > 0) {
int count = 0;
for (ModalFeedbackBuilder additional : additionals) {
RuledFeedbackForm conditionForm = new RuledFeedbackForm(additional, ++count);
conditionForm.initForm(ureq, formLayout);
additionalForms.add(conditionForm);
}
}
if (formLayout instanceof FormLayoutContainer) {
FormLayoutContainer layoutCont = (FormLayoutContainer) formLayout;
layoutCont.contextPut("additionals", additionalForms);
}
// Submit Button
if (!restrictedEdit && !readOnly) {
uifactory.addFormSubmitButton("submit", formLayout);
}
updateAddButtons();
}
use of org.olat.ims.qti21.model.xml.ModalFeedbackBuilder in project OpenOLAT by OpenOLAT.
the class QTI12To21Converter method convertItemBasics.
private void convertItemBasics(Item item, AssessmentItemBuilder itemBuilder) {
AssessmentItem assessmentItem = itemBuilder.getAssessmentItem();
if (StringHelper.containsNonWhitespace(item.getTitle())) {
assessmentItem.setTitle(item.getTitle());
}
if (StringHelper.containsNonWhitespace(item.getLabel())) {
assessmentItem.setLabel(item.getLabel());
}
Question question = item.getQuestion();
String questionText = question.getQuestion().renderAsHtmlForEditor();
questionText = blockedHtml(questionText);
if (StringHelper.isHtml(questionText)) {
itemBuilder.setQuestion(questionText);
} else {
itemBuilder.setQuestion("<p>" + questionText + "</p>");
}
String hintText = question.getHintText();
if (StringHelper.containsNonWhitespace(hintText)) {
ModalFeedbackBuilder hint = itemBuilder.createHint();
Translator translator = Util.createPackageTranslator(QTIModule.class, locale);
hint.setTitle(translator.translate("render.hint"));
hint.setText(hintText);
}
String solutionText = question.getSolutionText();
if (StringHelper.containsNonWhitespace(solutionText)) {
ModalFeedbackBuilder solution = itemBuilder.createCorrectSolutionFeedback();
solutionText = blockedHtml(solutionText);
solution.setText(solutionText);
}
String feedbackMastery = QTIEditHelper.getFeedbackMasteryText(item);
if (StringHelper.containsNonWhitespace(feedbackMastery)) {
ModalFeedbackBuilder feedback = itemBuilder.createCorrectFeedback();
feedbackMastery = blockedHtml(feedbackMastery);
feedback.setText(feedbackMastery);
}
String feedbackFail = QTIEditHelper.getFeedbackFailText(item);
if (StringHelper.containsNonWhitespace(feedbackFail)) {
ModalFeedbackBuilder feedback = itemBuilder.createIncorrectFeedback();
feedbackFail = blockedHtml(feedbackFail);
feedback.setText(feedbackFail);
}
}
use of org.olat.ims.qti21.model.xml.ModalFeedbackBuilder 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.ModalFeedbackBuilder in project OpenOLAT by OpenOLAT.
the class AssessmentItemBuilder method extractModalFeedbacks.
private void extractModalFeedbacks() {
List<ModalFeedback> feedbacks = assessmentItem.getModalFeedbacks();
for (ModalFeedback feedback : feedbacks) {
ModalFeedbackBuilder feedbackBuilder = new ModalFeedbackBuilder(assessmentItem, feedback);
ModalFeedbackType feedbackType = feedbackBuilder.getType();
if (feedbackType != null && feedbackType != ModalFeedbackType.unkown) {
switch(feedbackType) {
case correct:
correctFeedback = feedbackBuilder;
break;
case incorrect:
incorrectFeedback = feedbackBuilder;
break;
case correctSolution:
correctSolutionFeedback = feedbackBuilder;
break;
case empty:
emptyFeedback = feedbackBuilder;
break;
case answered:
answeredFeedback = feedbackBuilder;
break;
case hint:
hint = feedbackBuilder;
break;
case additional:
additionalFeedbacks.add(feedbackBuilder);
break;
case unkown:
log.error("Unkown feedback:");
break;
}
}
}
}
Aggregations