Search in sources :

Example 6 with ModalFeedbackBuilder

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()));
}
Also used : ModalFeedbackBuilder(org.olat.ims.qti21.model.xml.ModalFeedbackBuilder) ArrayList(java.util.ArrayList) AssessmentItemEvent(org.olat.ims.qti21.ui.editor.events.AssessmentItemEvent)

Example 7 with ModalFeedbackBuilder

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();
}
Also used : ModalFeedbackBuilder(org.olat.ims.qti21.model.xml.ModalFeedbackBuilder) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) DropdownItem(org.olat.core.gui.components.dropdown.DropdownItem)

Example 8 with ModalFeedbackBuilder

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);
    }
}
Also used : ModalFeedbackBuilder(org.olat.ims.qti21.model.xml.ModalFeedbackBuilder) Translator(org.olat.core.gui.translator.Translator) AssessmentItem(uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem) EssayQuestion(org.olat.ims.qti.editor.beecom.objects.EssayQuestion) ChoiceQuestion(org.olat.ims.qti.editor.beecom.objects.ChoiceQuestion) Question(org.olat.ims.qti.editor.beecom.objects.Question)

Example 9 with ModalFeedbackBuilder

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);
}
Also used : FIBResponse(org.olat.ims.qti.editor.beecom.objects.FIBResponse) ChoiceResponse(org.olat.ims.qti.editor.beecom.objects.ChoiceResponse) Response(org.olat.ims.qti.editor.beecom.objects.Response) EssayResponse(org.olat.ims.qti.editor.beecom.objects.EssayResponse) ChoiceResponse(org.olat.ims.qti.editor.beecom.objects.ChoiceResponse) ModalFeedbackBuilder(org.olat.ims.qti21.model.xml.ModalFeedbackBuilder) ArrayList(java.util.ArrayList) EssayQuestion(org.olat.ims.qti.editor.beecom.objects.EssayQuestion) ChoiceQuestion(org.olat.ims.qti.editor.beecom.objects.ChoiceQuestion) Question(org.olat.ims.qti.editor.beecom.objects.Question) Material(org.olat.ims.qti.editor.beecom.objects.Material) ModalFeedbackCondition(org.olat.ims.qti21.model.xml.ModalFeedbackCondition)

Example 10 with ModalFeedbackBuilder

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;
            }
        }
    }
}
Also used : ModalFeedbackType(org.olat.ims.qti21.model.xml.ModalFeedbackBuilder.ModalFeedbackType) ModalFeedback(uk.ac.ed.ph.jqtiplus.node.item.ModalFeedback)

Aggregations

AssessmentItem (uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem)20 URL (java.net.URL)18 Test (org.junit.Test)18 JqtiExtensionManager (uk.ac.ed.ph.jqtiplus.JqtiExtensionManager)18 ResolvedAssessmentItem (uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem)18 QtiSerializer (uk.ac.ed.ph.jqtiplus.serialization.QtiSerializer)18 Interaction (uk.ac.ed.ph.jqtiplus.node.item.interaction.Interaction)12 SimpleChoice (uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleChoice)12 ModalFeedbackBuilder (org.olat.ims.qti21.model.xml.ModalFeedbackBuilder)10 ChoiceInteraction (uk.ac.ed.ph.jqtiplus.node.item.interaction.ChoiceInteraction)10 EndAttemptInteraction (uk.ac.ed.ph.jqtiplus.node.item.interaction.EndAttemptInteraction)10 MultipleChoiceAssessmentItemBuilder (org.olat.ims.qti21.model.xml.interactions.MultipleChoiceAssessmentItemBuilder)8 SingleChoiceAssessmentItemBuilder (org.olat.ims.qti21.model.xml.interactions.SingleChoiceAssessmentItemBuilder)8 ArrayList (java.util.ArrayList)4 ChoiceQuestion (org.olat.ims.qti.editor.beecom.objects.ChoiceQuestion)4 EssayQuestion (org.olat.ims.qti.editor.beecom.objects.EssayQuestion)4 Question (org.olat.ims.qti.editor.beecom.objects.Question)4 DropdownItem (org.olat.core.gui.components.dropdown.DropdownItem)2 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)2 Translator (org.olat.core.gui.translator.Translator)2