use of org.olat.modules.qpool.model.SearchQuestionItemParams in project OpenOLAT by OpenOLAT.
the class QItemQueriesDAOTest method shouldGetAllItems.
@Test
public void shouldGetAllItems() {
Identity owner1 = createRandomIdentity();
QuestionItem item11 = createRandomItem(owner1);
QuestionItem item12 = createRandomItem(owner1);
QuestionItem item13 = createRandomItem(owner1);
Identity owner2 = createRandomIdentity();
QuestionItem item21 = createRandomItem(owner2);
QuestionItem item22 = createRandomItem(owner2);
QuestionItem item23 = createRandomItem(owner2);
dbInstance.commitAndCloseSession();
SearchQuestionItemParams params = new SearchQuestionItemParams(createRandomIdentity(), null);
List<QuestionItemView> loadedItems = qItemQueriesDao.getItems(params, null, 0, -1);
assertThat(loadedItems).hasSize(6);
assertThat(keysOf(loadedItems)).containsOnlyElementsOf(keysOf(item11, item12, item13, item21, item22, item23));
}
use of org.olat.modules.qpool.model.SearchQuestionItemParams in project OpenOLAT by OpenOLAT.
the class QItemQueriesDAOTest method shouldGetItemsIsEditableInAShare.
@Test
public void shouldGetItemsIsEditableInAShare() {
Identity owner1 = createRandomIdentity();
QuestionItem item11 = createRandomItem(owner1);
QuestionItem item12 = createRandomItem(owner1);
QuestionItem item13 = createRandomItem(owner1);
BusinessGroup group = businessGroupDao.createAndPersist(owner1, "QPool", "QPool", -1, -1, false, false, false, false, false);
List<OLATResource> groupResources = Arrays.asList(group.getResource());
questionDao.share(item11, groupResources, true);
questionDao.share(item12, groupResources, false);
dbInstance.commitAndCloseSession();
SearchQuestionItemParams params = new SearchQuestionItemParams(createRandomIdentity(), null);
List<QuestionItemView> loadedItems = qItemQueriesDao.getItems(params, null, 0, -1);
assertThat(filterByKey(loadedItems, item11).isEditableInShare()).isTrue();
assertThat(filterByKey(loadedItems, item12).isEditableInShare()).isFalse();
assertThat(filterByKey(loadedItems, item13).isEditableInShare()).isFalse();
}
use of org.olat.modules.qpool.model.SearchQuestionItemParams in project OpenOLAT by OpenOLAT.
the class CollectionOfItemsSource method getItems.
@Override
public List<QuestionItemView> getItems(Collection<Long> key) {
SearchQuestionItemParams params = new SearchQuestionItemParams(identity, roles);
params.setItemKeys(key);
if (StringHelper.containsNonWhitespace(restrictToFormat)) {
params.setFormat(restrictToFormat);
}
ResultInfos<QuestionItemView> items = qpoolService.getItemsOfCollection(collection, params, 0, -1);
return items.getObjects();
}
use of org.olat.modules.qpool.model.SearchQuestionItemParams in project OpenOLAT by OpenOLAT.
the class SharedItemsSource method getItems.
@Override
public List<QuestionItemView> getItems(Collection<Long> keys) {
SearchQuestionItemParams params = new SearchQuestionItemParams(identity, roles);
params.setItemKeys(keys);
if (StringHelper.containsNonWhitespace(restrictToFormat)) {
params.setFormat(restrictToFormat);
}
ResultInfos<QuestionItemView> items = qpoolService.getSharedItemByResource(group.getResource(), params, 0, -1);
return items.getObjects();
}
use of org.olat.modules.qpool.model.SearchQuestionItemParams in project OpenOLAT by OpenOLAT.
the class DefaultItemsSource method getItems.
@Override
public List<QuestionItemView> getItems(Collection<Long> keys) {
SearchQuestionItemParams params = defaultParams.clone();
params.setItemKeys(keys);
ResultInfos<QuestionItemView> items = qpoolService.getItems(params, 0, -1);
return items.getObjects();
}
Aggregations