String newTitle = title.getValue();
String oldTitle = item.getTitle();
boolean hasTitleChange = newTitle != null && !newTitle.equals(oldTitle);
String newObjectives = desc.getRawValue(); // trust authors, don't do XSS filtering
// Remove any conditional comments due to strange behavior in test (OLAT-4518)
Filter conditionalCommentFilter = FilterFactory.getConditionalHtmlCommentsFilter();
newObjectives = conditionalCommentFilter.filter(newObjectives);
String oldObjectives = item.getObjectives();
boolean hasObjectivesChange = newObjectives != null && !newObjectives.equals(oldObjectives);
NodeBeforeChangeEvent nce = new NodeBeforeChangeEvent();
if (hasTitleChange) {
nce.setNewTitle(newTitle);
}
if (hasObjectivesChange) {
nce.setNewObjectives(newObjectives);
}
if (hasTitleChange || hasObjectivesChange) {
// create a memento first
nce.setItemIdent(item.getIdent());
nce.setQuestionIdent(item.getQuestion().getQuestion().getId());
fireEvent(ureq, nce);
}
// Update item
item.setTitle(newTitle);
item.setObjectives(newObjectives); // trust authors, don't to XSS filtering
Question q = item.getQuestion();
if (layout != null) {
((ChoiceQuestion) q).setFlowLabelClass(layout.getSelectedKey() == "h" ? ChoiceQuestion.BLOCK : ChoiceQuestion.LIST);
}
if (!isSurvey && !isRestrictedEditMode) {
q.setShuffle(shuffle.getSelected() == 0);
Control itemControl = (Control) item.getItemcontrols().get(0);
itemControl.setFeedback(itemControl.getFeedback() == Control.CTRL_UNDEF ? Control.CTRL_NO : itemControl.getFeedback());
itemControl.setHint(showHints.getSelected() == 0 ? Control.CTRL_YES : Control.CTRL_NO);
itemControl.setSolution(showSolution.getSelected() == 0 ? Control.CTRL_YES : Control.CTRL_NO);
q.setHintText(conditionalCommentFilter.filter(hint.getRawValue())); // trust authors, don't to XSS filtering
q.setSolutionText(conditionalCommentFilter.filter(solution.getRawValue())); // trust authors, don't to XSS filtering
if (limitTime.getSelectedKey().equals("y")) {
item.setDuration(new Duration(1000 * timeSec.getIntValue() + 1000 * 60 * timeMin.getIntValue()));
} else {
item.setDuration(null);
}