Search in sources :

Example 21 with EvaluationFormElementWrapper

use of org.olat.modules.forms.ui.model.EvaluationFormElementWrapper in project openolat by klemens.

the class CompareEvaluationsFormController method forgeFileUpload.

private List<EvaluationFormElementWrapper> forgeFileUpload(UserRequest ureq, FileUpload element) {
    List<EvaluationFormResponse> responses = identifierToResponses.get(element.getId());
    if (responses == null) {
        return new ArrayList<>();
    }
    List<EvaluationFormElementWrapper> fileUploadWrappers = new ArrayList<>(responses.size());
    for (EvaluationFormResponse response : responses) {
        if (response.getFileResponse() != null) {
            FileUploadCompareWrapper fileUploadWrapper = createFileUploadCompareWrapper(ureq, element, response);
            EvaluationFormElementWrapper wrapper = new EvaluationFormElementWrapper(element);
            wrapper.setFileUploadCompareWrapper(fileUploadWrapper);
            fileUploadWrappers.add(wrapper);
        }
    }
    return fileUploadWrappers;
}
Also used : EvaluationFormElementWrapper(org.olat.modules.forms.ui.model.EvaluationFormElementWrapper) ArrayList(java.util.ArrayList) FileUploadCompareWrapper(org.olat.modules.forms.ui.model.FileUploadCompareWrapper) EvaluationFormResponse(org.olat.modules.forms.EvaluationFormResponse)

Example 22 with EvaluationFormElementWrapper

use of org.olat.modules.forms.ui.model.EvaluationFormElementWrapper in project openolat by klemens.

the class CompareEvaluationsFormController method updateElements.

private void updateElements(UserRequest ureq) {
    List<EvaluationFormElementWrapper> elementWrappers = new ArrayList<>();
    for (AbstractElement element : form.getElements()) {
        appendsElement(ureq, element, elementWrappers);
    }
    flc.contextPut("elements", elementWrappers);
}
Also used : AbstractElement(org.olat.modules.forms.model.xml.AbstractElement) EvaluationFormElementWrapper(org.olat.modules.forms.ui.model.EvaluationFormElementWrapper) ArrayList(java.util.ArrayList)

Example 23 with EvaluationFormElementWrapper

use of org.olat.modules.forms.ui.model.EvaluationFormElementWrapper in project openolat by klemens.

the class CompareEvaluationsFormController method forgeRadarRubric.

private EvaluationFormElementWrapper forgeRadarRubric(Rubric element) {
    EvaluationFormElementWrapper wrapper = new EvaluationFormElementWrapper(element);
    wrapper.setRadarOverview(true);
    List<String> axisList = new ArrayList<>();
    List<Slider> sliders = element.getSliders();
    Map<EvaluationFormSession, RadarSeries> series = new HashMap<>();
    for (Slider slider : sliders) {
        String axis;
        if (StringHelper.containsNonWhitespace(slider.getEndLabel())) {
            axis = slider.getEndLabel();
        } else if (StringHelper.containsNonWhitespace(slider.getStartLabel())) {
            axis = slider.getStartLabel();
        } else {
            axis = "";
        }
        axisList.add(axis);
        String responseIdentifier = slider.getId();
        List<EvaluationFormResponse> responses = identifierToResponses.get(responseIdentifier);
        if (responses != null && responses.size() > 0) {
            for (EvaluationFormResponse response : responses) {
                EvaluationFormSession responseSession = response.getSession();
                if (!series.containsKey(responseSession)) {
                    Identity identity = responseSession.getIdentity();
                    String legend = getLegend(identity);
                    String color = evaluatorToColors.get(identity);
                    series.put(responseSession, new RadarSeries(legend, color));
                }
                if (response.getNumericalResponse() != null) {
                    double value = response.getNumericalResponse().doubleValue();
                    series.get(responseSession).addPoint(axis, value);
                }
            }
        }
    }
    String id = "radar_" + (count++);
    RadarChartElement radarEl = new RadarChartElement(id);
    radarEl.setSeries(new ArrayList<>(series.values()));
    radarEl.setShowLegend(true);
    radarEl.setAxis(axisList);
    if (element.getSliderType() == SliderType.discrete || element.getSliderType() == SliderType.discrete_slider) {
        radarEl.setLevels(element.getSteps());
        radarEl.setMaxValue(element.getSteps());
        radarEl.setFormat(Format.integer);
    } else if (element.getSliderType() == SliderType.continuous) {
        radarEl.setLevels(10);
        radarEl.setMaxValue(100);
        radarEl.setFormat(Format.integer);
    }
    wrapper.setRadarEl(radarEl);
    flc.add(id, radarEl);
    return wrapper;
}
Also used : Slider(org.olat.modules.forms.model.xml.Slider) EvaluationFormElementWrapper(org.olat.modules.forms.ui.model.EvaluationFormElementWrapper) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) RadarSeries(org.olat.core.gui.components.chart.RadarSeries) EvaluationFormSession(org.olat.modules.forms.EvaluationFormSession) RadarChartElement(org.olat.core.gui.components.chart.RadarChartElement) EvaluationFormResponse(org.olat.modules.forms.EvaluationFormResponse) Identity(org.olat.core.id.Identity)

