use of org.olat.ims.qti21.ui.editor.events.AssessmentItemEvent in project openolat by klemens.
the class QTI21EditorController method event.
@Override
protected void event(UserRequest ureq, Controller source, Event event) {
if (source == editorCtrl) {
if (event instanceof AssessmentItemEvent) {
AssessmentItemEvent aie = (AssessmentItemEvent) event;
AssessmentItem assessmentItem = aie.getAssessmentItem();
qtiService.persistAssessmentObject(resourceFile, assessmentItem);
updateQuestionItem(ureq, assessmentItem);
}
}
}
use of org.olat.ims.qti21.ui.editor.events.AssessmentItemEvent in project openolat by klemens.
the class AssessmentItemEditorController method event.
@Override
protected void event(UserRequest ureq, Controller source, Event event) {
if (event instanceof AssessmentItemEvent) {
AssessmentItemEvent aie = (AssessmentItemEvent) event;
if (AssessmentItemEvent.ASSESSMENT_ITEM_CHANGED.equals(aie.getCommand())) {
doBuildAndSaveAssessmentItem();
doBuildAndCommitMetadata();
fireEvent(ureq, new AssessmentItemEvent(aie.getCommand(), aie.getAssessmentItem(), itemRef, aie.getQuestionType()));
} else if (AssessmentItemEvent.ASSESSMENT_ITEM_NEED_RELOAD.equals(aie.getCommand())) {
fireEvent(ureq, event);
}
} else if (poolEditor == source) {
if (event instanceof DetachFromPoolEvent) {
fireEvent(ureq, event);
}
}
super.event(ureq, source, event);
}
use of org.olat.ims.qti21.ui.editor.events.AssessmentItemEvent in project openolat by klemens.
the class MatchScoreController method formOK.
@Override
protected void formOK(UserRequest ureq) {
if (restrictedEdit || readOnly)
return;
super.formOK(ureq);
String maxScoreValue = maxScoreEl.getValue();
Double maxScore = Double.parseDouble(maxScoreValue);
itemBuilder.setMaxScore(maxScore);
String minScoreValue = minScoreEl.getValue();
Double minScore = Double.parseDouble(minScoreValue);
itemBuilder.setMinScore(minScore);
if (assessmentModeEl.isOneSelected() && assessmentModeEl.isSelected(1)) {
itemBuilder.setScoreEvaluationMode(ScoreEvaluation.perAnswer);
itemBuilder.clearMapping();
for (Map.Entry<DirectedPairValue, MatchScoreWrapper> entry : scoreWrappers.entrySet()) {
DirectedPairValue directedPair = entry.getKey();
MatchScoreWrapper scoreWrapper = entry.getValue();
String val = scoreWrapper.getScoreEl().getValue();
double score = Double.parseDouble(val);
itemBuilder.addScore(directedPair, score);
}
} else {
itemBuilder.setScoreEvaluationMode(ScoreEvaluation.allCorrectAnswers);
itemBuilder.clearMapping();
}
fireEvent(ureq, new AssessmentItemEvent(AssessmentItemEvent.ASSESSMENT_ITEM_CHANGED, itemBuilder.getAssessmentItem(), null));
}
use of org.olat.ims.qti21.ui.editor.events.AssessmentItemEvent in project openolat by klemens.
the class MultipleChoiceEditorController 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) {
// correct response
String[] correctAnswers = ureq.getHttpReq().getParameterValues("correct");
List<Identifier> correctAnswerList = new ArrayList<>();
if (correctAnswers != null) {
for (String correctAnswer : correctAnswers) {
correctAnswerList.add(Identifier.parseString(correctAnswer));
}
}
itemBuilder.setCorrectAnswers(correctAnswerList);
// 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 HotspotChoiceScoreController method formOK.
@Override
protected void formOK(UserRequest ureq) {
if (restrictedEdit || readOnly)
return;
super.formOK(ureq);
String maxScoreValue = maxScoreEl.getValue();
Double maxScore = Double.parseDouble(maxScoreValue);
itemBuilder.setMaxScore(maxScore);
String minScoreValue = minScoreEl.getValue();
Double minScore = Double.parseDouble(minScoreValue);
itemBuilder.setMinScore(minScore);
if (assessmentModeEl.isOneSelected() && assessmentModeEl.isSelected(1)) {
itemBuilder.setScoreEvaluationMode(ScoreEvaluation.perAnswer);
itemBuilder.clearMapping();
for (HotspotChoiceWrapper wrapper : wrappers) {
String pointsStr = wrapper.getPointsEl().getValue();
Double points = new Double(pointsStr);
itemBuilder.setMapping(wrapper.getChoice().getIdentifier(), points);
}
} else {
itemBuilder.setScoreEvaluationMode(ScoreEvaluation.allCorrectAnswers);
itemBuilder.clearMapping();
}
fireEvent(ureq, new AssessmentItemEvent(AssessmentItemEvent.ASSESSMENT_ITEM_CHANGED, itemBuilder.getAssessmentItem(), null));
}
Aggregations