use of org.olat.ims.qti21.model.xml.interactions.FIBAssessmentItemBuilder in project OpenOLAT by OpenOLAT.
the class AssessmentItemEditorController method initFIBEditors.
private AssessmentItemBuilder initFIBEditors(UserRequest ureq, QTI21QuestionType preferedType, AssessmentItem item) {
FIBAssessmentItemBuilder fibItemBuilder = new FIBAssessmentItemBuilder(item, qtiService.qtiSerializer());
itemEditor = new FIBEditorController(ureq, getWindowControl(), preferedType, fibItemBuilder, rootDirectory, rootContainer, itemFile, restrictedEdit, readOnly);
listenTo(itemEditor);
scoreEditor = new FIBScoreController(ureq, getWindowControl(), fibItemBuilder, itemRef, restrictedEdit, readOnly);
listenTo(scoreEditor);
feedbackEditor = new FeedbacksEditorController(ureq, getWindowControl(), fibItemBuilder, rootDirectory, rootContainer, itemFile, FeedbacksEnabler.standardFeedbacks(), restrictedEdit, readOnly);
listenTo(feedbackEditor);
tabbedPane.addTab(translate("form.fib"), itemEditor);
tabbedPane.addTab(translate("form.score"), scoreEditor);
tabbedPane.addTab(translate("form.feedback"), feedbackEditor);
return fibItemBuilder;
}
use of org.olat.ims.qti21.model.xml.interactions.FIBAssessmentItemBuilder in project OpenOLAT by OpenOLAT.
the class QTI12To21Converter method convertFIB.
private AssessmentItemBuilder convertFIB(Item item) {
FIBAssessmentItemBuilder itemBuilder = new FIBAssessmentItemBuilder("Gap text", EntryType.text, qtiSerializer);
itemBuilder.setQuestion("");
itemBuilder.clearTextEntries();
convertItemBasics(item, itemBuilder);
Question question = item.getQuestion();
boolean singleCorrect = question.isSingleCorrect();
if (singleCorrect) {
itemBuilder.setScoreEvaluationMode(ScoreEvaluation.allCorrectAnswers);
} else {
itemBuilder.setScoreEvaluationMode(ScoreEvaluation.perAnswer);
}
itemBuilder.getMinScoreBuilder().setScore(new Double(question.getMinValue()));
itemBuilder.getMaxScoreBuilder().setScore(new Double(question.getMaxValue()));
List<Response> responses = question.getResponses();
StringBuilder sb = new StringBuilder();
for (Response response : responses) {
if (response instanceof FIBResponse) {
FIBResponse gap = (FIBResponse) response;
if (FIBResponse.TYPE_BLANK.equals(gap.getType())) {
String responseId = itemBuilder.generateResponseIdentifier();
StringBuilder entryString = new StringBuilder();
entryString.append(" <textentryinteraction responseidentifier=\"").append(responseId).append("\"");
TextEntry entry = itemBuilder.createTextEntry(responseId);
entry.setCaseSensitive("Yes".equals(gap.getCaseSensitive()));
if (gap.getMaxLength() > 0) {
entry.setExpectedLength(gap.getMaxLength());
entryString.append(" expectedlength=\"").append(gap.getMaxLength()).append("\"");
} else if (gap.getSize() > 0) {
entry.setExpectedLength(gap.getSize());
entryString.append(" expectedlength=\"").append(gap.getSize()).append("\"");
}
parseAlternatives(gap.getCorrectBlank(), gap.getPoints(), entry);
entryString.append("></textentryinteraction>");
sb.append(entryString);
} else if (FIBResponse.TYPE_CONTENT.equals(gap.getType())) {
Material text = gap.getContent();
String htmltext = text.renderAsHtmlForEditor();
htmltext = blockedHtml(htmltext);
sb.append(htmltext);
}
}
}
String fib = "<div>" + sb.toString() + "</div>";
itemBuilder.setQuestion(fib);
return itemBuilder;
}
use of org.olat.ims.qti21.model.xml.interactions.FIBAssessmentItemBuilder in project OpenOLAT by OpenOLAT.
the class CSVToAssessmentItemConverter method processChoice_fib.
private void processChoice_fib(String[] parts, FIBAssessmentItemBuilder fibBuilder) {
String firstPart = parts[0].toLowerCase();
if ("text".equals(firstPart) || "texte".equals(firstPart)) {
String text = parts[1];
if (StringHelper.containsNonWhitespace(fibBuilder.getQuestion())) {
fibBuilder.setQuestion(fibBuilder.getQuestion() + " " + text);
} else {
fibBuilder.setQuestion(text);
}
} else {
double score = parseFloat(parts[0], 1.0f);
String correctBlank = parts[1];
String responseId = fibBuilder.generateResponseIdentifier();
TextEntry textEntry = fibBuilder.createTextEntry(responseId);
parseAlternatives(correctBlank, score, textEntry);
if (parts.length > 2) {
String sizes = parts[2];
String[] sizeArr = sizes.split(",");
if (sizeArr.length >= 2) {
int size = Integer.parseInt(sizeArr[0]);
textEntry.setExpectedLength(size);
}
}
String entry = " <textEntryInteraction responseIdentifier=\"" + responseId + "\"/>";
fibBuilder.setQuestion(fibBuilder.getQuestion() + " " + entry);
}
}
use of org.olat.ims.qti21.model.xml.interactions.FIBAssessmentItemBuilder in project openolat by klemens.
the class QTI21QPoolServiceProvider method createItem.
public QuestionItem createItem(Identity identity, QTI21QuestionType type, String title, Locale locale) {
AssessmentItemBuilder itemBuilder = null;
Translator translator = Util.createPackageTranslator(AssessmentTestComposerController.class, locale);
switch(type) {
case sc:
itemBuilder = new SingleChoiceAssessmentItemBuilder(translator.translate("new.sc"), translator.translate("new.answer"), qtiService.qtiSerializer());
break;
case mc:
itemBuilder = new MultipleChoiceAssessmentItemBuilder(translator.translate("new.mc"), translator.translate("new.answer"), qtiService.qtiSerializer());
break;
case kprim:
itemBuilder = new KPrimAssessmentItemBuilder(translator.translate("new.kprim"), translator.translate("new.answer"), qtiService.qtiSerializer());
break;
case match:
itemBuilder = new MatchAssessmentItemBuilder(translator.translate("new.match"), QTI21Constants.CSS_MATCH_MATRIX, qtiService.qtiSerializer());
break;
case matchdraganddrop:
itemBuilder = new MatchAssessmentItemBuilder(translator.translate("new.match"), QTI21Constants.CSS_MATCH_DRAG_AND_DROP, qtiService.qtiSerializer());
break;
case matchtruefalse:
itemBuilder = new MatchAssessmentItemBuilder(translator.translate("new.match"), QTI21Constants.CSS_MATCH_TRUE_FALSE, translator.translate("match.unanswered"), translator.translate("match.true"), translator.translate("match.false"), qtiService.qtiSerializer());
break;
case fib:
itemBuilder = new FIBAssessmentItemBuilder(translator.translate("new.fib"), EntryType.text, qtiService.qtiSerializer());
break;
case numerical:
itemBuilder = new FIBAssessmentItemBuilder(translator.translate("new.fib.numerical"), EntryType.numerical, qtiService.qtiSerializer());
break;
case essay:
itemBuilder = new EssayAssessmentItemBuilder(translator.translate("new.essay"), qtiService.qtiSerializer());
break;
case upload:
itemBuilder = new UploadAssessmentItemBuilder(translator.translate("new.upload"), qtiService.qtiSerializer());
break;
case drawing:
itemBuilder = new DrawingAssessmentItemBuilder(translator.translate("new.drawing"), qtiService.qtiSerializer());
break;
case hotspot:
itemBuilder = new HotspotAssessmentItemBuilder(translator.translate("new.hotspot"), qtiService.qtiSerializer());
break;
case hottext:
itemBuilder = new HottextAssessmentItemBuilder(translator.translate("new.hottext"), translator.translate("new.hottext.start"), translator.translate("new.hottext.text"), qtiService.qtiSerializer());
break;
default:
return null;
}
AssessmentItem assessmentItem = itemBuilder.getAssessmentItem();
assessmentItem.setLabel(title);
assessmentItem.setTitle(title);
AssessmentItemMetadata itemMetadata = new AssessmentItemMetadata();
itemMetadata.setQuestionType(type);
QTI21ImportProcessor processor = new QTI21ImportProcessor(identity, locale);
QuestionItemImpl qitem = processor.processItem(assessmentItem, "", null, "OpenOLAT", Settings.getVersion(), itemMetadata);
VFSContainer baseDir = qpoolFileStorage.getContainer(qitem.getDirectory());
VFSLeaf leaf = baseDir.createChildLeaf(qitem.getRootFilename());
File itemFile = ((LocalImpl) leaf).getBasefile();
qtiService.persistAssessmentObject(itemFile, assessmentItem);
// create imsmanifest
ManifestBuilder manifest = ManifestBuilder.createAssessmentItemBuilder();
manifest.appendAssessmentItem(itemFile.getName());
manifest.write(new File(itemFile.getParentFile(), "imsmanifest.xml"));
return qitem;
}
use of org.olat.ims.qti21.model.xml.interactions.FIBAssessmentItemBuilder in project openolat by klemens.
the class CSVToAssessmentItemConverter method processPoints.
private void processPoints(String[] parts) {
if (currentItem == null)
return;
double points = parseFloat(parts[1], 1.0f);
AssessmentItemBuilder itemBuilder = currentItem.getItemBuilder();
if (itemBuilder instanceof SimpleChoiceAssessmentItemBuilder) {
itemBuilder.setMinScore(0.0d);
itemBuilder.setMaxScore(points);
} else if (itemBuilder instanceof FIBAssessmentItemBuilder) {
itemBuilder.setMinScore(0.0d);
itemBuilder.setMaxScore(points);
} else if (itemBuilder instanceof KPrimAssessmentItemBuilder) {
itemBuilder.setMinScore(0.0d);
itemBuilder.setMaxScore(points);
} else if (itemBuilder instanceof MatchAssessmentItemBuilder) {
itemBuilder.setMinScore(0.0d);
itemBuilder.setMaxScore(points);
}
}
Aggregations