Example 24 with EvaluationFormElementWrapper

use of org.olat.modules.forms.ui.model.EvaluationFormElementWrapper in project openolat by klemens.

the class EvaluationFormController method doConfirmDone.

private void doConfirmDone(UserRequest ureq) {
    for (EvaluationFormElementWrapper elementWrapper : elementWrapperList) {
        if (elementWrapper.isTextInput()) {
            TextInputWrapper wrapper = elementWrapper.getTextInputWrapper();
            String value = wrapper.getTextEl().getValue();
            saveNumericalResponse(null, value, wrapper.getId());
        }
    }
    StringBuilder sb = new StringBuilder();
    sb.append("<p>").append(translate("confirm.done")).append("</p>");
    List<ValidationMessage> messages = new ArrayList<>();
    validate(ureq, messages);
    if (messages.size() > 0) {
        for (ValidationMessage message : messages) {
            sb.append("<p class='o_warning'>").append(message.getMessage()).append("</p>");
        }
    }
    confirmDoneCtrl = activateYesNoDialog(ureq, null, sb.toString(), confirmDoneCtrl);
}
Also used : ValidationMessage(org.olat.modules.portfolio.ui.editor.ValidationMessage) TextInputWrapper(org.olat.modules.forms.ui.model.TextInputWrapper) EvaluationFormElementWrapper(org.olat.modules.forms.ui.model.EvaluationFormElementWrapper) ArrayList(java.util.ArrayList)

Example 25 with EvaluationFormElementWrapper

use of org.olat.modules.forms.ui.model.EvaluationFormElementWrapper in project openolat by klemens.

the class EvaluationFormController method forgeElement.

private EvaluationFormElementWrapper forgeElement(UserRequest ureq, AbstractElement element) {
    EvaluationFormElementWrapper wrapper = null;
    String type = element.getType();
    switch(type) {
        case "formhtitle":
        case "formhr":
        case "formhtmlraw":
            wrapper = new EvaluationFormElementWrapper(element);
            break;
        case "formrubric":
            wrapper = forgeRubric((Rubric) element);
            break;
        case "formtextinput":
            wrapper = forgeTextInput((TextInput) element);
            break;
        case "formfileupload":
            wrapper = forgeFileUpload(ureq, (FileUpload) element);
            break;
    }
    return wrapper;
}
Also used : Rubric(org.olat.modules.forms.model.xml.Rubric) EvaluationFormElementWrapper(org.olat.modules.forms.ui.model.EvaluationFormElementWrapper) TextInput(org.olat.modules.forms.model.xml.TextInput) FileUpload(org.olat.modules.forms.model.xml.FileUpload)

Aggregations

EvaluationFormElementWrapper (org.olat.modules.forms.ui.model.EvaluationFormElementWrapper)28 ArrayList (java.util.ArrayList)18 EvaluationFormResponse (org.olat.modules.forms.EvaluationFormResponse)14 Slider (org.olat.modules.forms.model.xml.Slider)8 SliderWrapper (org.olat.modules.forms.ui.model.SliderWrapper)8 TextInputWrapper (org.olat.modules.forms.ui.model.TextInputWrapper)8 Identity (org.olat.core.id.Identity)4 AbstractElement (org.olat.modules.forms.model.xml.AbstractElement)4 Rubric (org.olat.modules.forms.model.xml.Rubric)4 SliderType (org.olat.modules.forms.model.xml.Rubric.SliderType)4 FileUploadWrapper (org.olat.modules.forms.ui.model.FileUploadWrapper)4 ValidationMessage (org.olat.modules.portfolio.ui.editor.ValidationMessage)4 File (java.io.File)2 HashMap (java.util.HashMap)2 RadarChartElement (org.olat.core.gui.components.chart.RadarChartElement)2 RadarSeries (org.olat.core.gui.components.chart.RadarSeries)2 FileElement (org.olat.core.gui.components.form.flexible.elements.FileElement)2 FormLink (org.olat.core.gui.components.form.flexible.elements.FormLink)2 TextElement (org.olat.core.gui.components.form.flexible.elements.TextElement)2 EvaluationFormSession (org.olat.modules.forms.EvaluationFormSession)2