editResponse = ((Response) item.getQuestion().getResponses().get(posid));
Material responseMat = ((Response) item.getQuestion().getResponses().get(posid)).getContent();
displayMaterialFormController(ureq, responseMat, restrictedEdit);
} else if (cmd.equals("addtext")) {
FIBQuestion fib = (FIBQuestion) item.getQuestion();
FIBResponse response = new FIBResponse();
response.setType(FIBResponse.TYPE_CONTENT);
Material mat = new Material();
mat.add(new Mattext(trnsltr.translate("newtextelement")));
response.setContent(mat);
fib.getResponses().add(response);
} else if (cmd.equals("addblank")) {
FIBQuestion fib = (FIBQuestion) item.getQuestion();
FIBResponse response = new FIBResponse();
response.setType(FIBResponse.TYPE_BLANK);
response.setCorrectBlank("");
response.setPoints(1f); // default value
fib.getResponses().add(response);
} else if (cmd.equals("del")) {
delYesNoCtrl = DialogController.createYesNoDialogController(ureq.getLocale(), trnsltr.translate("confirm.delete.element"), this,
new Integer(posid));
getWindowControl().pushAsModalDialog( delYesNoCtrl.getInitialComponent());
} else if (cmd.equals("sfib")) { // submit fib
FIBQuestion question = (FIBQuestion) item.getQuestion();
// Survey specific variables
if (surveyMode) {
List responses = question.getResponses();
for (int i = 0; i < responses.size(); i++) {
FIBResponse response = (FIBResponse) responses.get(i);
if (FIBResponse.TYPE_BLANK.equals(response.getType())) {
// Set size of input field
String size = ureq.getParameter("size_q" + i);
if (size != null) response.setSizeFromString(size);
String maxLength = ureq.getParameter("maxl_q" + i);
if (maxLength != null) response.setMaxLengthFromString(maxLength);
}
}
} else {
// For all other cases, non-surveys
// set min/max values before single_correct !!
if (!restrictedEdit) {
// only in full edit mode the following fields are available:
// min_value, max_value, valuation_method
question.setMinValue(ureq.getParameter("min_value"));
question.setMaxValue(ureq.getParameter("max_value"));
question.setSingleCorrect(ureq.getParameter("valuation_method").equals("single"));
if (question.isSingleCorrect()) {
question.setSingleCorrectScore(ureq.getParameter("single_score"));
} else {
question.setSingleCorrectScore(0);
}
}
NodeBeforeChangeEvent nce = new NodeBeforeChangeEvent();
nce.setItemIdent(item.getIdent());
List responses = question.getResponses();
for (int i = 0; i < responses.size(); i++) {
FIBResponse response = (FIBResponse) responses.get(i);
nce.setResponseIdent(response.getIdent());
fireEvent(ureq, nce);