Search in sources :

Example 11 with EvaluationFormResponse

use of org.olat.modules.forms.EvaluationFormResponse in project openolat by klemens.

the class EvaluationFormController method forgeTextInput.

private EvaluationFormElementWrapper forgeTextInput(TextInput element) {
    String initialValue = "";
    EvaluationFormResponse response = identifierToResponses.get(element.getId());
    if (response != null && StringHelper.containsNonWhitespace(response.getStringuifiedResponse())) {
        initialValue = response.getStringuifiedResponse();
    }
    int rows = 12;
    if (element.getRows() > 0) {
        rows = element.getRows();
    }
    TextElement textEl = uifactory.addTextAreaElement("textinput_" + (count++), null, Integer.MAX_VALUE, rows, 72, false, initialValue, flc);
    textEl.setEnabled(!readOnly);
    FormLink saveButton = uifactory.addFormLink("save_" + (count++), "save", null, flc, Link.BUTTON);
    saveButton.setVisible(!readOnly);
    TextInputWrapper textInputWrapper = new TextInputWrapper(element, textEl, saveButton);
    saveButton.setUserObject(textInputWrapper);
    textEl.setUserObject(textInputWrapper);
    EvaluationFormElementWrapper wrapper = new EvaluationFormElementWrapper(element);
    wrapper.setTextInputWrapper(textInputWrapper);
    return wrapper;
}
Also used : TextElement(org.olat.core.gui.components.form.flexible.elements.TextElement) TextInputWrapper(org.olat.modules.forms.ui.model.TextInputWrapper) EvaluationFormElementWrapper(org.olat.modules.forms.ui.model.EvaluationFormElementWrapper) EvaluationFormResponse(org.olat.modules.forms.EvaluationFormResponse) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink)

Example 12 with EvaluationFormResponse

use of org.olat.modules.forms.EvaluationFormResponse in project openolat by klemens.

the class EvaluationFormController method forgeRubric.

private EvaluationFormElementWrapper forgeRubric(Rubric element) {
    EvaluationFormElementWrapper wrapper = new EvaluationFormElementWrapper(element);
    List<Slider> sliders = element.getSliders();
    List<SliderWrapper> sliderWrappers = new ArrayList<>(sliders.size());
    for (Slider slider : sliders) {
        String responseIdentifier = slider.getId();
        EvaluationFormResponse response = identifierToResponses.get(responseIdentifier);
        SliderType type = element.getSliderType();
        SliderWrapper sliderWrapper = null;
        if (type == SliderType.discrete) {
            sliderWrapper = forgeDiscreteRadioButtons(slider, element, response);
        } else if (type == SliderType.discrete_slider) {
            sliderWrapper = forgeDiscreteSlider(slider, element, response);
        } else if (type == SliderType.continuous) {
            sliderWrapper = forgeContinuousSlider(slider, element, response);
        }
        if (sliderWrapper != null) {
            sliderWrappers.add(sliderWrapper);
        }
    }
    wrapper.setSliders(sliderWrappers);
    return wrapper;
}
Also used : SliderWrapper(org.olat.modules.forms.ui.model.SliderWrapper) Slider(org.olat.modules.forms.model.xml.Slider) EvaluationFormElementWrapper(org.olat.modules.forms.ui.model.EvaluationFormElementWrapper) ArrayList(java.util.ArrayList) SliderType(org.olat.modules.forms.model.xml.Rubric.SliderType) EvaluationFormResponse(org.olat.modules.forms.EvaluationFormResponse)

Example 13 with EvaluationFormResponse

use of org.olat.modules.forms.EvaluationFormResponse in project openolat by klemens.

the class EvaluationFormController method saveFileResponse.

private void saveFileResponse(File file, String filename, String responseIdentifier) {
    if (evaluator == null || readOnly)
        return;
    EvaluationFormResponse response = identifierToResponses.get(responseIdentifier);
    try {
        if (response == null) {
            response = evaluationFormManager.createResponseForPortfolioEvaluation(responseIdentifier, file, filename, session);
        } else {
            response = evaluationFormManager.updateResponseForPortfolioEvaluation(file, filename, response);
        }
    } catch (IOException e) {
        showError("error.cannot.save.file");
        log.warn("Cannot save file for an evaluation form response!", e);
    }
    updateCache(responseIdentifier, response);
}
Also used : IOException(java.io.IOException) EvaluationFormResponse(org.olat.modules.forms.EvaluationFormResponse)

Example 14 with EvaluationFormResponse

