Search in sources :

Example 1 with TestFeedbackBuilder

use of org.olat.ims.qti21.model.xml.TestFeedbackBuilder in project OpenOLAT by OpenOLAT.

the class AssessmentTestFeedbackEditorController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    setFormContextHelp("Test editor QTI 2.1 in detail#details_testeditor_feedback");
    String relativePath = rootDirectory.toPath().relativize(testFile.toPath().getParent()).toString();
    VFSContainer itemContainer = (VFSContainer) rootContainer.resolve(relativePath);
    // correct feedback
    TestFeedbackBuilder passedFeedback = testBuilder.getPassedFeedback();
    String passedTitle = passedFeedback == null ? "" : passedFeedback.getTitle();
    feedbackPassedTitleEl = uifactory.addTextElement("correctTitle", "form.test.correct.title", -1, passedTitle, formLayout);
    feedbackPassedTitleEl.setUserObject(passedFeedback);
    feedbackPassedTitleEl.setEnabled(!restrictedEdit);
    String passedText = passedFeedback == null ? "" : passedFeedback.getText();
    feedbackPassedTextEl = uifactory.addRichTextElementForQTI21("correctText", "form.test.correct.text", passedText, 8, -1, itemContainer, formLayout, ureq.getUserSession(), getWindowControl());
    feedbackPassedTextEl.getEditorConfiguration().setSimplestTextModeAllowed(TextMode.oneLine);
    feedbackPassedTextEl.setEnabled(!restrictedEdit);
    feedbackPassedTextEl.getEditorConfiguration().setFileBrowserUploadRelPath("media");
    // incorrect feedback
    TestFeedbackBuilder failedFeedback = testBuilder.getFailedFeedback();
    String failedTitle = failedFeedback == null ? "" : failedFeedback.getTitle();
    feedbackFailedTitleEl = uifactory.addTextElement("incorrectTitle", "form.test.incorrect.title", -1, failedTitle, formLayout);
    feedbackFailedTitleEl.setUserObject(failedFeedback);
    feedbackFailedTitleEl.setEnabled(!restrictedEdit);
    String fialedText = failedFeedback == null ? "" : failedFeedback.getText();
    feedbackFailedTextEl = uifactory.addRichTextElementForQTI21("incorrectText", "form.test.incorrect.text", fialedText, 8, -1, itemContainer, formLayout, ureq.getUserSession(), getWindowControl());
    feedbackFailedTextEl.getEditorConfiguration().setSimplestTextModeAllowed(TextMode.oneLine);
    feedbackFailedTextEl.setEnabled(!restrictedEdit);
    feedbackFailedTextEl.getEditorConfiguration().setFileBrowserUploadRelPath("media");
    // Submit Button
    FormLayoutContainer buttonsContainer = FormLayoutContainer.createButtonLayout("buttons", getTranslator());
    buttonsContainer.setRootForm(mainForm);
    formLayout.add(buttonsContainer);
    saveButton = uifactory.addFormSubmitButton("submit", buttonsContainer);
    // check the cut value
    sync();
}
Also used : TestFeedbackBuilder(org.olat.ims.qti21.model.xml.TestFeedbackBuilder) VFSContainer(org.olat.core.util.vfs.VFSContainer) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)

Example 2 with TestFeedbackBuilder

use of org.olat.ims.qti21.model.xml.TestFeedbackBuilder in project OpenOLAT by OpenOLAT.

the class AssessmentTestFeedbackEditorController method formOK.

@Override
protected void formOK(UserRequest ureq) {
    String passedTitle = feedbackPassedTitleEl.getValue();
    String passedText = feedbackPassedTextEl.getRawValue();
    if (StringHelper.containsNonWhitespace(FilterFactory.getHtmlTagsFilter().filter(passedText))) {
        TestFeedbackBuilder passedBuilder = testBuilder.getPassedFeedback();
        if (passedBuilder == null) {
            passedBuilder = testBuilder.createPassedFeedback();
        }
        passedBuilder.setTitle(passedTitle);
        passedBuilder.setText(passedText);
    }
    String failedTitle = feedbackFailedTitleEl.getValue();
    String failedText = feedbackFailedTextEl.getRawValue();
    if (StringHelper.containsNonWhitespace(FilterFactory.getHtmlTagsFilter().filter(failedText))) {
        TestFeedbackBuilder failedBuilder = testBuilder.getFailedFeedback();
        if (failedBuilder == null) {
            failedBuilder = testBuilder.createFailedFeedback();
        }
        failedBuilder.setTitle(failedTitle);
        failedBuilder.setText(failedText);
    }
    fireEvent(ureq, AssessmentTestEvent.ASSESSMENT_TEST_CHANGED_EVENT);
}
Also used : TestFeedbackBuilder(org.olat.ims.qti21.model.xml.TestFeedbackBuilder)

Example 3 with TestFeedbackBuilder

