Search in sources :

Example 6 with EvaluationFormResponse

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

the class EvaluationFormResponseDAOTest method createResponseforPortfolio.

@Test
public void createResponseforPortfolio() {
    // prepare a test case with the binder up to the page body
    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 responses");
    PageBody reloadedBody = pageDao.loadPageBodyByKey(page.getBody().getKey());
    EvaluationFormSession session = evaluationFormSessionDao.createSessionForPortfolio(id, reloadedBody, formEntry);
    dbInstance.commit();
    // create a response
    String responseIdentifier = UUID.randomUUID().toString();
    BigDecimal numericalValue = new BigDecimal("2.2");
    String stringuifiedResponse = numericalValue.toPlainString();
    Path fileResponse = Paths.get("this", "is", "a", "path");
    EvaluationFormResponse response = evaluationFormResponseDao.createResponse(responseIdentifier, numericalValue, stringuifiedResponse, fileResponse, session);
    dbInstance.commit();
    Assert.assertNotNull(response);
    Assert.assertNotNull(response.getKey());
    Assert.assertNotNull(response.getCreationDate());
    Assert.assertNotNull(response.getLastModified());
    Assert.assertEquals(session, response.getSession());
    Assert.assertEquals(numericalValue, response.getNumericalResponse());
    Assert.assertEquals(stringuifiedResponse, response.getStringuifiedResponse());
    Assert.assertEquals(fileResponse, response.getFileResponse());
    Assert.assertEquals(responseIdentifier, response.getResponseIdentifier());
}
Also used : Path(java.nio.file.Path) 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) EvaluationFormResponse(org.olat.modules.forms.EvaluationFormResponse) Section(org.olat.modules.portfolio.Section) PageBody(org.olat.modules.portfolio.PageBody) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Example 7 with EvaluationFormResponse

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

the class EvaluationFormResponseDAOTest method createResponseforPortfolio.

@Test
public void createResponseforPortfolio() {
    // prepare a test case with the binder up to the page body
    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 responses");
    PageBody reloadedBody = pageDao.loadPageBodyByKey(page.getBody().getKey());
    EvaluationFormSession session = evaluationFormSessionDao.createSessionForPortfolio(id, reloadedBody, formEntry);
    dbInstance.commit();
    // create a response
    String responseIdentifier = UUID.randomUUID().toString();
    BigDecimal numericalValue = new BigDecimal("2.2");
    String stringuifiedResponse = numericalValue.toPlainString();
    Path fileResponse = Paths.get("this", "is", "a", "path");
    EvaluationFormResponse response = evaluationFormResponseDao.createResponse(responseIdentifier, numericalValue, stringuifiedResponse, fileResponse, session);
    dbInstance.commit();
    Assert.assertNotNull(response);
    Assert.assertNotNull(response.getKey());
    Assert.assertNotNull(response.getCreationDate());
    Assert.assertNotNull(response.getLastModified());
    Assert.assertEquals(session, response.getSession());
    Assert.assertEquals(numericalValue, response.getNumericalResponse());
    Assert.assertEquals(stringuifiedResponse, response.getStringuifiedResponse());
    Assert.assertEquals(fileResponse, response.getFileResponse());
    Assert.assertEquals(responseIdentifier, response.getResponseIdentifier());
}
Also used : Path(java.nio.file.Path) 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) EvaluationFormResponse(org.olat.modules.forms.EvaluationFormResponse) Section(org.olat.modules.portfolio.Section) PageBody(org.olat.modules.portfolio.PageBody) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Example 8 with EvaluationFormResponse

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

the class CompareEvaluationsFormController method forgeRubric.

