use of org.olat.modules.qpool.QuestionItemShort in project openolat by klemens.
the class TaxonomyLevelItemsSource method postImport.
@Override
public int postImport(List<QuestionItem> items, boolean editable) {
if (items == null || items.isEmpty())
return 0;
for (QuestionItemShort item : items) {
if (item instanceof QuestionItemImpl) {
QuestionItemImpl itemImpl = (QuestionItemImpl) item;
itemImpl.setTaxonomyLevel(taxonomyLevel);
}
}
qpoolService.index(items);
return items.size();
}
use of org.olat.modules.qpool.QuestionItemShort in project openolat by klemens.
the class QuestionPoolServiceImplTest method shouldGetExportFormatOptions.
@Test
public void shouldGetExportFormatOptions() {
String formatA = "A";
String formatB = "B";
QuestionItemImpl formatAItem = new QuestionItemImpl();
formatAItem.setFormat(formatA);
List<QuestionItemShort> items = Arrays.asList(formatAItem);
ExportFormatOptions exportFormatAR = new DefaultExportFormat(formatA, Outcome.repository, null);
ExportFormatOptions exportFormatAD = new DefaultExportFormat(formatA, Outcome.download, null);
List<ExportFormatOptions> exportFormatsA = Arrays.asList(exportFormatAD, exportFormatAR);
ExportFormatOptions exportFormatBR = new DefaultExportFormat(formatA, Outcome.repository, null);
List<ExportFormatOptions> exportFormatsB = Arrays.asList(exportFormatBR);
QPoolSPI spiA = mock(QPoolSPI.class);
when(spiA.getTestExportFormats()).thenReturn(exportFormatsA);
when(qPoolModuleMock.getQuestionPoolProvider(formatA)).thenReturn(spiA);
QPoolSPI spiB = mock(QPoolSPI.class);
when(spiB.getTestExportFormats()).thenReturn(exportFormatsB);
when(qPoolModuleMock.getQuestionPoolProvider(formatB)).thenReturn(spiB);
Set<ExportFormatOptions> exportFormatOptions = sut.getExportFormatOptions(items, Outcome.repository);
assertThat(exportFormatOptions).hasSize(1).containsExactly(exportFormatAR);
}
use of org.olat.modules.qpool.QuestionItemShort in project openolat by klemens.
the class QuestionItemDAO method removeFromShares.
public int removeFromShares(List<? extends QuestionItemShort> items) {
List<Long> keys = new ArrayList<>();
for (QuestionItemShort item : items) {
keys.add(item.getKey());
}
StringBuilder sb = new StringBuilder();
sb.append("delete from qshareitem share where share.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 klemens.
the class QuestionPoolServiceImpl method createCollection.
@Override
public QuestionItemCollection createCollection(Identity owner, String collectionName, List<QuestionItemShort> initialItems) {
QuestionItemCollection coll = collectionDao.createCollection(collectionName, owner);
List<Long> keys = new ArrayList<>(initialItems.size());
for (QuestionItemShort item : initialItems) {
collectionDao.addItemToCollection(item, Collections.singletonList(coll));
keys.add(item.getKey());
}
lifeIndexer.indexDocument(QItemDocument.TYPE, keys);
return coll;
}
use of org.olat.modules.qpool.QuestionItemShort in project openolat by klemens.
the class QuestionPoolServiceImpl method copyItems.
@Override
public List<QuestionItem> copyItems(Identity owner, List<QuestionItemShort> itemsToCopy) {
List<QuestionItem> copies = new ArrayList<>();
for (QuestionItemShort itemToCopy : itemsToCopy) {
QuestionItemImpl original = questionItemDao.loadById(itemToCopy.getKey());
QuestionItemImpl copy = questionItemDao.copy(original);
questionItemDao.persist(owner, copy);
QPoolSPI provider = qpoolModule.getQuestionPoolProvider(copy.getFormat());
if (provider != null) {
provider.copyItem(original, copy);
}
licenseService.copy(original, copy);
copies.add(copy);
}
dbInstance.commit();
index(copies);
return copies;
}
Aggregations