use of org.olat.ims.qti21.model.xml.TestFeedbackBuilder in project openolat by klemens.

the class AssessmentTestFeedbackEditorController method formOK.

@Override
protected void formOK(UserRequest ureq) {
    String passedTitle = feedbackPassedTitleEl.getValue();
    String passedText = feedbackPassedTextEl.getRawValue();
    if (StringHelper.containsNonWhitespace(FilterFactory.getHtmlTagsFilter().filter(passedText))) {
        TestFeedbackBuilder passedBuilder = testBuilder.getPassedFeedback();
        if (passedBuilder == null) {
            passedBuilder = testBuilder.createPassedFeedback();
        }
        passedBuilder.setTitle(passedTitle);
        passedBuilder.setText(passedText);
    }
    String failedTitle = feedbackFailedTitleEl.getValue();
    String failedText = feedbackFailedTextEl.getRawValue();
    if (StringHelper.containsNonWhitespace(FilterFactory.getHtmlTagsFilter().filter(failedText))) {
        TestFeedbackBuilder failedBuilder = testBuilder.getFailedFeedback();
        if (failedBuilder == null) {
            failedBuilder = testBuilder.createFailedFeedback();
        }
        failedBuilder.setTitle(failedTitle);
        failedBuilder.setText(failedText);
    }
    fireEvent(ureq, AssessmentTestEvent.ASSESSMENT_TEST_CHANGED_EVENT);
}
Also used : TestFeedbackBuilder(org.olat.ims.qti21.model.xml.TestFeedbackBuilder)

Example 4 with TestFeedbackBuilder

use of org.olat.ims.qti21.model.xml.TestFeedbackBuilder in project openolat by klemens.

the class AssessmentTestFeedbackEditorController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    setFormContextHelp("Test editor QTI 2.1 in detail#details_testeditor_feedback");
    String relativePath = rootDirectory.toPath().relativize(testFile.toPath().getParent()).toString();
    VFSContainer itemContainer = (VFSContainer) rootContainer.resolve(relativePath);
    // correct feedback
    TestFeedbackBuilder passedFeedback = testBuilder.getPassedFeedback();
    String passedTitle = passedFeedback == null ? "" : passedFeedback.getTitle();
    feedbackPassedTitleEl = uifactory.addTextElement("correctTitle", "form.test.correct.title", -1, passedTitle, formLayout);
    feedbackPassedTitleEl.setUserObject(passedFeedback);
    feedbackPassedTitleEl.setEnabled(!restrictedEdit);
    String passedText = passedFeedback == null ? "" : passedFeedback.getText();
    feedbackPassedTextEl = uifactory.addRichTextElementForQTI21("correctText", "form.test.correct.text", passedText, 8, -1, itemContainer, formLayout, ureq.getUserSession(), getWindowControl());
    feedbackPassedTextEl.getEditorConfiguration().setSimplestTextModeAllowed(TextMode.oneLine);
    feedbackPassedTextEl.setEnabled(!restrictedEdit);
    feedbackPassedTextEl.getEditorConfiguration().setFileBrowserUploadRelPath("media");
    // incorrect feedback
    TestFeedbackBuilder failedFeedback = testBuilder.getFailedFeedback();
    String failedTitle = failedFeedback == null ? "" : failedFeedback.getTitle();
    feedbackFailedTitleEl = uifactory.addTextElement("incorrectTitle", "form.test.incorrect.title", -1, failedTitle, formLayout);
    feedbackFailedTitleEl.setUserObject(failedFeedback);
    feedbackFailedTitleEl.setEnabled(!restrictedEdit);
    String fialedText = failedFeedback == null ? "" : failedFeedback.getText();
    feedbackFailedTextEl = uifactory.addRichTextElementForQTI21("incorrectText", "form.test.incorrect.text", fialedText, 8, -1, itemContainer, formLayout, ureq.getUserSession(), getWindowControl());
    feedbackFailedTextEl.getEditorConfiguration().setSimplestTextModeAllowed(TextMode.oneLine);
    feedbackFailedTextEl.setEnabled(!restrictedEdit);
    feedbackFailedTextEl.getEditorConfiguration().setFileBrowserUploadRelPath("media");
    // Submit Button
    FormLayoutContainer buttonsContainer = FormLayoutContainer.createButtonLayout("buttons", getTranslator());
    buttonsContainer.setRootForm(mainForm);
    formLayout.add(buttonsContainer);
    saveButton = uifactory.addFormSubmitButton("submit", buttonsContainer);
    // check the cut value
    sync();
}
Also used : TestFeedbackBuilder(org.olat.ims.qti21.model.xml.TestFeedbackBuilder) VFSContainer(org.olat.core.util.vfs.VFSContainer) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)

Aggregations

TestFeedbackBuilder (org.olat.ims.qti21.model.xml.TestFeedbackBuilder)4 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)2 VFSContainer (org.olat.core.util.vfs.VFSContainer)2