private EvaluationFormElementWrapper forgeRubric(Rubric element) {
    EvaluationFormElementWrapper wrapper = new EvaluationFormElementWrapper(element);
    wrapper.setSliderOverview(true);
    List<Slider> sliders = element.getSliders();
    List<SliderWrapper> sliderWrappers = new ArrayList<>(sliders.size());
    for (Slider slider : sliders) {
        String responseIdentifier = slider.getId();
        List<EvaluationFormResponse> responses = identifierToResponses.get(responseIdentifier);
        SliderWrapper sliderWrapper = forgeSliderStats(slider, element, responses);
        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) EvaluationFormResponse(org.olat.modules.forms.EvaluationFormResponse)

Example 9 with EvaluationFormResponse

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

the class CompareEvaluationsFormController method loadResponses.

private void loadResponses() {
    flc.contextPut("messageNotDone", Boolean.FALSE);
    List<Identity> evaluatorIdentities = evaluators.stream().map(evaluator -> evaluator.getIdentity()).collect(Collectors.toList());
    List<EvaluationFormResponse> responses = evaluationFormManager.getResponsesFromPortfolioEvaluation(evaluatorIdentities, anchor, EvaluationFormSessionStatus.done);
    for (EvaluationFormResponse response : responses) {
        List<EvaluationFormResponse> responseList = identifierToResponses.get(response.getResponseIdentifier());
        if (responseList == null) {
            responseList = new ArrayList<>();
            identifierToResponses.put(response.getResponseIdentifier(), responseList);
        }
        responseList.add(response);
    }
}
Also used : EvaluationFormSessionStatus(org.olat.modules.forms.EvaluationFormSessionStatus) EvaluationFormElementWrapper(org.olat.modules.forms.ui.model.EvaluationFormElementWrapper) Autowired(org.springframework.beans.factory.annotation.Autowired) TextInput(org.olat.modules.forms.model.xml.TextInput) Map(java.util.Map) EvaluationFormManager(org.olat.modules.forms.EvaluationFormManager) VFSLeaf(org.olat.core.util.vfs.VFSLeaf) Rubric(org.olat.modules.forms.model.xml.Rubric) AbstractElement(org.olat.modules.forms.model.xml.AbstractElement) Slider(org.olat.modules.forms.model.xml.Slider) RadarChartElement(org.olat.core.gui.components.chart.RadarChartElement) FORM_XML_FILE(org.olat.modules.forms.handler.EvaluationFormResource.FORM_XML_FILE) WindowControl(org.olat.core.gui.control.WindowControl) FileUploadCompareWrapper(org.olat.modules.forms.ui.model.FileUploadCompareWrapper) Collectors(java.util.stream.Collectors) List(java.util.List) Identity(org.olat.core.id.Identity) Format(org.olat.core.gui.components.chart.RadarChartComponent.Format) TextInputWrapper(org.olat.modules.forms.ui.model.TextInputWrapper) SliderType(org.olat.modules.forms.model.xml.Rubric.SliderType) VFSMediaMapper(org.olat.core.util.vfs.VFSMediaMapper) FormEvent(org.olat.core.gui.components.form.flexible.impl.FormEvent) PageBody(org.olat.modules.portfolio.PageBody) HashMap(java.util.HashMap) FileResourceManager(org.olat.fileresource.FileResourceManager) RepositoryEntry(org.olat.repository.RepositoryEntry) Form(org.olat.modules.forms.model.xml.Form) FormItem(org.olat.core.gui.components.form.flexible.FormItem) ArrayList(java.util.ArrayList) FormBasicController(org.olat.core.gui.components.form.flexible.impl.FormBasicController) FormItemContainer(org.olat.core.gui.components.form.flexible.FormItemContainer) MetaInfo(org.olat.core.commons.modules.bc.meta.MetaInfo) StringHelper(org.olat.core.util.StringHelper) MetaTagged(org.olat.core.commons.modules.bc.meta.tagged.MetaTagged) Formatter(org.olat.core.util.Formatter) RadarSeries(org.olat.core.gui.components.chart.RadarSeries) SliderOverviewElement(org.olat.modules.forms.ui.component.SliderOverviewElement) Evaluator(org.olat.modules.forms.ui.model.Evaluator) SliderWrapper(org.olat.modules.forms.ui.model.SliderWrapper) Controller(org.olat.core.gui.control.Controller) File(java.io.File) SliderPoint(org.olat.modules.forms.ui.component.SliderPoint) EvaluationFormSession(org.olat.modules.forms.EvaluationFormSession) EvaluationFormResponse(org.olat.modules.forms.EvaluationFormResponse) CSSHelper(org.olat.core.gui.util.CSSHelper) FormXStream(org.olat.modules.forms.model.xml.FormXStream) UserRequest(org.olat.core.gui.UserRequest) XStreamHelper(org.olat.core.util.xml.XStreamHelper) FileUpload(org.olat.modules.forms.model.xml.FileUpload) Identity(org.olat.core.id.Identity) EvaluationFormResponse(org.olat.modules.forms.EvaluationFormResponse)

Example 10 with EvaluationFormResponse

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

the class CompareEvaluationsFormController method forgeTextInput.

private List<EvaluationFormElementWrapper> forgeTextInput(TextInput element) {
    List<EvaluationFormResponse> responses = identifierToResponses.get(element.getId());
    if (responses == null) {
        // in review - selbstreview ??
        return new ArrayList<>();
    }
    List<EvaluationFormElementWrapper> inputWrappers = new ArrayList<>(responses.size());
    for (EvaluationFormResponse response : responses) {
        if (StringHelper.containsNonWhitespace(response.getStringuifiedResponse())) {
            String initialValue = response.getStringuifiedResponse();
            if (initialValue != null) {
                initialValue = Formatter.stripTabsAndReturns(initialValue).toString();
            }
            Identity evaluator = response.getSession().getIdentity();
            String legend = getLegend(evaluator);
            String color = evaluatorToColors.get(evaluator);
            TextInputWrapper textInputWrapper = new TextInputWrapper(legend, color, initialValue, null);
            EvaluationFormElementWrapper wrapper = new EvaluationFormElementWrapper(element);
            wrapper.setTextInputWrapper(textInputWrapper);
            inputWrappers.add(wrapper);
        }
    }
    return inputWrappers;
}
Also used : TextInputWrapper(org.olat.modules.forms.ui.model.TextInputWrapper) EvaluationFormElementWrapper(org.olat.modules.forms.ui.model.EvaluationFormElementWrapper) ArrayList(java.util.ArrayList) EvaluationFormResponse(org.olat.modules.forms.EvaluationFormResponse) Identity(org.olat.core.id.Identity)

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