use of org.olat.ims.qti.editor.beecom.objects.Item in project OpenOLAT by OpenOLAT.
the class QTIQPoolServiceProvider method importBeecomItem.
public QuestionItemImpl importBeecomItem(Identity owner, ItemAndMetadata itemAndMetadata, VFSContainer sourceDir, Locale defaultLocale) {
QTIImportProcessor processor = new QTIImportProcessor(owner, defaultLocale);
String editor = null;
String editorVersion = null;
Item item = itemAndMetadata.getItem();
if (!item.isAlient()) {
editor = "OpenOLAT";
editorVersion = Settings.getVersion();
}
Document doc = QTIEditHelper.itemToXml(item);
Element itemEl = (Element) doc.selectSingleNode("questestinterop/item");
QuestionItemImpl qitem = processor.processItem(itemEl, "", null, editor, editorVersion, null, itemAndMetadata);
// save to file System
VFSContainer baseDir = qpoolFileStorage.getContainer(qitem.getDirectory());
VFSLeaf leaf = baseDir.createChildLeaf(qitem.getRootFilename());
QTIEditHelper.serialiazeDoc(doc, leaf);
if (sourceDir != null) {
List<String> materials = processor.getMaterials(itemEl);
// copy materials
for (String material : materials) {
VFSItem sourceItem = sourceDir.resolve(material);
if (sourceItem instanceof VFSLeaf) {
VFSLeaf targetItem = baseDir.createChildLeaf(material);
VFSManager.copyContent((VFSLeaf) sourceItem, targetItem);
}
}
}
return qitem;
}
use of org.olat.ims.qti.editor.beecom.objects.Item in project OpenOLAT by OpenOLAT.
the class QTIQPoolServiceProvider method exportToEditorPackage.
public void exportToEditorPackage(QTIEditorPackageImpl editorPackage, List<QuestionItemShort> items, boolean newTest) {
VFSContainer editorContainer = editorPackage.getBaseDir();
List<Long> itemKeys = toKeys(items);
List<QuestionItemFull> fullItems = questionItemDao.loadByIds(itemKeys);
Section section = editorPackage.getQTIDocument().getAssessment().getSections().get(0);
if (newTest) {
// remove autogenerated question
section.getItems().clear();
}
QTIExportProcessor processor = new QTIExportProcessor(qpoolFileStorage);
for (QuestionItemFull fullItem : fullItems) {
Element itemEl = processor.exportToQTIEditor(fullItem, editorContainer);
Item item = (Item) new ParserManager().parse(itemEl);
item.setIdent(QTIEditHelper.generateNewIdent(item.getIdent()));
section.getItems().add(item);
}
}
use of org.olat.ims.qti.editor.beecom.objects.Item in project OpenOLAT by OpenOLAT.
the class QTIQPoolServiceProvider method exportToQTIEditor.
/**
* Export to QTI editor an item from the pool. The ident of the item
* is always regenerated as an UUID.
* @param qitem
* @param editorContainer
* @return
*/
public Item exportToQTIEditor(QuestionItemShort qitem, VFSContainer editorContainer) {
QTIExportProcessor processor = new QTIExportProcessor(qpoolFileStorage);
QuestionItemFull fullItem = questionItemDao.loadById(qitem.getKey());
Element itemEl = processor.exportToQTIEditor(fullItem, editorContainer);
Item exportedItem = (Item) new ParserManager().parse(itemEl);
exportedItem.setIdent(QTIEditHelper.generateNewIdent(exportedItem.getIdent()));
return exportedItem;
}
use of org.olat.ims.qti.editor.beecom.objects.Item in project OpenOLAT by OpenOLAT.
the class QTIQPoolServiceProvider method createItem.
public QuestionItem createItem(Identity owner, QTI12ItemFactory.Type type, String title, Locale defaultLocale) {
Translator trans = Util.createPackageTranslator(QTIEditorMainController.class, defaultLocale);
Item item;
switch(type) {
case sc:
item = QTIEditHelper.createSCItem(trans);
break;
case mc:
item = QTIEditHelper.createMCItem(trans);
break;
case kprim:
item = QTIEditHelper.createKPRIMItem(trans);
break;
case fib:
item = QTIEditHelper.createFIBItem(trans);
break;
case essay:
item = QTIEditHelper.createEssayItem(trans);
break;
default:
return null;
}
item.setLabel(title);
item.setTitle(title);
QTIImportProcessor processor = new QTIImportProcessor(owner, defaultLocale);
Document doc = QTIEditHelper.itemToXml(item);
Element itemEl = (Element) doc.selectSingleNode("questestinterop/item");
QuestionItemImpl qitem = processor.processItem(itemEl, "", null, "OpenOLAT", Settings.getVersion(), null, null);
// save to file System
VFSContainer baseDir = qpoolFileStorage.getContainer(qitem.getDirectory());
VFSLeaf leaf = baseDir.createChildLeaf(qitem.getRootFilename());
QTIEditHelper.serialiazeDoc(doc, leaf);
return qitem;
}
use of org.olat.ims.qti.editor.beecom.objects.Item in project OpenOLAT by OpenOLAT.
the class CSVToQuestionConverter method processFeedbackCorrectAnswer.
private void processFeedbackCorrectAnswer(String[] parts) {
if (currentItem == null || parts.length < 2)
return;
String feedback = parts[1];
if (StringHelper.containsNonWhitespace(feedback)) {
Item item = currentItem.getItem();
Control control = QTIEditHelper.getControl(item);
if (control.getFeedback() != 1) {
control.setFeedback(1);
}
QTIEditHelper.setFeedbackMastery(item, feedback);
}
}
Aggregations