use of org.olat.modules.qpool.QuestionItemShort in project OpenOLAT by OpenOLAT.
the class QuestionPoolServiceImpl method convertItems.
@Override
public List<QuestionItem> convertItems(Identity cloner, List<QuestionItemShort> itemsToConvert, String format, Locale locale) {
QPoolSPI sp = qpoolModule.getQuestionPoolProvider(format);
List<QuestionItem> convertedQuestions = new ArrayList<>(itemsToConvert.size());
for (QuestionItemShort item : itemsToConvert) {
QuestionItem convertedQuestion = sp.convert(cloner, item, locale);
licenseService.copy(item, convertedQuestion);
if (convertedQuestion != null) {
convertedQuestions.add(convertedQuestion);
}
}
dbInstance.commit();
index(convertedQuestions);
return convertedQuestions;
}
use of org.olat.modules.qpool.QuestionItemShort in project OpenOLAT by OpenOLAT.
the class QuestionPoolServiceImpl method addItemsInPools.
@Override
public void addItemsInPools(List<? extends QuestionItemShort> items, List<Pool> pools, boolean editable) {
if (items == null || items.isEmpty() || pools == null || pools.isEmpty()) {
// nothing to do
return;
}
List<Long> keys = new ArrayList<>(items.size());
for (QuestionItemShort item : items) {
poolDao.addItemToPool(item, pools, editable);
keys.add(item.getKey());
}
dbInstance.commit();
lifeIndexer.indexDocument(QItemDocument.TYPE, keys);
}
use of org.olat.modules.qpool.QuestionItemShort in project OpenOLAT by OpenOLAT.
the class CollectionDAO method deleteItemFromCollections.
public int deleteItemFromCollections(List<? extends QuestionItemShort> items) {
// noting to do
if (items == null || items.isEmpty())
return 0;
List<Long> keys = new ArrayList<>();
for (QuestionItemShort item : items) {
keys.add(item.getKey());
}
StringBuilder sb = new StringBuilder();
sb.append("delete from qcollection2item coll2item where coll2item.item.key in (:itemKeys)");
return dbInstance.getCurrentEntityManager().createQuery(sb.toString()).setParameter("itemKeys", keys).executeUpdate();
}
use of org.olat.modules.qpool.QuestionItemShort in project OpenOLAT by OpenOLAT.
the class QTI21QPoolServiceProvider method loadQuestionFullItems.
private List<QuestionItemFull> loadQuestionFullItems(List<QuestionItemShort> items) {
List<Long> itemKeys = toKeys(items);
List<QuestionItemFull> fullItems = questionItemDao.loadByIds(itemKeys);
Map<Long, QuestionItemFull> fullItemMap = new HashMap<>();
for (QuestionItemFull fullItem : fullItems) {
fullItemMap.put(fullItem.getKey(), fullItem);
}
// reorder the fullItems;
List<QuestionItemFull> reorderedFullItems = new ArrayList<>(fullItems.size());
for (QuestionItemShort item : items) {
QuestionItemFull itemFull = fullItemMap.get(item.getKey());
if (itemFull != null) {
reorderedFullItems.add(itemFull);
}
}
return reorderedFullItems;
}
use of org.olat.modules.qpool.QuestionItemShort in project OpenOLAT by OpenOLAT.
the class QuestionItemDetailsController method doDelete.
private void doDelete(UserRequest ureq, List<QuestionItemShort> items) {
for (QuestionItemShort item : items) {
QuestionItem qitem = qpoolService.loadItemById(item.getKey());
QuestionItemAuditLogBuilder builder = qpoolService.createAuditLogBuilder(getIdentity(), Action.DELETE_QUESTION_ITEM);
builder.withBefore(qitem);
qpoolService.persist(builder.create());
}
qpoolService.deleteItems(items);
fireEvent(ureq, new QPoolEvent(QPoolEvent.ITEM_DELETED));
showInfo("item.deleted");
}
Aggregations