use of org.olat.ims.qti21.ui.editor.events.AssessmentItemEvent in project openolat by klemens.
the class HotspotEditorController method formOK.
@Override
protected void formOK(UserRequest ureq) {
if (readOnly)
return;
itemBuilder.setTitle(titleEl.getValue());
// set the question with the text entries
String questionText = textEl.getRawValue();
itemBuilder.setQuestion(questionText);
itemBuilder.setResponsive(responsiveEl.isAtLeastSelected(1));
File objectImg = null;
if (backgroundImage != null) {
objectImg = backgroundImage;
} else if (initialBackgroundImage != null) {
objectImg = initialBackgroundImage;
}
if (cardinalityEl.isOneSelected()) {
String selectedCardinality = cardinalityEl.getSelectedKey();
itemBuilder.setCardinality(Cardinality.valueOf(selectedCardinality));
}
boolean updateHotspot = true;
if (objectImg != null) {
String filename = objectImg.getName();
String mimeType = WebappHelper.getMimeType(filename);
Size currentSize = imageService.getSize(new LocalFileImpl(objectImg), null);
Size size = currentSize;
if (resizeEl.isVisible() && !resizeEl.isSelected(0)) {
int maxSize = Integer.parseInt(resizeEl.getSelectedKey());
if (maxSize < currentSize.getHeight() || maxSize < currentSize.getWidth()) {
String extension = FileUtils.getFileSuffix(filename);
size = imageService.scaleImage(objectImg, extension, objectImg, maxSize, maxSize, false);
setBackgroundSize(size);
scaleHotspot(currentSize, size);
optimizeResizeEl(size, false);
updateHotspot = false;
}
}
int height = -1;
int width = -1;
if (size != null) {
height = size.getHeight();
width = size.getWidth();
}
String relPath = itemFile.getParentFile().toPath().relativize(objectImg.toPath()).toString();
itemBuilder.setBackground(relPath, mimeType, height, width);
}
if (updateHotspot) {
updateHotspots(ureq);
}
if (layoutEl.isOneSelected()) {
String selectedLayout = layoutEl.getSelectedKey();
for (HotspotLayouts layout : HotspotLayouts.values()) {
itemBuilder.removeHotspotInteractionClass(layout.cssClass());
}
itemBuilder.addHotspotInteractionClass(selectedLayout);
}
if (shadowEl.isAtLeastSelected(1)) {
itemBuilder.removeHotspotInteractionClass(QTI21Constants.CSS_HOTSPOT_DISABLE_SHADOW);
} else {
itemBuilder.addHotspotInteractionClass(QTI21Constants.CSS_HOTSPOT_DISABLE_SHADOW);
}
fireEvent(ureq, new AssessmentItemEvent(AssessmentItemEvent.ASSESSMENT_ITEM_CHANGED, itemBuilder.getAssessmentItem(), QTI21QuestionType.hotspot));
}
use of org.olat.ims.qti21.ui.editor.events.AssessmentItemEvent in project openolat by klemens.
the class KPrimEditorController method formOK.
@Override
protected void formOK(UserRequest ureq) {
if (readOnly)
return;
// title
itemBuilder.setTitle(titleEl.getValue());
// question
String questionText = textEl.getRawValue();
itemBuilder.setQuestion(questionText);
// shuffle
if (!restrictedEdit) {
itemBuilder.setShuffle(shuffleEl.isOneSelected() && shuffleEl.isSelected(0));
// alignment
if (alignmentEl.isOneSelected() && alignmentEl.isSelected(1)) {
itemBuilder.addClass(QTI21Constants.CHOICE_ALIGN_RIGHT);
} else {
itemBuilder.removeClass(QTI21Constants.CHOICE_ALIGN_RIGHT);
}
}
// update kprims
for (KprimWrapper choiceWrapper : choiceWrappers) {
SimpleAssociableChoice choice = choiceWrapper.getSimpleChoice();
String answer = choiceWrapper.getAnswer().getRawValue();
itemBuilder.getHtmlHelper().appendHtml(choice, answer);
}
// set associations
if (!restrictedEdit) {
List<SimpleAssociableChoice> choices = new ArrayList<>();
for (KprimWrapper choiceWrapper : choiceWrappers) {
SimpleAssociableChoice choice = choiceWrapper.getSimpleChoice();
Identifier choiceIdentifier = choice.getIdentifier();
String association = ureq.getHttpReq().getParameter(choiceIdentifier.toString());
if ("correct".equals(association)) {
itemBuilder.setAssociation(choiceIdentifier, QTI21Constants.CORRECT_IDENTIFIER);
} else if ("wrong".equals(association)) {
itemBuilder.setAssociation(choiceIdentifier, QTI21Constants.WRONG_IDENTIFIER);
}
choices.add(choice);
}
itemBuilder.setKprimChoices(choices);
}
fireEvent(ureq, new AssessmentItemEvent(AssessmentItemEvent.ASSESSMENT_ITEM_CHANGED, itemBuilder.getAssessmentItem(), QTI21QuestionType.kprim));
}
use of org.olat.ims.qti21.ui.editor.events.AssessmentItemEvent in project openolat by klemens.
the class FeedbacksEditorController method formOK.
@Override
protected void formOK(UserRequest ureq) {
if (restrictedEdit || readOnly)
return;
hintForm.commit();
hintForm.setVisible(!hintForm.isEmpty());
correctSolutionForm.commit();
correctSolutionForm.setVisible(!correctSolutionForm.isEmpty());
correctForm.commit();
correctForm.setVisible(!correctForm.isEmpty());
incorrectForm.commit();
incorrectForm.setVisible(!incorrectForm.isEmpty());
answeredForm.commit();
answeredForm.setVisible(!answeredForm.isEmpty());
emptyForm.commit();
emptyForm.setVisible(!emptyForm.isEmpty());
List<RuledFeedbackForm> validAdditionalForms = new ArrayList<>();
List<ModalFeedbackBuilder> additionalBuilders = new ArrayList<>();
for (RuledFeedbackForm additionalForm : additionalForms) {
ModalFeedbackBuilder additionalBuilder = additionalForm.commit();
if (additionalBuilder != null) {
additionalBuilders.add(additionalBuilder);
validAdditionalForms.add(additionalForm);
}
}
itemBuilder.setAdditionalFeedbackBuilders(additionalBuilders);
additionalForms.clear();
additionalForms.addAll(validAdditionalForms);
updateAddButtons();
fireEvent(ureq, new AssessmentItemEvent(AssessmentItemEvent.ASSESSMENT_ITEM_CHANGED, itemBuilder.getAssessmentItem()));
}
use of org.olat.ims.qti21.ui.editor.events.AssessmentItemEvent in project openolat by klemens.
the class UnkownItemEditorController method doConvertItem.
private void doConvertItem(UserRequest ureq, QTI21QuestionType alternativeType) {
item.setToolName(QTI21Constants.TOOLNAME);
item.setToolVersion(Settings.getVersion());
if (alternativeType == QTI21QuestionType.matchdraganddrop) {
addClassToInteraction(QTI21Constants.CSS_MATCH_DRAG_AND_DROP);
}
qtiService.updateAssesmentObject(itemFileRef, resolvedAssessmentItem);
fireEvent(ureq, new AssessmentItemEvent(AssessmentItemEvent.ASSESSMENT_ITEM_NEED_RELOAD, item));
}
use of org.olat.ims.qti21.ui.editor.events.AssessmentItemEvent in project OpenOLAT by OpenOLAT.
the class EssayEditorController method formOK.
@Override
protected void formOK(UserRequest ureq) {
if (readOnly)
return;
// title
itemBuilder.setTitle(titleEl.getValue());
// question
String questionText = textEl.getRawValue();
itemBuilder.setQuestion(questionText);
itemBuilder.setPlaceholder(placeholderEl.getValue());
if (!restrictedEdit) {
itemBuilder.setExpectedLength(getValue(lengthEl));
itemBuilder.setExpectedLines(getValue(heightEl));
// min. max. words
itemBuilder.setMinStrings(getValue(minWordsEl));
itemBuilder.setMaxStrings(getValue(maxWordsEl));
}
fireEvent(ureq, new AssessmentItemEvent(AssessmentItemEvent.ASSESSMENT_ITEM_CHANGED, itemBuilder.getAssessmentItem(), QTI21QuestionType.essay));
}
Aggregations