use of org.olat.modules.forms.EvaluationFormResponse in project openolat by klemens.
the class EvaluationFormController method forgeTextInput.
private EvaluationFormElementWrapper forgeTextInput(TextInput element) {
String initialValue = "";
EvaluationFormResponse response = identifierToResponses.get(element.getId());
if (response != null && StringHelper.containsNonWhitespace(response.getStringuifiedResponse())) {
initialValue = response.getStringuifiedResponse();
}
int rows = 12;
if (element.getRows() > 0) {
rows = element.getRows();
}
TextElement textEl = uifactory.addTextAreaElement("textinput_" + (count++), null, Integer.MAX_VALUE, rows, 72, false, initialValue, flc);
textEl.setEnabled(!readOnly);
FormLink saveButton = uifactory.addFormLink("save_" + (count++), "save", null, flc, Link.BUTTON);
saveButton.setVisible(!readOnly);
TextInputWrapper textInputWrapper = new TextInputWrapper(element, textEl, saveButton);
saveButton.setUserObject(textInputWrapper);
textEl.setUserObject(textInputWrapper);
EvaluationFormElementWrapper wrapper = new EvaluationFormElementWrapper(element);
wrapper.setTextInputWrapper(textInputWrapper);
return wrapper;
}
use of org.olat.modules.forms.EvaluationFormResponse in project openolat by klemens.
the class EvaluationFormController method forgeRubric.
private EvaluationFormElementWrapper forgeRubric(Rubric element) {
EvaluationFormElementWrapper wrapper = new EvaluationFormElementWrapper(element);
List<Slider> sliders = element.getSliders();
List<SliderWrapper> sliderWrappers = new ArrayList<>(sliders.size());
for (Slider slider : sliders) {
String responseIdentifier = slider.getId();
EvaluationFormResponse response = identifierToResponses.get(responseIdentifier);
SliderType type = element.getSliderType();
SliderWrapper sliderWrapper = null;
if (type == SliderType.discrete) {
sliderWrapper = forgeDiscreteRadioButtons(slider, element, response);
} else if (type == SliderType.discrete_slider) {
sliderWrapper = forgeDiscreteSlider(slider, element, response);
} else if (type == SliderType.continuous) {
sliderWrapper = forgeContinuousSlider(slider, element, response);
}
if (sliderWrapper != null) {
sliderWrappers.add(sliderWrapper);
}
}
wrapper.setSliders(sliderWrappers);
return wrapper;
}
use of org.olat.modules.forms.EvaluationFormResponse in project openolat by klemens.
the class EvaluationFormController method saveFileResponse.
private void saveFileResponse(File file, String filename, String responseIdentifier) {
if (evaluator == null || readOnly)
return;
EvaluationFormResponse response = identifierToResponses.get(responseIdentifier);
try {
if (response == null) {
response = evaluationFormManager.createResponseForPortfolioEvaluation(responseIdentifier, file, filename, session);
} else {
response = evaluationFormManager.updateResponseForPortfolioEvaluation(file, filename, response);
}
} catch (IOException e) {
showError("error.cannot.save.file");
log.warn("Cannot save file for an evaluation form response!", e);
}
updateCache(responseIdentifier, response);
}
use of org.olat.modules.forms.EvaluationFormResponse in project OpenOLAT by OpenOLAT.
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);
}
}
use of org.olat.modules.forms.EvaluationFormResponse in project OpenOLAT by OpenOLAT.
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;
}
Aggregations