use of org.olat.ims.qti21.model.xml.interactions.FIBAssessmentItemBuilder.AbstractEntry in project openolat by klemens.
the class TextEntryInteractionArchive method writeInteractionData.
@Override
public int writeInteractionData(AssessmentItem item, AssessmentResponse response, Interaction interaction, int itemNumber, Row dataRow, int col, OpenXMLWorkbook workbook) {
String stringuifiedResponses = response == null ? null : response.getStringuifiedResponse();
if (StringHelper.containsNonWhitespace(stringuifiedResponses)) {
TextEntryInteraction textEntryInteraction = (TextEntryInteraction) interaction;
AbstractEntry correctAnswers = CorrectResponsesUtil.getCorrectTextResponses(item, textEntryInteraction);
stringuifiedResponses = CorrectResponsesUtil.stripResponse(stringuifiedResponses);
boolean correct = correctAnswers.match(stringuifiedResponses);
if (correct) {
dataRow.addCell(col++, stringuifiedResponses, workbook.getStyles().getCorrectStyle());
} else {
dataRow.addCell(col++, stringuifiedResponses, null);
}
} else {
col++;
}
return col;
}
use of org.olat.ims.qti21.model.xml.interactions.FIBAssessmentItemBuilder.AbstractEntry in project openolat by klemens.
the class FIBEditorController method createEntry.
private AbstractEntry createEntry(String responseIdentifier, String selectedText, String type, boolean newEntry) {
AbstractEntry interaction = null;
if ("string".equalsIgnoreCase(type)) {
TextEntry textInteraction = itemBuilder.createTextEntry(responseIdentifier);
if (StringHelper.containsNonWhitespace(selectedText)) {
String[] alternatives = selectedText.split(",");
for (String alternative : alternatives) {
if (StringHelper.containsNonWhitespace(alternative)) {
alternative = alternative.trim();
if (textInteraction.getSolution() == null) {
textInteraction.setSolution(alternative);
} else {
textInteraction.addAlternative(alternative, textInteraction.getScore());
}
}
}
if (alternatives.length > 0) {
String solution = alternatives[0];
if (newEntry && "gap".equals(solution)) {
solution = "";
}
textInteraction.setSolution(solution);
}
}
interaction = textInteraction;
} else if ("float".equalsIgnoreCase(type)) {
NumericalEntry numericalInteraction = itemBuilder.createNumericalEntry(responseIdentifier);
if (newEntry && "gap".equals(selectedText)) {
// skip it, it's a placeholder
} else if (StringHelper.containsNonWhitespace(selectedText)) {
try {
Double val = Double.parseDouble(selectedText.trim());
numericalInteraction.setSolution(val);
} catch (NumberFormatException e) {
//
}
}
interaction = numericalInteraction;
}
return interaction;
}
use of org.olat.ims.qti21.model.xml.interactions.FIBAssessmentItemBuilder.AbstractEntry in project openolat by klemens.
the class FIBEditorController method doGapEntry.
private void doGapEntry(UserRequest ureq, String responseIdentifier, String selectedText, String emptySolution, String type, boolean newEntry) {
if (textEntrySettingsCtrl != null || numericalEntrySettingsCtrl != null)
return;
AbstractEntry interaction = itemBuilder.getEntry(responseIdentifier);
if (interaction == null) {
interaction = createEntry(responseIdentifier, selectedText, type, newEntry);
} else if (StringHelper.containsNonWhitespace(selectedText)) {
updateSolution(interaction, selectedText, emptySolution);
}
if (interaction instanceof TextEntry) {
textEntrySettingsCtrl = new FIBTextEntrySettingsController(ureq, getWindowControl(), (TextEntry) interaction, restrictedEdit, readOnly);
listenTo(textEntrySettingsCtrl);
cmc = new CloseableModalController(getWindowControl(), translate("close"), textEntrySettingsCtrl.getInitialComponent(), true, translate("title.add"));
cmc.activate();
listenTo(cmc);
} else if (interaction instanceof NumericalEntry) {
numericalEntrySettingsCtrl = new FIBNumericalEntrySettingsController(ureq, getWindowControl(), (NumericalEntry) interaction, restrictedEdit, readOnly);
listenTo(numericalEntrySettingsCtrl);
cmc = new CloseableModalController(getWindowControl(), translate("close"), numericalEntrySettingsCtrl.getInitialComponent(), true, translate("title.add"));
cmc.activate();
listenTo(cmc);
}
}
use of org.olat.ims.qti21.model.xml.interactions.FIBAssessmentItemBuilder.AbstractEntry in project openolat by klemens.
the class FIBScoreController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
setFormContextHelp("Test editor QTI 2.1 in detail#details_testeditor_score");
super.initForm(formLayout, listener, ureq);
minScoreEl = uifactory.addTextElement("min.score", "min.score", 8, "0.0", formLayout);
minScoreEl.setElementCssClass("o_sel_assessment_item_min_score");
minScoreEl.setEnabled(false);
ScoreBuilder maxScore = itemBuilder.getMaxScoreBuilder();
String maxValue = maxScore == null ? "" : (maxScore.getScore() == null ? "" : maxScore.getScore().toString());
maxScoreEl = uifactory.addTextElement("max.score", "max.score", 8, maxValue, formLayout);
maxScoreEl.setElementCssClass("o_sel_assessment_item_max_score");
maxScoreEl.setEnabled(!restrictedEdit && !readOnly);
String[] modeValues = new String[] { translate("form.score.assessment.all.correct"), translate("form.score.assessment.per.answer") };
assessmentModeEl = uifactory.addRadiosHorizontal("assessment.mode", "form.score.assessment.mode", formLayout, modeKeys, modeValues);
assessmentModeEl.addActionListener(FormEvent.ONCHANGE);
assessmentModeEl.setEnabled(!restrictedEdit && !readOnly);
if (itemBuilder.getScoreEvaluationMode() == ScoreEvaluation.perAnswer) {
assessmentModeEl.select(ScoreEvaluation.perAnswer.name(), true);
} else {
assessmentModeEl.select(ScoreEvaluation.allCorrectAnswers.name(), true);
}
String scorePage = velocity_root + "/fib_score.html";
scoreCont = FormLayoutContainer.createCustomFormLayout("scores", getTranslator(), scorePage);
formLayout.add(scoreCont);
scoreCont.setLabel(null, null);
for (AbstractEntry entry : itemBuilder.getOrderedTextEntries()) {
wrappers.add(createTextEntryWrapper(entry));
}
scoreCont.contextPut("choices", wrappers);
scoreCont.setVisible(assessmentModeEl.isSelected(1));
// Submit Button
FormLayoutContainer buttonsContainer = FormLayoutContainer.createButtonLayout("buttons", getTranslator());
buttonsContainer.setRootForm(mainForm);
buttonsContainer.setVisible(!readOnly);
formLayout.add(buttonsContainer);
uifactory.addFormSubmitButton("submit", buttonsContainer);
}
use of org.olat.ims.qti21.model.xml.interactions.FIBAssessmentItemBuilder.AbstractEntry in project OpenOLAT by OpenOLAT.
the class FIBEditorController method createEntry.
private AbstractEntry createEntry(String responseIdentifier, String selectedText, String type, boolean newEntry) {
AbstractEntry interaction = null;
if ("string".equalsIgnoreCase(type)) {
TextEntry textInteraction = itemBuilder.createTextEntry(responseIdentifier);
if (StringHelper.containsNonWhitespace(selectedText)) {
String[] alternatives = selectedText.split(",");
for (String alternative : alternatives) {
if (StringHelper.containsNonWhitespace(alternative)) {
alternative = alternative.trim();
if (textInteraction.getSolution() == null) {
textInteraction.setSolution(alternative);
} else {
textInteraction.addAlternative(alternative, textInteraction.getScore());
}
}
}
if (alternatives.length > 0) {
String solution = alternatives[0];
if (newEntry && "gap".equals(solution)) {
solution = "";
}
textInteraction.setSolution(solution);
}
}
interaction = textInteraction;
} else if ("float".equalsIgnoreCase(type)) {
NumericalEntry numericalInteraction = itemBuilder.createNumericalEntry(responseIdentifier);
if (newEntry && "gap".equals(selectedText)) {
// skip it, it's a placeholder
} else if (StringHelper.containsNonWhitespace(selectedText)) {
try {
Double val = Double.parseDouble(selectedText.trim());
numericalInteraction.setSolution(val);
} catch (NumberFormatException e) {
//
}
}
interaction = numericalInteraction;
}
return interaction;
}
Aggregations