Search in sources :

Example 6 with EvaluationFormSession

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

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 7 with EvaluationFormSession

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

the class MultiEvaluationFormController method isViewOthers.

private boolean isViewOthers() {
    boolean viewOthers;
    if (doneFirst) {
        EvaluationFormSession session = evaluationFormManager.getSessionForPortfolioEvaluation(getIdentity(), anchor);
        viewOthers = session == null ? false : session.getEvaluationFormSessionStatus() == EvaluationFormSessionStatus.done;
    } else {
        viewOthers = true;
    }
    return viewOthers;
}
Also used : EvaluationFormSession(org.olat.modules.forms.EvaluationFormSession)

Example 8 with EvaluationFormSession

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

the class PortfolioNotificationsHandler method getEvaluationNotifications.

public List<SubscriptionListItem> getEvaluationNotifications(Binder binder, BinderSecurityCallback secCallback, Date compareDate, String rootBusinessPath, Translator translator) {
    StringBuilder sb = new StringBuilder();
    sb.append("select page, evasession").append(" from pfpage as page").append(" inner join fetch page.section as section").append(" inner join fetch section.binder as binder").append(" left join evaluationformsession as evasession on (page.body.key = evasession.pageBody.key)").append(" where binder.key=:binderKey and evasession.status='done' and evasession.submissionDate>=:compareDate");
    List<Object[]> objects = dbInstance.getCurrentEntityManager().createQuery(sb.toString(), Object[].class).setParameter("binderKey", binder.getKey()).setParameter("compareDate", compareDate).getResultList();
    List<SubscriptionListItem> items = new ArrayList<>(objects.size());
    for (Object[] object : objects) {
        // page
        Page page = (Page) object[0];
        Long pageKey = page.getKey();
        String pageTitle = page.getTitle();
        // session
        EvaluationFormSession evaluationSession = (EvaluationFormSession) object[1];
        Date submissionDate = evaluationSession.getSubmissionDate();
        Date firstSubmissionDate = evaluationSession.getFirstSubmissionDate();
        if (submissionDate != null && secCallback.canViewElement(page)) {
            if (submissionDate.compareTo(firstSubmissionDate) == 0) {
                SubscriptionListItem item = evaluationNewItem(pageKey, pageTitle, submissionDate, rootBusinessPath, translator);
                items.add(item);
            } else {
                SubscriptionListItem item = evaluationModifiedItem(pageKey, pageTitle, submissionDate, rootBusinessPath, translator);
                items.add(item);
            }
        }
    }
    return items;
}
Also used : SubscriptionListItem(org.olat.core.commons.services.notifications.model.SubscriptionListItem) EvaluationFormSession(org.olat.modules.forms.EvaluationFormSession) ArrayList(java.util.ArrayList) Page(org.olat.modules.portfolio.Page) Date(java.util.Date)

Example 9 with EvaluationFormSession

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

the class EvaluationFormSessionDAOTest method createSessionForPortfolio.

@Test
public void createSessionForPortfolio() {
    Identity id = JunitTestHelper.createAndPersistIdentityAsRndUser("eva-1");
    BinderImpl binder = binderDao.createAndPersist("Binder evaluation 1", "A binder with an evaluation", null, null);
    Section section = binderDao.createSection("Section", "First section", null, null, binder);
    dbInstance.commit();
    Section reloadedSection = binderDao.loadSectionByKey(section.getKey());
    Page page = pageDao.createAndPersist("Page 1", "A page with an evalutation.", null, null, true, reloadedSection, null);
    dbInstance.commit();
    RepositoryEntry formEntry = createFormEntry("Eva. form for session");
    PageBody reloadedBody = pageDao.loadPageBodyByKey(page.getBody().getKey());
    EvaluationFormSession session = evaluationFormSessionDao.createSessionForPortfolio(id, reloadedBody, formEntry);
    dbInstance.commit();
    Assert.assertNotNull(session);
    Assert.assertNotNull(session.getKey());
    Assert.assertNotNull(session.getCreationDate());
    Assert.assertNotNull(session.getLastModified());
    Assert.assertEquals(reloadedBody, session.getPageBody());
    Assert.assertEquals(id, session.getIdentity());
}
Also used : EvaluationFormSession(org.olat.modules.forms.EvaluationFormSession) BinderImpl(org.olat.modules.portfolio.model.BinderImpl) Page(org.olat.modules.portfolio.Page) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) Section(org.olat.modules.portfolio.Section) PageBody(org.olat.modules.portfolio.PageBody) Test(org.junit.Test)

Example 10 with EvaluationFormSession

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

Aggregations

EvaluationFormSession (org.olat.modules.forms.EvaluationFormSession)10 Identity (org.olat.core.id.Identity)6 Page (org.olat.modules.portfolio.Page)6 ArrayList (java.util.ArrayList)4 Test (org.junit.Test)4 EvaluationFormResponse (org.olat.modules.forms.EvaluationFormResponse)4 PageBody (org.olat.modules.portfolio.PageBody)4 Section (org.olat.modules.portfolio.Section)4 BinderImpl (org.olat.modules.portfolio.model.BinderImpl)4 RepositoryEntry (org.olat.repository.RepositoryEntry)4 BigDecimal (java.math.BigDecimal)2 Path (java.nio.file.Path)2 Date (java.util.Date)2 HashMap (java.util.HashMap)2 SubscriptionListItem (org.olat.core.commons.services.notifications.model.SubscriptionListItem)2 RadarChartElement (org.olat.core.gui.components.chart.RadarChartElement)2 RadarSeries (org.olat.core.gui.components.chart.RadarSeries)2 Slider (org.olat.modules.forms.model.xml.Slider)2 EvaluationFormElementWrapper (org.olat.modules.forms.ui.model.EvaluationFormElementWrapper)2