use of org.olat.modules.qpool.QuestionItem in project OpenOLAT by OpenOLAT.
the class QTIQPoolServiceProvider method importRepositoryEntry.
public List<QuestionItem> importRepositoryEntry(Identity owner, RepositoryEntry repositoryEntry, Locale defaultLocale) {
OLATResourceable ores = repositoryEntry.getOlatResource();
FileResourceManager frm = FileResourceManager.getInstance();
File testFile = frm.getFileResource(ores);
List<QuestionItem> importedItem = importItems(owner, defaultLocale, testFile.getName(), testFile);
if (importedItem != null && importedItem.size() > 0) {
dbInstance.getCurrentEntityManager().flush();
}
return importedItem;
}
use of org.olat.modules.qpool.QuestionItem 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.modules.qpool.QuestionItem in project OpenOLAT by OpenOLAT.
the class QTIQPoolServiceProvider method importBeecomItem.
public List<QuestionItem> importBeecomItem(Identity owner, List<ItemAndMetadata> items, Locale defaultLocale) {
int count = 0;
List<QuestionItem> qItems = new ArrayList<>(items.size());
for (ItemAndMetadata item : items) {
QuestionItem qItem = importBeecomItem(owner, item, null, defaultLocale);
qItems.add(qItem);
if (++count % 10 == 0) {
dbInstance.commitAndCloseSession();
}
}
return qItems;
}
use of org.olat.modules.qpool.QuestionItem in project OpenOLAT by OpenOLAT.
the class QTI12ItemFactory method createItem.
@Override
public QuestionItem createItem(Identity owner, String title, Locale locale) {
QTIQPoolServiceProvider spi = CoreSpringFactory.getImpl(QTIQPoolServiceProvider.class);
QuestionItem newItem = spi.createItem(owner, type, title, locale);
return newItem;
}
use of org.olat.modules.qpool.QuestionItem in project OpenOLAT by OpenOLAT.
the class QTIImportProcessor method process.
private List<QuestionItem> process(DocInfos docInfos) {
List<QuestionItem> qItems = new ArrayList<>();
if (docInfos.doc != null) {
List<ItemInfos> itemInfos = getItemList(docInfos);
for (ItemInfos itemInfo : itemInfos) {
QuestionItemImpl qItem = processItem(docInfos, itemInfo, null);
if (qItem != null) {
processFiles(qItem, itemInfo, docInfos);
qItem = questionItemDao.merge(qItem);
qItems.add(qItem);
}
}
}
return qItems;
}
Aggregations