Search in sources :

Example 21 with EvaluationFormResponse

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

the class CompareEvaluationsFormController method forgeSliderStats.

private SliderWrapper forgeSliderStats(Slider slider, Rubric element, List<EvaluationFormResponse> responses) {
    String id = "overview_" + (count++);
    SliderOverviewElement overviewEl = new SliderOverviewElement(id);
    overviewEl.setMinValue(element.getStart());
    overviewEl.setMaxValue(element.getEnd());
    flc.add(id, overviewEl);
    List<SliderPoint> values = new ArrayList<>();
    if (responses != null && responses.size() > 0) {
        for (EvaluationFormResponse response : responses) {
            if (response.getNumericalResponse() != null) {
                Identity evaluator = response.getSession().getIdentity();
                String color = evaluatorToColors.get(evaluator);
                double value = response.getNumericalResponse().doubleValue();
                values.add(new SliderPoint(color, value));
            }
        }
    }
    overviewEl.setValues(values);
    return new SliderWrapper(slider, overviewEl);
}
Also used : SliderWrapper(org.olat.modules.forms.ui.model.SliderWrapper) SliderOverviewElement(org.olat.modules.forms.ui.component.SliderOverviewElement) ArrayList(java.util.ArrayList) EvaluationFormResponse(org.olat.modules.forms.EvaluationFormResponse) Identity(org.olat.core.id.Identity) SliderPoint(org.olat.modules.forms.ui.component.SliderPoint)

Example 22 with EvaluationFormResponse

use of org.olat.modules.forms.EvaluationFormResponse 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 23 with EvaluationFormResponse

use of org.olat.modules.forms.EvaluationFormResponse 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 EvaluationFormResponse

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

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 25 with EvaluationFormResponse

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

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