use of org.olat.modules.forms.EvaluationFormResponse in project OpenOLAT by OpenOLAT.

the class EvaluationFormController method loadResponses.

private void loadResponses() {
    if (evaluator == null)
        return;
    flc.contextPut("messageNotDone", Boolean.FALSE);
    session = evaluationFormManager.getSessionForPortfolioEvaluation(evaluator, anchor);
    if (session == null) {
        session = evaluationFormManager.createSessionForPortfolioEvaluation(evaluator, anchor, formEntry);
    }
    if (session.getEvaluationFormSessionStatus() == EvaluationFormSessionStatus.done) {
        readOnly = true;
    } else if (!evaluator.equals(getIdentity())) {
        flc.contextPut("messageNotDone", Boolean.TRUE);
    }
    List<EvaluationFormResponse> responses = evaluationFormManager.getResponsesFromPortfolioEvaluation(evaluator, anchor);
    for (EvaluationFormResponse response : responses) {
        identifierToResponses.put(response.getResponseIdentifier(), response);
    }
}
Also used : EvaluationFormResponse(org.olat.modules.forms.EvaluationFormResponse)

Example 15 with EvaluationFormResponse

use of org.olat.modules.forms.EvaluationFormResponse in project OpenOLAT by OpenOLAT.

the class EvaluationFormController method forgeFileUpload.

private EvaluationFormElementWrapper forgeFileUpload(UserRequest ureq, FileUpload element) {
    FileElement fileEl = uifactory.addFileElement(getWindowControl(), "file_upload_" + CodeHelper.getRAMUniqueID(), "", flc);
    fileEl.setPreview(ureq.getUserSession(), true);
    fileEl.addActionListener(FormEvent.ONCHANGE);
    fileEl.setDeleteEnabled(true);
    fileEl.setMaxUploadSizeKB(element.getMaxUploadSizeKB(), "file.upload.error.limit.exeeded", null);
    Set<String> mimeTypes = MimeTypeSetFactory.getMimeTypes(element.getMimeTypeSetKey());
    fileEl.limitToMimeType(mimeTypes, "file.upload.error.mime.type.wrong", null);
    EvaluationFormResponse response = identifierToResponses.get(element.getId());
    File responseFile = evaluationFormManager.loadResponseFile(response);
    if (responseFile != null) {
        fileEl.setInitialFile(responseFile);
    }
    fileEl.setEnabled(!readOnly);
    FileUploadWrapper fileUploadWrapper = new FileUploadWrapper(fileEl, element);
    fileEl.setUserObject(fileUploadWrapper);
    EvaluationFormElementWrapper wrapper = new EvaluationFormElementWrapper(element);
    wrapper.setFileUploadWrapper(fileUploadWrapper);
    return wrapper;
}
Also used : EvaluationFormElementWrapper(org.olat.modules.forms.ui.model.EvaluationFormElementWrapper) FileElement(org.olat.core.gui.components.form.flexible.elements.FileElement) EvaluationFormResponse(org.olat.modules.forms.EvaluationFormResponse) FileUploadWrapper(org.olat.modules.forms.ui.model.FileUploadWrapper) File(java.io.File)

Aggregations

EvaluationFormResponse (org.olat.modules.forms.EvaluationFormResponse)26 EvaluationFormElementWrapper (org.olat.modules.forms.ui.model.EvaluationFormElementWrapper)16 ArrayList (java.util.ArrayList)14 Identity (org.olat.core.id.Identity)10 Slider (org.olat.modules.forms.model.xml.Slider)8 SliderWrapper (org.olat.modules.forms.ui.model.SliderWrapper)8 EvaluationFormSession (org.olat.modules.forms.EvaluationFormSession)6 TextInputWrapper (org.olat.modules.forms.ui.model.TextInputWrapper)6 File (java.io.File)4 HashMap (java.util.HashMap)4 RadarChartElement (org.olat.core.gui.components.chart.RadarChartElement)4 RadarSeries (org.olat.core.gui.components.chart.RadarSeries)4 SliderType (org.olat.modules.forms.model.xml.Rubric.SliderType)4 FileUploadCompareWrapper (org.olat.modules.forms.ui.model.FileUploadCompareWrapper)4 PageBody (org.olat.modules.portfolio.PageBody)4 RepositoryEntry (org.olat.repository.RepositoryEntry)4 BigDecimal (java.math.BigDecimal)2 Path (java.nio.file.Path)2 List (java.util.List)2 Map (java.util.Map)2