use of org.olat.ims.qti21.ui.editor.events.AssessmentItemEvent in project openolat by klemens.
the class MatchEditorController method formOK.
@Override
protected void formOK(UserRequest ureq) {
if (readOnly)
return;
// title
itemBuilder.setTitle(titleEl.getValue());
// question
String questionText = textEl.getRawValue();
itemBuilder.setQuestion(questionText);
if (!restrictedEdit) {
boolean singleChoice = singleMultiEl.isOneSelected() && singleMultiEl.isSelected(0);
itemBuilder.setMultipleChoice(!singleChoice);
}
// shuffle
if (!restrictedEdit) {
itemBuilder.setShuffle(shuffleEl.isOneSelected() && shuffleEl.isSelected(0));
}
// layout
if (!restrictedEdit && layoutEl != null) {
itemBuilder.removeMatchInteractionClass(layoutKeys);
String cssClass = layoutEl.getSelectedKey();
itemBuilder.addMatchInteractionClass(cssClass);
}
// update
for (MatchWrapper sourceWrapper : sourceWrappers) {
SimpleAssociableChoice choice = sourceWrapper.getSimpleChoice();
String answer = sourceWrapper.getText().getRawValue();
itemBuilder.getHtmlHelper().appendHtml(choice, answer);
}
for (MatchWrapper sourceWrapper : targetWrappers) {
SimpleAssociableChoice choice = sourceWrapper.getSimpleChoice();
String answer = sourceWrapper.getText().getRawValue();
itemBuilder.getHtmlHelper().appendHtml(choice, answer);
}
// correct answers
commitAssociations(ureq);
fireEvent(ureq, new AssessmentItemEvent(AssessmentItemEvent.ASSESSMENT_ITEM_CHANGED, itemBuilder.getAssessmentItem(), QTI21QuestionType.match));
}
use of org.olat.ims.qti21.ui.editor.events.AssessmentItemEvent in project openolat by klemens.
the class SingleChoiceEditorController method formOK.
@Override
protected void formOK(UserRequest ureq) {
if (readOnly)
return;
// title
itemBuilder.setTitle(titleEl.getValue());
// question
String questionText = textEl.getRawValue();
itemBuilder.setQuestion(questionText);
Identifier correctAnswerIdentifier = null;
if (!restrictedEdit) {
// correct response
String correctAnswer = ureq.getParameter("correct");
correctAnswerIdentifier = Identifier.parseString(correctAnswer);
itemBuilder.setCorrectAnswer(correctAnswerIdentifier);
// shuffle
itemBuilder.setShuffle(shuffleEl.isOneSelected() && shuffleEl.isSelected(0));
// orientation
itemBuilder.setOrientation(Orientation.valueOf(orientationEl.getSelectedKey()));
// alignment
if (alignmentEl.isOneSelected() && alignmentEl.isSelected(1)) {
itemBuilder.addClass(QTI21Constants.CHOICE_ALIGN_RIGHT);
} else {
itemBuilder.removeClass(QTI21Constants.CHOICE_ALIGN_RIGHT);
}
}
// replace simple choices
List<SimpleChoice> choiceList = new ArrayList<>();
for (SimpleChoiceWrapper choiceWrapper : choiceWrappers) {
SimpleChoice choice = choiceWrapper.getSimpleChoice();
// text
String answer = choiceWrapper.getAnswer().getRawValue();
itemBuilder.getHtmlHelper().appendHtml(choice, answer);
choiceList.add(choice);
}
itemBuilder.setSimpleChoices(choiceList);
fireEvent(ureq, new AssessmentItemEvent(AssessmentItemEvent.ASSESSMENT_ITEM_CHANGED, itemBuilder.getAssessmentItem(), QTI21QuestionType.sc));
}
use of org.olat.ims.qti21.ui.editor.events.AssessmentItemEvent in project openolat by klemens.
the class TrueFalseEditorController method formOK.
@Override
protected void formOK(UserRequest ureq) {
if (readOnly)
return;
// title
itemBuilder.setTitle(titleEl.getValue());
// question
String questionText = textEl.getRawValue();
itemBuilder.setQuestion(questionText);
if (!restrictedEdit) {
itemBuilder.setMultipleChoice(false);
itemBuilder.setShuffle(false);
}
// update
for (SourceWrapper sourceWrapper : sourceWrappers) {
SimpleAssociableChoice choice = sourceWrapper.getSimpleChoice();
String answer = sourceWrapper.getText().getRawValue();
itemBuilder.getHtmlHelper().appendHtml(choice, answer);
}
// correct answers
commitAssociations(ureq);
fireEvent(ureq, new AssessmentItemEvent(AssessmentItemEvent.ASSESSMENT_ITEM_CHANGED, itemBuilder.getAssessmentItem(), QTI21QuestionType.match));
}
use of org.olat.ims.qti21.ui.editor.events.AssessmentItemEvent in project openolat by klemens.
the class UploadEditorController method formOK.
@Override
protected void formOK(UserRequest ureq) {
if (readOnly)
return;
// title
itemBuilder.setTitle(titleEl.getValue());
// question
String questionText = textEl.getRawValue();
itemBuilder.setQuestion(questionText);
fireEvent(ureq, new AssessmentItemEvent(AssessmentItemEvent.ASSESSMENT_ITEM_CHANGED, itemBuilder.getAssessmentItem(), QTI21QuestionType.upload));
}
use of org.olat.ims.qti21.ui.editor.events.AssessmentItemEvent in project openolat by klemens.
the class AssessmentTestComposerController method event.
@Override
protected void event(UserRequest ureq, Controller source, Event event) {
if (event instanceof AssessmentTestEvent) {
AssessmentTestEvent ate = (AssessmentTestEvent) event;
if (ate == AssessmentTestEvent.ASSESSMENT_TEST_CHANGED_EVENT) {
doSaveAssessmentTest(ureq, null);
}
} else if (event instanceof AssessmentTestPartEvent) {
AssessmentTestPartEvent atpe = (AssessmentTestPartEvent) event;
if (atpe == AssessmentTestPartEvent.ASSESSMENT_TEST_PART_CHANGED_EVENT) {
doSaveAssessmentTest(ureq, null);
}
} else if (event instanceof AssessmentSectionEvent) {
AssessmentSectionEvent ase = (AssessmentSectionEvent) event;
if (AssessmentSectionEvent.ASSESSMENT_SECTION_CHANGED.equals(ase.getCommand())) {
doSaveAssessmentTest(ureq, null);
doUpdate(ase.getSection().getIdentifier(), ase.getSection().getTitle());
doSaveManifest();
}
} else if (event instanceof AssessmentItemEvent) {
AssessmentItemEvent aie = (AssessmentItemEvent) event;
if (AssessmentItemEvent.ASSESSMENT_ITEM_CHANGED.equals(aie.getCommand())) {
assessmentChanged(ureq);
doSaveAssessmentTest(ureq, null);
doUpdate(aie.getAssessmentItemRef().getIdentifier(), aie.getAssessmentItem().getTitle());
doSaveManifest();
} else if (AssessmentItemEvent.ASSESSMENT_ITEM_METADATA_CHANGED.equals(aie.getCommand())) {
doSaveManifest();
} else if (AssessmentItemEvent.ASSESSMENT_ITEM_NEED_RELOAD.equals(aie.getCommand())) {
doReloadItem(ureq);
}
} else if (event instanceof DetachFromPoolEvent) {
DetachFromPoolEvent dfpe = (DetachFromPoolEvent) event;
doDetachItemFromPool(ureq, dfpe.getItemRef());
} else if (selectQItemCtrl == source) {
cmc.deactivate();
cleanUp();
if (event instanceof QItemViewEvent) {
QItemViewEvent e = (QItemViewEvent) event;
List<QuestionItemView> items = e.getItemList();
doInsert(ureq, items);
}
} else if (importTableWizard == source) {
AssessmentItemsPackage importPackage = (AssessmentItemsPackage) importTableWizard.getRunContext().get("importPackage");
getWindowControl().pop();
cleanUp();
if (event == Event.DONE_EVENT || event == Event.CHANGED_EVENT) {
doInsert(ureq, importPackage);
}
} else if (confirmDeleteCtrl == source) {
if (DialogBoxUIFactory.isYesEvent(event)) {
// yes, delete
doDelete(ureq, (TreeNode) confirmDeleteCtrl.getUserObject());
}
cleanUp();
} else if (cmc == source) {
cleanUp();
}
super.event(ureq, source, event);
}
Aggregations