use of org.olat.modules.qpool.model.SearchQuestionItemParams in project OpenOLAT by OpenOLAT.
the class CollectionOfItemsSource method getItems.
@Override
public ResultInfos<QuestionItemView> getItems(String query, List<String> condQueries, int firstResult, int maxResults, SortKey... orderBy) {
SearchQuestionItemParams params = new SearchQuestionItemParams(identity, roles);
params.setSearchString(query);
params.setCondQueries(condQueries);
if (StringHelper.containsNonWhitespace(restrictToFormat)) {
params.setFormat(restrictToFormat);
}
return qpoolService.getItemsOfCollection(collection, params, firstResult, maxResults, orderBy);
}
use of org.olat.modules.qpool.model.SearchQuestionItemParams in project OpenOLAT by OpenOLAT.
the class SharedItemsSource method getItems.
@Override
public ResultInfos<QuestionItemView> getItems(String query, List<String> condQueries, int firstResult, int maxResults, SortKey... orderBy) {
SearchQuestionItemParams params = new SearchQuestionItemParams(identity, roles);
params.setSearchString(query);
params.setCondQueries(condQueries);
if (StringHelper.containsNonWhitespace(restrictToFormat)) {
params.setFormat(restrictToFormat);
}
return qpoolService.getSharedItemByResource(group.getResource(), params, firstResult, maxResults, orderBy);
}
use of org.olat.modules.qpool.model.SearchQuestionItemParams in project openolat by klemens.
the class DefaultItemsSource method getItems.
@Override
public ResultInfos<QuestionItemView> getItems(String query, List<String> condQueries, int firstResult, int maxResults, SortKey... orderBy) {
SearchQuestionItemParams params = defaultParams.clone();
params.setSearchString(query);
params.setCondQueries(condQueries);
return doSearch(params, firstResult, maxResults, orderBy);
}
use of org.olat.modules.qpool.model.SearchQuestionItemParams in project openolat by klemens.
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 klemens.
the class QItemQueriesDAOTest method shouldGetItemsNumberOfRating.
@Test
public void shouldGetItemsNumberOfRating() {
Identity owner1 = createRandomIdentity();
QuestionItem item11 = createRandomItem(owner1);
commentAndRatingService.createRating(createRandomIdentity(), item11, null, 2);
commentAndRatingService.createRating(createRandomIdentity(), item11, null, 3);
commentAndRatingService.createRating(createRandomIdentity(), item11, null, 4);
commentAndRatingService.createRating(createRandomIdentity(), item11, null, 4);
QuestionItem item12 = createRandomItem(owner1);
commentAndRatingService.createRating(createRandomIdentity(), item12, null, 4);
dbInstance.commitAndCloseSession();
SearchQuestionItemParams params = new SearchQuestionItemParams(createRandomIdentity(), null);
List<QuestionItemView> loadedItems = qItemQueriesDao.getItems(params, null, 0, -1);
assertThat(filterByKey(loadedItems, item11).getNumberOfRatings()).isEqualTo(4);
}
Aggregations