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());
}
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());
}
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;
}
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);
}
}
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;
}
Aggregations